:root {
    color-scheme: light;
    --green: #0b6b57;
    --green-dark: #074f41;
    --mint: #e9f5f1;
    --ink: #17211e;
    --muted: #60706b;
    --surface: #ffffff;
    --border: #d9e4e0;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: #f3f7f5;
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

button, input, select, textarea { font: inherit; }
a { color: var(--green); text-underline-offset: 3px; }

.shell {
    width: min(100%, 520px);
    margin: 0 auto;
    padding: max(24px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom));
}

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; }
.brand img { border-radius: 16px; box-shadow: 0 8px 22px rgb(11 107 87 / 18%); }
.brand h1, .brand p { margin: 0; }
.brand h1 { font-size: 28px; line-height: 1.05; }
.eyebrow { color: var(--muted); font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; }

.hero, .draft {
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: 0 18px 48px rgb(23 33 30 / 8%);
}

.hero h2 { margin: 18px 0 10px; font-size: clamp(30px, 9vw, 42px); line-height: 1.04; letter-spacing: -.035em; }
.hero > p:not(.status) { margin: 0 0 24px; color: var(--muted); font-size: 18px; line-height: 1.5; }
.status { display: inline-flex; align-items: center; gap: 8px; margin: 0; color: var(--green-dark); font-size: 13px; font-weight: 650; }
.status span { width: 9px; height: 9px; border-radius: 50%; background: #27a878; }

.primary, .secondary {
    width: 100%; min-height: 58px; padding: 14px 18px; border-radius: 16px; font-weight: 750; cursor: pointer;
}
.primary { border: 0; background: var(--green); color: white; box-shadow: 0 10px 24px rgb(11 107 87 / 24%); }
.primary:hover, .primary:focus-visible { background: var(--green-dark); }
.secondary { margin-top: 12px; border: 1px solid var(--green); background: white; color: var(--green); }

.draft { margin-top: 16px; }
.draft h2 { margin-top: 0; }
.draft label { display: block; margin-bottom: 8px; font-weight: 700; }
.draft input { width: 100%; min-height: 56px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; color: var(--ink); }
.draft input:focus { outline: 3px solid rgb(11 107 87 / 18%); border-color: var(--green); }
.draft p { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.offline { padding: 12px 14px; border-radius: 12px; background: #fff2ce; color: #684b00; font-size: 14px; }

@media (min-width: 700px) {
    .shell { padding-top: 48px; }
    .hero { padding: 34px; }
}

.topbar {
    min-height: 68px; padding: 12px max(18px, calc((100vw - 1120px) / 2)); display: flex; align-items: center;
    justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--border); background: rgb(255 255 255 / 92%);
}
.logo { display: flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-size: 20px; }
.logo img { border-radius: 10px; }
.topbar nav { display: flex; align-items: center; gap: 16px; overflow-x: auto; }
.topbar nav a { white-space: nowrap; font-size: 14px; font-weight: 650; text-decoration: none; }
.page { width: min(100% - 32px, 1120px); margin: 0 auto; padding: 32px 0 56px; }
.page h1 { margin: 4px 0 0; font-size: clamp(30px, 6vw, 44px); letter-spacing: -.035em; }
.page h2 { margin-top: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.card { padding: 24px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); box-shadow: 0 14px 40px rgb(23 33 30 / 6%); }
.auth-card { width: min(100%, 460px); margin: 7vh auto 0; }
.auth-card h1 { margin: 6px 0; }
.muted { color: var(--muted); }
.form-stack { display: grid; gap: 17px; }
.form-stack label { display: grid; gap: 7px; font-weight: 700; }
.form-stack input, .form-stack select, .form-stack textarea, .searchbar input, .searchbar select {
    width: 100%; min-height: 52px; padding: 11px 13px; border: 1px solid var(--border); border-radius: 12px; background: white; color: var(--ink);
}
.form-stack textarea { min-height: 100px; resize: vertical; }
.form-stack input:focus, .form-stack select:focus, .form-stack textarea:focus, .searchbar input:focus, .searchbar select:focus { outline: 3px solid rgb(11 107 87 / 15%); border-color: var(--green); }
.form-stack small { color: var(--muted); font-weight: 400; }
.button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.compact { width: auto; min-height: 46px; padding: 10px 16px; }
.inline-form { display: inline; }
.link-button { border: 0; padding: 8px; background: transparent; color: var(--green); cursor: pointer; font-weight: 700; }
.alert { margin: 0 0 18px; padding: 14px 16px; border-radius: 12px; line-height: 1.45; }
.alert.error { background: #fde8e8; color: #852020; border: 1px solid #f6caca; }
.alert.success { background: #e6f5ee; color: #145c45; border: 1px solid #c7e8da; }
.alert ul { margin: 0; padding-left: 20px; }
.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.metric { display: grid; gap: 8px; }
.metric strong { color: var(--green); font-size: clamp(34px, 8vw, 48px); line-height: 1; }
.metric span { color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; }
.actions .button { width: auto; }
.profile-summary dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin: 0; }
.profile-summary dl div { min-width: 0; }
.profile-summary dt { color: var(--muted); font-size: 13px; }
.profile-summary dd { margin: 5px 0 0; overflow-wrap: anywhere; font-weight: 700; }
.profile-summary .wide { grid-column: 1 / -1; }
.feature-grid, .two-column { display: grid; gap: 16px; margin-top: 16px; }
.coming { opacity: .82; }
.coming span, .badge { display: inline-block; padding: 5px 9px; border-radius: 999px; background: var(--mint); color: var(--green-dark); font-size: 12px; font-weight: 750; }
.coming h2 { margin: 16px 0 6px; }
.coming p { margin-bottom: 0; color: var(--muted); }
.badge.blocked { background: #fde8e8; color: #852020; }
.searchbar { display: grid; grid-template-columns: minmax(180px, 1fr) 190px auto; gap: 10px; margin-bottom: 16px; }
.searchbar .secondary { margin: 0; width: auto; min-height: 52px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 16px; background: white; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 14px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:last-child td { border-bottom: 0; }
.empty { padding: 32px; color: var(--muted); text-align: center; }
.danger-zone { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.danger { width: 100%; min-height: 50px; border: 1px solid #b62e2e; border-radius: 12px; background: white; color: #a32121; font-weight: 750; cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.wizard { width:min(100%,720px);margin:auto; }
.wizard-bar { display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:24px;color:var(--muted);font-size:14px; }
.wizard-step { display:none; }
.wizard-step.active { display:block;animation:step-in .18s ease-out; }
.wizard-step>label { display:grid;gap:8px;margin:18px 0;font-weight:700; }
.wizard-step>label input,.wizard-step>label textarea { width:100%;min-height:58px;padding:14px;border:1px solid var(--border);border-radius:15px;font:inherit; }
.choice-grid { display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin-top:24px; }
.choice { min-height:76px;padding:15px;border:1px solid var(--border);border-radius:17px;background:white;color:var(--ink);font-size:17px;font-weight:750;cursor:pointer; }
.choice:active { transform:scale(.98);background:var(--mint); }
.item-list { display:grid;gap:10px;margin:20px 0; }
.item-card { display:flex;align-items:center;justify-content:space-between;gap:10px;padding:14px;border:1px solid var(--border);border-radius:16px;background:white; }
.item-card>div:first-child { display:grid;gap:3px; }.item-card span{color:var(--muted);font-size:13px}.hidden{display:none!important}
.counter { display:flex;align-items:center;gap:5px; }.counter button{width:46px;height:46px;border:0;border-radius:13px;background:var(--mint);color:var(--green);font-size:26px;font-weight:700}.counter input{width:58px;height:46px;border:1px solid var(--border);border-radius:10px;text-align:center;font-weight:750}
.wizard-actions { display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:20px; }.wizard-actions .secondary{margin:0}
.estimate-list { display:grid;gap:10px; }.estimate-row{display:flex;align-items:center;justify-content:space-between;gap:12px;text-decoration:none;color:var(--ink)}.estimate-row>div{display:grid;gap:5px}.estimate-row span{color:var(--muted);font-size:13px}
.estimate-section{margin-bottom:14px}.summary-item{display:flex;justify-content:space-between;gap:15px;padding:12px 0;border-top:1px solid var(--border)}.resume{display:flex;align-items:center;justify-content:space-between;gap:12px}
fieldset{border:1px solid var(--border);border-radius:12px;padding:12px}legend{font-weight:700}.check{display:block!important;padding:7px 0;font-weight:500!important}.check input{width:auto!important;min-height:0!important}
@keyframes step-in{from{opacity:0;transform:translateX(10px)}to{opacity:1;transform:none}}

@media (min-width: 760px) {
    .metrics { grid-template-columns: repeat(4, 1fr); }
    .feature-grid { grid-template-columns: repeat(3, 1fr); }
    .two-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
    .topbar { align-items: flex-start; flex-direction: column; }
    .topbar nav { width: 100%; padding-bottom: 2px; }
    .page { padding-top: 24px; }
    .page-head { align-items: flex-start; }
    .profile-summary dl { grid-template-columns: 1fr; }
    .profile-summary .wide { grid-column: auto; }
    .searchbar { grid-template-columns: 1fr; }
    .searchbar .secondary { width: 100%; }
    .choice-grid{grid-template-columns:1fr}.item-card{align-items:flex-start;flex-direction:column}.counter{width:100%;justify-content:flex-end}.wizard-actions{grid-template-columns:1fr}
}

/* Cabinet 3.0 */
.role-master .page { padding-bottom: 122px; }
.cabinet-greeting { margin: 0 0 18px; }
.cabinet-greeting h1 { margin: 0; font-size: 18px; line-height: 1.25; letter-spacing: -.015em; }
.cabinet-greeting p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.resume-card {
    display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 12px;
    margin-bottom: 14px; padding: 13px 15px; border: 1px solid #bfe3d6; border-radius: 17px;
    background: var(--mint); color: var(--ink); text-decoration: none;
}
.resume-card__icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 13px; background: white; color: var(--green); font-size: 22px; }
.resume-card span:nth-child(2) { display: grid; gap: 3px; min-width: 0; }
.resume-card small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.work-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; max-width: 720px; }
.work-card {
    position: relative; display: grid; align-content: start; min-height: 150px; padding: 17px;
    border: 1px solid var(--border); border-radius: 20px; background: var(--surface); color: var(--ink);
    box-shadow: 0 9px 26px rgb(23 33 30 / 5%); text-decoration: none;
}
.work-card:active { transform: scale(.985); background: #fbfdfc; }
.work-card__icon, .empty-state__icon { display: grid; width: 46px; height: 46px; place-items: center; border-radius: 15px; background: var(--mint); color: var(--green); }
.work-card__icon::before, .empty-state__icon::before, .nav-icon::before { font-size: 22px; line-height: 1; }
.icon-home::before { content: "⌂"; }
.icon-clipboard::before { content: "▤"; }
.icon-star::before { content: "☆"; }
.icon-draft::before { content: "✎"; }
.icon-user::before { content: "♙"; }
.icon-settings::before { content: "⚙"; }
.work-card__body { display: grid; gap: 5px; margin-top: 18px; }
.work-card__body strong { font-size: 17px; }
.work-card__body small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.work-card__arrow { position: absolute; top: 18px; right: 16px; color: #9aaba5; font-size: 24px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 20px; }
.section-head .eyebrow { margin: 0 0 4px; }
.section-head h1 { margin: 0; }
.section-head form { flex: 0 0 auto; }
.cabinet-estimates { margin-top: 28px; }
.cabinet-estimates .section-head { margin-bottom: 12px; }
.cabinet-estimates .section-head h2 { margin: 0; font-size: clamp(24px, 5vw, 32px); }
.cabinet-panel { max-width: 680px; margin: 0 auto 14px; }
.cabinet-panel h2 { font-size: 20px; }
.profile-details { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0 0 22px; }
.profile-details div { min-width: 0; padding: 13px; border-radius: 13px; background: #f5f8f7; }
.profile-details dt { color: var(--muted); font-size: 12px; }
.profile-details dd { margin: 5px 0 0; overflow-wrap: anywhere; font-weight: 700; }
.profile-name-form { padding-top: 20px; border-top: 1px solid var(--border); }
.locked-field { margin: 12px 0 0; color: var(--muted); font-size: 12px; }
.logout-panel { margin-top: 14px; }
.empty-state { display: grid; justify-items: center; padding: 42px 24px; text-align: center; }
.empty-state h2 { margin: 16px 0 7px; font-size: 20px; }
.empty-state p { max-width: 320px; margin: 0; color: var(--muted); }
.bottom-nav {
    position: fixed; z-index: 50; right: 50%; bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr);
    width: min(100%, 520px); min-height: 72px; padding: 8px max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    border: 1px solid var(--border); border-bottom: 0; border-radius: 22px 22px 0 0; background: rgb(255 255 255 / 96%);
    box-shadow: 0 -10px 35px rgb(23 33 30 / 12%); transform: translateX(50%); backdrop-filter: blur(16px);
}
.bottom-nav > a { display: grid; place-items: center; align-content: center; gap: 3px; min-width: 0; color: var(--muted); text-decoration: none; }
.bottom-nav > a.active { color: var(--green); }
.bottom-nav small { font-size: 10px; line-height: 1; }
.nav-icon { display: grid; width: 28px; height: 28px; place-items: center; }
.nav-icon::before { font-size: 20px; }
.bottom-create { display: grid; place-items: center; }
.bottom-create input { display: none; }
.bottom-create button {
    display: grid; width: 58px; height: 58px; margin-top: -27px; padding: 0; place-items: center;
    border: 5px solid #f3f7f5; border-radius: 50%; background: var(--green); color: white;
    box-shadow: 0 8px 22px rgb(11 107 87 / 28%); cursor: pointer;
}
.bottom-create button > span { font-size: 34px; font-weight: 300; line-height: .7; }
.is-loading #app-content { opacity: .55; pointer-events: none; }
#app-content { transition: opacity .15s ease; }

@media (min-width: 760px) {
    .work-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
    .role-master .topbar { min-height: 54px; padding: 8px 16px; flex-direction: row; align-items: center; }
    .role-master .topbar .logo img { width: 32px; height: 32px; }
    .role-master .topbar .logo { font-size: 17px; }
    .role-master .topbar nav { display: none; }
    .role-master .page { width: min(100% - 28px, 560px); padding-top: 18px; }
    .section-head h1 { font-size: 30px; }
    .section-head .compact { min-height: 46px; padding: 9px 13px; }
    .card { padding: 18px; border-radius: 18px; }
    .profile-details { grid-template-columns: 1fr; }
    .work-card { min-height: 142px; padding: 15px; }
    .estimate-row { align-items: flex-start; }
}

@media (max-width: 360px) {
    .work-grid { grid-template-columns: 1fr; }
    .work-card { min-height: 112px; grid-template-columns: 46px minmax(0, 1fr); align-items: center; gap: 13px; }
    .work-card__body { margin-top: 0; }
}
