/* board.css — the design system.
 *
 * The idiom is the administrative SaaS Dealerware itself works in, because the
 * two tools sit side by side on the same desk all day and switching between
 * them should not feel like changing buildings: a light ground, white cards on
 * it, a single blue that means "actionable", dense readable tables, and status
 * carried by a pill rather than by colouring a whole row.
 *
 * LIGHT ONLY, ON PURPOSE
 * There is no dark theme yet. A half-built second theme is worse than one good
 * one — it is where contrast bugs live and where a status colour quietly stops
 * meaning what it means. Every colour below is defined once, so adding dark
 * later is a second block of tokens and not a rewrite.
 */

:root {
  color-scheme: light;

  /* ground and surfaces */
  --bg:         #f2f4f7;
  --surface:    #ffffff;
  --surface-2:  #f7f9fb;
  --surface-3:  #eef2f6;

  /* lines */
  --line:       #dde3ea;
  --line-strong:#c3ccd8;

  /* type */
  --text:       #131a24;
  --text-2:     #4a5768;
  --muted:      #778394;

  /* the one blue */
  --brand:      #0f5ea8;
  --brand-ink:  #ffffff;
  --brand-soft: #e8f1fa;
  --brand-line: #b6d4ee;

  /* status. Meaning first, colour second — see STATUS_META in shared/status.js */
  --crit:       #b3261e;   --crit-soft:  #fdecea;  --crit-line:  #f3c2be;
  --high:       #b5541a;   --high-soft:  #fdf0e6;  --high-line:  #f2d0b3;
  --attn:       #8a6100;   --attn-soft:  #fdf6e3;  --attn-line:  #eddfb4;
  --ok:         #1c6b45;   --ok-soft:    #e9f6ef;  --ok-line:    #bfe2d0;
  --info:       #4a5768;   --info-soft:  #eef2f6;  --info-line:  #d5dde6;

  --radius:     10px;
  --radius-lg:  14px;
  --shadow:     0 1px 2px rgb(19 26 36 / .06), 0 1px 3px rgb(19 26 36 / .04);
  --shadow-lg:  0 2px 4px rgb(19 26 36 / .06), 0 8px 24px rgb(19 26 36 / .08);

  --sidebar:    236px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* The `hidden` attribute is how this application shows one view and not
   another, and the browser implements it as a low-priority `display: none`.
   Any author rule that sets `display` on the same element silently beats it —
   which is exactly what `.shell { display: grid }` and `.signin { display: grid }`
   were doing, leaving the sign-in card on screen after a successful sign-in and
   making it look as though the password had not worked.
   
   Stated once, loudly, so no later layout rule can quietly re-open that. */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0; min-height: 100%;
  background: var(--bg); color: var(--text);
  /* Up ~8% from 15px. The desk view is read across a desk, often standing, and
     the old scale was pitched for a laptop at arm's length rather than a
     monitor at the parts counter. */
  font: 16px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }
p  { margin: 0 0 10px; }
a  { color: var(--brand); }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.tnum  { font-variant-numeric: tabular-nums; }

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

.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }

.side {
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}

.brand { padding: 20px 20px 16px; border-bottom: 1px solid var(--line); }
.brand-star {
  width: 29px; height: 29px; display: block; margin-bottom: 9px; color: var(--text);
}
.brand-name { font-weight: 650; font-size: 1rem; letter-spacing: -.01em; }
.brand-sub  { color: var(--muted); font-size: .8125rem; margin-top: 1px; }

.nav { padding: 10px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 8px; text-decoration: none;
  color: var(--text-2); font-size: .9375rem; font-weight: 500;
}
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a.is-on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav svg { width: 19px; height: 19px; flex: none; }
.nav-sep { height: 1px; background: var(--line); margin: 8px 11px; }

.side-foot { padding: 14px 20px 18px; border-top: 1px solid var(--line); font-size: .8125rem; color: var(--muted); }
.side-foot .row { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 16px 30px; display: flex; align-items: center; gap: 18px;
  position: sticky; top: 0; z-index: 10;
}
.topbar .sub { color: var(--muted); font-size: .875rem; margin-top: 2px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.content { padding: 26px 30px 56px; max-width: 1280px; width: 100%; }

/* ---------------- status light ---------------- */

.light { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.light-green { background: #1c9b62; }
.light-amber { background: #d59a1a; }
.light-red   { background: #cf3a30; }
.light-grey  { background: #a6b0be; }

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

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.card + .card { margin-top: 18px; }
.card-head {
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
}
.card-head .muted { font-size: .875rem; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }

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

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(172px, 1fr)); gap: 14px; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 17px 18px; box-shadow: var(--shadow);
}
.tile .n { font-size: 1.9375rem; font-weight: 650; line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.tile .k { font-size: .875rem; color: var(--muted); margin-top: 3px; }
.tile .foot { font-size: .8125rem; color: var(--muted); margin-top: 7px; }
.tile.crit { border-left: 3px solid var(--crit); }
.tile.crit .n { color: var(--crit); }
.tile.high { border-left: 3px solid var(--high); }
.tile.high .n { color: var(--high); }
.tile.ok   { border-left: 3px solid var(--ok); }

/* ---------------- pills ---------------- */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: .8125rem; font-weight: 550;
  border: 1px solid var(--info-line); background: var(--info-soft); color: var(--info);
  white-space: nowrap;
}
.pill-crit { background: var(--crit-soft); border-color: var(--crit-line); color: var(--crit); }
.pill-high { background: var(--high-soft); border-color: var(--high-line); color: var(--high); }
.pill-attn { background: var(--attn-soft); border-color: var(--attn-line); color: var(--attn); }
.pill-ok   { background: var(--ok-soft);   border-color: var(--ok-line);   color: var(--ok); }
.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------------- tables ---------------- */

.table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.table th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: .8125rem;
  text-transform: uppercase; letter-spacing: .04em;
  padding: 11px 20px; border-bottom: 1px solid var(--line); background: var(--surface-2);
  position: sticky; top: 0;
}
.table td { padding: 13px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { font-weight: 650; font-variant-numeric: tabular-nums; }
.table .right { text-align: right; }
.table-wrap { overflow-x: auto; }

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

.btn {
  appearance: none; border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--text); border-radius: 8px; padding: 9px 16px;
  font-size: .9375rem; font-weight: 550; cursor: pointer; min-height: 40px;
  display: inline-flex; align-items: center; gap: 7px; text-decoration: none;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: #0d5395; border-color: #0d5395; }
.btn-danger { border-color: var(--crit-line); color: var(--crit); background: var(--crit-soft); }
.btn-danger:hover { background: var(--crit); color: #fff; border-color: var(--crit); }
.btn svg { width: 16px; height: 16px; }

.field {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 9px 12px; font-size: .9375rem; min-height: 40px; font-family: inherit;
}
.field:focus { outline: 2px solid var(--brand-line); outline-offset: -1px; border-color: var(--brand); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { margin-left: auto; }

.msg { min-height: 1.3em; font-size: .875rem; margin: 9px 0; }
.msg.is-bad { color: var(--crit); }
.msg.is-ok  { color: var(--ok); }
/* Something to read before continuing, which is not the same as something that
   went wrong. The import preview uses it for a status word the board has never
   seen and for rows claiming a disposal — both are worth a person's eye and
   neither is a failure. */
.msg.is-attn { color: var(--attn); }

/* The projection, shown literally in the import preview. Small, wrapping, and
   visibly a quotation of data rather than prose. */
.msg-sample {
  margin: 6px 0 0; padding: 8px 10px; font-size: .8125rem; line-height: 1.5;
  background: var(--attn-soft); border: 1px solid var(--attn-line); border-radius: 6px;
  white-space: pre-wrap; overflow-x: auto;
}

.empty { padding: 40px 20px; text-align: center; color: var(--muted); font-size: .9375rem; }

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

.banner {
  background: var(--attn-soft); border-bottom: 1px solid var(--attn-line);
  color: var(--attn); padding: 10px 30px; font-size: .875rem;
}
.hint {
  background: var(--brand-soft); border: 1px solid var(--brand-line);
  border-radius: var(--radius); padding: 13px 16px; font-size: .875rem; color: var(--text-2);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; }
  .nav { flex-direction: row; }
  .brand, .side-foot { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 16px; }
}

/* ---------------- print ----------------
   A report is printed to be filed and read on paper. Everything that only makes
   sense on a screen goes away, and nothing is allowed to break across a page in
   the middle of a row. */
@media print {
  :root { --bg: #fff; }
  body { background: #fff; font-size: 11pt; }
  .side, .topbar, .toolbar, .no-print, .banner { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; max-width: none; }
  .card { border: 1px solid #999; box-shadow: none; break-inside: avoid; }
  .card + .card { margin-top: 12pt; }
  .table th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .table tr { break-inside: avoid; }
  .pill { border: 1px solid #999 !important; background: #fff !important; color: #000 !important; }
  .print-only { display: block !important; }
  a[href]::after { content: ""; }
  @page { margin: 14mm; }
}
.print-only { display: none; }

/* ---------------- utilities ----------------
   A small, closed set of spacing and emphasis helpers, so no element needs a
   style attribute. That is not tidiness for its own sake: `style-src 'self'`
   blocks inline style attributes as well as <style> blocks, and keeping the
   policy strict is worth more than the convenience of writing a margin inline. */
.m0    { margin: 0 !important; }
.mt-sm { margin-top: 8px; }
.mt    { margin-top: 14px; }
.mt-lg { margin-top: 18px; }
.mb-sm { margin-top: 0; margin-bottom: 10px; }
.mb    { margin-bottom: 14px; }
.mb-lg { margin-bottom: 18px; }
.my    { margin: 14px 0; }
.push  { margin-left: auto; }
.lead  { font-size: 1.125rem; font-weight: 600; margin: 0 0 6px; }
.row-wrap { display: flex; gap: 7px; flex-wrap: wrap; }
.bullets { margin: 8px 0 0 20px; padding: 0; }
.divide-top { border-top: 1px solid var(--line); }
.hint-warn { border-color: var(--attn-line); background: var(--attn-soft); }
.icon-sm { width: 22px; height: 22px; flex: none; }

/* ---------------- sign-in ---------------- */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.signin-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 30px; width: 100%; max-width: 380px;
}
.signin-card h1 { font-size: 1.25rem; margin-bottom: 2px; }
.signin-label { display: block; font-size: .875rem; font-weight: 550; margin-bottom: 6px; }
.signin-card .field { width: 100%; }
.btn-block { width: 100%; justify-content: center; min-height: 44px; }
.linkish {
  appearance: none; background: none; border: 0; padding: 0;
  color: var(--brand); font: inherit; font-size: .8125rem; cursor: pointer; text-decoration: underline;
}

/* ---------------- key history ----------------
   The lookup that answers "what happened with 146". Its own block rather than
   reusing the sign-in card's, because this field is typed into all day and the
   sign-in field is typed into twice a shift. */

.lookup-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.lookup-field {
  width: 150px; font-size: 1.25rem; font-weight: 600; letter-spacing: .04em;
  padding: 9px 13px;
}
.lookup-field::placeholder { font-weight: 400; color: var(--line-strong); letter-spacing: normal; }

/* A night nobody walked is drawn quieter than a night somebody did, because it
   is not a finding about the key — it is an absence of one. Making it look like
   the other rows is how a gap in the record gets read as a fact about the key. */
.row-quiet td { background: var(--surface-2); color: var(--muted); }

/* A verdict carries a tone and the sentence should show it. Every one of these
   is the same sentence a person reads first on the page it heads, so a missing
   key and a clean night must not arrive in the same colour. `info` and the
   empty tone stay body-coloured on purpose: they are the absence of a finding,
   not a finding of their own. */
.lead.is-crit { color: var(--crit); }
.lead.is-high { color: var(--high); }
.lead.is-attn { color: var(--attn); }
.lead.is-ok   { color: var(--ok); }
