/* Structural CSS — ported from the NWGACIL reference demo. Colors come from
   CSS custom properties defined per-org in base.html (org_config.json). */

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--lime); color: var(--navy);
  padding: .5rem 1rem; border-radius: 0 0 6px 0; z-index: 10;
}
.skip-link:focus { left: 0; }
a { color: var(--accent); }
button { font: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.demo-note {
  background: var(--ink); color: var(--ground);
  text-align: center; font-size: .85rem;
  padding: .4rem 1rem;
}
header.app {
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
  padding: 1.1rem 0 1rem;
}
.shell { max-width: 1160px; margin: 0 auto; padding: 0 1.25rem; }
.shell.narrow { max-width: 620px; }
.masthead { display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: baseline; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: .85rem; flex-wrap: wrap; }
.brand-logo { height: 46px; width: auto; background: #fff; border-radius: 8px; padding: 3px; box-sizing: content-box; }
.brand h1 { margin: 0; font-size: 1.35rem; letter-spacing: -.01em; }
.brand h1 .three60 { color: var(--accent); }
.brand .org { color: var(--ink-2); font-size: .95rem; border-left: 1px solid var(--hairline); padding-left: .75rem; }
.period { display: flex; align-items: center; gap: .6rem; font-size: .9rem; color: var(--ink-2); }
.period select {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--hairline); border-radius: 6px; padding: .3rem .5rem;
}
.masthead-actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.masthead-actions a, .masthead-actions button.link {
  font-size: .88rem; color: var(--ink-2); background: none; border: none; cursor: pointer; text-decoration: underline;
}
.user-badge { font-size: .85rem; color: var(--ink-2); }

main { padding: 1.75rem 0 3rem; display: grid; gap: 2rem; }
section > .shell > h2, .sect-head h2 { margin: 0; font-size: 1.05rem; }
.eyebrow {
  display: block; font-size: .72rem; font-weight: 650;
  letter-spacing: .09em; text-transform: uppercase; color: var(--accent);
  margin-bottom: .25rem;
}
.sect-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 1.5rem; margin-bottom: 1rem; }
.sect-head p { margin: 0; color: var(--ink-2); font-size: .92rem; max-width: 62ch; }

/* ---- Source intake ---- */
.sources { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .9rem; }
.source {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 10px; padding: .9rem 1rem; display: grid; gap: .35rem;
}
.source h3 { margin: 0; font-size: .95rem; }
.source .file { color: var(--ink-2); font-size: .85rem; }
.source .meta { color: var(--ink-3); font-size: .8rem; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .76rem; font-weight: 650; border-radius: 999px;
  padding: .12rem .6rem; width: fit-content;
}
.chip::before { content: ""; width: .55rem; height: .55rem; border-radius: 50%; background: currentColor; }
.chip.current { color: var(--good-text); background: color-mix(in srgb, var(--st-good) 12%, transparent); }
.chip.stale { color: var(--ink); background: color-mix(in srgb, var(--st-warning) 25%, transparent); }
.chip.stale::before { background: var(--st-warning); }
.chip.missing { color: var(--ink-3); background: color-mix(in srgb, var(--ink-3) 12%, transparent); }
.dropzone {
  margin-top: .9rem; border: 2px dashed var(--hairline); border-radius: 10px;
  padding: .9rem 1rem; color: var(--ink-2); font-size: .9rem;
  display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between;
  background: var(--wash);
}
.dropzone.dragover { background: color-mix(in srgb, var(--accent) 12%, var(--wash)); border-color: var(--accent); }
.dropzone strong { color: var(--ink); }
.btn {
  background: var(--lime); color: var(--navy); border: none;
  border-radius: 8px; padding: .55rem 1.1rem; font-weight: 650; cursor: pointer;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost {
  background: transparent; color: var(--accent);
  border: 1.5px solid var(--accent);
}
.btn.danger { background: var(--st-critical); color: #fff; }

/* ---- Brief + issues ---- */
.brief-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 1.25rem; align-items: start; }
@media (max-width: 860px) { .brief-grid { grid-template-columns: 1fr; } }
.card {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 1.25rem 1.4rem;
}
.brief h2 { font-size: 1.05rem; margin: 0 0 .25rem; }
.brief .stamp { color: var(--ink-3); font-size: .8rem; margin-bottom: .9rem; }
.brief-body { font-family: Georgia, "Times New Roman", serif; font-size: 1.03rem; line-height: 1.65; max-width: 62ch; }
.brief-body p { margin: 0 0 .9rem; }
.brief-body .src { font-family: system-ui, sans-serif; font-size: .72rem; color: var(--ink-3); white-space: nowrap; }
.brief-body textarea { width: 100%; min-height: 320px; font: inherit; font-family: Georgia, serif; padding: .6rem; border: 1px solid var(--hairline); border-radius: 8px; background: var(--surface); color: var(--ink); }
.brief-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .5rem; }

.issues { display: grid; gap: .8rem; }
.issue {
  background: var(--surface); border: 1px solid var(--hairline);
  border-left-width: 5px; border-radius: 10px; padding: .85rem 1rem .9rem;
}
.issue.critical { border-left-color: var(--st-critical); }
.issue.serious  { border-left-color: var(--st-serious); }
.issue.watch    { border-left-color: var(--st-warning); }
.issue .sev { font-size: .74rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; display: inline-flex; gap: .35rem; align-items: center; }
.issue.critical .sev { color: var(--st-critical); }
.issue.serious  .sev { color: color-mix(in srgb, var(--st-serious) 80%, var(--ink)); }
.issue.watch    .sev { color: color-mix(in srgb, var(--st-warning) 55%, var(--ink)); }
.issue h3 { margin: .25rem 0 .3rem; font-size: .98rem; }
.issue p { margin: 0; font-size: .89rem; color: var(--ink-2); }
.issue .meta { display: block; margin-top: .45rem; font-size: .78rem; color: var(--ink-3); }

/* ---- KPIs ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: .9rem; }
.kpi { background: var(--surface); border: 1px solid var(--hairline); border-radius: 10px; padding: .9rem 1rem; }
.kpi .label { font-size: .82rem; color: var(--ink-2); }
.kpi .value { font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.kpi .note { font-size: .8rem; color: var(--ink-3); }
.kpi .note .up { color: var(--good-text); font-weight: 650; }
.kpi .note .down { color: var(--st-critical); font-weight: 650; }

/* ---- Charts ---- */
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 1.1rem; }
figure.viz {
  margin: 0; background: var(--chart-surface); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 1.1rem 1.2rem 1rem; position: relative;
}
figure.viz figcaption { margin-bottom: .15rem; }
figure.viz figcaption .t { font-weight: 650; font-size: .98rem; display: block; }
figure.viz figcaption .s { font-size: .82rem; color: var(--ink-2); display: block; }
.plot-wrap { position: relative; margin-top: .5rem; }
.plot-wrap svg { display: block; width: 100%; height: auto; }
.viz .summary { font-size: .84rem; color: var(--ink-2); margin: .6rem 0 0; max-width: 58ch; }
.viz .legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .8rem; color: var(--ink-2); margin-top: .35rem; }
.viz .legend span { display: inline-flex; align-items: center; gap: .4rem; }
.viz .legend i { width: .8rem; height: .8rem; border-radius: 3px; display: inline-block; }
.table-toggle {
  margin-top: .7rem; background: none; border: none; color: var(--accent);
  font-size: .84rem; font-weight: 650; cursor: pointer; padding: .15rem 0;
  text-decoration: underline; text-underline-offset: 3px;
}
.viz table {
  width: 100%; border-collapse: collapse; margin-top: .6rem; font-size: .85rem;
  font-variant-numeric: tabular-nums;
}
.viz table caption { text-align: left; font-size: .78rem; color: var(--ink-3); padding-bottom: .3rem; }
.viz th, .viz td { text-align: left; padding: .3rem .5rem; border-bottom: 1px solid var(--grid); }
.viz td.num, .viz th.num { text-align: right; }
.viz [hidden] { display: none; }
.tip {
  position: absolute; pointer-events: none; background: var(--ink); color: var(--ground);
  font-size: .78rem; padding: .25rem .55rem; border-radius: 6px; white-space: nowrap;
  transform: translate(-50%, -130%); opacity: 0; transition: opacity .12s;
}
@media (prefers-reduced-motion: reduce) { .tip { transition: none; } }

.card-title { margin: 0; font-size: 1.05rem; }
.card-sub { color: var(--ink-3); font-size: .8rem; margin: .15rem 0 .5rem; }

/* ---- Suggested actions & follow-through ---- */
.actions-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 1.25rem; align-items: start; }
@media (max-width: 860px) { .actions-grid { grid-template-columns: 1fr; } }
ol.actions { margin: .5rem 0 0; padding: 0 0 0 1.4rem; display: grid; gap: .95rem; }
ol.actions li { padding-left: .3rem; }
ol.actions li::marker { font-weight: 700; color: var(--accent); }
ol.actions .act { font-weight: 650; }
ol.actions .why { display: block; font-size: .88rem; color: var(--ink-2); margin-top: .15rem; }
.due {
  display: inline-block; font-size: .74rem; font-weight: 700; color: var(--accent);
  border: 1.5px solid currentColor; border-radius: 999px; padding: .02rem .55rem;
  margin-left: .45rem; white-space: nowrap; vertical-align: middle;
}
ul.followups { list-style: none; margin: .4rem 0 0; padding: 0; }
ul.followups li { padding: .75rem 0; border-top: 1px solid var(--hairline); }
ul.followups li:first-child { border-top: none; padding-top: .35rem; }
.fu-head { display: flex; justify-content: space-between; gap: .75rem; align-items: baseline; }
.fu-head h4 { margin: 0; font-size: .93rem; }
.fu-chip { font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }
.fu-chip.worse { color: var(--st-critical); }
.fu-chip.better { color: var(--good-text); }
.fu-chip.same { color: color-mix(in srgb, var(--st-warning) 50%, var(--ink)); }
ul.followups p { margin: .2rem 0 0; font-size: .85rem; color: var(--ink-2); }

/* ---- Looking ahead ---- */
.ahead-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
@media (max-width: 860px) { .ahead-grid { grid-template-columns: 1fr; } }
.ahead-grid .span2 { grid-column: 1 / -1; }
.ahead-grid .big { font-size: 1.55rem; font-weight: 700; letter-spacing: -.015em; margin: .25rem 0 0; }
.ahead-grid .big small { font-size: .95rem; font-weight: 600; color: var(--ink-2); }
.ahead-grid p { font-size: .9rem; color: var(--ink-2); margin: .35rem 0 0; }
ul.renewals { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 1rem; }
ul.renewals > li { display: grid; grid-template-columns: minmax(200px, 2fr) minmax(0, 3fr); gap: .3rem 1.5rem; align-items: center; }
@media (max-width: 700px) { ul.renewals > li { grid-template-columns: 1fr; } }
.renewal-who strong { display: block; font-size: .93rem; }
.renewal-who span { color: var(--ink-3); font-size: .8rem; }
.tl { position: relative; height: 12px; border-radius: 6px; background: color-mix(in srgb, var(--ink) 9%, transparent); }
.tl .cover { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 6px; background: var(--series-1); }
.renewal-note { font-size: .8rem; color: var(--ink-2); margin-top: .3rem; }
ul.deadlines { list-style: none; margin: .6rem 0 0; padding: 0; display: grid; gap: .5rem; font-size: .92rem; }
ul.deadlines .d { display: inline-block; min-width: 4.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---- Grants ---- */
.grants { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 1.1rem; align-items: start; }
.grant h3 { margin: 0; font-size: 1rem; }
.grant .gmeta { font-size: .82rem; color: var(--ink-3); margin: .15rem 0 .9rem; }
.grant ul.obs { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem; }
.ob-head { display: flex; justify-content: space-between; gap: .75rem; align-items: baseline; font-size: .9rem; }
.ob-name { font-weight: 600; }
.ob-chip { font-size: .73rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }
.ob-chip.ontrack, .ob-chip.complete { color: var(--good-text); }
.ob-chip.behind { color: color-mix(in srgb, var(--st-serious) 80%, var(--ink)); }
.ob-chip.watch { color: color-mix(in srgb, var(--st-warning) 50%, var(--ink)); }
.bar { position: relative; height: 10px; border-radius: 5px; background: color-mix(in srgb, var(--ink) 9%, transparent); margin: .35rem 0 .25rem; }
.bar .fill { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 5px; background: var(--series-1); }
.bar .pace { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink-2); }
.ob-note { font-size: .8rem; color: var(--ink-2); }
.grant-flags { margin-top: 1rem; padding-top: .85rem; border-top: 1px solid var(--hairline); display: grid; gap: .35rem; font-size: .85rem; }
.grant-flags .win { color: var(--good-text); }
.grant-flags .focus { color: color-mix(in srgb, var(--st-serious) 80%, var(--ink)); }

/* ---- Board packet ---- */
.packet { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1.5rem; align-items: start; }
@media (max-width: 820px) { .packet { grid-template-columns: 1fr; } }
.packet ul { margin: .4rem 0 0; padding-left: 1.2rem; color: var(--ink-2); font-size: .92rem; }
.packet li { margin-bottom: .3rem; }
fieldset.formats, fieldset.sections { border: 1px solid var(--hairline); border-radius: 10px; padding: .8rem 1rem 1rem; margin: 0; }
fieldset.formats legend, fieldset.sections legend { font-size: .85rem; font-weight: 650; padding: 0 .4rem; }
.formats label, .sections label { display: flex; gap: .55rem; align-items: center; font-size: .9rem; padding: .25rem 0; }
fieldset.sections { margin-top: 1rem; }
.packet .btn { margin-top: 1rem; }

.sample-banner {
  background: #111318; color: #ffffff; text-align: center;
  font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  font-size: .8rem; padding: .5rem 1rem;
}
footer.app {
  border-top: 1px solid var(--hairline); color: var(--ink-3);
  font-size: .82rem; padding: 1.25rem 0 2rem;
}

/* ==================== New for the real app (auth, forms, wizard, review) ==================== */

.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card { max-width: 420px; width: 100%; }
.auth-card h1 { font-size: 1.3rem; margin: 0 0 .3rem; }
.auth-card .sub { color: var(--ink-2); font-size: .9rem; margin: 0 0 1.25rem; }
.field { display: grid; gap: .35rem; margin-bottom: 1rem; }
.field label { font-size: .88rem; font-weight: 650; }
.field .hint { font-size: .8rem; color: var(--ink-3); font-weight: 400; }
.field input[type=text], .field input[type=password], .field input[type=email],
.field input[type=number], .field input[type=date], .field select, .field textarea {
  font: inherit; padding: .55rem .65rem; border: 1px solid var(--hairline);
  border-radius: 8px; background: var(--surface); color: var(--ink); width: 100%;
}
.field textarea { min-height: 90px; }
.form-error { background: color-mix(in srgb, var(--st-critical) 12%, transparent); color: var(--st-critical);
  border: 1px solid color-mix(in srgb, var(--st-critical) 40%, transparent); border-radius: 8px; padding: .6rem .8rem; font-size: .88rem; margin-bottom: 1rem; }
.form-note { background: color-mix(in srgb, var(--st-warning) 16%, transparent); color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--st-warning) 45%, transparent); border-radius: 8px; padding: .6rem .8rem; font-size: .88rem; margin-bottom: 1rem; }
.qr-wrap { text-align: center; margin: 1rem 0; }
.qr-wrap img { border: 1px solid var(--hairline); border-radius: 8px; }
.totp-secret { font-family: ui-monospace, monospace; font-size: .85rem; background: var(--wash); padding: .3rem .5rem; border-radius: 6px; word-break: break-all; }

/* Wizard */
.wizard-progress { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.5rem; list-style: none; padding: 0; }
.wizard-progress li { font-size: .82rem; padding: .3rem .7rem; border-radius: 999px; background: var(--wash); color: var(--ink-2); }
.wizard-progress li.done { background: color-mix(in srgb, var(--st-good) 15%, transparent); color: var(--good-text); font-weight: 650; }
.wizard-progress li.current { background: var(--accent); color: var(--accent-ink); font-weight: 650; }
.wizard-step { max-width: 720px; }
.wizard-step h2 { margin-top: 0; }
.wizard-actions { display: flex; gap: .75rem; margin-top: 1.5rem; flex-wrap: wrap; }
.report-howto { background: var(--wash); border-radius: 8px; padding: .8rem 1rem; font-size: .88rem; margin-bottom: 1rem; }
.report-howto strong { display: block; margin-bottom: .2rem; }
.alt-path { border-top: 1px dashed var(--hairline); margin-top: 1.25rem; padding-top: 1.25rem; }
.alt-path summary { cursor: pointer; font-weight: 650; font-size: .92rem; color: var(--accent); }

/* Review screen */
.review-table-wrap { margin-bottom: 1.5rem; }
.review-table-wrap h3 { margin-bottom: .4rem; font-size: .98rem; }
table.review-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.review-table th, table.review-table td { text-align: left; padding: .4rem .6rem; border-bottom: 1px solid var(--hairline); }
table.review-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.confidence-flag { color: var(--st-warning); font-weight: 650; font-size: .78rem; }
.agg-sublist { margin: 0; padding-left: 1.1rem; font-size: .88rem; }
.provenance { color: var(--ink-3); font-size: .78rem; }

/* Repeatable rows (objectives, grants) */
.repeat-row { border: 1px solid var(--hairline); border-radius: 8px; padding: .8rem; margin-bottom: .6rem; position: relative; }
.repeat-row .remove-row { position: absolute; top: .5rem; right: .5rem; background: none; border: none; color: var(--st-critical); cursor: pointer; font-size: .82rem; }
.row-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 640px) { .row-grid { grid-template-columns: 1fr; } }

/* Progress / loading state */
.progress-wrap { max-width: 520px; margin: 3rem auto; text-align: center; }
.progress-wrap .spinner { width: 40px; height: 40px; border: 4px solid var(--hairline); border-top-color: var(--accent); border-radius: 50%; margin: 0 auto 1.2rem; animation: e360-spin 1s linear infinite; }
@media (prefers-reduced-motion: reduce) { .progress-wrap .spinner { animation: none; } }
@keyframes e360-spin { to { transform: rotate(360deg); } }
.progress-stage { font-size: .95rem; color: var(--ink-2); min-height: 1.4em; }

/* Onboarding gate banner */
.gate-banner { background: color-mix(in srgb, var(--st-warning) 18%, transparent); border: 1px solid color-mix(in srgb, var(--st-warning) 45%, transparent); border-radius: 10px; padding: 1rem 1.25rem; margin-bottom: 1.5rem; }
.gate-banner a.btn { margin-top: .5rem; display: inline-block; }

/* Users table (admin) */
table.admin-table { width: 100%; border-collapse: collapse; }
table.admin-table th, table.admin-table td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--hairline); font-size: .9rem; }

/* Diff/version note */
.superseded-note { font-size: .8rem; color: var(--ink-3); font-style: italic; }
