/* ============================================================================
   app.css - Business Analytics design system

   A cream paper ground with a deep blue accent - the palette of a printed
   credit file. The dark variant is restepped from the same family rather than
   inverted: a warm near-black, not a blue-black, so the two themes read as one
   identity seen under different light.

   Cream is the default in every case. The page deliberately does NOT follow
   prefers-color-scheme: the client asked for this palette to be the product's
   face, so a viewer whose operating system is dark still opens on cream and
   reaches the dark variant only by choosing it. That choice stamps
   data-theme="dark" on the root element, which is the single block below that
   redefines the tokens.

   (To follow the operating system instead, duplicate that block inside
   @media (prefers-color-scheme: dark) with a :root:not([data-theme="light"])
   guard, and restore the matchMedia branch in initTheme.)
   ========================================================================== */

:root {
  color-scheme: light;

  --paper:        #f5f1e8;
  --surface:      #fffdf8;
  --surface-2:    #faf6ec;
  --surface-3:    #efe9db;

  --ink:          #1a1713;
  --ink-2:        #554f45;
  --muted:        #8a8376;

  --line:         #e4ddcc;
  --line-strong:  #cdc4ae;

  --accent:       #2b3f9e;
  --accent-hover: #22327e;
  --accent-soft:  #e8e9f5;
  --accent-ink:   #1d2b6e;

  /* Severity is reserved: never used for a chart series or as decoration. */
  --good:         #0ca30c;
  --warning:      #fab219;
  --serious:      #ec835a;
  --critical:     #d03b3b;
  --good-soft:    #e6f3e2;
  --warning-soft: #fcf1d6;
  --serious-soft: #fae9e0;
  --critical-soft:#f8e3e0;

  --s1:           #2a78d6;
  --s2:           #eb6834;
  --s3:           #1baf7a;

  --grid:         #eae3d4;
  --axis:         #cdc4ae;

  --shadow-sm:    0 1px 2px rgba(40, 32, 20, .06);
  --shadow-md:    0 4px 16px -4px rgba(40, 32, 20, .13);

  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 14px;

  --font-display: "Archivo", "Segoe UI", system-ui, sans-serif;
  --font-body:    "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono:    "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper:        #14110c;
  --surface:      #1e1a14;
  --surface-2:    #26211a;
  --surface-3:    #332c22;
  --ink:          #f5f1e8;
  --ink-2:        #b5ad9c;
  --muted:        #8a8376;
  --line:         #322c22;
  --line-strong:  #4a4234;
  --accent:       #93a4f0;
  --accent-hover: #aab8f5;
  --accent-soft:  #232742;
  --accent-ink:   #c4cdfa;
  --good-soft:    #13260f;
  --warning-soft: #2e2510;
  --serious-soft: #2e1d14;
  --critical-soft:#2d1614;
  --s1:           #3987e5;
  --s2:           #d95926;
  --s3:           #199e70;
  --grid:         #2a2419;
  --axis:         #4a4234;
  --shadow-sm:    0 1px 2px rgba(0, 0, 0, .45);
  --shadow-md:    0 6px 22px -6px rgba(0, 0, 0, .65);
}

/* ------------------------------------------------------------------ base */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -.015em;
  text-wrap: balance;
  margin: 0;
}

p { margin: 0; }

a { color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num  { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* The publish skeleton supplies this, a plain file does not - and without it
   an SVG carrying the hidden attribute still paints, because the UA rule for
   [hidden] does not reach the SVG namespace in every engine. */
[hidden] { display: none !important; }

/* --------------------------------------------------------------- sidebar */

.layout { display: flex; align-items: flex-start; min-height: 100%; }

.sidebar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 40;
  width: 244px;
  flex: none;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 28px 0 18px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 18px; margin-bottom: 4px; }

.brand-mark {
  width: 34px; height: 34px; flex: none;
  border-radius: 9px;
  background: linear-gradient(155deg, var(--accent-hover), var(--accent) 65%);
  box-shadow: 0 3px 8px -2px color-mix(in srgb, var(--accent) 45%, transparent),
              inset 0 1px 0 rgba(255,255,255,.14);
  display: grid; place-items: center;
}
.brand-mark svg { display: block; width: 18px; height: 18px; }

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -.02em;
  line-height: 1.1;
  color: var(--ink);
}
.brand-sub {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav { display: flex; flex-direction: column; gap: 1px; padding: 0 10px; }

.nav-item {
  position: relative;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  padding: 9px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 11px;
  white-space: nowrap;
  transition: background .14s, color .14s;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--accent-soft) 55%, white 45%);
}
/* The rail marks the active section without spending another colour on it. */
.nav-item[aria-selected="true"]::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--accent);
}
.nav-num {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex: none;
  line-height: 0;
}
.nav-item[aria-selected="true"] .nav-num { color: var(--accent); }

/* Sits below the section list, separated, because it leaves the product. */
.staff-link {
  margin: 6px 10px 0;
  text-decoration: none;
  border-top: 1px solid var(--line);
  border-radius: 0;
  padding-top: 13px;
  color: var(--muted);
}
.staff-link:hover { background: transparent; color: var(--accent); }
.staff-link .nav-num { font-size: 12px; }
@media (max-width: 900px) {
  .staff-link { margin: 0; border-top: 0; padding-top: 7px; }
}

.sidebar-foot {
  margin-top: auto;
  padding: 14px 16px 0;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

/* ------------------------------------------------------- public header */
/* The no-login landing page repurposes .sidebar as a horizontal bar (see
   admin.html's precedent), but seven nav items plus a two-line brand block
   overflow a single row at anything narrower than a wide desktop - wrapping
   .nav-item, built for the vertical rail, looks broken once it does: its
   active-state marker is an absolutely-positioned bar meant to sit in a
   rail's left gutter, which reads as a stray floating box once the item
   wraps onto its own line. .public-header/.public-nav/.public-nav-item are a
   dedicated, compact variant that wraps cleanly instead of assuming one row. */

.public-header {
  flex-wrap: wrap;
  row-gap: 10px;
}
.public-header .brand { padding: 0; margin-bottom: 0; min-width: 0; }
.public-header .brand-text { min-width: 0; }
.public-header .brand-name {
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.public-header .brand-sub {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

/* Minimal corporate treatment: plain text links, generous tracking, an
   underline accent marks the active item - no filled pill, no background
   box on either state, so nothing reads as a "button" fighting the brand
   wordmark for attention. */
.public-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
  padding: 0;
  flex: 1 1 auto;
  min-width: 0;
  justify-content: flex-end;
}
.public-nav-item {
  position: relative;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  border: 0;
  box-shadow: none;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: .02em;
  line-height: 1.3;
  white-space: nowrap;
  padding: 6px 1px;
  border-radius: 0;
  cursor: pointer;
  transition: color .16s ease;
}
.public-nav-item::-moz-focus-inner { border: 0; }
.public-nav-item::after {
  content: "";
  position: absolute;
  left: 0; right: 100%;
  bottom: 0;
  height: 1.5px;
  background: var(--accent);
  transition: right .18s ease;
}
.public-nav-item:hover { color: var(--ink); }
.public-nav-item[aria-selected="true"] {
  color: var(--accent-ink);
  font-weight: 600;
}
.public-nav-item[aria-selected="true"]::after { right: 0; }

@media (max-width: 1100px) {
  .public-header { padding: 10px 16px; }
}
@media (max-width: 720px) {
  .public-header { padding: 10px 14px; box-sizing: border-box; }
  .public-header .sidebar-foot { margin-left: 0; width: 100%; justify-content: space-between; }
  .public-nav { width: 100%; order: 3; justify-content: flex-start; gap: 16px 20px; }
}
@media (max-width: 420px) {
  .public-nav { gap: 12px 16px; }
  .public-nav-item { font-size: 12px; }
}

.icon-btn {
  appearance: none;
  width: 32px; height: 32px;
  flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color .14s, color .14s, box-shadow .14s, transform .14s;
}
.icon-btn:hover {
  border-color: var(--line-strong);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.icon-btn:active { transform: translateY(0); }

/* Below this width the rail would eat the working area, so it lies down into
   a scrollable strip across the top and the labels drop away first. */
@media (max-width: 900px) {
  .layout { flex-direction: column; align-items: stretch; }
  .sidebar {
    width: auto;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    overflow-y: visible;
  }
  .brand { padding: 0; flex: none; }
  .brand-text { display: none; }
  .nav { flex-direction: row; padding: 0; gap: 2px; }
  .nav-item { padding: 7px 11px; }
  .nav-item[aria-selected="true"]::before { display: none; }
  .sidebar-foot {
    margin-top: 0;
    margin-left: auto;
    padding: 0;
    border-top: 0;
    flex: none;
  }
}
@media (max-width: 560px) {
  .nav-label { display: none; }
  .nav-item { gap: 0; }
  .nav-num { font-size: 11px; }
}

/* ------------------------------------------------------------------ shell */

.main { flex: 1 1 auto; min-width: 0; }

.page { max-width: 1240px; margin: 0 auto; padding: 24px 22px 72px; }

.section-head { margin-bottom: 18px; }
.section-head h1 { font-size: clamp(21px, 3.2vw, 27px); margin-top: 4px; }
.section-head .lede {
  color: var(--ink-2);
  max-width: 68ch;
  margin-top: 7px;
  font-size: 13.5px;
}

.workbench {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
/* The rail already takes 236px, so the two-column workbench has to give up
   earlier than the viewport width alone would suggest. */
@media (max-width: 1160px) { .workbench { grid-template-columns: 1fr; } }

.scan-overview {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 14px;
  margin-top: 14px;
}
@media (max-width: 720px) { .scan-overview { grid-template-columns: 1fr; } }

.health-visuals {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
@media (max-width: 860px) { .health-visuals { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------- team page */

.team-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
@media (max-width: 900px) { .team-grid { grid-template-columns: 1fr; } }
.team-card { display: flex; flex-direction: column; }
.team-photo {
  width: 136px; height: 136px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--surface-2);
  box-shadow: var(--shadow-sm);
  margin-bottom: 10px;
}
.team-role {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: -6px;
  margin-bottom: 4px;
}
.team-email {
  display: inline-block;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--accent);
  text-decoration: none;
}
.team-email:hover { text-decoration: underline; }

/* -------------------------------------------------------- plain summary */

.plain-summary { margin-bottom: 14px; border-color: var(--accent); border-width: 1.5px; }
.plain-summary-verdict { font-size: 14px; line-height: 1.6; color: var(--ink); margin-top: 4px; }
.plain-summary-verdict b { color: var(--accent-ink); }
.plain-summary-action {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--accent-soft);
}
.plain-summary-action-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent-ink);
  font-weight: 600;
  flex: none;
  padding-top: 1px;
}

.chart-plain-note { margin-top: 8px; font-style: italic; }

/* ---------------------------------------------------- advanced details */

.advanced-details { margin-top: 14px; }
.advanced-details summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  list-style: none;
}
.advanced-details summary::-webkit-details-marker { display: none; }
.advanced-details summary::before { content: '▸ '; }
.advanced-details[open] summary::before { content: '▾ '; }
.advanced-details summary:hover { border-color: var(--line-strong); color: var(--ink); }

.stack { display: flex; flex-direction: column; gap: 14px; }

/* ------------------------------------------------------------------ cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
}
.card.flush { padding: 0; overflow: hidden; }

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.card-head h3 { font-size: 14px; letter-spacing: -.01em; }
.card-note { font-size: 11.5px; color: var(--muted); }

.hint { font-size: 11.5px; color: var(--muted); line-height: 1.5; }

/* ------------------------------------------------------------ stat tiles */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.stat {
  background: var(--surface);
  padding: 13px 15px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.stat-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.15;
  color: var(--ink);
}
.stat-value.sm { font-size: 18px; }
.stat-meta { font-size: 11px; color: var(--ink-2); }

/* --------------------------------------------------------------- severity */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  white-space: nowrap;
}
.chip::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.chip-critical { color: var(--critical); background: var(--critical-soft); border-color: color-mix(in srgb, var(--critical) 26%, transparent); }
.chip-serious  { color: var(--serious);  background: var(--serious-soft);  border-color: color-mix(in srgb, var(--serious) 30%, transparent); }
.chip-warning  { color: var(--warning);  background: var(--warning-soft);  border-color: color-mix(in srgb, var(--warning) 34%, transparent); }
.chip-good     { color: var(--good);     background: var(--good-soft);     border-color: color-mix(in srgb, var(--good) 26%, transparent); }
.chip-neutral  { color: var(--ink-2);    background: var(--surface-3);     border-color: var(--line); }

:root[data-theme="dark"] .chip-critical,
:root[data-theme="dark"] .chip-warning,
:root[data-theme="dark"] .chip-serious,
:root[data-theme="dark"] .chip-good { filter: brightness(1.2); }

.stripe { width: 3px; border-radius: 2px; align-self: stretch; flex: none; min-height: 18px; }
.stripe-critical { background: var(--critical); }
.stripe-serious  { background: var(--serious); }
.stripe-warning  { background: var(--warning); }
.stripe-good     { background: var(--good); }
.stripe-neutral  { background: var(--line-strong); }

/* --------------------------------------------------------------- controls */

.field { display: flex; flex-direction: column; gap: 5px; }
.field > label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-2);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.field-unit { font-family: var(--font-mono); font-size: 10px; color: var(--muted); }

input[type="text"], input[type="number"], input[type="password"], select, textarea {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 7px 9px;
  transition: border-color .14s, background .14s;
}
textarea { font-family: var(--font-body); line-height: 1.55; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}
select {
  font-family: var(--font-body);
  appearance: none;
  padding-right: 26px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 14px) 52%, calc(100% - 9px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

input[type="range"] {
  width: 100%;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-3);
  outline-offset: 6px;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  cursor: pointer;
}

.btn {
  appearance: none;
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background .14s, border-color .14s, opacity .14s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--line-strong); background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
:root[data-theme="dark"] .btn-primary { color: #14110c; }
.btn-sm { padding: 5px 10px; font-size: 11.5px; }
.btn-block { width: 100%; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.seg {
  display: inline-flex;
  background: var(--surface-3);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 2px;
}
.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.seg button[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* -------------------------------------------------------------- dropzone */

.dropzone {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .14s, background .14s;
}
.dropzone:hover, .dropzone.drag {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone-title { font-weight: 600; font-size: 13px; }
.dropzone-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

/* -------------------------------------------------------- column mapping */

.map-list { display: flex; flex-direction: column; gap: 7px; max-height: 340px; overflow-y: auto; padding-right: 3px; }

.map-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: center;
}
.map-label { font-size: 11.5px; color: var(--ink-2); display: flex; align-items: center; gap: 5px; }
.map-req {
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--critical);
  border: 1px solid color-mix(in srgb, var(--critical) 30%, transparent);
  border-radius: 3px;
  padding: 0 3px;
  letter-spacing: .06em;
}
.map-row select { font-size: 11.5px; padding: 5px 24px 5px 7px; }
.map-row select.unmapped { color: var(--muted); }

/* ----------------------------------------------------------------- table */

.table-wrap { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
table.data th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}
table.data td {
  padding: 8px 11px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: nowrap;
}
table.data tbody tr:hover td { background: var(--surface-2); }
table.data td.n { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
table.data td.wrap { white-space: normal; min-width: 180px; }
table.data .dim { color: var(--muted); }

.scroll-y { max-height: 460px; overflow-y: auto; }

/* ------------------------------------------------------------------ bars */

.barline { display: flex; flex-direction: column; gap: 5px; }
.barline-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
}
.barline-head .v { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600; }
.bartrack { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.barfill { height: 100%; border-radius: 3px; transition: width .5s cubic-bezier(.22,.8,.3,1); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ----------------------------------------------------------- attributions */

.attr { display: flex; flex-direction: column; gap: 7px; }
.attr-row {
  display: grid;
  grid-template-columns: 132px 1fr 62px;
  align-items: center;
  gap: 9px;
  font-size: 11.5px;
}
.attr-name { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attr-track { position: relative; height: 15px; background: var(--surface-2); border-radius: 3px; }
.attr-zero { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--axis); }
.attr-bar { position: absolute; top: 3px; bottom: 3px; border-radius: 2px; }
.attr-bar.up { background: var(--critical); }
.attr-bar.down { background: var(--s1); }
.attr-val { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; color: var(--ink-2); font-size: 11px; }

/* ----------------------------------------------------------------- gauge */

.gauge-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.gauge { position: relative; width: 158px; height: 158px; flex: none; }
.gauge svg { display: block; transform: rotate(-90deg); }
.gauge-centre {
  position: absolute; inset: 0;
  display: grid; place-content: center; text-align: center;
}
.gauge-score {
  font-family: var(--font-mono);
  font-size: 40px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.03em;
}
.gauge-outof { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); margin-top: 3px; }

/* ----------------------------------------------------------------- donut */

.donut-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.donut-num {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  fill: var(--ink);
}
.donut-sub {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .08em;
  text-transform: uppercase;
  fill: var(--muted);
}

.grade-scale { display: flex; flex-direction: column; gap: 3px; font-size: 11px; }
.grade-scale div { display: flex; align-items: center; gap: 7px; color: var(--muted); }
.grade-scale div.on { color: var(--ink); font-weight: 600; }
.grade-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }

/* ------------------------------------------------------------ health radar */

.radar-wrap { width: 100%; }
.radar-wrap svg { display: block; width: 100%; max-width: 320px; height: auto; margin: 0 auto; overflow: visible; }
.radar-wrap text { font-family: var(--font-mono); font-size: 9.5px; fill: var(--muted); }
.radar-wrap .radar-axis-line { stroke: var(--axis); stroke-width: 1; }
.radar-wrap .radar-grid-ring { fill: none; stroke: var(--grid); stroke-width: 1; }
.radar-wrap .radar-label { font-family: var(--font-display); font-size: 10.5px; fill: var(--ink-2); font-weight: 600; }
.radar-wrap .radar-shape { fill: var(--s1); fill-opacity: .22; stroke: var(--s1); stroke-width: 2; stroke-linejoin: round; }
.radar-wrap .radar-vertex { fill: var(--s1); stroke: var(--surface); stroke-width: 1.5; cursor: default; }

/* ------------------------------------------------------- model comparison */

.mc-wrap { width: 100%; }
.mc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.mc-title { font-size: 13px; font-weight: 600; color: var(--ink); margin: 0; }
.mc-grade { font-size: 11px; color: var(--muted); font-family: var(--font-mono); white-space: nowrap; }
.mc-wrap .mc-label { font-family: var(--font-body); font-size: 10.5px; fill: var(--ink-2); }
.mc-wrap .mc-label-strong { font-weight: 700; fill: var(--ink); }
.mc-wrap .mc-value { font-family: var(--font-mono); font-size: 11px; fill: var(--ink-2); }
.mc-wrap .mc-value-strong { font-family: var(--font-mono); font-size: 13px; font-weight: 700; fill: var(--ink); }
.mc-note { margin-top: 8px; max-width: 60ch; }

/* --------------------------------------------------------- balance bridge */

.waterfall-wrap { width: 100%; }
.waterfall-wrap svg { display: block; width: 100%; max-width: 380px; height: auto; margin: 0 auto; overflow: visible; }
.waterfall-wrap text { font-family: var(--font-mono); font-size: 9.5px; fill: var(--muted); }
.waterfall-wrap .axis-line { stroke: var(--axis); stroke-width: 1; }
.waterfall-wrap .grid-line { stroke: var(--grid); stroke-width: 1; }
.waterfall-wrap .wf-bridge { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 3 3; }
.waterfall-wrap .wf-value { font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; fill: var(--ink); }
.waterfall-wrap .wf-name { font-family: var(--font-display); font-size: 10.5px; fill: var(--ink-2); font-weight: 600; }
.waterfall-wrap rect { cursor: default; }
.wf-note { margin-top: 10px; font-family: var(--font-body); font-size: 11.5px; color: var(--ink-2); text-align: center; }

/* ----------------------------------------------------------- pillar flow */

.pflow-wrap { width: 100%; }
.pflow-wrap svg { display: block; width: 100%; max-width: 480px; height: auto; margin: 0 auto; overflow: visible; }
.pflow-wrap .pflow-link { fill: none; stroke-linecap: round; }
.pflow-wrap .pflow-link-good { stroke: var(--good); stroke-opacity: .45; }
.pflow-wrap .pflow-link-bad { stroke: var(--critical); stroke-opacity: .45; }
.pflow-wrap .pflow-link:hover { stroke-opacity: .8; }
.pflow-wrap .pflow-node { cursor: default; }
.pflow-wrap .pflow-pillar-box { stroke: var(--surface); stroke-width: 2; }
.pflow-wrap .pflow-pillar-label { font-family: var(--font-display); font-size: 10.5px; font-weight: 700; fill: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.25); }
.pflow-wrap .pflow-pillar-score { font-family: var(--font-mono); font-size: 10px; fill: #fff; opacity: .92; }
.pflow-wrap .pflow-feat-box { fill: var(--surface-2); stroke: var(--line); stroke-width: 1; }
.pflow-wrap .pflow-feat-good { stroke: var(--good); }
.pflow-wrap .pflow-feat-bad { stroke: var(--critical); }
.pflow-wrap .pflow-feat-label { font-family: var(--font-body); font-size: 10.5px; fill: var(--ink); }
.pflow-wrap .pflow-dot-good { fill: var(--good); }
.pflow-wrap .pflow-dot-bad { fill: var(--critical); }

/* ---------------------------------------------------------------- charts */

.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font-mono); font-size: 9.5px; fill: var(--muted); }
.chart .axis-line { stroke: var(--axis); stroke-width: 1; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--ink-2); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 11px; height: 3px; border-radius: 2px; flex: none; }

.tooltip {
  position: fixed;
  z-index: 90;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  padding: 7px 10px;
  font-size: 11.5px;
  max-width: 240px;
  line-height: 1.45;
}
.tooltip .t-title { font-weight: 600; margin-bottom: 2px; }
.tooltip .t-row { display: flex; justify-content: space-between; gap: 14px; color: var(--ink-2); }
.tooltip .t-row b { font-family: var(--font-mono); font-weight: 600; color: var(--ink); }

/* -------------------------------------------------------- confusion grid */

.cm { display: grid; grid-template-columns: auto 1fr 1fr; gap: 4px; align-items: stretch; }
.cm-cell {
  border-radius: var(--r-md);
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid var(--line);
}
.cm-cell .k { font-family: var(--font-mono); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.cm-cell .v { font-family: var(--font-mono); font-size: 19px; font-weight: 600; line-height: 1.1; }
.cm-hit  { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 22%, transparent); }
.cm-miss { background: var(--critical-soft); border-color: color-mix(in srgb, var(--critical) 22%, transparent); }
.cm-axis { display: grid; place-items: center; font-family: var(--font-mono); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 0 6px; }

/* ------------------------------------------------------------ methodology */

.method-list { display: flex; flex-direction: column; gap: 0; }

.method {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 260px;
  gap: 20px;
  padding: 22px 0;
  border-top: 1px solid var(--line);
  align-items: start;
}
.method:first-child { border-top: 0; }
@media (max-width: 860px) {
  .method { grid-template-columns: 42px minmax(0, 1fr); gap: 14px; }
  .method-evidence { grid-column: 2; }
}

.method-num {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -.03em;
  line-height: 1;
  padding-top: 2px;
}
.method h3 { font-size: 16px; margin-bottom: 3px; }
.method-kind {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.method-body { color: var(--ink-2); font-size: 13px; max-width: 62ch; }
.method-body p + p { margin-top: 9px; }
.method-body code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--surface-3);
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--ink);
}

.method-evidence {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 11px 13px;
}
.method-evidence .eyebrow { margin-bottom: 7px; display: block; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 11.5px; padding: 3px 0; }
.kv + .kv { border-top: 1px dashed var(--line); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 500; }

/* ------------------------------------------------------------------ misc */

.token {
  display: inline-block;
  padding: 1px 4px;
  margin: 1px 1px;
  border-radius: 3px;
  font-size: 12.5px;
  line-height: 1.7;
}
.token-unk { color: var(--muted); text-decoration: underline dotted; }

.banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 13px;
  border-radius: var(--r-md);
  font-size: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
}
.banner-warn { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 34%, transparent); }
.banner-bad  { background: var(--critical-soft); border-color: color-mix(in srgb, var(--critical) 26%, transparent); }
.banner b { color: var(--ink); }

.rec-list { display: flex; flex-direction: column; gap: 9px; }
.rec {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.rec-title { font-weight: 600; font-size: 12.5px; }
.rec-body { font-size: 12px; color: var(--ink-2); margin-top: 2px; }

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(20, 15, 8, .58);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  width: min(720px, 100%);
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.modal-body { padding: 14px 16px; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.modal-body textarea {
  font-family: var(--font-mono);
  font-size: 11px;
  min-height: 240px;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}

.spinner {
  width: 13px; height: 13px;
  border: 2px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  padding: 34px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}

.footnote {
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
  max-width: 78ch;
}

/* ------------------------------------------------------------ sign-in */

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--paper);
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom, 0px));
}

.auth-card {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  justify-content: center;
  margin-bottom: 2px;
}

.auth-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-panel h1 { font-size: 19px; }
.auth-panel .lede { font-size: 12.5px; color: var(--ink-2); margin-top: 4px; }

.auth-switch {
  display: flex;
  gap: 2px;
  background: var(--surface-3);
  padding: 3px;
  border-radius: var(--r-md);
}
.auth-switch button {
  appearance: none;
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 500;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.auth-switch button[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.auth-form { display: flex; flex-direction: column; gap: 11px; }
.auth-error {
  font-size: 12px;
  color: var(--critical);
  background: var(--critical-soft);
  border: 1px solid color-mix(in srgb, var(--critical) 26%, transparent);
  border-radius: var(--r-md);
  padding: 8px 11px;
}

/* The reveal button overlaps the input's right edge, so the input carries
   enough right padding that a long password never runs under it. Edge and
   Chrome both draw their own reveal icon in that same corner on a password
   field with a value in it, which then sits on top of ours - the three
   selectors below are each browser's hook for switching it off. */
.pw-wrap { position: relative; display: block; }
.pw-input { padding-right: 38px; }
.pw-input::-ms-reveal, .pw-input::-ms-clear { display: none; }
.pw-input::-webkit-credentials-auto-fill-button,
.pw-input::-webkit-textfield-decoration-container { display: none !important; }
.pw-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
}
.pw-toggle:hover { color: var(--ink); background: var(--surface-3); border-color: transparent; }
.pw-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.pw-strength {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}
.pw-strength .bartrack { flex: 1 1 auto; height: 4px; }
.pw-strength-label {
  flex: none;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .04em;
  color: var(--muted);
  min-width: 62px;
  text-align: right;
}

/* --------------------------------------------------------- user block */

/* Sits below sidebar-foot, at the very bottom of the rail - the last thing a
   viewer's eye reaches, since it is "who am I" rather than navigation. */
.user-block {
  margin: 10px 12px 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--surface) 60%, white 40%);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: border-color .16s;
}
.user-block:hover { border-color: var(--line-strong); }

.avatar {
  width: 30px; height: 30px;
  flex: none;
  border-radius: 8px;
  background: linear-gradient(155deg, var(--accent-hover), var(--accent) 65%);
  box-shadow: 0 2px 6px -2px color-mix(in srgb, var(--accent) 45%, transparent),
              inset 0 1px 0 rgba(255,255,255,.14);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .01em;
}
:root[data-theme="dark"] .avatar { color: #14110c; }

/* Single line now - the card shows only the signed-in person's name. */
.user-meta { min-width: 0; flex: 1 1 auto; display: flex; align-items: center; }
.user-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 900px) {
  .user-block { margin: 0; padding: 5px 8px; }
  .user-meta { display: none; }
}

/* ------------------------------------------------------ admin console */

.console-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.spark-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--ink-2);
  margin-top: 8px;
}
.spark-legend span { display: inline-flex; align-items: center; gap: 6px; }
.spark-legend i { width: 9px; height: 9px; border-radius: 2px; flex: none; }
