:root {
  /* VPA360 palette: navy header + brand-blue accent. No orange anywhere —
     the former warm-gold accent is replaced by --vb-accent (brand blue).
     Tokens mirror VPA360-Results-Spec.md §1. */
  --vb-navy: #163a6b;        /* header gradient top */
  --vb-navy-2: #122f57;      /* header gradient bottom */
  --vb-accent: #1a5dab;      /* brand blue — primary accent everywhere */
  --vb-accent-2: #134a8a;    /* brand blue hover */
  --ink: #15233a;            /* headings */
  --ink-muted: #6b7689;      /* secondary text */
  --ink-label: #97a1b2;      /* uppercase field labels */
  --bg: #f1f4f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e3e8ef;
  --border-strong: #cdd6e2;
  --text: #1d2733;
  --muted: #6b7689;
  --ok: #1c7a4a;
  --ok-bg: #e7f5ee;
  --err: #b23b34;
  --err-bg: #fdeded;
  --warn: #8a6d1f;
  --warn-bg: #fbf3da;
  --info: #1a5dab;
  --info-bg: #e8f1fb;
  --shadow: 0 1px 2px rgba(20, 40, 80, .04), 0 4px 12px rgba(20, 40, 80, .06);
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14.5px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

/* ---------- header ---------- */
.site-header {
  background: linear-gradient(180deg, var(--vb-navy) 0%, var(--vb-navy-2) 100%);
  color: #fff;
  border-bottom: 3px solid var(--vb-accent);
  box-shadow: 0 2px 8px rgba(15, 23, 42, .15);
}
.site-header .inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: .85rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.brand {
  display: flex; align-items: center; gap: .85rem;
  text-decoration: none; color: #fff;
}
.brand-emblem { height: 40px; width: auto; display: block; flex-shrink: 0; }
.brand-divider { width: 1px; height: 30px; background: rgba(255,255,255,.22); }
.brand-title { font-size: 1rem; font-weight: 600; color: #fff; }
.spacer { flex: 1; }
.site-header nav a {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  font-size: .9rem;
  margin-left: 1rem;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: border-color .15s, color .15s;
}
.site-header nav a:hover { color: #fff; border-bottom-color: var(--vb-accent); }

/* ---------- layout ---------- */
main {
  max-width: 1180px;
  margin: 1.75rem auto 3rem;
  padding: 0 1.5rem;
}
.page-title { margin: 0 0 .25rem; font-size: 1.45rem; font-weight: 600; color: var(--vb-navy); }
.page-sub { color: var(--muted); margin: 0 0 1.5rem; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
h2 {
  font-size: 1.05rem;
  margin: 1.25rem 0 .5rem;
  color: var(--vb-navy);
  font-weight: 600;
}

/* ---------- forms ---------- */
form { display: grid; gap: 1rem; }
form .row { display: grid; gap: .35rem; }
label { font-size: .82rem; font-weight: 600; color: #374151; letter-spacing: .01em; }
input[type="text"], input[type="file"] {
  font: inherit;
  padding: .55rem .7rem;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
  max-width: 32rem;
  transition: border-color .15s, box-shadow .15s;
}
input[type="text"]:focus, input[type="file"]:focus {
  outline: none;
  border-color: var(--vb-navy-2);
  box-shadow: 0 0 0 3px rgba(36, 58, 99, .15);
}
input[type="file"] { padding: .35rem .5rem; cursor: pointer; }
.field-hint { font-size: .8rem; color: var(--muted); }

/* The `button, .btn { display: inline-flex }` below overrides the UA
   `[hidden] { display: none }`, which would otherwise leave hidden buttons
   (e.g. vpa-submit / vpa-refresh / vpa-reconcile) visible. Restore it. */
[hidden] { display: none !important; }

button, .btn {
  font: inherit;
  font-weight: 600;
  padding: .55rem 1.1rem;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  transition: background .15s, border-color .15s, transform .05s;
}
/* Disabled buttons: dimmed, not-allowed, and no hover/active feedback.
   (The :hover rules below are guarded with :not(:disabled) so a disabled
   button never looks clickable.) */
button:disabled, .btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}
button[type="submit"], .btn-primary {
  background: var(--vb-accent);
  color: #fff;
}
button[type="submit"]:not(:disabled):hover, .btn-primary:not(:disabled):hover {
  background: var(--vb-accent-2);
}
button[type="submit"]:not(:disabled):active { transform: translateY(1px); }
.btn-accent { background: var(--vb-accent); color: #fff; }
.btn-accent:not(:disabled):hover { background: var(--vb-accent-2); }
.btn-secondary {
  background: var(--surface);
  color: var(--vb-navy);
  border-color: var(--border-strong);
}
.btn-secondary:not(:disabled):hover { background: var(--surface-2); border-color: var(--vb-navy); }

.actions { display: flex; gap: .6rem; align-items: center; }

/* ---------- status panel ---------- */
.status {
  background: var(--surface-2);
  padding: .7rem .9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .85rem;
  white-space: pre-wrap;
  color: var(--muted);
  min-height: 2rem;
}
.status:empty::before { content: "Ready."; }
.status.error { color: var(--err); border-color: #f4c4c4; background: var(--err-bg); }
.status.success { color: var(--ok); border-color: #b4dcc7; background: var(--ok-bg); }

/* ---------- pills / badges ---------- */
.pill {
  display: inline-flex; align-items: center;
  padding: .15rem .6rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600;
  letter-spacing: .03em;
  background: var(--info-bg); color: var(--info);
  border: 1px solid transparent;
}
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.err { background: var(--err-bg); color: var(--err); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.muted { background: #eef0f4; color: var(--muted); }

.state-badge {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .35rem .8rem; border-radius: 999px;
  font-weight: 600; font-size: .9rem;
  background: var(--info-bg); color: var(--info);
  border: 1px solid transparent;
}
.state-badge::before {
  content: ""; width: 8px; height: 8px; border-radius: 999px;
  background: currentColor;
}
.state-badge.ok { background: var(--ok-bg); color: var(--ok); }
.state-badge.err { background: var(--err-bg); color: var(--err); }
.state-badge.pending::before { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .35; transform: scale(.8); }
}

/* ---------- summary stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .75rem;
  margin: .75rem 0 1.25rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .8rem 1rem;
}
.stat .label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat .value { font-size: 1.4rem; font-weight: 600; color: var(--vb-navy); margin-top: .15rem; }
.stat.err .value { color: var(--err); }
.stat.warn .value { color: var(--warn); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
table {
  border-collapse: collapse;
  width: 100%;
  font-size: .87rem;
}
thead th {
  background: var(--surface-2);
  text-align: left;
  font-weight: 600;
  color: var(--vb-navy);
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--border);
  font-size: .78rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}
tbody td {
  padding: .55rem .75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tbody tr:nth-child(2n) td { background: var(--surface-2); }
tbody tr:hover td { background: #f6f9fd; }
tbody tr:last-child td { border-bottom: 0; }
.empty {
  padding: 1.25rem;
  color: var(--muted);
  font-style: italic;
  text-align: center;
}

/* ---------- inline code ---------- */
code {
  background: #eef1f5;
  color: var(--vb-navy);
  padding: 1px .35rem;
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .85em;
}

/* ---------- download list ---------- */
.downloads { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.downloads li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .6rem .8rem;
  display: flex; align-items: center; gap: .6rem;
}
.downloads .icon {
  width: 28px; height: 28px; border-radius: 4px;
  background: var(--vb-navy);
  display: grid; place-items: center;
  color: #fff; font-size: .7rem; font-weight: 700;
  letter-spacing: .03em;
}
.downloads .icon.json { background: var(--info); }
.downloads .icon.xlsx { background: var(--ok); }
.downloads .icon.html { background: var(--vb-accent); }
.downloads .icon.intermediate { background: var(--vb-navy); }
.downloads a {
  color: var(--vb-navy);
  text-decoration: none;
  font-weight: 600;
  flex: 1;
}
.downloads a:hover { color: var(--vb-accent); }
.downloads .desc { color: var(--muted); font-size: .82rem; font-weight: 400; display: block; }

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: .8rem;
  padding: 1rem 1.5rem;
  text-align: center;
}
.site-footer code { font-size: .8em; }

/* ---------- helpers ---------- */
.muted { color: var(--muted); }
.row-inline { display: flex; gap: .75rem; align-items: end; flex-wrap: wrap; }
.row-inline > * { flex: 0 0 auto; }
hr.subtle { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }

/* ===================================================================
   Import Results redesign (VPA360-Results-Spec.md). Scoped to the
   results page via classes; does not affect upload/status/help.
   =================================================================== */

/* tracking chip */
.track-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .78rem; color: #455061;
  background: #e8edf4; padding: 2px 7px; border-radius: 5px;
}

/* sign-in gate (shown only when no/invalid token) */
.signin {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.25rem 1.4rem; box-shadow: var(--shadow);
  max-width: 34rem; margin: 0 auto;
}
.signin h2 { margin-top: 0; }

/* meta strip */
.meta-strip { position: relative; }
.meta-strip .meta-row {
  display: flex; align-items: center; gap: 2rem;
  flex-wrap: wrap; padding-right: 11rem; min-height: 38px;
}
.meta-strip .meta-action { position: absolute; top: 0; right: 0; }
.meta-field { display: flex; flex-direction: column; gap: 2px; }
.meta-field .k {
  font-size: .66rem; font-weight: 600; color: var(--ink-label);
  text-transform: uppercase; letter-spacing: .06em;
}
.meta-field .v { font-size: .85rem; color: #2b3850; font-weight: 500; }
.meta-file {
  display: flex; flex-direction: column; gap: 2px;
  margin-top: 1rem; padding-top: .95rem; border-top: 1px solid #eef2f7;
}
.status-pill {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .35rem .8rem; border-radius: 999px;
  background: var(--info-bg); border: 1px solid #cfe0f4;
  font-size: .82rem; font-weight: 600; color: var(--vb-accent);
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 999px; background: var(--vb-accent); }
.status-pill.done { color: var(--ok); border-color: #bfe6cf; background: var(--ok-bg); }
.status-pill.done .dot { background: var(--ok); }
.status-pill.bad { color: var(--err); border-color: #f1c4c1; background: var(--err-bg); }
.status-pill.bad .dot { background: var(--err); }

/* report sections */
.rsection { margin-bottom: 2.4rem; }
.rsection > h2 { margin: 0; font-size: 1.18rem; color: var(--ink); font-weight: 700; }
.rsection > .sub { margin: .35rem 0 1rem; font-size: .85rem; color: var(--ink-muted); }

/* data-extractor validation banner + counts */
.validation { border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
.validation .banner {
  display: flex; align-items: center; gap: .85rem; padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, #edf7f1 0%, #f5faf7 100%);
}
.validation .banner.bad { background: linear-gradient(90deg, #fdeded 0%, #fdf5f5 100%); }
.badge-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 999px; color: #fff; flex-shrink: 0;
  background: var(--ok); font-weight: 700;
}
.badge-icon.bad { background: var(--err); }
.validation .banner .h { font-size: .95rem; font-weight: 600; color: #1c5e3a; }
.validation .banner.bad .h { color: #8f2d27; }
.validation .banner .s { font-size: .82rem; color: #4c7a5f; }
.validation .banner.bad .s { color: #9b5a55; }
.count-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: #eef2f7; }
.count-cell { background: var(--surface); padding: 1rem 1.4rem; display: flex; align-items: center; justify-content: space-between; }
.count-cell .k { font-size: .85rem; font-weight: 600; color: #5b6675; }
.count-cell .n { font-size: 1.4rem; font-weight: 700; color: var(--ink); }

/* gated (pre-submit) placeholder */
.gated {
  border: 1.5px dashed #c5d0df; border-radius: 12px;
  padding: 2.6rem 1.5rem; text-align: center; background: #fafcfe;
}
.gated .h { font-size: 1rem; font-weight: 600; color: #44506b; }
.gated .s { font-size: .85rem; color: #7f8aa0; margin-top: .25rem; }

/* metric cards */
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; margin-bottom: 1.6rem; }
.metric-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.metric-card .top { display: flex; align-items: center; gap: .45rem; margin-bottom: .6rem; }
.metric-card .dot { width: 8px; height: 8px; border-radius: 999px; }
.metric-card .k { font-size: .68rem; font-weight: 700; color: #8a94a6; text-transform: uppercase; letter-spacing: .06em; }
.metric-card .n { font-size: 2rem; font-weight: 700; line-height: 1; }
@media (max-width: 720px) { .metric-grid { grid-template-columns: repeat(2, 1fr); } }

/* grouped collapsible results */
.subhead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0 0 .75rem; }
.subhead h3 { margin: 0; font-size: .98rem; font-weight: 700; color: #28354c; }
.linklike { background: none; border: none; color: var(--vb-accent); font-size: .82rem; font-weight: 600; cursor: pointer; padding: .25rem .4rem; border-radius: 6px; }
.linklike:hover { background: #eaf2fb; }
.allgood { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.25rem; display: flex; align-items: center; gap: .75rem; }
.allgood .ico { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 999px; background: var(--ok-bg); color: var(--ok); flex-shrink: 0; font-weight: 700; }
.allgood span.t { font-size: .85rem; color: #4f5a6b; }

.egroup { border: 1px solid var(--border); border-radius: 10px; margin-bottom: .5rem; overflow: hidden; background: var(--surface); }
.egroup > .ghead {
  width: 100%; display: flex; align-items: center; gap: .75rem;
  padding: .85rem 1rem; background: var(--surface); border: none; cursor: pointer; text-align: left;
}
.egroup > .ghead:hover { background: #f6f9fd; }
.egroup.open > .ghead { background: #f6f9fd; }
.egroup .chev { color: var(--vb-accent); transition: transform .12s; display: inline-flex; }
.egroup.open .chev { transform: rotate(90deg); }
.egroup .glabel { font-size: .88rem; font-weight: 600; color: var(--text); flex: 1; }
.egroup .gcount { font-size: .8rem; font-weight: 600; color: #fff; background: var(--err); padding: 2px 10px; border-radius: 999px; }
.egroup.unmapped .gcount { background: #6b7689; }
.egroup .gbody { border-top: 1px solid #eef2f7; background: #fbfcfe; }
.egroup .grow {
  display: grid; grid-template-columns: 160px 150px 1fr; gap: 1rem;
  padding: .7rem 1.1rem; border-bottom: 1px solid #f0f3f7; align-items: center;
}
.egroup .grow.hdr { padding: .55rem 1.1rem; }
.egroup .grow.hdr span { font-size: .66rem; font-weight: 700; color: var(--ink-label); text-transform: uppercase; letter-spacing: .06em; }
.egroup .grow .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; }
.egroup .grow .pid { color: var(--vb-accent); font-weight: 600; }
.egroup .grow .cell { color: #5b6675; }
.egroup .grow .issue { font-size: .83rem; color: #3a4658; }
.unmapped-flag { font-size: .68rem; color: var(--warn); margin-left: .4rem; }
@media (max-width: 720px) { .egroup .grow { grid-template-columns: 1fr; gap: .25rem; } }

/* downloads — Excel prominent + collapsible other formats */
.dl-row { display: flex; align-items: center; gap: .9rem; border: 1px solid var(--border-strong); border-radius: 10px; padding: .85rem 1rem; text-decoration: none; }
.dl-row:hover { background: #f6f9fd; border-color: var(--vb-accent); }
.dl-row.minor { border-color: #e6eaf1; background: #fbfcfe; }
.dl-row.minor:hover { background: #f2f6fb; border-color: #c6d2e2; }
.dl-badge { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; color: #fff; font-size: .6rem; font-weight: 800; flex-shrink: 0; }
.dl-badge.xlsx { background: #1e7a52; }
.dl-badge.json { background: #3b6fd4; }
.dl-badge.html { background: #5b6675; }
.dl-badge.intermediate { background: #26334a; }
.dl-row .t { flex: 1; }
.dl-row .t .name { display: block; font-size: .9rem; font-weight: 600; color: var(--text); }
.dl-row .t .desc { display: block; font-size: .8rem; color: var(--muted); }
.dl-other { display: flex; flex-direction: column; gap: .5rem; margin-top: .65rem; }
