/* FSPA scrutiny - application shell and components. Light + dark, keyboard-friendly. */

:root {
  --bg: #f3f5f8; --panel: #ffffff; --panel-2: #f8fafc; --ink: #18202c; --muted: #5d6878; --line: #e2e6ec;
  --accent: #1f4fa3; --accent-ink: #ffffff; --accent-soft: #e8eefb; --on-accent: #ffffff;
  --side-bg: #ffffff; --side-ink: #2a3442; --side-active: #e8eefb; --side-active-ink: #1f4fa3;
  --top-bg: #0f2d5c; --top-ink: #ffffff;
  --fail: #c81e2d; --fail-bg: #fdecee; --verify: #b86e00; --verify-bg: #fff4e0; --nd: #5a5f6a; --nd-bg: #eef0f3;
  --pass: #14824a; --pass-bg: #e7f6ee; --na: #7b8494; --na-bg: #f1f2f4;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --side-w: 236px; --top-h: 56px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218; --panel: #171b23; --panel-2: #1c212b; --ink: #e6e9ef; --muted: #9aa4b2; --line: #2a313c;
    --accent: #7aa7ff; --accent-ink: #0b1220; --accent-soft: #1d2a44; --on-accent: #0b1220;
    --side-bg: #13171e; --side-ink: #c9d1dc; --side-active: #1d2a44; --side-active-ink: #a9c4ff;
    --top-bg: #0b1424; --top-ink: #e6e9ef;
    --fail: #ff6b77; --fail-bg: #3a1a1f; --verify: #f0a640; --verify-bg: #3a2a12; --nd: #b5bcc8; --nd-bg: #262b33;
    --pass: #4cc488; --pass-bg: #15301f; --na: #8d96a5; --na-bg: #22262d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
/* the hidden attribute must win over component display rules (label, .form-grid) */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
       font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif; }
a { color: var(--accent); }
h1 { font-size: 22px; line-height: 1.25; margin: 0; }
h2 { font-size: 17px; margin: 26px 0 10px; }
h3 { font-size: 15px; }
code, .code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.hint { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.rid { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--panel); padding: 8px 12px; z-index: 50; }
.skip-link:focus { left: 8px; }

/* ------------------------------------------------------------------ app shell */
.topbar { position: sticky; top: 0; z-index: 30; height: var(--top-h); display: flex; align-items: center; gap: 12px;
          padding: 0 16px; background: var(--top-bg); color: var(--top-ink); box-shadow: 0 1px 0 rgba(0, 0, 0, .15); }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 700; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-weight: 800;
              background: rgba(255, 255, 255, .14); }
.brand small { display: block; font-weight: 500; font-size: 11.5px; opacity: .75; letter-spacing: .02em; }
.env-badge { font-size: 11px; font-weight: 700; letter-spacing: .06em; padding: 2px 8px; border-radius: 999px;
             background: rgba(255, 255, 255, .16); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.nav-toggle { display: none; background: transparent; border: 1px solid rgba(255, 255, 255, .35); color: inherit;
              border-radius: 8px; padding: 4px 9px; font-size: 18px; line-height: 1; cursor: pointer; }

.usermenu { position: relative; }
.usermenu > summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 4px 8px;
                      border-radius: 8px; }
.usermenu > summary::-webkit-details-marker { display: none; }
.usermenu > summary:hover, .usermenu[open] > summary { background: rgba(255, 255, 255, .1); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 13px;
          font-weight: 700; background: #ffffff; color: var(--top-bg); }
.u-name { font-weight: 600; font-size: 14px; line-height: 1.15; }
.u-roles { display: block; font-size: 11.5px; opacity: .78; font-weight: 400; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px; background: var(--panel); color: var(--ink);
        border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(16, 24, 40, .18);
        padding: 10px; z-index: 40; }
.menu .menu-head { padding: 4px 6px 10px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.menu .menu-head b { display: block; }
.menu button { width: 100%; justify-content: flex-start; }

.layout { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: calc(100vh - var(--top-h)); }
.sidebar { background: var(--side-bg); border-right: 1px solid var(--line); padding: 16px 10px; position: sticky;
           top: var(--top-h); height: calc(100vh - var(--top-h)); overflow-y: auto; display: flex; flex-direction: column; }
.nav-section { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
               margin: 14px 10px 6px; }
.nav-section:first-child { margin-top: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--side-ink);
            text-decoration: none; font-weight: 500; font-size: 14.5px; }
.nav-item svg { width: 18px; height: 18px; flex: none; opacity: .8; }
.nav-item:hover { background: var(--panel-2); }
.nav-item.active { background: var(--side-active); color: var(--side-active-ink); font-weight: 650; }
.nav-item.active svg { opacity: 1; }
.sidebar-foot { margin-top: auto; padding: 12px 10px 2px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }

.content { padding: 18px 28px 64px; min-width: 0; }
.content-inner { max-width: 1180px; margin: 0 auto; }
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 13px; color: var(--muted);
               margin: 0 0 12px; }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); text-decoration: underline; }
.breadcrumbs .sep { opacity: .55; }
.breadcrumbs [aria-current] { color: var(--ink); font-weight: 600; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px;
             margin: 0 0 18px; }
.page-head .sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.page-head .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ------------------------------------------------------------------ surfaces */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
         box-shadow: var(--shadow); }
.panel h3 { margin: 0 0 8px; }
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin: 14px 0; }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 0 0 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
        box-shadow: var(--shadow); }
.stat b { display: block; font-size: 24px; line-height: 1.2; }
.stat span { font-size: 12.5px; color: var(--muted); }

/* ------------------------------------------------------------------ buttons & forms */
button, .btn { font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
               cursor: pointer; padding: 8px 14px; border-radius: 8px; border: 1px solid transparent;
               background: var(--accent); color: var(--on-accent); text-decoration: none; line-height: 1.3; }
button:hover, .btn:hover { filter: brightness(1.06); }
button.secondary, .btn.secondary { background: var(--panel); color: var(--ink); border-color: var(--line); }
button.danger, .btn.danger { background: var(--fail); color: #fff; }
button:disabled { opacity: .55; cursor: progress; }
/* text-style buttons: must beat `button` and `button.danger` (red fill) */
button.linkbtn, button.linkbtn.danger { background: none; border: 0; padding: 0; font: inherit; font-weight: 500;
  color: var(--accent); cursor: pointer; text-decoration: underline; }
button.linkbtn.danger { color: var(--fail); }
label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line);
                          border-radius: 8px; padding: 8px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea.code, input.code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; }
textarea.code { min-height: 90px; width: 100%; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 14px 0; background: var(--panel); }
legend { font-weight: 650; padding: 0 6px; }
.form-grid { display: grid; gap: 12px 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin: 12px 0; }
.toolbar form, .inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin: 0; }
form.upload { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: end; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.checks label { display: flex; gap: 6px; align-items: center; font-weight: 500; color: var(--ink); }
.choices { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.choices label { display: flex; gap: 4px; align-items: center; font-weight: 500; color: var(--ink); }
.inline-form { display: inline; margin: 0; }

/* ------------------------------------------------------------------ tables */
.table-scroll { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line);
        border-radius: var(--radius); font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11.5px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; background: var(--panel-2); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td, table tr:hover td { background: color-mix(in srgb, var(--panel-2) 70%, transparent); }
tr.superseded td { opacity: .62; }
.nowrap { white-space: nowrap; }
.row-actions { display: flex; flex-wrap: wrap; gap: 4px 12px; }

/* ------------------------------------------------------------------ status chips & messages */
.chip { display: inline-block; border-radius: 999px; padding: 1px 10px; font-weight: 600; font-size: 12.5px;
        white-space: nowrap; text-decoration: none; }
.s-fail, .s-failed { color: var(--fail); background: var(--fail-bg); }
.s-verify { color: var(--verify); background: var(--verify-bg); }
.s-not_determinable { color: var(--nd); background: var(--nd-bg); }
.s-pass, .s-done { color: var(--pass); background: var(--pass-bg); }
.s-not_applicable, .s-queued, .s-processing { color: var(--na); background: var(--na-bg); }
.sev { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.sev-critical { color: var(--fail); }
.sev-major { color: var(--verify); }
.draft-tag { font-size: 11px; font-weight: 700; color: var(--verify); border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; }
.msg { border-radius: var(--radius); padding: 10px 14px; margin: 12px 0; border: 1px solid transparent; }
.msg p { margin: 0; font-weight: 600; }
.msg ul { margin: 6px 0 0; padding-left: 20px; }
.msg-ok, .notice { background: var(--pass-bg); color: var(--pass); border-color: color-mix(in srgb, var(--pass) 25%, transparent); }
.notice { border-radius: var(--radius); padding: 10px 14px; margin: 12px 0; font-weight: 600; }
.msg-err { background: var(--fail-bg); color: var(--fail); border-color: color-mix(in srgb, var(--fail) 25%, transparent); }
.who-line { margin: 6px 0 12px; }
.done-by { font-size: 12px; color: var(--accent); margin-top: 4px; }
.locked { font-size: 14px; }

/* ------------------------------------------------------------------ rule editor / imports */
.fixture { display: grid; gap: 8px 12px; grid-template-columns: minmax(160px, 1fr) 170px auto; align-items: start;
           border-top: 1px solid var(--line); padding: 10px 0; }
.fixture .facts { grid-column: 1 / -1; }

/* ------------------------------------------------------------------ officer review */
.review-row td { font-size: 14px; }
.review-row textarea { width: 100%; min-height: 34px; }
tr.row-error td { background: var(--fail-bg); }
.row-msg { color: var(--fail); font-size: 13px; font-weight: 600; margin-top: 4px; }
details.why { display: inline; }
details.why > summary { display: inline-flex; align-items: center; justify-content: center; list-style: none;
  width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line); color: var(--accent);
  font-size: 13px; cursor: pointer; vertical-align: middle; margin-left: 4px; }
details.why > summary::-webkit-details-marker { display: none; }
details.why[open] > summary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.why-panel { margin: 8px 0 4px; padding: 10px 12px; border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 8px; background: var(--panel-2); font-size: 13.5px; }
.why-panel p { margin: 0 0 6px; }
.why-panel ul { margin: 0 0 6px; padding-left: 18px; }
.why-panel img { max-width: 100%; border: 1px solid var(--line); border-radius: 6px; background: #fff; margin-top: 4px; }
.why-panel li.culprit { font-weight: 600; }
.culprit-tag { color: var(--fail); margin-left: 4px; }

/* ------------------------------------------------------------------ login */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 460px); }
.auth-aside { background: linear-gradient(160deg, #0f2d5c, #1f4fa3); color: #fff; padding: 48px; display: flex;
              flex-direction: column; justify-content: space-between; }
.auth-aside h1 { font-size: 28px; margin: 18px 0 10px; }
.auth-aside p { opacity: .85; max-width: 46ch; }
.auth-aside ul { padding-left: 18px; opacity: .85; }
.auth-main { display: grid; place-items: center; padding: 32px 20px; background: var(--panel); }
.login { width: 100%; max-width: 360px; }
.login h2 { margin: 0 0 4px; font-size: 22px; }
.login form { display: grid; gap: 14px; margin-top: 18px; }
.login input { width: 100%; }
.login button[type="submit"] { width: 100%; padding: 10px 14px; }

/* ------------------------------------------------------------------ embedded compliance report */
.fspa-report header.top { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: baseline; justify-content: space-between; }
.fspa-report h2 { font-size: 17px; margin: 30px 0 6px; }
.fspa-report .meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 18px 0; }
.fspa-report .meta div { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.fspa-report .meta b { display: block; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.fspa-report .chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.fspa-report .chip { padding: 4px 12px; font-size: 14px; }
.fspa-report .finding { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--line);
                        border-radius: 8px; padding: 12px 14px; margin: 10px 0; }
.fspa-report .finding.fail { border-left-color: var(--fail); }
.fspa-report .finding.verify { border-left-color: var(--verify); }
.fspa-report .finding.not_determinable { border-left-color: var(--nd); }
.fspa-report .finding.pass { border-left-color: var(--pass); }
.fspa-report .finding .head { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; }
.fspa-report .finding .title { font-weight: 650; }
.fspa-report .sev.critical { color: var(--fail); }
.fspa-report .msg { margin: 6px 0 4px; padding: 0; border: 0; background: none; color: inherit; border-radius: 0; }
.fspa-report .kv { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 14px; }
.fspa-report .kv span b { color: var(--muted); font-weight: 600; }
.fspa-report .cite { font-size: 13px; color: var(--muted); margin-top: 6px; }
.fspa-report .draft { font-size: 11px; font-weight: 700; color: var(--verify); border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; margin-left: 4px; }
.fspa-report .action { font-size: 14px; margin-top: 6px; padding: 6px 10px; background: var(--bg); border-radius: 6px; }
.fspa-report .ev { font-size: 13px; color: var(--muted); margin-top: 6px; }
.fspa-report .ev code { font-size: 12px; }
.fspa-report .review { font-size: 13px; margin-top: 6px; font-weight: 600; color: var(--accent); }
.fspa-report details > summary { cursor: pointer; color: var(--accent); margin: 8px 0; }
.fspa-report figure { margin: 14px 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.fspa-report figure img { width: 100%; height: auto; display: block; background: #fff; }
.fspa-report figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; }
.fspa-report figure.zoom { margin: 10px 0 2px; padding: 6px; max-width: 520px; }
.fspa-report .banner { background: var(--verify-bg); color: var(--ink); border-radius: 8px; padding: 10px 14px; margin: 12px 0; font-size: 14px; }
.fspa-report footer { margin-top: 40px; font-size: 13px; color: var(--muted); }
.revision-bar { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; padding: 10px 14px; margin: 0 0 14px;
                border-radius: var(--radius); background: var(--accent-soft); font-size: 14px; }

/* ------------------------------------------------------------------ responsive & print */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .nav-toggle { display: inline-block; }
  .sidebar { position: fixed; left: 0; top: var(--top-h); z-index: 25; width: min(280px, 85vw); transform: translateX(-100%);
             transition: transform .18s ease; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }
  body.nav-open .sidebar { transform: none; }
  .content { padding: 14px 16px 48px; }
  .u-name, .u-roles { display: none; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { display: none; }
}
@media (max-width: 560px) { .fixture { grid-template-columns: 1fr; } }
@media print {
  .topbar, .sidebar, .breadcrumbs, .page-head .actions, .noprint, .revision-bar { display: none !important; }
  .layout { display: block; }
  .content { padding: 0; }
  body { background: #fff; }
}
