:root {
    --navy: #0c2340;
    --navy-2: #16355c;
    --gold: #b8973a;
    --ink: #1d2430;
    --muted: #5c6570;
    --paper: #f3efe6;
    --panel: #fffcf7;
    --line: #d8d0c3;
    --yes: #215c45;
    --no: #8f3a32;
    --na: #5f6770;
    --good: #215c45;
    --mid: #8a6a1f;
    --low: #8f3a32;
    --radius: 6px;
    --max: 1180px;
    font-family: "Segoe UI", "Aptos", Calibri, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--navy-2); }

.site-header {
    background: var(--navy);
    color: #f4efe4;
}

.header-inner,
.context-bar,
.site-main,
.site-footer {
    width: min(var(--max), calc(100% - 2rem));
    margin-inline: auto;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: inherit;
    text-decoration: none;
}

.brand img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    background: #fff;
    border-radius: 4px;
}

.brand small {
    display: block;
    color: #c9c1b2;
    font-size: 0.8rem;
}

.site-nav {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    flex-wrap: wrap;
}

.nav-user {
    color: #d9d2c5;
    font-size: 0.9rem;
    padding: 0.4rem 0.5rem;
}

.nav-form { margin: 0; }

.nav-button {
    background: var(--navy-2);
    color: #fff;
    border: 0;
    border-radius: var(--radius);
    padding: 0.4rem 0.7rem;
    font: inherit;
    cursor: pointer;
}

.nav-danger { color: #f3ddd9 !important; }

.narrow-panel { max-width: 36rem; }

.text-link {
    align-self: center;
    font-weight: 650;
}

input[type="password"],
input[type="email"] {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0.55rem 0.65rem;
    font: inherit;
    background: #fff;
}

.btn-danger {
    background: var(--no);
    color: #fff;
    display: inline-block;
    text-decoration: none;
}

.btn-danger:hover { filter: brightness(1.05); }

.banner-ok {
    background: #e7efe9;
    border-color: #b7cfc3;
}

.site-nav a {
    color: #d9d2c5;
    text-decoration: none;
    padding: 0.4rem 0.7rem;
    border-radius: var(--radius);
}

.site-nav a.is-active,
.site-nav a:hover {
    background: var(--navy-2);
    color: #fff;
}

.site-nav a.nav-cta {
    background: var(--gold);
    color: #0c2340;
    font-weight: 650;
}

.site-nav a.nav-cta:hover,
.site-nav a.nav-cta.is-active {
    background: #d4b45a;
    color: #0c2340;
}

.site-nav a.nav-danger {
    color: #f3ddd9;
}

.table-wrap {
    overflow-x: auto;
}

.assessment-table {
    width: 100%;
    border-collapse: collapse;
}

.assessment-table th,
.assessment-table td {
    text-align: left;
    vertical-align: top;
    padding: 0.7rem 0.55rem;
    border-bottom: 1px solid var(--line);
}

.assessment-table th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.inline-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin: 0;
}

.context-bar {
    display: flex;
    gap: 1.25rem;
    padding: 0.45rem 0 0.8rem;
    color: #c9c1b2;
    font-size: 0.9rem;
}

.site-main {
    flex: 1;
    padding: 1.75rem 0 3rem;
}

.site-footer {
    padding: 1rem 0 1.5rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.hero, .results-hero {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    align-items: end;
}

.eyebrow {
    margin: 0 0 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.75rem;
    color: var(--gold);
    font-weight: 700;
}

h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 600; }
h1 { margin: 0 0 0.5rem; font-size: 2rem; }
h2 { margin: 0 0 0.75rem; font-size: 1.25rem; }

.lede { margin: 0; color: var(--muted); max-width: 42rem; }

.hero-stats, .scorecard {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
}

.hero-stats div, .scorecard div {
    background: var(--panel);
    border: 1px solid var(--line);
    padding: 0.85rem;
    border-radius: var(--radius);
}

.hero-stats dt, .scorecard .label, .label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.hero-stats dd, .scorecard strong {
    margin: 0.2rem 0 0;
    font-size: 1.6rem;
    font-weight: 700;
}

.split {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 1rem;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.1rem 1.2rem 1.25rem;
}

.stack { display: grid; gap: 0.85rem; }

label { display: grid; gap: 0.35rem; font-size: 0.92rem; font-weight: 600; }

input[type="text"], textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0.55rem 0.65rem;
    font: inherit;
    background: #fff;
}

.button-row { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.btn {
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 0.55rem 0.9rem;
    font: inherit;
    font-weight: 650;
    cursor: pointer;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--navy-2); }
.btn-secondary { background: #fff; border-color: var(--line); color: var(--navy); }

.hint, .muted { color: var(--muted); font-size: 0.9rem; }
.hint { margin: 0; font-weight: 400; }

.banner, .banner-error {
    background: #efe6c9;
    border: 1px solid #d7c48a;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.banner-error { background: #f3ddd9; border-color: #d9a79f; }

.saved-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }

.saved-item {
    width: 100%;
    text-align: left;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0.7rem 0.8rem;
    display: grid;
    gap: 0.15rem;
    cursor: pointer;
}

.saved-item span { color: var(--muted); font-size: 0.85rem; }

.survey-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 1rem;
    align-items: start;
}

.family-nav ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.3rem; }

.nav-link {
    width: 100%;
    display: grid;
    grid-template-columns: 2.4rem 1fr auto;
    gap: 0.45rem;
    align-items: center;
    text-align: left;
    border: 1px solid transparent;
    background: transparent;
    padding: 0.4rem 0.45rem;
    border-radius: 4px;
    cursor: pointer;
    font: inherit;
}

.nav-link.is-active { background: var(--navy); color: #fff; }
.nav-link.is-complete:not(.is-active) { background: #e7efe9; }
.nav-code { font-weight: 700; font-size: 0.8rem; }
.nav-title { font-size: 0.82rem; }
.nav-count { font-size: 0.75rem; color: var(--muted); }
.nav-link.is-active .nav-count { color: #d9d2c5; }

.progress-label { margin: 1rem 0 0.35rem; font-size: 0.85rem; color: var(--muted); }

.meter {
    height: 8px;
    background: #e6dfd3;
    border-radius: 99px;
    overflow: hidden;
}

.meter span {
    display: block;
    height: 100%;
    background: var(--gold);
}

.family-head { margin-bottom: 1.1rem; }
.control-block { border-top: 1px solid var(--line); padding: 1rem 0; }
.control-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 0.7rem;
}
.control-head h2 { margin: 0; font-size: 1.05rem; }
.control-id { color: var(--gold); margin-right: 0.25rem; }

.weight-pill {
    flex: none;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.5rem;
    border-radius: 99px;
    border: 1px solid var(--line);
}
.weight-high { background: #f3ddd9; color: var(--low); }
.weight-mid { background: #efe6c9; color: var(--mid); }
.weight-low { background: #e7efe9; color: var(--good); }

.question-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.question {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    align-items: center;
    padding: 0.7rem 0.8rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 4px;
}
.question p { margin: 0; }
.question-odp { background: #f7f4ee; }
.ao-id {
    display: inline-block;
    margin-right: 0.4rem;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 700;
}

.choices {
    display: flex;
    gap: 0.35rem;
    border: 0;
    margin: 0;
    padding: 0;
}

.choice {
    cursor: pointer;
}

.choice span {
    display: inline-block;
    min-width: 3.2rem;
    text-align: center;
    padding: 0.4rem 0.55rem;
    border: 1px solid var(--line);
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 700;
}

.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice-yes input:checked + span { background: var(--yes); color: #fff; border-color: var(--yes); }
.choice-no input:checked + span { background: var(--no); color: #fff; border-color: var(--no); }
.choice-na input:checked + span { background: var(--na); color: #fff; border-color: var(--na); }

.survey-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    position: sticky;
    bottom: 0;
    background: var(--panel);
    padding: 0.9rem 0 0.2rem;
    border-top: 1px solid var(--line);
}

.section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.6rem 1rem;
    margin-bottom: 0.9rem;
}
.section-head h2 { margin: 0; }
.section-head .muted { margin: 0; flex: 1; }
.print-btn { margin-left: auto; }

.impact-chart { display: grid; gap: 0.45rem; }
.impact-row {
    display: grid;
    grid-template-columns: 2.5rem 1fr 4.5rem 6.5rem;
    gap: 0.6rem;
    align-items: center;
    font-size: 0.9rem;
}
.impact-bar {
    height: 10px;
    background: #e6dfd3;
    border-radius: 99px;
    overflow: hidden;
}
.impact-fill { display: block; height: 100%; background: var(--navy); }
.impact-fill.score-good { background: var(--good); }
.impact-fill.score-mid { background: var(--gold); }
.impact-fill.score-low { background: var(--low); }
.impact-weight { color: var(--muted); text-align: right; }

.table-wrap { overflow-x: auto; }

.results-table, .gaps-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.results-table th, .results-table td,
.gaps-table th, .gaps-table td {
    border-bottom: 1px solid var(--line);
    padding: 0.5rem 0.55rem;
    text-align: left;
    vertical-align: top;
}

.num { text-align: right; font-variant-numeric: tabular-nums; }

.overall-row th, .overall-row td {
    background: var(--navy);
    color: #fff;
    font-weight: 700;
}

.family-row th, .family-row td {
    background: #e8eef5;
    font-weight: 700;
}

.control-toggle {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.control-toggle:hover { color: var(--navy-2); text-decoration: underline; }

.detail-row td { background: #faf7f1; }
tr[hidden] { display: none !important; }
.detail-questions { margin: 0; padding-left: 1.1rem; display: grid; gap: 0.35rem; }
.status-label {
    display: inline-block;
    min-width: 5.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    margin-right: 0.4rem;
}
.status-implemented .status-label { color: var(--good); }
.status-gap .status-label, .status-unanswered .status-label { color: var(--low); }
.status-na .status-label { color: var(--na); }

.score-good { color: var(--good); }
.score-mid { color: var(--mid); }
.score-low { color: var(--low); }
.overall-row .score-good, .overall-row .score-mid, .overall-row .score-low { color: #fff; }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

@media (max-width: 900px) {
    .hero, .results-hero, .split, .survey-layout, .question, .impact-row {
        grid-template-columns: 1fr;
    }
    .survey-actions { justify-content: stretch; }
    .survey-actions .btn { flex: 1; }
}

@media print {
    .site-header, .site-footer, .print-btn, .site-nav, .banner { display: none; }
    body, .panel { background: #fff; }
    .detail-row { display: table-row !important; }
    a { color: inherit; text-decoration: none; }
}
