:root {
    color-scheme: light;
    --bg: #f7f4ef;
    --panel: #ffffff;
    --ink: #1f2933;
    --muted: #667085;
    --line: #e4dfd6;
    --accent: #85644b;
    --accent-dark: #634734;
    --soft: #f1e8de;
    --shadow: 0 14px 40px rgba(31, 41, 51, 0.08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
}

.shell {
    width: min(1120px, calc(100% - 40px));
    margin: 0 auto;
}

.site-header {
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    backdrop-filter: blur(10px);
    z-index: 10;
}

.header-shell {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    font-size: 1.25rem;
    font-weight: 750;
    letter-spacing: -0.02em;
}

.subtle, .module-status {
    color: var(--muted);
    font-size: 0.9rem;
}

.top-nav {
    display: flex;
    gap: 14px;
}

.top-nav a {
    color: var(--ink);
    text-decoration: none;
    font-weight: 600;
    padding: 8px 10px;
    border-radius: 10px;
}

.top-nav a:hover {
    background: var(--soft);
}

.main-content {
    padding: 44px 0 72px;
}

.hero, .panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 28px;
    box-shadow: var(--shadow);
    padding: clamp(28px, 5vw, 56px);
    margin-bottom: 24px;
}

.hero h1 {
    margin: 0 0 16px;
    max-width: 820px;
    font-size: clamp(2rem, 5vw, 4.2rem);
    line-height: 0.98;
    letter-spacing: -0.06em;
}

.hero p {
    max-width: 780px;
    color: var(--muted);
    font-size: 1.12rem;
}

.eyebrow {
    margin: 0 0 14px;
    color: var(--accent-dark) !important;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.8rem !important;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 28px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 18px;
    border-radius: 999px;
    font-weight: 700;
    text-decoration: none;
}

.button.primary {
    color: #fff;
    background: var(--accent);
}

.button.primary:hover {
    background: var(--accent-dark);
}

.pill {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--muted);
    border-radius: 999px;
    padding: 9px 13px;
    font-size: 0.92rem;
}

.panel h2 {
    margin: 0 0 20px;
    font-size: 1.5rem;
    letter-spacing: -0.03em;
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.module-card {
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 20px;
    background: #fffdfb;
}

.module-card h3 {
    margin: 8px 0 8px;
}

.module-card p {
    margin: 0;
    color: var(--muted);
}

.muted-panel {
    background: #fbfaf7;
}

.checklist {
    margin: 0;
    padding-left: 20px;
    color: var(--muted);
}

.site-footer {
    border-top: 1px solid var(--line);
    padding: 24px 0;
    color: var(--muted);
    background: #fff;
}

/* Stage 2 account and role UI */
.messages { margin: 0 0 1rem; display: grid; gap: .5rem; }
.message { padding: .85rem 1rem; border-radius: 14px; border: 1px solid rgba(20, 82, 80, .18); background: #f7fbfa; }
.message.success { border-color: rgba(22, 122, 71, .25); background: #f0fbf4; }
.message.error { border-color: rgba(184, 37, 37, .25); background: #fff3f3; }
.message.warning { border-color: rgba(194, 126, 0, .28); background: #fff8e7; }

.auth-card { max-width: 560px; margin: 0 auto; background: #fff; border: 1px solid rgba(20, 82, 80, .12); border-radius: 24px; padding: 2rem; box-shadow: 0 18px 70px rgba(16, 42, 42, .08); }
.auth-card.wide { max-width: 760px; }
.section-kicker { text-transform: uppercase; letter-spacing: .08em; color: #53736f; font-size: .78rem; font-weight: 700; margin-bottom: .35rem; }
.form-card { display: grid; gap: 1rem; margin-top: 1rem; }
.field { display: grid; gap: .35rem; }
.field label { font-weight: 700; color: #173b38; }
.field input, .field textarea, .field select { width: 100%; box-sizing: border-box; border: 1px solid rgba(20,82,80,.18); border-radius: 12px; padding: .8rem .9rem; font: inherit; background: #fff; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 3px solid rgba(213,12,45,.12); border-color: #d50c2d; }
.checkbox-field label { display: flex; gap: .55rem; align-items: flex-start; }
.checkbox-field input { width: auto; margin-top: .25rem; }
.errorlist { color: #9f1c2e; margin: .25rem 0 0; padding-left: 1.2rem; }
.help, .small { font-size: .9rem; }

.logout-form { display: inline; }
.logout-form button { border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; padding: .3rem .55rem; border-radius: 999px; }
.logout-form button:hover { background: rgba(255,255,255,.2); }

.grid { display: grid; gap: 1rem; margin: 1rem 0; }
.grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 760px) { .grid.two, .grid.three, .grid.four { grid-template-columns: 1fr; } }

.stat-card { background: #fff; border: 1px solid rgba(20,82,80,.12); border-radius: 22px; padding: 1.2rem; box-shadow: 0 10px 35px rgba(16,42,42,.05); }

.dashboard-summary { display: grid; grid-template-columns: minmax(220px, 360px); gap: 1rem; margin: 1rem 0; }
.stat-card--primary { padding: 1.35rem 1.5rem; }
.stat-card--primary .stat-value { font-size: 2rem; }
.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;
}
.stat-value { display: block; font-size: 1.8rem; font-weight: 800; color: #173b38; }
.stat-label { color: #5b706e; font-size: .94rem; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.data-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.data-table th, .data-table td { text-align: left; padding: .75rem; border-bottom: 1px solid rgba(20,82,80,.12); vertical-align: top; }
.data-table th { color: #53736f; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; }

.data-table th.action-column, .data-table td.action-column { text-align: right; vertical-align: middle; white-space: nowrap; }
.table-action-link { display: inline-flex; align-items: center; justify-content: flex-end; padding: .25rem 0; line-height: 1.2; }
.badge { display: inline-block; padding: .25rem .55rem; border-radius: 999px; background: #edf6f4; color: #173b38; font-size: .82rem; font-weight: 700; }
.chip { display: inline-block; padding: .45rem .75rem; border: 1px solid rgba(20,82,80,.15); border-radius: 999px; margin: 0 .35rem .5rem 0; text-decoration: none; color: #173b38; }
.chip.active { background: #173b38; color: white; }
.inline-form { display: inline-block; margin: .15rem .25rem .15rem 0; }
.inline-form.vertical { display: grid; gap: .35rem; max-width: 220px; }
.inline-form input { border: 1px solid rgba(20,82,80,.15); border-radius: 10px; padding: .55rem; }
.button.small { padding: .45rem .7rem; font-size: .88rem; }
.button.danger { background: #fff3f3; color: #a0182c; border-color: rgba(160,24,44,.22); }
.action-panel { display: flex; gap: .75rem; flex-wrap: wrap; }
.meta-list { display: grid; grid-template-columns: auto 1fr; gap: .45rem .9rem; }
.meta-list dt { color: #53736f; font-weight: 700; }
.meta-list dd { margin: 0; }
.check-list { padding-left: 1.2rem; }

/* Stage 3 case/dossier UI refinements */
.hero-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 28px;
    box-shadow: var(--shadow);
    padding: clamp(28px, 5vw, 48px);
    margin-bottom: 24px;
}
.hero-card h1 { margin: 0 0 12px; font-size: clamp(2rem, 4vw, 3.5rem); line-height: 1; letter-spacing: -0.05em; }
.hero-card p { color: var(--muted); max-width: 820px; }
.muted { color: var(--muted); }
.data-table a { color: var(--accent-dark); font-weight: 700; text-decoration: none; }
.data-table a:hover { text-decoration: underline; }

/* Stage 4 questionnaire UI */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
@media (max-width: 860px) { .form-grid { grid-template-columns: 1fr; } }
.questionnaire-section { scroll-margin-top: 96px; }
.questionnaire-field textarea { min-height: 110px; resize: vertical; }
.readonly-field { min-height: 44px; padding: .8rem .9rem; border: 1px solid rgba(20,82,80,.12); border-radius: 12px; background: #faf7f2; color: #5b706e; }
.repeat-group { margin-top: 1.25rem; border-top: 1px solid rgba(20,82,80,.12); padding-top: 1rem; }
.repeat-row { margin: 1rem 0; padding: 1rem; border: 1px solid rgba(20,82,80,.12); border-radius: 18px; background: #fffdfb; }
.repeat-row h4 { margin: 0 0 .75rem; }

/* Stage 5 report workflow */
.notice-box { margin-top: 1rem; padding: 1rem; border: 1px solid rgba(20,82,80,.18); border-radius: 16px; background: #fbfaf7; }
.warning-box, .message.warning { border-color: rgba(194, 126, 0, .28); background: #fff8e7; }
.review-submit-form { display: grid; gap: .5rem; max-width: 640px; width: 100%; }
.review-submit-form textarea, .review-card textarea { width: 100%; border: 1px solid rgba(20,82,80,.18); border-radius: 12px; padding: .8rem .9rem; font: inherit; }
.review-actions { align-items: stretch; }
.review-card { border: 1px solid rgba(20,82,80,.12); border-radius: 18px; padding: 1rem; background: #fffdfb; }
.report-preview { border: 1px solid rgba(20,82,80,.15); border-radius: 20px; overflow: hidden; background: #fff; }
.report-cover { padding: 2rem; border-bottom: 1px solid rgba(20,82,80,.12); background: linear-gradient(180deg, #fffdfb 0%, #faf7f2 100%); }
.report-brand { font-weight: 800; color: #173b38; margin-bottom: .75rem; }
.report-cover h2 { margin: 0 0 .5rem; }
.report-block { padding: 1.4rem 2rem; border-bottom: 1px solid rgba(20,82,80,.10); }
.report-block:last-child { border-bottom: 0; }
.report-block h3 { margin: 0 0 1rem; }
.report-block h4 { margin: 1rem 0 .35rem; color: #173b38; }
.report-items { margin-top: 1rem; }
.data-table.compact th, .data-table.compact td { padding: .55rem; }

/* Stage 14 notifications and pilot feedback */
.top-nav { align-items: center; flex-wrap: wrap; }
.top-nav-feedback { color: var(--accent-dark) !important; }
.notification-widget { position: relative; display: inline-flex; align-items: center; }
.notification-widget summary { list-style: none; }
.notification-widget summary::-webkit-details-marker { display: none; }
.notification-bell {
    position: relative;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(20,82,80,.14);
    border-radius: 999px;
    background: #fffdfb;
    color: #53736f;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(16,42,42,.04);
    transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.notification-bell:hover, .notification-widget[open] .notification-bell { background: var(--soft); border-color: rgba(99,71,52,.24); transform: translateY(-1px); }
.notification-bell-icon svg { display: block; fill: currentColor; }
.notification-widget.has-unread .notification-bell { color: var(--accent-dark); background: #fff8ee; border-color: rgba(133,100,75,.30); }
.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #a84f3c;
    color: #fff;
    border: 2px solid #fff;
    font-size: .68rem;
    font-weight: 800;
    line-height: 1;
}
.notification-popover {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    width: min(360px, calc(100vw - 40px));
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: 0 18px 55px rgba(31, 41, 51, 0.16);
    padding: .75rem;
    z-index: 30;
}
.notification-popover-header { display: flex; justify-content: space-between; align-items: center; padding: .35rem .45rem .65rem; color: #173b38; }
.notification-popover-header span { color: var(--muted); font-size: .85rem; }
.notification-list-compact { display: grid; gap: .35rem; }
.notification-item {
    display: grid;
    grid-template-columns: 10px 1fr;
    gap: .55rem;
    padding: .75rem;
    border-radius: 16px;
    color: var(--ink) !important;
    text-decoration: none !important;
}
.notification-item:hover { background: #fbfaf7; }
.notification-item.unread { background: #fff8ee; }
.notification-dot { width: 7px; height: 7px; border-radius: 999px; background: transparent; margin-top: .45rem; }
.notification-item.unread .notification-dot { background: #a84f3c; }
.notification-item strong { display: block; font-size: .92rem; color: #173b38; }
.notification-item small { display: block; color: var(--muted); line-height: 1.35; }
.notification-item em { display: block; color: #8b8176; font-size: .78rem; font-style: normal; margin-top: .2rem; }
.notification-empty { padding: 1rem .75rem; color: var(--muted); }
.notification-all-link { display: block; margin-top: .55rem; padding: .65rem .75rem; border-radius: 14px; text-align: center; background: #fbfaf7; color: var(--accent-dark) !important; font-weight: 800; text-decoration: none !important; }
.badge-unread { background: #fff8ee; color: #8b3d2d; }
@media (max-width: 900px) { .notification-popover { right: -90px; } }

/* Stage 18 product identity and role-aware homepage */
.product-hero h1 { max-width: 760px; }
.public-product-panel .panel-header { margin-bottom: 1.25rem; }
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px;
}
.feature-card {
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 22px;
    background: linear-gradient(180deg, #fffdfb 0%, #fbfaf7 100%);
}
.feature-card h3 { margin: 0 0 .55rem; color: var(--ink); letter-spacing: -0.02em; }
.feature-card p { margin: 0; color: var(--muted); }
.public-login-note { max-width: 860px; }
.role-home-grid { margin-bottom: 24px; }
.admin-module-panel { border-style: solid; }


/* Stage 19 account/security/public-surface polish */
.top-nav a.active { background: var(--soft); color: var(--accent-dark); }
@media (max-width: 900px) {
  .header-shell { align-items: flex-start; flex-direction: column; gap: 12px; padding: 14px 0; }
  .top-nav { width: 100%; gap: 8px; align-items: flex-start; }
  .top-nav a, .logout-form button { padding: 7px 9px; }
  .notification-widget { margin-left: 0; }
}
