/* Ford North East — WADE. Design system: "service-lane instrument panel".
   Light, restrained, Ford-blue-anchored. Flat elevation, hairline borders,
   full-bleed layout, fixed type scale. */

/* Self-hosted type (no runtime CDN dependency). IBM Plex Sans for UI,
   IBM Plex Mono for codes / RO numbers / VINs. */
@font-face {
  font-family: "IBM Plex Sans";
  src: url("/fonts/plex-sans.woff2") format("woff2");
  font-weight: 100 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/plex-mono-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/plex-mono-600.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}

:root {
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  /* Brand (fixed — Ford) */
  --primary:    #003499;
  --primary-dk: #00246b;
  --ms-red: #f25022; --ms-green: #7fba00; --ms-blue: #00a4ef; --ms-yellow: #ffb900;   /* Microsoft logo (sign-in button only) */
  --primary-lt: #eaf0ff;
  --accent:     #1b56d3;
  --accent-lt:  #eef3ff;

  /* Neutrals — tinted toward the brand hue, cool */
  --ink:        #131a2b;
  --text:       #3a4353;
  --text-muted: #667085;
  --muted-2:    #8b94a3;
  --bg:         #f4f6fb;
  --white:      #ffffff;
  --surface:    #ffffff;
  --surface-2:  #fafbfe;
  --light-grey: #eef0f5;
  --border:     #e6e9f0;
  --border-2:   #d7dce5;
  --line-soft:  #eef0f5;
  --zebra:      #f4f6fa;   /* alternate table rows */

  /* Semantic — status only */
  --red:   #d22d3f; --red-bg:   #fdeef0; --red-tx:   #a12433;
  --amber: #b7791f; --amber-bg: #fbf1de; --amber-tx: #8a5a12;
  --green: #1f8a54; --green-bg: #e7f4ec; --green-tx: #166b42;

  --sage: #4A5A7A; --soon-bg: #eef0f4; --soon-border: #e4e7ee;

  /* Topbar text on the brand colour */
  --topbar-sub:  #a9bdef;
  --topbar-link: #cfdcff;

  /* 3C story score bands (>=70 good, >=50 ok, else poor) */
  --score-good: var(--green); --score-ok: var(--amber); --score-poor: var(--red);

  --r-sm: 7px; --r-md: 10px; --r-lg: 14px;
  --shadow:    0 1px 2px rgba(20,26,42,.04), 0 1px 1px rgba(20,26,42,.03);
  --shadow-lg: 0 1px 2px rgba(20,26,42,.05), 0 6px 18px -12px rgba(20,26,42,.22);
  --ring: 0 0 0 3px rgba(27,86,211,.28);
  --ease: cubic-bezier(.22,.61,.36,1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

/* ─── Topbar — the brand anchor ───────────────────────────────────── */
header.topbar {
  background: var(--primary);
  color: #fff;
  padding: 0 clamp(16px, 3vw, 44px);
  height: 60px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(0,0,0,.06);
}
.topbar-logo { height: 32px; width: auto; object-fit: contain; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: #fff; color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; letter-spacing: .3px; flex: 0 0 auto;
}
.topbar-brand { display: flex; flex-direction: column; gap: 0; line-height: 1.2; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: .2px; }
.brand-tagline { font-size: 11.5px; color: var(--topbar-sub); }
.topbar-nav { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.topbar-admin-link {
  color: var(--topbar-link); text-decoration: none; font-size: 13px;
  padding: 6px 12px; border-radius: var(--r-md);
  transition: background .15s var(--ease), color .15s var(--ease);
}
.topbar-admin-link:hover { background: rgba(255,255,255,.12); color: #fff; }

/* ─── Main — full-bleed, hug the edges ────────────────────────────── */
main {
  flex: 1;
  width: 100%;
  max-width: none;
  padding: clamp(18px, 2vw, 30px) clamp(14px, 2vw, 40px) 48px;
}

/* ─── Headings — fixed scale ──────────────────────────────────────── */
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); }
.page-h1 { font-size: 28px; font-weight: 700; color: var(--ink); margin: 6px 0 6px; letter-spacing: -.02em; }
.lead { color: var(--text-muted); font-size: 14px; margin: 0 0 22px; }   /* full width — no artificial wrapping */
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); text-decoration: none; margin-bottom: 14px; transition: color .15s var(--ease); }
.back-link:hover { color: var(--accent); }
.hub-intro { margin-bottom: 26px; }
.hub-intro h1 { font-size: 24px; font-weight: 700; color: var(--ink); margin: 0 0 5px; letter-spacing: -.01em; }
.hub-intro p { color: var(--text-muted); margin: 0; font-size: 14px; }
.section-heading { font-size: 15px; font-weight: 700; color: var(--ink); margin: 0 0 12px; letter-spacing: -.005em; }

/* ─── Cards / panels — flat, hairline ─────────────────────────────── */
.card, .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.panel-head { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-2); padding: 14px 16px 8px; }

/* ─── Tools grid ──────────────────────────────────────────────────── */
.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.tool-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 20px; display: flex; flex-direction: column; gap: 12px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), transform .15s var(--ease);
}
.tool-card:hover:not(.tool-card--soon) { border-color: var(--border-2); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.tool-card--soon { opacity: .68; }
.tool-icon { width: 40px; height: 40px; background: var(--accent-lt); border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; color: var(--accent); flex-shrink: 0; }
.tool-card--soon .tool-icon { background: var(--light-grey); color: var(--muted-2); }
.tool-content { flex: 1; }
.tool-header { display: flex; align-items: center; gap: 9px; margin-bottom: 6px; flex-wrap: wrap; }
.tool-name { font-size: 15.5px; color: var(--ink); margin: 0; font-weight: 700; }
.tool-card--soon .tool-name { color: var(--text-muted); }
.tool-desc { font-size: 13px; color: var(--text-muted); margin: 0; line-height: 1.55; }

/* ─── Badges / pills / chips ──────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge--soon { background: var(--soon-bg); color: var(--text-muted); border: 1px solid var(--border); }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; border-radius: 999px; padding: 3px 10px; white-space: nowrap; line-height: 1.5; }
.pill--red   { background: var(--red-bg);   color: var(--red-tx); }
.pill--amber { background: var(--amber-bg); color: var(--amber-tx); }
.pill--green { background: var(--green-bg); color: var(--green-tx); }
.pill--navy  { background: var(--primary-lt); color: var(--primary); }
.pill--gray, .pill--grey { background: var(--light-grey); color: var(--text-muted); }
.pilldot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.chip { font-size: 12px; color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 2px 8px; white-space: nowrap; }
.tag { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ─── Buttons — full state set ────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--r-md);
  font-size: 13.5px; font-family: inherit; font-weight: 600;
  cursor: pointer; border: 1px solid transparent; text-decoration: none; width: 100%;
  transition: background .15s var(--ease), border-color .15s var(--ease), box-shadow .12s var(--ease);
}
.btn:active { transform: translateY(.5px); }
.btn:focus-visible { box-shadow: var(--ring); }
.btn--inline { width: auto; }
.btn-open, .btn-solid { background: var(--primary); color: #fff; }
.btn-open:hover, .btn-solid:hover { background: var(--primary-dk); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--muted-2); }
.btn-text { background: none; color: var(--text-muted); border-color: transparent; }
.btn-text:hover { color: var(--ink); background: var(--surface-2); }
.btn-soon { background: var(--light-grey); color: var(--text-muted); cursor: not-allowed; border: 1px solid var(--border); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.tool-action { margin-top: 2px; }

/* ─── KPI cards — number-led, selectable, double as filters ───────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin: 0 0 26px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px 18px; box-shadow: var(--shadow); transition: border-color .18s var(--ease), box-shadow .18s var(--ease), transform .18s var(--ease); }
.stat-clickable { cursor: pointer; }
a.stat-card { display: block; color: inherit; text-decoration: none; }   /* a stat card that filters the list is a link */
.stat-clickable:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.stat-clickable.is-active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.stat-bar { display: none; }
.stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.stat-label { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.stat-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.stat-num { font-size: 18px; font-weight: 700; color: var(--ink); line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat-foot { font-size: 12px; color: var(--muted-2); margin-top: 7px; }

/* ─── Toolbar (search + filters) ──────────────────────────────────── */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 14px; }
.search { flex: 1 1 300px; max-width: 480px; min-width: 220px; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 0 12px; transition: border-color .15s var(--ease), box-shadow .12s var(--ease); }
.toolbar .fchip:first-of-type { margin-left: auto; }
.search:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.search input { border: none; outline: none; background: none; font: inherit; font-size: 13.5px; color: var(--text); width: 100%; padding: 9px 0; }
.search svg { color: var(--muted-2); flex: 0 0 auto; }
.fchip { font-size: 13px; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); border-radius: 999px; padding: 7px 14px; cursor: pointer; white-space: nowrap; font-weight: 500; transition: background .12s var(--ease), color .12s var(--ease), border-color .12s var(--ease); }
.fchip:hover { border-color: var(--border-2); color: var(--text); }
.fchip.on { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ─── Filters (views/partials/filters.ejs) — lists, calendars, boards ─ */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
.filter-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.filter-label { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-2); margin-right: 2px; }
a.fchip { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.fchip-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.fchip-dot--red { background: var(--red); } .fchip-dot--amber { background: var(--amber); }
.fchip-dot--green { background: var(--green); } .fchip-dot--navy { background: var(--primary); }
.fchip.on .fchip-dot { box-shadow: 0 0 0 2px rgba(255,255,255,.7); }
.fchip-count { font-size: 11px; font-variant-numeric: tabular-nums; opacity: .75; }

/* ─── Data table ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted-2); font-weight: 600; text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.data-table td { padding: 12px 12px; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; color: var(--text); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .1s var(--ease); }
.data-table tbody tr:hover { background: var(--bg); }
.ro-link { white-space: nowrap; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; letter-spacing: .01em; text-decoration: none; }
.ro-link:hover { text-decoration: underline; }
.meter-wrap { display: flex; align-items: center; gap: 9px; min-width: 96px; }
.meter { flex: 1; height: 5px; background: var(--light-grey); border-radius: 999px; overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; }
.meter-num { font-size: 12.5px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; min-width: 22px; text-align: right; }

/* ─── Footer ──────────────────────────────────────────────────────── */
footer.site-footer { background: var(--surface); border-top: 1px solid var(--border); padding: 12px clamp(14px, 2vw, 40px); font-size: 12px; color: var(--muted-2); display: flex; gap: 9px; align-items: center; flex-shrink: 0; }
.footer-sep { opacity: .45; }

@media (max-width: 600px) {
  .tools-grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════════════
   Shared components promoted from page <style> blocks.
   Class names are kept identical to the originals so the per-page
   copies can be deleted without touching markup. Live reference:
   /styleguide
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Flash / callout ─────────────────────────────────────────────── */
.flash { background: var(--green-bg); border: 1px solid #bfe3cc; color: var(--green-tx); border-radius: var(--r-md); padding: 11px 15px; margin: 0 0 18px; font-size: 13px; }
.flash--error { background: var(--red-bg); border-color: #f3c6cc; color: var(--red-tx); }
.callout { display: flex; gap: 11px; align-items: flex-start; background: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--r-md); padding: 12px 15px; margin-bottom: 24px; font-size: 12.5px; line-height: 1.5; color: var(--text); }
.callout svg { flex: 0 0 auto; margin-top: 1px; color: var(--text-muted); }
.callout strong { color: var(--ink); }
.callout .lookup-action { margin-top: 8px; }
.callout--dashed { background: none; border-style: dashed; border-color: var(--border); }

/* ─── Empty state ─────────────────────────────────────────────────── */
.empty { text-align: center; padding: 44px 20px; color: var(--text-muted); font-size: 13.5px; }
.empty-icon { color: var(--muted-2); margin-bottom: 10px; }
.empty-title { font-size: 15px; font-weight: 700; color: var(--ink); margin: 0 0 4px; }

/* ─── Form fields ─────────────────────────────────────────────────── */
/* Layout lives on the child classes so legacy pages that already use a bare
   .field (admin, login, build plan, Open/Mate form) are unaffected. */
.field { display: block; margin-bottom: 14px; }   /* block: a <label class="field"> is inline by default and would ignore the margin */
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--ink); margin-bottom: 5px; }
.field-hint { display: block; font-size: 11.5px; color: var(--muted-2); margin-top: 4px; }
.field > .input, .field > .select, .field > .textarea, .field > .input-group { width: 100%; }
.input, .select, .textarea { font: inherit; font-size: 13.5px; color: var(--ink); background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-md); padding: 8px 11px; transition: border-color .15s var(--ease), box-shadow .12s var(--ease); }
.textarea { resize: vertical; line-height: 1.55; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.btn-danger { background: var(--surface); color: var(--red-tx); border-color: #f3c6cc; }
.btn-danger:hover { background: var(--red-bg); border-color: var(--red); }

/* ─── Mono values (op codes, RO numbers, VINs, part numbers) ──────── */
.mono { font-family: var(--mono); font-weight: 600; }

/* ─── RO status banner + score ring ───────────────────────────────── */
.status { display: flex; align-items: center; gap: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 20px 24px; margin-bottom: 16px; position: relative; overflow: hidden; }
.status::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--red); }
.status--advisory::before { background: var(--amber); }
.status--clear::before { background: var(--green); }
.status--progress::before { background: var(--muted-2); }
.status-body { flex: 1; min-width: 0; }
.status-h { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; }
.status-title { font-size: 19px; font-weight: 700; color: var(--ink); }
.status-sub { font-size: 13.5px; color: var(--text-muted); margin-top: 3px; }
.ring { position: relative; width: 74px; height: 74px; flex: 0 0 auto; }
.ring svg { transform: rotate(-90deg); }
.ring-num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-num b { font-family: var(--mono); font-size: 20px; font-weight: 700; color: var(--ink); line-height: 1; }
.ring-num span { font-size: 9px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-2); margin-top: 2px; }

/* ─── Metadata strip (key/value utility row) ──────────────────────── */
.ro-strip { display: flex; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow); padding: 2px 0; margin-bottom: 26px; }
.ro-item { padding: 11px 20px; min-width: 118px; border-right: 1px solid var(--line-soft); }
.ro-item:last-child { border-right: none; }
.ro-info-label { font-size: 10px; color: var(--muted-2); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; margin-bottom: 4px; }
.ro-info-val { font-size: 14px; font-weight: 600; color: var(--ink); word-break: break-word; }

/* ─── Flag row (views/wade/_flag.ejs) ─────────────────────────────── */
.inline-flag { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; border-radius: var(--r-sm); padding: 8px 11px; margin-top: 6px; line-height: 1.5; }
.inline-flag--error   { background: var(--red-bg);   color: #7a2020; }
.inline-flag--warning { background: var(--amber-bg); color: #6d4409; }
.inline-flag .dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 5px; flex: 0 0 auto; }
.inline-flag--error .dot { background: var(--red); }
.inline-flag--warning .dot { background: var(--amber); }
.inline-flag .sug { color: var(--text-muted); }
.inline-flag-body { flex: 1; min-width: 0; }
.inline-flag.resolved { opacity: .5; }
.ig-wrap { margin: 0 0 0 auto; flex: 0 0 auto; }
.ig-btn { font: inherit; font-size: 11px; font-weight: 600; border: 1px solid #cdd5e4; background: var(--surface); color: #5a677f; border-radius: 999px; padding: 3px 11px; cursor: pointer; white-space: nowrap; }
.ig-btn:hover { background: var(--bg); }
.ig-done { border-color: #bfe3cc; background: var(--green-bg); color: var(--green-tx); cursor: default; }

/* ─── Signal cards (fixed, always-visible findings on an RO) ─────── */
.signal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; margin-bottom: 16px; }
.signal-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 18px; box-shadow: var(--shadow); }
.signal-card--alert { background: var(--amber-bg); border-color: #f0d9ad; }
.signal-card--error { background: var(--red-bg); border-color: #f3c6cc; }
.signal-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 8px; color: var(--muted-2); }
.signal-head .t-h3 { margin-right: auto; }
.signal-list { margin: 0 0 8px; padding-left: 18px; font-size: 13px; color: var(--ink); }
.signal-list li { padding: 2px 0; }
.signal-list li.is-resolved { color: var(--muted-2); text-decoration: line-through; }
.signal-empty { margin: 0 0 8px; font-size: 13px; color: var(--green-tx); font-weight: 600; }
.signal-note { margin: 0; font-size: 11.5px; color: var(--text-muted); }

/* ─── Work bar + progress tracker ─────────────────────────────────── */
.workbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow); padding: 9px 14px; margin: 0 0 16px; }
.workbar-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.workbar-left .meta { font-size: 12px; color: var(--muted-2); }
.workbar-prog { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.workbar-prog-num { font-size: 12.5px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tracker-bar { height: 8px; background: var(--line-soft); border-radius: 999px; overflow: hidden; }
.tracker-fill { height: 100%; background: var(--green); border-radius: 999px; }

/* ─── Repair-line card ────────────────────────────────────────────── */
.op-card { background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); margin-bottom: 22px; overflow: hidden; }
.op-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 16px 22px; background: var(--primary-lt); border-bottom: 1px solid var(--border-2); }
.op-card--alt .op-head { background: #eceff5; }
.op-body { padding: 18px 22px; }
.op-line-badge { font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #fff; background: var(--primary); border-radius: var(--r-sm); padding: 6px 11px; flex: 0 0 auto; }
.op-card--alt .op-line-badge { background: var(--ink); }
.op-code-chip { font-family: var(--mono); font-size: 12.5px; font-weight: 600; color: var(--accent); background: var(--primary-lt); border-radius: var(--r-sm); padding: 3px 10px; }
.op-code-big { font-family: var(--mono); font-size: 20px; font-weight: 600; color: var(--primary); background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-md); padding: 6px 14px; line-height: 1.15; flex: 0 0 auto; }
.op-code-cap { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-2); }
.op-code-desc { font-size: 13.5px; color: var(--ink); font-weight: 600; line-height: 1.35; }
.op-meta { font-size: 12px; color: var(--text-muted); }

/* ─── Compact table (parts on a line) ─────────────────────────────── */
.op-parts { overflow-x: auto; margin-top: 12px; border-top: 1px solid var(--line-soft); padding-top: 11px; }
.op-parts-h { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-2); margin-bottom: 5px; }
.op-parts-table { width: 100%; max-width: 640px; border-collapse: collapse; font-size: 12.5px; margin-top: 4px; }
.op-parts-table th { text-align: left; font-size: 10px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: var(--muted-2); padding: 4px 10px; border-bottom: 1px solid var(--line-soft); }
.op-parts-table td { padding: 7px 10px; border-bottom: 1px solid var(--line-soft); color: var(--text); vertical-align: top; }
.op-parts-table tr:last-child td { border-bottom: none; }
.op-parts-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.op-parts-table .mono { color: var(--ink); white-space: nowrap; }
.op-parts-table .basis { color: var(--muted-2); }

/* ─── 3C narrative editor ─────────────────────────────────────────── */
.narr-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line-soft); }
@media (max-width: 900px) { .narr-grid { grid-template-columns: 1fr; } }
.narr-head { padding: 0 0 8px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line-soft); margin-bottom: 11px; }
.narr-type { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.narr-pill { font-size: 11px; font-weight: 600; border-radius: 6px; padding: 2px 8px; }
.np-good { background: var(--green-bg); color: var(--green-tx); }
.np-ok   { background: var(--amber-bg); color: var(--amber-tx); }
.np-poor { background: var(--red-bg);   color: var(--red-tx); }
.narr-issue { font-size: 12px; font-weight: 600; color: var(--red-tx); line-height: 1.45; margin: 0 0 11px; }
.narr-issue.is-resolved { color: var(--muted-2); font-weight: 500; }
.narr-was { font-size: 12px; color: var(--text-muted); line-height: 1.5; margin-bottom: 13px; }
.narr-was-lbl { display: inline-block; font-size: 9.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-2); margin-right: 7px; vertical-align: 1px; }
.narr-was--empty { font-style: italic; color: var(--muted-2); }
.narr-sug-lbl { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--primary); margin-bottom: 6px; }
.narr-text { width: 100%; font: inherit; font-size: 12.5px; line-height: 1.55; color: var(--ink); border: 1px solid var(--border-2); border-radius: var(--r-md); padding: 10px 12px; resize: vertical; background: var(--surface); box-shadow: inset 0 1px 2px rgba(15,23,42,.04); transition: border-color .15s var(--ease), box-shadow .15s var(--ease); }
.narr-text[readonly] { background: var(--bg); color: var(--text); box-shadow: none; }
.narr-text:focus { outline: none; border-color: var(--primary); box-shadow: inset 0 1px 2px rgba(15,23,42,.03), var(--ring); }
.narr-actions { display: flex; gap: 6px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.narr-actions .narr-ign-btn { color: var(--text-muted); }
.narr-actions .js-update { margin-left: auto; }

/* Read-only narrative text (no write access / submitted RO) */
.narr-orig { font-size: 12.5px; color: var(--text); line-height: 1.55; background: var(--bg); border-radius: var(--r-sm); padding: 8px 10px; margin-bottom: 10px; }
.narr-orig--suggested { background: var(--green-bg); color: var(--green-tx); }

/* ─── Panel header note + choice list (tick-to-approve rows) ──────── */
.panel-note { background: var(--primary-lt); padding: 10px 16px; font-size: 12px; color: var(--primary-dk); font-weight: 600; }
.panel-foot { padding: 13px 16px; }
.panel--clip { overflow: hidden; }
.panel--pad { padding: 18px 20px; }                     /* a panel holding content directly (record details, drawer sections) */
.panel--pad + .panel--pad { margin-top: 16px; }
.panel--pad > h2, .panel--pad > h3 { margin: 0 0 12px; }
.t-preline { white-space: pre-line; }                   /* text typed with line breaks (notes, details) keeps them */
.choice-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.choice-row:hover { background: var(--surface-2); }
.choice-row > input { margin-top: 3px; width: 16px; height: 16px; flex: 0 0 16px; accent-color: var(--primary); }
.choice-row--placeholder { opacity: .7; cursor: default; }
.choice-row--placeholder:hover { background: none; }
.choice-box-placeholder { width: 16px; height: 16px; flex: 0 0 16px; margin-top: 3px; border: 2px dashed var(--muted-2); border-radius: 3px; }
.choice-body { flex: 1; min-width: 0; }
.choice-title { display: flex; align-items: center; gap: 9px; margin-bottom: 3px; font-size: 13px; font-weight: 600; color: var(--ink); }
.choice-detail { font-size: 12.5px; }
.choice-note { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* ─── Before → after diff (correction proposals) ──────────────────── */
.diff-before { color: var(--red-tx); text-decoration: line-through; }
.diff-arrow  { color: var(--text-muted); }
.diff-after  { color: var(--green-tx); font-weight: 600; }

/* ═══════════════════════════════════════════════════════════════════
   Base component library. Every page builds from these; a page
   <style> block may add layout only, never restyle a component.
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Typography scale (fixed — do not invent sizes) ──────────────── */
.t-display { font-size: 28px; font-weight: 700; color: var(--ink); letter-spacing: -.02em; line-height: 1.2; }
.t-h2 { font-size: 19px; font-weight: 700; color: var(--ink); letter-spacing: -.01em; line-height: 1.3; margin: 0; }
.t-h3 { font-size: 15px; font-weight: 700; color: var(--ink); line-height: 1.35; margin: 0; }
.t-body { font-size: 14px; color: var(--text); }
.t-small { font-size: 12.5px; color: var(--text); }
.t-muted { color: var(--text-muted); }
.t-caption { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-2); }
.t-num { font-variant-numeric: tabular-nums; }
a.link, .link { color: var(--accent); text-decoration: none; font-weight: 600; }
a.link:hover, .link:hover { text-decoration: underline; }
.kbd { font-family: var(--mono); font-size: 11px; background: var(--surface); border: 1px solid var(--border-2); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; color: var(--ink); }

/* ─── Layout primitive: a wrapping row of items ───────────────────── */
.cluster { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ─── Page intro (under the header; the H1 lives in the header) ──── */
.page-intro { margin: 0 0 20px; }
.page-heading { font-size: 22px; font-weight: 700; color: var(--ink); margin: 4px 0 4px; letter-spacing: -.015em; }
.page-intro .lead { margin-bottom: 0; }

/* ─── Tabs + segmented control ────────────────────────────────────── */
/* The base line is an inset shadow (not a border + negative margin) so the strip can scroll sideways on narrow screens without a stray vertical scrollbar. */
.tabs { display: flex; gap: 2px; box-shadow: inset 0 -1px 0 var(--border); margin: 0 0 18px; overflow-x: auto; overflow-y: hidden; }
.tab { font: inherit; font-size: 13.5px; font-weight: 600; color: var(--text-muted); background: none; border: none; border-bottom: 2px solid transparent; padding: 10px 14px; cursor: pointer; text-decoration: none; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; }
.tab:hover { color: var(--ink); }
.tab.is-active, .tab[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.tab-count { font-size: 11px; background: var(--light-grey); color: var(--text-muted); border-radius: 999px; padding: 0 7px; }
.segmented { display: inline-flex; background: var(--light-grey); border-radius: var(--r-md); padding: 3px; gap: 2px; }
.segmented button, .segmented a { font: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-muted); background: none; border: none; border-radius: var(--r-sm); padding: 5px 12px; cursor: pointer; text-decoration: none; }
.segmented .is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ─── Data table extensions ───────────────────────────────────────── */
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover, .data-table th[aria-sort] { color: var(--ink); }
.data-table th[aria-sort="ascending"]::after  { content: " \2191"; }
.data-table th[aria-sort="descending"]::after { content: " \2193"; }
.data-table .row-actions { text-align: right; white-space: nowrap; }
.data-table tr.is-selected { background: var(--accent-lt); }
.data-table--compact th { padding: 9px 14px; }
.data-table--compact td { padding: 9px 12px; font-size: 13px; }
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 18px; border-top: 1px solid var(--line-soft); font-size: 12.5px; color: var(--text-muted); }

/* ─── Pagination ──────────────────────────────────────────────────── */
.pager { display: inline-flex; align-items: center; gap: 4px; }
.pager a, .pager span { min-width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; padding: 0 9px; border-radius: var(--r-sm); font-size: 13px; color: var(--text); text-decoration: none; font-variant-numeric: tabular-nums; }
.pager a:hover { background: var(--light-grey); }
.pager [aria-current="page"] { background: var(--primary); color: #fff; font-weight: 600; }
.pager .is-disabled { color: var(--muted-2); pointer-events: none; }

/* ─── Select + dropdown menu ──────────────────────────────────────── */
.select { appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
.menu { position: relative; display: inline-block; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; z-index: 20; top: calc(100% + 6px); right: 0; min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-lg), 0 12px 28px -14px rgba(20,26,42,.28); padding: 5px; }
.menu-list--left { right: auto; left: 0; }
.menu-item { display: flex; align-items: center; gap: 9px; width: 100%; font: inherit; font-size: 13px; color: var(--text); background: none; border: none; border-radius: var(--r-sm); padding: 8px 10px; text-align: left; text-decoration: none; cursor: pointer; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); color: var(--ink); }
.menu-item--danger { color: var(--red-tx); }
.menu-item--danger:hover { background: var(--red-bg); }
.menu-sep { height: 1px; background: var(--line-soft); margin: 5px 0; }
.menu-label { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-2); padding: 7px 10px 4px; }

/* ─── Checkbox, radio, toggle ─────────────────────────────────────── */
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); cursor: pointer; flex: 0 0 auto; }
.toggle { display: inline-flex; align-items: center; gap: 9px; font-size: 13.5px; cursor: pointer; }
.toggle input { appearance: none; width: 34px; height: 20px; margin: 0; border-radius: 999px; background: var(--border-2); position: relative; cursor: pointer; transition: background .15s var(--ease); flex: 0 0 auto; }
.toggle input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s var(--ease); }
.toggle input:checked { background: var(--primary); }
.toggle input:checked::after { transform: translateX(14px); }
.toggle input:focus-visible { box-shadow: var(--ring); }

/* ─── Field states + input group ──────────────────────────────────── */
.field-label .req { color: var(--red); margin-left: 2px; }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--red); }
.field-error { display: block; margin-top: 4px; font-size: 11.5px; color: var(--red-tx); font-weight: 600; }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--light-grey); color: var(--muted-2); cursor: not-allowed; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { flex: 1; min-width: 0; border-radius: 0; }
.input-group .input:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.input-group .input:last-child { border-radius: 0 var(--r-md) var(--r-md) 0; }
.input-addon { display: flex; align-items: center; padding: 0 11px; font-size: 13px; color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border-2); }
.input-addon:first-child { border-right: none; border-radius: var(--r-md) 0 0 var(--r-md); }
.input-addon:last-child  { border-left: none;  border-radius: 0 var(--r-md) var(--r-md) 0; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }
.pw-rules { list-style: none; margin: 6px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 3px 14px; font-size: 11.5px; color: var(--text-muted); }
.pw-rules li { display: flex; align-items: center; gap: 6px; }
.pw-rules li[data-rule]::before { content: ""; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--border-2); flex: 0 0 auto; }
.pw-rules li.is-met { color: var(--green-tx); }
.pw-rules li.is-met::before { background: var(--green); border-color: var(--green); }
.pw-rules .pw-rule-note { grid-column: 1 / -1; color: var(--muted-2); }
.form-footer { display: flex; gap: 8px; justify-content: flex-end; padding-top: 6px; }
input[type="date"].input, input[type="time"].input { font-variant-numeric: tabular-nums; }

/* ─── Calendar (month grid — views/partials/calendar.ejs) ─────────── */
.cal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.cal-title { font-size: 15px; font-weight: 700; color: var(--ink); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-dow { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-2); text-align: center; padding: 8px 0; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cal-day { min-height: 84px; padding: 6px 7px; border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); font-size: 12px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-day:nth-child(7n) { border-right: none; }
.cal-day.is-out { background: var(--surface-2); }
.cal-date { font-size: 12px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.cal-day.is-out .cal-date { color: var(--muted-2); }
.cal-day.is-today .cal-date { background: var(--primary); color: #fff; }
.cal-event { font-size: 11px; font-weight: 600; border-radius: 4px; padding: 2px 6px; background: var(--primary-lt); color: var(--primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event--amber { background: var(--amber-bg); color: var(--amber-tx); }
.cal-event--green { background: var(--green-bg); color: var(--green-tx); }
.cal-event--red   { background: var(--red-bg);   color: var(--red-tx); }
.cal-nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
a.cal-event { text-decoration: none; }
a.cal-event:hover { filter: brightness(.96); }
.cal-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 18px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.cal-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 11.5px; color: var(--text-muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-key { width: 10px; height: 10px; border-radius: 3px; background: var(--primary-lt); border: 1px solid var(--primary); }
.cal-key--red   { background: var(--red-bg);   border-color: var(--red); }
.cal-key--amber { background: var(--amber-bg); border-color: var(--amber); }
.cal-key--green { background: var(--green-bg); border-color: var(--green); }
.cal-more { font-size: 11px; color: var(--text-muted); padding-left: 2px; }
@media (max-width: 700px) { .cal-day { min-height: 54px; } .cal-event { font-size: 0; padding: 0; height: 5px; } }

/* ─── Dialog (replaces window.confirm — see /js/confirm.js) ───────── */
dialog.dialog { border: none; border-radius: var(--r-lg); padding: 0; width: min(460px, calc(100vw - 32px)); box-shadow: 0 24px 60px -20px rgba(20,26,42,.45); color: var(--text); }
dialog.dialog::backdrop { background: rgba(19,26,43,.45); }
.dialog-body { padding: 22px 24px 8px; }
.dialog-title { font-size: 16px; font-weight: 700; color: var(--ink); margin: 0 0 6px; }
.dialog-text { font-size: 13.5px; color: var(--text-muted); margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 24px 18px; }
/* Overlay panels (dialog, drawer) share one shape: fixed header, scrolling body, fixed footer holding the actions. */
.dialog[open] { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.dialog[open] .dialog-body { overflow-y: auto; }
.dialog-actions, .drawer-foot { flex: 0 0 auto; border-top: 1px solid var(--line-soft); background: var(--surface); }

/* ─── Toast ───────────────────────────────────────────────────────── */
.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 380px; background: var(--ink); color: #fff; border-radius: var(--r-md); padding: 11px 14px; font-size: 13px; box-shadow: var(--shadow-lg); }
.toast .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex: 0 0 auto; }
.toast--error .dot { background: var(--red); }
.toast--warning .dot { background: var(--amber); }

/* ─── Tooltip (data-tip="…") ──────────────────────────────────────── */
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 11.5px; font-weight: 500; line-height: 1.4; padding: 5px 8px; border-radius: 6px; white-space: nowrap; z-index: 30; pointer-events: none; }

/* ─── Loading: spinner + skeleton ─────────────────────────────────── */
.spinner { width: 16px; height: 16px; border: 2px solid var(--border-2); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--light-grey) 25%, var(--surface-2) 50%, var(--light-grey) 75%); background-size: 200% 100%; animation: shimmer 1.3s ease-in-out infinite; border-radius: var(--r-sm); height: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .spinner, .skeleton { animation: none; } }

/* ─── Key/value list ──────────────────────────────────────────────── */
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 22px; margin: 0; font-size: 13.5px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; color: var(--ink); font-weight: 600; min-width: 0; overflow-wrap: anywhere; }   /* long ids, URLs and setting names wrap inside the card */
.code-block { font-family: var(--mono); font-size: 12.5px; line-height: 1.55; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 14px; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 420px; overflow-y: auto; }

/* ─── Timeline (audit trail) ──────────────────────────────────────── */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.timeline li::after { content: ""; position: absolute; left: 7.5px; top: 17px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline-meta { font-size: 11.5px; color: var(--muted-2); }

/* ─── Accordion ───────────────────────────────────────────────────── */
.accordion { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.accordion details + details { border-top: 1px solid var(--line-soft); }
.accordion summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 18px; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--muted-2); border-bottom: 2px solid var(--muted-2); transform: rotate(45deg); transition: transform .15s var(--ease); margin-top: -4px; }
.accordion details[open] summary::after { transform: rotate(-135deg); margin-top: 3px; }
.accordion-body { padding: 0 18px 15px; font-size: 13px; color: var(--text); }

/* ─── Stepper ─────────────────────────────────────────────────────── */
.stepper { display: flex; list-style: none; margin: 0 0 20px; padding: 0; counter-reset: step; }
.stepper li { flex: 1; display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted-2); counter-increment: step; }
.stepper li::before { content: counter(step); width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 11.5px; background: var(--light-grey); color: var(--text-muted); flex: 0 0 auto; }
.stepper li:not(:last-child)::after { content: ""; flex: 1; height: 1px; background: var(--border-2); margin: 0 8px; }
.stepper .is-done { color: var(--text); }
.stepper .is-done::before { content: "\2713"; background: var(--green-bg); color: var(--green-tx); }
.stepper .is-current { color: var(--ink); }
.stepper .is-current::before { background: var(--primary); color: #fff; }

/* ─── Avatar ──────────────────────────────────────────────────────── */
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--primary-lt); color: var(--primary); font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }

/* ─── Error page ──────────────────────────────────────────────────── */
.error-page { max-width: 440px; margin: 8vh auto; text-align: center; }
.error-code { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--accent); }

/* ─── Icon (views/partials/icon.ejs) ──────────────────────────────── */
.icon { flex: 0 0 auto; vertical-align: -3px; }   /* size comes from the partial's width/height attributes */
.icon--lg { width: 20px; height: 20px; }

/* ═══════════════════════════════════════════════════════════════════
   App shell — header, sidebar, avatar menu, footer.
   views/partials/shell-start.ejs + shell-end.ejs. Every signed-in page.
   ═══════════════════════════════════════════════════════════════════ */
:root { --header-h: 60px; --sidebar-w: 232px; --sidebar-w-collapsed: 64px; }

.app { flex: 1; display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); grid-template-rows: var(--header-h) 1fr; min-height: 100vh; }
.app-header { grid-column: 1 / -1; position: sticky; top: 0; z-index: 40; }
.app-main { display: flex; flex-direction: column; min-width: 0; }
.app-main > main { flex: 1; }
html.sb-collapsed .app { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }
@media (max-width: 1180px) { .hdr-brand { width: auto; } .hdr-brand .topbar-brand { display: none; } }

/* Header (extends .topbar) */
.app-header.topbar { padding: 0 16px 0 12px; gap: 12px; }
.hdr-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: var(--r-md); background: none; border: none; color: var(--topbar-link); cursor: pointer; flex: 0 0 auto; }
.hdr-icon-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
.hdr-brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: #fff; flex: 0 0 auto; width: calc(var(--sidebar-w) - 44px); min-width: 0; }
.hdr-brand .topbar-brand { min-width: 0; overflow: hidden; }
.hdr-brand .brand-name { font-size: 14px; letter-spacing: .1px; }
.hdr-brand .brand-name, .hdr-brand .brand-tagline { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Page title / breadcrumb — the page's H1 lives here, not in the content */
.hdr-title { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1 1 auto; padding-left: 14px; border-left: 1px solid rgba(255,255,255,.16); }
.hdr-crumb { color: var(--topbar-link); text-decoration: none; font-size: 15px; font-weight: 500; white-space: nowrap; }
.hdr-crumb:hover { color: #fff; text-decoration: underline; }
.hdr-sep { color: var(--topbar-sub); display: inline-flex; flex: 0 0 auto; }
.hdr-h1 { margin: 0; font-size: 16px; font-weight: 700; color: #fff; letter-spacing: -.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.hdr-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.hdr-action { background: rgba(255,255,255,.10); color: #fff; border-color: rgba(255,255,255,.22); }
.hdr-action:hover { background: rgba(255,255,255,.18); }
.hdr-action--primary { background: #fff; color: var(--primary); border-color: #fff; }
.hdr-action--primary:hover { background: var(--primary-lt); }
@media (max-width: 1100px) { .hdr-action-label { display: none; } }
.hdr-search { flex: 0 1 320px; min-width: 180px; display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.12); border: 1px solid transparent; border-radius: var(--r-md); padding: 0 11px; color: var(--topbar-link); transition: background .15s var(--ease), border-color .15s var(--ease); }
.hdr-search:focus-within { background: #fff; color: var(--text-muted); border-color: #fff; box-shadow: var(--ring); }
.hdr-search input { border: none; outline: none; background: none; font: inherit; font-size: 13.5px; color: #fff; width: 100%; padding: 8px 0; min-width: 0; }
.hdr-search:focus-within input { color: var(--ink); }
.hdr-search input::placeholder { color: var(--topbar-link); opacity: .85; }
.hdr-search:focus-within input::placeholder { color: var(--muted-2); }
.hdr-right { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

/* Store switcher (header) */
.store-switch > summary { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 11px; border-radius: var(--r-md); color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.18); white-space: nowrap; }
.store-switch > summary:hover { background: rgba(255,255,255,.18); }
.store-switch .store-switch-cap { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--topbar-sub); }
.store-switch form { margin: 0; }
.menu-item.is-current { font-weight: 600; color: var(--primary); }
.menu-item.is-current::after { content: ""; margin-left: auto; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }

/* Avatar menu */
.avatar-menu > summary { display: inline-flex; align-items: center; gap: 6px; padding: 3px; border-radius: 999px; cursor: pointer; color: var(--topbar-link); }
.avatar-menu > summary:hover { background: rgba(255,255,255,.12); }
.avatar-menu .avatar { width: 32px; height: 32px; background: #fff; color: var(--primary); font-size: 12px; }
.menu-head { padding: 9px 10px 8px; border-bottom: 1px solid var(--line-soft); margin-bottom: 5px; }
.menu-head-name { font-size: 13.5px; font-weight: 700; color: var(--ink); }
.menu-head-meta { font-size: 12px; color: var(--text-muted); }

/* Sidebar */
.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: var(--fixed-top); height: calc(100vh - var(--fixed-top) - var(--fixed-bottom)); overflow-y: auto; padding: 14px 10px 10px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-label { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted-2); padding: 14px 10px 6px; white-space: nowrap; overflow: hidden; }
.side-link { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--r-md); color: var(--text); text-decoration: none; font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; transition: background .12s var(--ease), color .12s var(--ease); }
.side-link .icon { width: 18px; height: 18px; color: var(--muted-2); }
.side-link:hover { background: var(--surface-2); color: var(--ink); }
.side-link:hover .icon { color: var(--text); }
.side-link.is-active { background: var(--primary-lt); color: var(--primary); font-weight: 600; }
.side-link.is-active .icon { color: var(--primary); }
.side-sub { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 6px 14px; padding-left: 10px; border-left: 1px solid var(--border); }
.side-link--sub { padding: 7px 10px; font-size: 13px; }
.side-link--sub .icon { width: 16px; height: 16px; }
.side-link.is-open { color: var(--ink); font-weight: 600; }
.side-link.is-open .icon { color: var(--primary); }
html.sb-collapsed .side-sub { margin-left: 0; padding-left: 0; border-left: none; }
.side-badge { margin-left: auto; font-size: 11px; font-weight: 700; background: var(--red-bg); color: var(--red-tx); border-radius: 999px; padding: 0 7px; font-variant-numeric: tabular-nums; }
.side-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line-soft); }
button.side-link { width: 100%; border: none; background: none; font: inherit; font-size: 13.5px; cursor: pointer; text-align: left; }
.side-collapse .icon { transition: transform .15s var(--ease); }
html.sb-collapsed .side-label, html.sb-collapsed .side-text, html.sb-collapsed .side-badge { display: none; }
html.sb-collapsed .side-link { justify-content: center; padding: 10px 0; }
html.sb-collapsed .side-collapse .icon { transform: rotate(180deg); }
.side-only-mobile { display: none; }
.side-search { flex: 0 0 auto; max-width: none; min-width: 0; margin-bottom: 8px; }   /* in the column-flex sidebar, .search's 300px flex-basis would become its height */

/* Footer inside the main column */
.app-main > footer.site-footer { margin-top: auto; }
.footer-version { margin-left: auto; font-family: var(--mono); font-size: 11px; }

/* Mobile: off-canvas sidebar */
.sb-scrim { display: none; }
@media (max-width: 900px) {
  .app, html.sb-collapsed .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 45; left: 0; top: var(--header-h); bottom: 0; height: auto; width: min(280px, 86vw); transform: translateX(-100%); transition: transform .2s var(--ease); box-shadow: var(--shadow-lg); }
  html.sb-open .sidebar { transform: none; }
  html.sb-open .sb-scrim { display: block; position: fixed; inset: var(--header-h) 0 0 0; z-index: 44; background: rgba(19,26,43,.35); }
  html.sb-collapsed .side-label, html.sb-collapsed .side-text, html.sb-collapsed .side-badge { display: initial; }
  html.sb-collapsed .side-link { justify-content: flex-start; padding: 9px 10px; }
  .side-collapse { display: none; }
  .side-only-mobile { display: block; }
  .side-search.side-only-mobile { display: flex; }
  .hdr-search { display: none; }
  .store-switch .store-switch-cap { display: none; }
  .hdr-title { padding-left: 4px; border-left: none; }
  .hdr-title .hdr-crumb, .hdr-title .hdr-sep { display: none; }
  .hdr-brand { display: none; }
}
@media (min-width: 901px) { .hdr-menu-btn { display: none; } }
@media (max-width: 480px) { .store-switch > summary .store-switch-name { max-width: 110px; overflow: hidden; text-overflow: ellipsis; } }

/* ─── Home: quick access ──────────────────────────────────────────── */
.qa-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin-bottom: 30px; }
.qa-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.qa-head { display: flex; align-items: center; gap: 11px; }
.qa-stats { display: flex; gap: 22px; flex-wrap: wrap; }
.qa-stat b { display: block; font-size: 22px; font-weight: 700; color: var(--ink); line-height: 1.1; font-variant-numeric: tabular-nums; }
.qa-stat span { font-size: 12px; color: var(--text-muted); }
.qa-card .btn { align-self: flex-start; margin-top: auto; }
.link-list { display: flex; flex-wrap: wrap; gap: 8px; }

/* ═══════════════════════════════════════════════════════════════════
   Fixed-chrome offsets. Anything sticky, and anchor jumps, must clear the
   fixed header (and any future fixed footer). Use these — never a raw px top.
   ═══════════════════════════════════════════════════════════════════ */
:root {
  --fixed-top: var(--header-h);                     /* height of fixed chrome at the top */
  --fixed-bottom: 0px;                              /* set if a fixed footer is ever added */
  --sticky-top: calc(var(--fixed-top) + 16px);      /* top: for sticky elements */
}
html { scroll-padding-top: var(--sticky-top); scroll-padding-bottom: var(--fixed-bottom); }

/* ═══════════════════════════════════════════════════════════════════
   Data table standard (lib/table.js + partials/table-start / table-end)
   ═══════════════════════════════════════════════════════════════════ */
.data-table tbody tr:nth-child(even) { background: var(--zebra); }       /* zebra — every table */
.data-table tbody tr:hover { background: var(--accent-lt); }
.op-parts-table tbody tr:nth-child(even) td { background: var(--zebra); }

.dt { margin-bottom: 24px; }
.dt-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 0 0 12px; }
.dt-search { flex: 0 1 360px; }
.dt-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.dt-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--primary); background: var(--primary-lt); border-radius: 999px; padding: 4px 9px 4px 11px; text-decoration: none; }
.dt-chip:hover { background: var(--accent-lt); }
.dt-chip-k { font-weight: 500; color: var(--text-muted); }
.dt-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dt-tools .col-filter-pop { left: auto; right: 0; }
/* Long tables: the table scrolls inside the card (capped to the viewport), so
   the header row stays frozen and the pagination footer stays in reach. */
.dt--long .table-wrap { max-height: calc(100vh - var(--fixed-top) - var(--fixed-bottom) - 150px); min-height: 320px; overflow: auto; }
.dt--long .data-table thead th { position: sticky; top: 0; z-index: 2; box-shadow: inset 0 -1px 0 var(--border); }
.dt--long .table-foot { position: sticky; bottom: var(--fixed-bottom); background: var(--surface); z-index: 3; }
.dt-count { margin-left: auto; font-size: 12.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.th-inner { display: flex; align-items: center; gap: 4px; }
.num .th-inner { justify-content: flex-end; }
.th-sort { display: inline-flex; align-items: center; gap: 3px; color: inherit; text-decoration: none; white-space: nowrap; }
.th-sort:hover { color: var(--ink); }
.sort-ind { display: inline-flex; opacity: 0; transition: opacity .12s var(--ease); }
.th-sort:hover .sort-ind, th[aria-sort] .sort-ind { opacity: 1; }
th[aria-sort] { color: var(--ink); }
.data-table th[aria-sort="ascending"]::after, .data-table th[aria-sort="descending"]::after { content: none; }

.col-filter > summary { list-style: none; }
.col-filter > summary::-webkit-details-marker { display: none; }
.col-filter-btn { display: inline-flex; align-items: center; gap: 3px; padding: 3px 4px; border-radius: 5px; color: var(--muted-2); cursor: pointer; opacity: .55; }
.th-inner:hover .col-filter-btn, .col-filter[open] .col-filter-btn, .col-filter-btn.is-on { opacity: 1; }
.col-filter-btn:hover { background: var(--light-grey); color: var(--ink); }
.col-filter-btn.is-on { color: var(--primary); background: var(--primary-lt); }
.col-filter-n { font-size: 10px; font-weight: 700; }
.col-filter-pop { width: 260px; left: 0; right: auto; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--text); padding: 8px; }
.num .col-filter-pop { left: auto; right: 0; }
.col-filter-actions { display: flex; justify-content: flex-end; gap: 6px; padding-top: 8px; border-top: 1px solid var(--line-soft); margin-top: 6px; }

/* ═══════════════════════════════════════════════════════════════════
   Combobox (public/js/combobox.js) — every dropdown is type-to-filter
   ═══════════════════════════════════════════════════════════════════ */
.cbx-native { position: absolute !important; width: 1px !important; height: 1px !important; opacity: 0; pointer-events: none; }
.cbx { position: relative; }
.cbx-trigger { width: 100%; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cbx-pop { display: none; position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; min-width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-lg), 0 12px 28px -14px rgba(20,26,42,.28); padding: 6px; }
.cbx.is-open .cbx-pop, .cbx--inline .cbx-pop { display: block; }
.cbx--inline .cbx-pop { position: static; border: none; box-shadow: none; padding: 0; max-width: none; }
.cbx-search, .menu-list .cbx-search { width: 100%; font: inherit; font-size: 13px; border: 1px solid var(--border-2); border-radius: var(--r-sm); padding: 7px 9px; margin-bottom: 6px; color: var(--ink); background: var(--surface); }
.cbx-search:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.cbx-list { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow-y: auto; }
.cbx-opt { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: var(--r-sm); font-size: 13px; color: var(--text); cursor: pointer; }
.cbx-opt:hover, .cbx-opt.is-active { background: var(--surface-2); color: var(--ink); }
.cbx-opt[aria-selected="true"] { color: var(--primary); font-weight: 600; }
.cbx:not(.cbx--multi) .cbx-opt[aria-selected="true"]::after { content: ""; margin-left: auto; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }
.cbx-box { width: 15px; height: 15px; border: 1.5px solid var(--border-2); border-radius: 4px; flex: 0 0 auto; background: var(--surface); }
.cbx-opt[aria-selected="true"] .cbx-box { background: var(--primary); border-color: var(--primary); box-shadow: inset 0 0 0 2px var(--surface); }
.cbx-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cbx-count { margin-left: auto; font-size: 11.5px; color: var(--muted-2); font-variant-numeric: tabular-nums; font-weight: 400; }
.cbx-none { padding: 8px 9px; font-size: 12.5px; color: var(--muted-2); }
.cbx-none[hidden], .cbx-opt[hidden], .menu-item[hidden] { display: none; }

.table-card .data-table th:first-child, .table-card .data-table td:first-child { padding-left: 18px; }
.table-card .data-table th:last-child, .table-card .data-table td:last-child { padding-right: 18px; }

/* ═══════════════════════════════════════════════════════════════════
   Docs section (header icon) — reader, prose, editor
   ═══════════════════════════════════════════════════════════════════ */
.inline-form { display: inline; margin: 0; }
.hdr-docs.is-active { background: rgba(255,255,255,.18); color: #fff; }

.doc-reader { overflow: hidden; }
.doc-frame { display: block; width: 100%; height: calc(100vh - var(--sticky-top) - var(--fixed-bottom) - 40px); min-height: 520px; border: 0; background: var(--surface-2); }
.doc-image { padding: 16px; text-align: center; background: var(--surface-2); }
.doc-image img { max-width: 100%; height: auto; border-radius: var(--r-sm); }
.doc-linkcard { display: flex; align-items: center; gap: 14px; padding: 18px 20px; border-top: 1px solid var(--line-soft); }
.doc-linkcard:first-child { border-top: none; }
.doc-linkcard .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* Written docs + converted Word files */
.doc-prose { padding: 26px 32px; font-size: 15px; line-height: 1.7; color: var(--text); max-width: 860px; }
.doc-prose h1, .doc-prose h2 { font-size: 21px; color: var(--ink); margin: 1.4em 0 .5em; line-height: 1.3; }
.doc-prose h3, .doc-prose h4 { font-size: 17px; color: var(--ink); margin: 1.2em 0 .4em; }
.doc-prose > :first-child { margin-top: 0; }
.doc-prose p { margin: 0 0 .9em; }
.doc-prose a { color: var(--accent); }
.doc-prose img { max-width: 100%; height: auto; border-radius: var(--r-sm); }
.doc-prose blockquote { margin: 0 0 1em; padding: 4px 16px; border-left: 3px solid var(--border-2); color: var(--text-muted); }
.doc-prose table { border-collapse: collapse; margin: 0 0 1em; font-size: 14px; }
.doc-prose th, .doc-prose td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.doc-prose th { background: var(--surface-2); }
.doc-prose code, .doc-prose pre { font-family: var(--mono); font-size: 13px; background: var(--surface-2); border-radius: 4px; }
.doc-prose pre { padding: 10px 12px; overflow-x: auto; }

/* Upload / Write / Link switcher */
.doc-type label { display: inline-flex; align-items: center; cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--text-muted); border-radius: var(--r-sm); padding: 5px 12px; }
.doc-type label.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.doc-type input { position: absolute; opacity: 0; pointer-events: none; }
.doc-type label:focus-within { box-shadow: var(--ring); }
.doc-link-rules { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 4px; }

/* Editor (public/vendor/editor.js) */
.editor { border: 1px solid var(--border-2); border-radius: var(--r-md); background: var(--surface); }
.editor:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.ed-toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line-soft); background: var(--surface-2); border-radius: var(--r-md) var(--r-md) 0 0; position: sticky; top: var(--fixed-top); z-index: 2; }
.ed-btn { font: inherit; font-size: 12.5px; font-weight: 600; color: var(--text); background: none; border: 1px solid transparent; border-radius: var(--r-sm); padding: 4px 9px; cursor: pointer; }
.ed-btn:hover { background: var(--surface); border-color: var(--border); }
.ed-btn.is-on { background: var(--primary-lt); color: var(--primary); }
.ed-surface .ProseMirror { min-height: 320px; padding: 16px 20px; outline: none; font-size: 15px; line-height: 1.7; color: var(--text); }
.ed-surface .ProseMirror h2 { font-size: 21px; color: var(--ink); margin: 1em 0 .4em; }
.ed-surface .ProseMirror h3 { font-size: 17px; color: var(--ink); margin: 1em 0 .4em; }
.ed-surface .ProseMirror p { margin: 0 0 .8em; }
.ed-surface .ProseMirror img { max-width: 100%; height: auto; }
.ed-surface .ProseMirror img.ProseMirror-selectednode { outline: 2px solid var(--accent); }
.ed-surface .ProseMirror table { border-collapse: collapse; }
.ed-surface .ProseMirror th, .ed-surface .ProseMirror td { border: 1px solid var(--border); padding: 6px 10px; min-width: 60px; }
.ed-surface .ProseMirror blockquote { border-left: 3px solid var(--border-2); margin: 0 0 1em; padding-left: 14px; color: var(--text-muted); }
.ed-surface .ProseMirror p.is-editor-empty:first-child::before { content: attr(data-placeholder); color: var(--muted-2); float: left; height: 0; pointer-events: none; }

/* ─── Assistant (partials/assistant-chat, assistant-panel; public/js/assistant.js) ── */
.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; }
.asst { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.asst-log { flex: 1 1 auto; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.asst-empty[hidden] { display: none; }
.asst-empty { margin: auto 0; text-align: center; color: var(--text-muted); display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px; }
.asst-empty p { margin: 0; font-size: 13.5px; color: var(--ink); }
.asst-empty svg { color: var(--primary); }
.asst-suggest { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 6px; }
.asst-suggest .chip { cursor: pointer; white-space: normal; text-align: left; font: inherit; font-size: 12px; }
.asst-suggest .chip:hover { border-color: var(--primary); color: var(--primary); }
.asst-msg { display: flex; flex-direction: column; gap: 6px; max-width: 92%; }
.asst-msg--user { align-self: flex-end; align-items: flex-end; }
.asst-msg--assistant { align-self: flex-start; }
.asst-bubble { font-size: 13.5px; line-height: 1.55; color: var(--ink); border-radius: var(--r-lg); padding: 10px 13px; overflow-wrap: anywhere; }
.asst-msg--user .asst-bubble { background: var(--primary); color: #fff; white-space: pre-wrap; border-bottom-right-radius: 4px; }
.asst-msg--assistant .asst-bubble { background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.asst-msg--error .asst-bubble { background: var(--red-bg); border-color: var(--red-bg); color: var(--red-tx); }
.asst-bubble p { margin: 0 0 8px; } .asst-bubble p:last-child { margin-bottom: 0; }
.asst-bubble ul, .asst-bubble ol { margin: 0 0 8px; padding-left: 20px; } .asst-bubble li + li { margin-top: 3px; }
.asst-cite { display: inline-flex; align-items: center; justify-content: center; min-width: 16px; height: 16px; padding: 0 4px; margin: 0 1px; border-radius: 8px; background: var(--primary-lt); color: var(--primary); font-size: 10.5px; font-weight: 700; text-decoration: none; vertical-align: 1px; }
a.asst-cite:hover { background: var(--primary); color: #fff; }
.asst-status { display: inline-flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 12.5px; }
.asst-caret { display: inline-block; width: 7px; height: 14px; margin-left: 2px; background: var(--text-muted); vertical-align: -2px; animation: asst-blink 1s steps(2) infinite; }
@keyframes asst-blink { 50% { opacity: 0; } }
.asst-sources { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.asst-sources-h { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-2); }
.asst-src { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; font-size: 12px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px 2px 3px; text-decoration: none; }
.asst-src > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.asst-src:hover { border-color: var(--primary); color: var(--primary); }
.asst-src-n { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; border-radius: 9px; background: var(--primary-lt); color: var(--primary); font-size: 10.5px; font-weight: 700; }
.asst-fb { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.asst-fb-btn { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: var(--r-sm); border: 1px solid transparent; background: none; color: var(--text-muted); cursor: pointer; }
.asst-fb-btn:hover { background: var(--surface-2); color: var(--ink); }
.asst-fb-btn[aria-pressed="true"] { background: var(--primary-lt); color: var(--primary); border-color: var(--primary-lt); }
.asst-fb-btn:focus-visible { box-shadow: var(--ring); outline: none; }
.asst-fb-note { display: flex; gap: 6px; flex: 1 1 100%; margin-top: 4px; }
.asst-fb-note .input { flex: 1 1 auto; min-width: 0; padding: 5px 9px; font-size: 12.5px; }
.asst-compose { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--surface); }
.asst-input { flex: 1 1 auto; min-width: 0; resize: none; max-height: 160px; }
.asst-send { flex: 0 0 auto; height: 38px; width: 42px; padding: 0; justify-content: center; }

/* Panel: opens under the fixed header; full-screen sheet on phones. */
.asst-panel { position: fixed; z-index: 38; top: var(--fixed-top); right: 0; bottom: var(--fixed-bottom); width: min(420px, 100vw); background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; }
.asst-panel[hidden] { display: none; }
.asst-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--border); }
.asst-panel-tools { display: flex; align-items: center; gap: 2px; }
.asst-panel .asst-close { color: var(--text-muted); }
.asst-panel .asst-close:hover { background: var(--surface-2); color: var(--ink); }
@media (max-width: 640px) { .asst-panel { width: 100vw; border-left: 0; } }

/* Full page: history list + chat. */
.asst-page-main { height: calc(100vh - var(--sticky-top) - var(--fixed-bottom) - 40px); min-height: 460px; padding: 0; overflow: hidden; display: flex; }
.asst-page-main .asst { flex: 1 1 auto; }
.asst-history { padding-bottom: 8px; }
.asst-history-list { list-style: none; margin: 0; padding: 0 6px; }
.asst-history-list li { display: flex; align-items: center; border-radius: var(--r-md); }
.asst-history-list li:hover, .asst-history-list li.is-current { background: var(--surface-2); }
.asst-history-list a { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; color: var(--ink); text-decoration: none; }
.asst-history-title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asst-history-del { flex: 0 0 auto; width: 28px; height: 28px; margin-right: 4px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; color: var(--muted-2); border-radius: var(--r-sm); cursor: pointer; }
.asst-history-del:hover { color: var(--red-tx); background: var(--red-bg); }
.asst-history-empty { padding: 4px 16px 8px; margin: 0; }

/* ─── Bar list (counts by category, each row a link) — e.g. Op codes → By vehicle system ── */
.bar-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 2px; }
.bar-list a, .bar-list .bar-list-row { display: grid; grid-template-columns: minmax(90px, 140px) minmax(0, 1fr) 56px; align-items: center; gap: 10px; padding: 4px 6px; border-radius: var(--r-sm); color: var(--ink); text-decoration: none; font-size: 12.5px; }
.bar-list a:hover { background: var(--surface-2); }
.bar-list-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-list-bar { height: 8px; background: var(--light-grey); border-radius: 999px; overflow: hidden; }
.bar-list-bar > span { display: block; height: 100%; width: var(--w, 0%); background: var(--primary); border-radius: 999px; }
.bar-list-n { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-muted); }

/* Assistant voice (A3): mic in the composer, status line under it, read-aloud in the answer bar */
.asst-mic { flex: 0 0 auto; height: 38px; width: 42px; padding: 0; justify-content: center; }
.asst-mic.is-listening, .asst-mic[aria-pressed="true"] { color: var(--red-tx); border-color: var(--red); background: var(--red-bg); animation: asst-pulse 1.2s ease-in-out infinite; }
.asst-mic:disabled { opacity: .45; cursor: not-allowed; }
@keyframes asst-pulse { 0%, 100% { box-shadow: 0 0 0 0 var(--red-bg); } 50% { box-shadow: 0 0 0 5px var(--red-bg); } }
@media (prefers-reduced-motion: reduce) { .asst-mic.is-listening { animation: none; } }
.asst-voice-status { padding: 0 14px 10px; color: var(--text-muted); background: var(--surface); }
.asst-voice-status[hidden] { display: none; }
.asst-voice-status.is-error { color: var(--red-tx); }
.asst-fb-btn:disabled { opacity: .4; cursor: not-allowed; }
.asst-reading { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-top: 1px solid var(--border); background: var(--primary-lt); color: var(--primary); font-size: 12.5px; font-weight: 600; }
.asst-reading[hidden] { display: none; }
.asst-reading span { flex: 1 1 auto; }
.asst-options { padding: 0 14px 10px; background: var(--surface); color: var(--text-muted); }
.asst-options .toggle { font-size: 12px; }
.asst-admin-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 0 0 16px; }

/* Assistant on phones: a floating chat button in thumb reach (the header icon is for larger
   screens). It clears fixed chrome (--fixed-bottom) and a long table's sticky pager, and
   hides while the chat is open. */
.asst-fab { display: none; }
@media (max-width: 640px) {
  .hdr-assistant { display: none; }
  .asst-fab { display: inline-flex; align-items: center; justify-content: center; position: fixed; z-index: 37; right: 16px; bottom: calc(var(--fixed-bottom) + 16px + env(safe-area-inset-bottom, 0px)); width: 56px; height: 56px; border-radius: 50%; border: none; background: var(--primary); color: #fff; box-shadow: var(--shadow-lg); cursor: pointer; }
  .asst-fab:focus-visible { outline: none; box-shadow: var(--ring), var(--shadow-lg); }
  body:has(.dt--long .table-foot) .asst-fab { bottom: calc(var(--fixed-bottom) + 72px + env(safe-area-inset-bottom, 0px)); }
  html.asst-open .asst-fab { display: none; }
  .asst-panel { top: 0; z-index: 46; }     /* full screen over the header on phones */
  main#main { padding-bottom: 88px; }      /* the last row is never hidden behind the button */
}

/* ═══════════════════════════════════════════════════════════════════
   Phones (≤ 640px) — mobile UX pass, 9 Oct 2026
   ═══════════════════════════════════════════════════════════════════ */
.store-switch-short, .asst-full-phone { display: none; }
.dt-mbar, .dt-scrim { display: none; }               /* phone-only table bar + sheet backdrop */
@media (max-width: 640px) {
  /* Header: the page title gets the room — store switcher shows the short store id,
     the title may wrap to two lines instead of being cut to "Pre…" */
  .app-header.topbar { gap: 6px; padding: 0 10px 0 6px; }
  .hdr-right { gap: 4px; }
  .store-switch > summary { padding: 0 8px; gap: 4px; }
  .store-switch > summary .store-switch-name { display: none; }
  .store-switch-short { display: inline; font-variant-numeric: tabular-nums; }
  .hdr-h1 { white-space: normal; font-size: 14.5px; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

  /* Stat cards: two compact columns, so the list starts on the first screen */
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
  .stat-card { padding: 10px 12px; }
  .stat-top { margin-bottom: 4px; }
  .stat-num { font-size: 16px; }
  .stat-foot { display: none; }

  /* Key / value lists: long labels wrap instead of pushing values off the card */
  .kv { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 14px; }
  .kv dd { min-width: 0; overflow-wrap: anywhere; }

  /* Data tables (lib/table.js): every row is a card of "label  value" lines (labels from the
     column definitions — --lbl, set by partials/table-start). The header row is a "Sort & filter"
     bar that sticks below the header while the cards scroll (when the screen is tall enough), and
     opens as a bottom sheet listing every column: tap a name to sort, the funnel to filter. */
  .dt .table-card { background: none; border: 0; box-shadow: none; overflow: visible; border-radius: 0; }
  .dt .table-wrap, .dt--long .table-wrap { max-height: none; min-height: 0; overflow: visible; }
  .dt .data-table, .dt .data-table tbody { display: block; }
  .dt .dt-toolbar .dt-count { display: none; }                 /* the bar shows the count */
  .dt-mbar { display: flex; align-items: center; gap: 10px; padding: 6px 0 10px; background: var(--bg); }
  .dt-mbar-meta { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dt-mbar-done, .dt--sheet .dt-mbar-open { display: none; }
  .dt--sheet .dt-mbar-done { display: inline; }
  .dt .data-table thead { display: none; }
  .dt--sheet .dt-scrim { display: block; position: fixed; inset: 0; z-index: 46; background: rgba(19,26,43,.35); }
  .dt--sheet .data-table thead { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 47; max-height: 75vh; overflow-y: auto;
    background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: var(--shadow-lg); padding: 6px 16px calc(16px + env(safe-area-inset-bottom, 0px)); }
  .dt--sheet .data-table thead::before { content: attr(data-sheet-title); display: block; padding: 10px 0 8px; font-size: 12px; font-weight: 600; color: var(--muted-2); }
  .dt--sheet .data-table thead tr { display: block; }
  .dt .table-card .data-table thead th, .dt--long .data-table thead th { display: block; position: static; padding: 0; border: 0; border-top: 1px solid var(--line-soft); background: none; box-shadow: none; }
  .dt--sheet .data-table thead .th-inner { justify-content: space-between; min-height: 48px; gap: 10px; }
  .dt--sheet .data-table thead .th-sort, .dt--sheet .data-table thead .th-inner > span { flex: 1; font-size: 14px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--ink); }
  .dt--sheet .data-table thead th[aria-sort] .th-sort { color: var(--primary); }
  .dt .col-filter-btn { opacity: 1; padding: 8px 10px; }
  body:has(.dt--sheet) { overflow: hidden; }
  body:has(.dt--sheet) .asst-fab { display: none; }

  .dt .data-table tbody tr, .dt .data-table tbody tr:nth-child(even) { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 4px 14px; margin-bottom: 10px; }
  .dt .table-card .data-table td, .dt .table-card .data-table td:first-child, .dt .table-card .data-table td:last-child {
    display: block; position: relative; min-height: 34px; padding: 8px 0 8px calc(38% + 10px); text-align: left; white-space: normal; overflow-wrap: anywhere; border-bottom: 1px solid var(--line-soft); }
  .dt .data-table tbody tr > td:last-child { border-bottom: 0; }
  .dt .data-table td::before { content: var(--lbl, ""); position: absolute; left: 0; top: 8px; width: 38%; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted-2); overflow-wrap: anywhere; }
  .dt .data-table td.num { font-variant-numeric: tabular-nums; }
  .dt .table-foot { padding: 8px 2px; gap: 6px 8px; background: var(--bg); }   /* one line unless the pager is long */
  .dt .table-foot .t-muted { display: none; }                 /* "Rows per page" — the 25/50/100 switch says it */
  .dt .table-foot .pager { margin-left: auto; }
  .dt .table-card .data-table td, .dt .table-card .data-table td:first-child, .dt .table-card .data-table td:last-child { padding-top: 7px; padding-bottom: 7px; min-height: 32px; }
  .dt .data-table td::before { top: 7px; }

  /* Assistant page: the chat fills the screen; the floating chat button isn't needed there */
  .asst-page-main { height: calc(100dvh - var(--fixed-top) - var(--fixed-bottom) - 32px); min-height: 0; }
  body:has(.asst-page) .asst-fab { display: none; }
  .asst-full-wide { display: none; }
  .asst-full-phone { display: inline; }
}
@media (max-width: 640px) {
  /* Short tables outside the table standard (settings, small admin lists): .data-table--stack
     turns each row into a block — the first cell is the title, the rest are "label  value"
     lines labelled from data-label. */
  .table-card .data-table--stack, .data-table--stack thead, .data-table--stack tbody { display: block; }
  .data-table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .data-table--stack tbody tr { display: block; padding: 10px 16px; border-bottom: 1px solid var(--line-soft); }
  .table-card .data-table--stack td, .table-card .data-table--stack td:first-child, .table-card .data-table--stack td:last-child {
    display: block; position: relative; padding: 6px 0; border: 0; text-align: left; white-space: normal; }
  .table-card .data-table--stack td[data-label] { padding-left: calc(38% + 10px); min-height: 32px; }
  .data-table--stack td[data-label]::before { content: attr(data-label); position: absolute; left: 0; top: 8px; width: 38%; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted-2); }
  .data-table--stack .row-actions { padding-top: 8px; }
  /* Detail tables inside a record (parts on a line): tighter cells so they fit */
  .data-table--compact th, .data-table--compact td, .op-parts-table th, .op-parts-table td { padding-left: 6px; padding-right: 6px; }
  .op-parts-table .basis { display: block; }
}

@media (max-width: 640px) and (min-height: 560px) {
  /* Enough room: the table’s Sort & filter bar sticks below the header while its cards scroll past. */
  .dt-mbar { position: sticky; top: var(--fixed-top); z-index: 30; }
}

/* ─── Drawer (partials/shell-end + shell.js): a record's details beside the list ─── */
.drawer { position: fixed; z-index: 45; top: var(--fixed-top); right: 0; bottom: 0; width: min(560px, 100vw); display: flex; flex-direction: column; background: var(--bg); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.drawer[hidden] { display: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px 10px 18px; background: var(--surface); border-bottom: 1px solid var(--line-soft); }
.drawer-head strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--ink); }
.drawer-close { color: var(--text-muted); }
.drawer-close:hover { background: var(--surface-2); color: var(--ink); }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px; }
.drawer-foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); }
.drawer-foot:empty { display: none; }
.drawer-foot > :first-child:not(:only-child) { margin-right: auto; }   /* secondary action left, primary right */
.drawer-scrim { display: none; }
html.drawer-open .drawer-scrim { display: block; position: fixed; inset: var(--fixed-top) 0 0 0; z-index: 44; background: rgba(19,26,43,.25); }
@media (max-width: 640px) {
  .drawer { top: 0; width: 100vw; z-index: 47; border-left: 0; }
  html.drawer-open .asst-fab { display: none; }

  /* Compact table cards: tighter lines, lighter dividers, smaller labels (≈ half the height). */
  .dt .data-table tbody tr, .dt .data-table tbody tr:nth-child(even) { padding: 6px 12px; margin-bottom: 8px; }
  .dt .table-card .data-table td, .dt .table-card .data-table td:first-child, .dt .table-card .data-table td:last-child {
    min-height: 0; padding: 3px 0 3px calc(34% + 8px); border-bottom: 0; font-size: 13px; line-height: 1.35; }
  .dt .data-table td::before { top: 4px; width: 34%; font-size: 10.5px; letter-spacing: .04em; }
  .dt .data-table td .pill, .dt .data-table td .tag, .dt .data-table td .chip { font-size: 11.5px; padding-top: 1px; padding-bottom: 1px; }
  /* The row action (e.g. Audit) sits top-right of the card, beside the first line. */
  .dt .data-table tbody tr { position: relative; }
  .dt .table-card .data-table td.row-actions { position: absolute; top: 6px; right: 10px; padding: 0; min-height: 0; width: auto; }
  .dt .table-card .data-table td.row-actions::before { content: none; }
  .dt .data-table tbody tr:has(td.row-actions) > td:first-child { padding-right: 96px; }
  .dt .data-table td.row-actions .btn { min-height: 28px; }
}

/* ─── Login (views/login.ejs — standalone, no shell) ─────────────────────────── */
.login-page { margin: 0; min-height: 100vh; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); background: var(--bg); }
.login-brand { background: var(--primary-dk); color: #fff; padding: 40px 48px; display: flex; flex-direction: column; gap: 28px; }
.login-brand .topbar-brand { display: flex; flex-direction: column; }
.login-brand .brand-name { font-size: 15px; font-weight: 700; letter-spacing: .04em; }
.login-brand .brand-tagline { color: var(--topbar-sub); font-size: 12.5px; }
.login-logo { height: 40px; width: auto; align-self: flex-start; }
.login-hero { margin-top: auto; margin-bottom: auto; }
.login-hero h1 { font-size: 30px; line-height: 1.15; margin: 0; color: #fff; letter-spacing: -.01em; }
.login-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 32px 32px 28px; }
.login-card h2 { margin: 0 0 4px; font-size: 20px; color: var(--ink); }
.login-card .login-sub { margin: 0 0 22px; color: var(--text-muted); font-size: 13.5px; }
.btn-ms { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 44px; border: 1px solid var(--border-2); border-radius: var(--r-md); background: var(--surface); color: var(--ink); font: inherit; font-size: 14.5px; font-weight: 600; text-decoration: none; cursor: pointer; transition: background .12s var(--ease), border-color .12s var(--ease); }
.btn-ms:hover { background: var(--surface-2); border-color: var(--muted-2); }
.btn-ms.is-disabled { color: var(--muted-2); background: var(--light-grey); cursor: not-allowed; pointer-events: none; }
.btn-ms.is-disabled .icon { filter: grayscale(1); opacity: .5; }
.login-hint { margin: 8px 0 0; font-size: 12px; color: var(--muted-2); text-align: center; }
.login-or { display: flex; align-items: center; gap: 12px; margin: 22px 0 18px; color: var(--muted-2); font-size: 12px; }
.login-or::before, .login-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.login-card .field > .input { width: 100%; }
.login-card .btn-solid { width: 100%; justify-content: center; height: 42px; margin-top: 6px; }
@media (max-width: 860px) {
  .login-page { grid-template-columns: minmax(0, 1fr); }
  .login-brand { padding: 22px 20px; gap: 14px; }
  .login-hero h1 { font-size: 22px; }
  .login-main { align-items: flex-start; padding: 20px 16px 32px; }
  .login-card { padding: 24px 20px; }
}
