/* Base NVA — one stylesheet, no framework */
:root {
    --brand: #b3260b;
    --brand-dark: #8c1d08;
    --ink: #1f2328;
    --muted: #5f6670;
    --line: #d9dde3;
    --bg: #f4f5f7;
    --card: #fff;
    --ok-bg: #e8f5ec;
    --ok-ink: #1d5f33;
    --err-bg: #fdecea;
    --err-ink: #9b1c12;
    --radius: 8px;
    --focus: 0 0 0 3px rgb(179 38 11 / 35%);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
h1 { font-size: 1.4rem; margin: 0 0 .5rem; font-weight: 600; }
h1 strong { color: var(--brand); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: #fff; padding: .5rem 1rem; z-index: 10; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); margin: 0; }

/* top bar */
.topbar { background: var(--brand); color: #fff; }
.topbar__inner { max-width: 1240px; margin: 0 auto; padding: .6rem 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem; }
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.brand:hover { color: #fff; }
.brand__year { font-weight: 400; opacity: .85; }
.mainnav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; flex: 1; }
.mainnav a { color: #fff; text-decoration: none; padding: .25rem 0; border-bottom: 2px solid transparent; }
.mainnav a:hover, .mainnav a[aria-current] { border-bottom-color: #fff; color: #fff; }
.mainnav a[aria-current] { font-weight: 600; }
.session { display: flex; align-items: center; gap: .75rem; font-size: .9rem; }
.session form { margin: 0; }
.session .link { color: #fff; }

.page { max-width: 1240px; width: 100%; margin: 0 auto; padding: 1.25rem 1rem 2rem; flex: 1; }
.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 1rem; }

/* building blocks */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin: 0 0 1rem; }
.card--narrow { max-width: 420px; margin: 3rem auto; }
.stack { display: grid; gap: .9rem; }
label { display: grid; gap: .3rem; font-weight: 500; }
input[type=text], input[type=search], input[type=password], input[type=date], input:not([type]), select {
    font: inherit; padding: .5rem .6rem; border: 1px solid #b8bec6; border-radius: 6px; background: #fff; width: 100%; min-width: 0;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: var(--focus); outline: none; }
.button { font: inherit; font-weight: 600; background: var(--brand); color: #fff; border: 1px solid var(--brand); border-radius: 6px; padding: .55rem 1.1rem; cursor: pointer; text-decoration: none; display: inline-block; }
.button:hover { background: var(--brand-dark); color: #fff; }
.button--ghost { background: #fff; color: var(--brand); }
.button--ghost:hover { background: #fbeae6; color: var(--brand-dark); }
.link { font: inherit; background: none; border: 0; padding: 0; color: var(--brand); text-decoration: underline; cursor: pointer; }
.link--danger { color: var(--err-ink); }

.notice { border-radius: var(--radius); padding: .75rem 1rem; margin: 0 0 1rem; }
.notice p { margin: 0 0 .25rem; }
.notice ul { margin: 0; padding-left: 1.2rem; }
.notice--success { background: var(--ok-bg); color: var(--ok-ink); }
.notice--error { background: var(--err-bg); color: var(--err-ink); }
.notice--error a { color: inherit; }
.error { color: var(--err-ink); font-weight: 500; margin: .25rem 0; font-size: .92rem; }
.error-message { white-space: pre-wrap; font-family: inherit; }
.has-error { border-color: var(--err-ink); }

/* login */
.public__main { flex: 1; padding: 0 1rem; }
.login h1 { color: var(--brand); }
.years { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.25rem; font-size: .9rem; }
.years [aria-current] { font-weight: 700; }

/* tabs */
.tabs { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.tabs a { text-decoration: none; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: .4rem 1rem; }
.tabs a[aria-current] { background: var(--brand); border-color: var(--brand); color: #fff; }
.tabs a[aria-current] strong { color: #fff; }

/* report form */
.report__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: flex-end; }
.report__date { max-width: 220px; }
.question { margin-bottom: .9rem; }
.question legend { font-weight: 600; padding: 0 .25rem; font-size: 1.02rem; }
.question__number { color: var(--brand); }
.required { color: var(--err-ink); }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .15rem 1rem; margin-top: .4rem; }
.choices--grouped { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .75rem 1.5rem; }
.choices__group { display: grid; gap: .1rem; align-content: start; }
.choices:not(.choices--grouped) .choices__group { display: contents; }
.choices__title { font-weight: 700; margin: 0 0 .2rem; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; }
.choice { display: flex; align-items: flex-start; gap: .45rem; font-weight: 400; padding: .25rem .3rem; border-radius: 4px; cursor: pointer; grid-template-columns: none; }
.choice:hover { background: #f6f1f0; }
.choice input { margin-top: .2rem; accent-color: var(--brand); width: 1.05rem; height: 1.05rem; flex: none; }
.help { display: inline-grid; place-items: center; width: 1.2rem; height: 1.2rem; padding: 0; border: 0; border-radius: 50%; background: var(--brand); color: #fff; font: 700 .72rem/1 system-ui, sans-serif; cursor: pointer; flex: none; margin-left: auto; position: relative; }
.help::after { content: ""; position: absolute; inset: -.6rem; } /* larger touch target */
.popover { max-width: min(28rem, calc(100vw - 2rem)); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: 0 10px 30px rgb(0 0 0 / 18%); color: var(--ink); }
.popover::backdrop { background: rgb(0 0 0 / 15%); }
.popover p { margin: 0 0 .6rem; }
.popover__title { font-weight: 700; }
.question__text { margin-top: .9rem; display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: .3rem .5rem; }
.question__text label { font-weight: 500; }
.question__text .help { margin-left: 0; }
.question__text input { grid-column: 1 / -1; }
.select-search { margin-bottom: .4rem; }
.actions { display: flex; gap: 1rem; justify-content: center; padding: 1rem 0; flex-wrap: wrap; }

/* lists */
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin: .75rem 0 1rem; }
.filters label { min-width: 160px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; margin-top: .75rem; }
.table th, .table td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); }
.table th { font-size: .85rem; color: var(--muted); font-weight: 600; }
.table tbody tr:hover { background: #fafafa; }
.table__actions { display: flex; gap: 1rem; justify-content: flex-end; white-space: nowrap; }
.table__actions form { margin: 0; }
.pager { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: 1rem; }
.pager a, .pager span { padding: .2rem .55rem; border: 1px solid var(--line); border-radius: 4px; text-decoration: none; }
.pager [aria-current] { background: var(--brand); color: #fff; border-color: var(--brand); }

@media (max-width: 640px) {
    .topbar__inner { gap: .3rem 1rem; padding-bottom: 0; }
    .session { margin-left: auto; }
    .session__user { display: none; }
    .mainnav, .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
    .mainnav { order: 3; flex-basis: 100%; gap: 1.1rem; padding-bottom: .1rem; }
    .mainnav a, .tabs a { white-space: nowrap; flex: none; }
    .mainnav a { padding: .45rem 0; }
    .tabs { margin-right: -1rem; padding-right: 1rem; }
    .choice { padding: .5rem .3rem; }
    .page { padding-top: 1rem; }
    .report__date { max-width: none; width: 100%; }
    .table__actions { flex-direction: column; gap: .3rem; }
}

@media print {
    .topbar, .footer, .tabs, .actions, .filters, .pager, .skip, .table__actions form { display: none !important; }
    body { background: #fff; }
    .card { border: 0; padding: 0; }
    .question { break-inside: avoid; margin-bottom: .4rem; }
    /* a printed report lists the answers only */
    .choice:not(:has(input:checked)), .choices__group:not(:has(input:checked)), .help, .popover, .select-search, .mainnav { display: none !important; }
    .choices, .choices--grouped { display: block; }
    .question legend { font-size: 10pt; }
    .question__text:has(input[value=""]) { display: none; }
    select { border: 0; appearance: none; padding: 0; }
    a[href]::after { content: none; }
}

/* back office */
h2 { font-size: 1.1rem; margin: 1.25rem 0 .6rem; font-weight: 600; }
.buttons { display: flex; flex-wrap: wrap; gap: .5rem; }
.card__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-top: 1rem; }
.stat { display: grid; gap: .2rem; padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); }
.stat:hover { border-color: var(--brand); color: var(--ink); }
.stat__label { font-weight: 600; }
.stat__value { font-size: 2rem; font-weight: 700; color: var(--brand); line-height: 1.1; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem 1.25rem; }
.grid-form__wide { grid-column: 1 / -1; }
textarea { font: inherit; padding: .5rem .6rem; border: 1px solid #b8bec6; border-radius: 6px; width: 100%; }
input[type=email], input[type=number] { font: inherit; padding: .5rem .6rem; border: 1px solid #b8bec6; border-radius: 6px; background: #fff; width: 100%; min-width: 0; }
.actions--left { justify-content: flex-start; padding: 0; }
.button--danger { background: var(--err-ink); border-color: var(--err-ink); }
.button--danger:hover { background: #7a150d; }
.compact-list { margin: .5rem 0 0; padding-left: 1.2rem; }
.split { display: grid; grid-template-columns: 260px 1fr; gap: 1rem; align-items: start; }
.sidelist { display: grid; gap: .1rem; padding: .6rem; position: sticky; top: 1rem; }
.sidelist a { text-decoration: none; color: var(--ink); padding: .35rem .5rem; border-radius: 4px; font-size: .92rem; }
.sidelist a:hover { background: #f6f1f0; }
.sidelist a[aria-current] { background: var(--brand); color: #fff; }
.ref-line { display: flex; gap: .75rem; align-items: center; border-top: 1px solid var(--line); padding: .5rem 0; }
.ref-line form:last-child { margin: 0; }
.ref-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; flex: 1; margin: 0; }
.ref-row input[name=label] { flex: 2 1 220px; }
.ref-row input[name=help] { flex: 2 1 200px; }
.ref-row select { flex: 1 1 180px; width: auto; }
.ref-row .input-order { width: 5.5rem; flex: none; }
.ref-row .error { flex-basis: 100%; }
.report__owner { min-width: 260px; margin-bottom: .4rem; }
@media (max-width: 800px) { .split { grid-template-columns: 1fr; } .sidelist { position: static; } }

/* statistics */
.table--stats { font-size: .9rem; }
.table--stats caption { text-align: left; font-weight: 700; font-size: 1.05rem; padding-bottom: .5rem; }
.table--stats thead th { text-align: center; white-space: nowrap; }
.table--stats thead th:first-child { text-align: left; }
.table--stats td { padding: .35rem .45rem; white-space: nowrap; }
.table--stats td.num { text-align: right; }
.table--stats td.pct { text-align: right; color: var(--muted); font-size: .8rem; border-right: 1px solid var(--line); }
.table--stats tbody th { color: var(--ink); font-weight: 400; min-width: 12rem; }
.table--stats tr.is-group th, .table--stats tr.is-group td { background: #f6f6f6; font-weight: 600; }
.table--stats tr.is-total th, .table--stats tr.is-total td { background: #fbeae6; font-weight: 700; border-top: 2px solid var(--brand); }
@media print { .filters, .card__head .button { display: none; } .table--stats { font-size: 8pt; } }

/* references: one grid line per value on wide screens */
.ref-head { display: none; }
@media (min-width: 1000px) {
    .ref-list { --cols: minmax(0, 2fr) 5rem; }
    .ref-list--list { --cols: minmax(0, 2fr) 5rem minmax(0, 2fr); }
    .ref-list--item { --cols: minmax(0, 2fr) 5rem minmax(0, 1.5fr) minmax(0, 2fr); }
    .ref-head, .ref-line { display: grid; grid-template-columns: var(--cols) 8rem 5.5rem; gap: .5rem; align-items: center; }
    .ref-head { font-size: .8rem; font-weight: 600; color: var(--muted); padding: 0 0 .3rem; }
    .ref-line .ref-row { display: grid; grid-template-columns: subgrid; grid-column: 1 / -2; }
    .ref-row > * { width: 100%; min-width: 0; }
    .ref-row .error { grid-column: 1 / -1; }
}
