@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* ── DESIGN WORLD: consignment manifest ──────────────────────────────────
   V's visual identity is the multi-copy courier waybill: a filing
   moves through tracked stages (upload -> map -> validate -> export) the
   same way a consignment moves through booked -> in transit -> delivered,
   and gets a status stamp at each one. Manifold-paper tones (ivory top
   copy, dusty-rose and amber duplicate/triplicate sheets), one ink-stamp
   accent (cinnabar), typewriter-mono for tracking codes/serials, a
   confident grotesk for display type. Token NAMES are unchanged from the
   previous palette (dozens of templates reference them) -- only the
   values change, so this is a genuine recoloring of the whole system, not
   a new component vocabulary bolted on top. */

:root {
  --bg:        #F2ECDF;
  --panel:     #FBF8F1;
  --ink:       #2B2420;
  --sage:      #A8402E;
  --petrol:    #B4823C;
  --warn:      #B4823C;
  --ok:        #5B7A8C;
  /* Independent of --sage (the brand accent, now vermillion): a genuine
     "this is good" semantic color, e.g. .conf.good's mapping-confidence
     tier -- without this, a positive-confidence indicator would render
     in the same alarm-red family as .conf.low, backwards from what it means. */
  --success:   #3F6B4A;
  --muted:     rgba(43, 36, 32, 0.72);
  --hairline:  rgba(43, 36, 32, 0.12);
  --hairline-strong: rgba(43, 36, 32, 0.22);
  --active-cell-bg: rgba(168, 64, 46, 0.08);
  --active-cell-border: #A8402E;
  --row-hover: rgba(168, 64, 46, 0.05);
  --shadow-sm: 0 1px 1px rgba(43, 36, 32, 0.06);
  --shadow-md: 0 1px 2px rgba(43, 36, 32, 0.05), 0 6px 18px rgba(43, 36, 32, 0.08);
  --shadow-lg: 0 8px 32px rgba(43, 36, 32, 0.16);
}
html[data-theme="dark"] {
  --bg:        #211C17;
  --panel:     #2B241D;
  --ink:       #F0E6D6;
  --sage:      #E8806A;
  --petrol:    #D4A054;
  --warn:      #D4A054;
  --ok:        #8FAEC0;
  --success:   #6FA37C;
  --muted:     rgba(240, 230, 214, 0.58);
  --hairline:  rgba(240, 230, 214, 0.10);
  --hairline-strong: rgba(240, 230, 214, 0.20);
  --active-cell-bg: rgba(224, 114, 92, 0.12);
  --active-cell-border: #E0725C;
  --row-hover: rgba(224, 114, 92, 0.07);
  --shadow-sm: 0 1px 1px rgba(0, 0, 0, 0.30);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.30), 0 6px 18px rgba(0, 0, 0, 0.20);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html, body { margin:0; padding:0; height:100%; }
body {
  background: var(--bg); color: var(--ink);
  /* Space Grotesk (display) + Inter (body/UI copy) load via the @import
     above when there's internet; fall back to Segoe UI Variable Text
     (Windows 11's own sharper default, no download needed) rather than
     plain Segoe UI, so this stays crisp even offline or on a network that
     blocks Google Fonts -- a real risk for a compliance tool. */
  font-family: 'Inter', 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 13px; line-height: 1.45;
  transition: background 0.30s ease, color 0.30s ease;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
.mono { font-family: 'IBM Plex Mono', 'JetBrains Mono', 'Cascadia Mono', monospace; }
button { font-family: inherit; }
a { color: var(--sage); text-decoration: none; }
/* Auth pages (.login) are not the app shell: let them scroll on short screens. */
body:has(.login) { overflow-y: auto; }
/* Plain content pages under the topbar (batch, admin feedback). */
.page-scroll { overflow-y: auto; height: calc(100vh - 56px); }

/* ---- HEADER ---- */
.topbar {
  height: 56px; display: flex; align-items: center;
  padding: 0 20px; border-bottom: 1px solid var(--hairline);
  background: var(--bg); gap: 18px; position: relative; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 220px; }
/* Logo mark: a vermilion badge holding a V that doubles as a validation check. */
.brand-mark { width: 32px; height: 32px; display: block; flex-shrink: 0; border-radius: 9px;
  box-shadow: 0 1px 2px rgba(43,36,32,.18), 0 3px 8px rgba(138,45,29,.22); }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -0.02em; line-height: 1.05; font-family: 'Space Grotesk', 'Inter', sans-serif; }
.brand-ai { font-weight: 700; color: var(--sage); margin-left: 2px; }
.brand-sub  { font-size: 9.5px; color: var(--sage); font-weight: 700; letter-spacing: 0.32em; line-height: 1.2; }

.crumbs { display:flex; align-items:center; gap:8px; color:var(--muted); font-size:12.5px; }
.crumbs strong { color: var(--ink); font-weight: 600; }
.crumbs .sep { color: var(--muted); }
.topbar-spacer { flex: 1; }

.actions { display:flex; align-items:center; gap:10px; }
.chip {
  display:inline-flex; align-items:center; gap:8px;
  padding:6px 11px; border-radius:999px;
  background:var(--panel); border:1px solid var(--hairline);
  box-shadow:var(--shadow-sm); font-size:12px;
  color: var(--ink); cursor: pointer;
  transition: border-color 0.18s ease, transform 0.18s ease;
}
.chip:hover { border-color: var(--hairline-strong); transform: translateY(-1px); }
.chip .dot { width:7px; height:7px; border-radius:50%; background:var(--sage); }
.chip .num { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--sage); }

.btn {
  padding: 7px 14px; border-radius: 7px; border: 1px solid transparent;
  background: var(--sage); color: white; font-weight: 600; font-size: 12.5px;
  cursor: pointer; box-shadow: var(--shadow-sm);
  transition: filter 0.18s ease, transform 0.18s ease;
}
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--hairline-strong); box-shadow: none; }
.btn-ghost:hover { background: var(--row-hover); }
.btn-petrol { background: var(--petrol); }

.theme-toggle {
  width: 36px; height: 30px; border-radius: 7px; border: 1px solid var(--hairline-strong);
  background: var(--panel); cursor: pointer; display:flex; align-items:center; justify-content:center;
  transition: border-color 0.18s ease, transform 0.18s ease;
}
.theme-toggle:hover { border-color: var(--sage); transform: translateY(-1px); }
.theme-toggle svg { stroke: var(--ink); }
.avatar {
  width:30px; height:30px; border-radius:50%;
  background: linear-gradient(135deg, #8F6322, var(--sage));
  color: white; font-weight: 700; font-size: 12px;
  display:flex; align-items:center; justify-content:center; cursor: pointer;
  box-shadow: var(--shadow-sm);
}

/* ---- Build-panel / notes semantic tokens (light defaults; dark below) ---- */
:root {
  --p-ok-bg:#E6F2E6; --p-ok-bd:#8DBB92; --p-ok-fg:#1B5E20; --p-ok-sub:#2E5E33; --p-ok-solid:#2E7D32; --p-ok-on:#fff;
  --p-ok-note-bg:#F1F8F1; --p-ok-note-bd:#A9CFAD; --p-ok-note-fg:#25502B;
  --p-ok-chip-bg:#E6F2E6; --p-ok-chip-bd:#8DBB92; --p-ok-chip-fg:#1F4D24;
  --p-warn-bg:#FBF1D9; --p-warn-bd:#D8B35E; --p-warn-fg:#7A4500; --p-warn-sub:#6A4E12; --p-warn-solid:#E6A030; --p-warn-on:#1A1000;
  --p-warn-card-bg:#FFF8E6; --p-warn-head-bg:#FBEBC4; --p-warn-head-bd:#E3C77A; --p-warn-chip-bg:#F3DFA6; --p-warn-chip-fg:#5E3A00;
  --p-warn-msg:#4A3200; --p-warn-txt:#5E4510; --p-warn-det:#5E4A1E;
  --p-err-bg:#FBE6E4; --p-err-bd:#D88A86; --p-err-fg:#A31F1F; --p-err-sub:#7A2A2A; --p-err-strong:#8A1A1A; --p-err-solid:#C62828;
  --p-err-card-bg:#FFF3F2; --p-err-head-bg:#FBE6E4; --p-err-head-bd:#E4B0AC; --p-err-chip-bg:#F4C7C4; --p-err-chip-fg:#7A1515;
  --p-err-msg:#5A1010; --p-err-txt:#6E2020; --p-err-det-bg:#FBEDEC; --p-err-det-bd:#E4B0AC; --p-err-det-fg:#5E3A3A;
  --p-act-bg:#FBF1D9; --p-act-bd:#D8B35E; --p-act-fg:#7A4500; --p-act-sub:#5E4A1E;
  --p-act-in-bg:#fff; --p-act-in-fg:#3A2A00; --p-act-in-bd:#B08A30; --p-act-btn-bg:#8A4B00; --p-act-btn-on:#fff;
  --p-info-bg:#E5EEFA; --p-info-bd:#9DB8E0; --p-info-fg:#1D4F9A; --p-info-sub:#2F4A78;
  --p-info-tip-bg:#EAF0FA; --p-info-tip-bd:#9DB8E0; --p-info-tip-fg:#2F4A78;
  --p-teal-bg:#E3F1F4; --p-teal-bd:#9CC5D0; --p-teal-fg:#1F5566;
  --p-card-bg:#fff; --p-card-bd:#D8D0C0; --p-card-fg:#2B2420; --p-card-dim:#5C5448; --p-card-mono:#1F6B3A;
  --p-opt-bg:#F0EBE0; --p-opt-bd:#D8D0C0; --p-opt-fg:#6B6258;
  --p-dis-bg:#E4DED0; --p-dis-fg:#5C5448;
}

html[data-theme="dark"] {
  --p-ok-bg:#1c401c; --p-ok-bd:#3a6a3a; --p-ok-fg:#4caf50; --p-ok-sub:#8bc98b; --p-ok-solid:#4caf50; --p-ok-on:#04210a;
  --p-ok-note-bg:#131f13; --p-ok-note-bd:#2a4a2a; --p-ok-note-fg:#9ecf9e;
  --p-ok-chip-bg:#1a3a1a; --p-ok-chip-bd:#2a5a2a; --p-ok-chip-fg:#c8e6c8;
  --p-warn-bg:#2a2a1a; --p-warn-bd:#5a5020; --p-warn-fg:#ffb347; --p-warn-sub:#c8b070; --p-warn-solid:#e6a030; --p-warn-on:#000;
  --p-warn-card-bg:#1e1800; --p-warn-head-bg:#2a2000; --p-warn-head-bd:#3a3000; --p-warn-chip-bg:#3a2a00; --p-warn-chip-fg:#ffd080;
  --p-warn-msg:#ffe0a0; --p-warn-txt:#e0c080; --p-warn-det:#a8a08a;
  --p-err-bg:#2e1515; --p-err-bd:#6a2a2a; --p-err-fg:#ff6b6b; --p-err-sub:#cc8888; --p-err-strong:#ffaaaa; --p-err-solid:#e53935;
  --p-err-card-bg:#1e0e0e; --p-err-head-bg:#2e1515; --p-err-head-bd:#4a1a1a; --p-err-chip-bg:#5a1515; --p-err-chip-fg:#ff9999;
  --p-err-msg:#ffcccc; --p-err-txt:#ffb3b3; --p-err-det-bg:#130808; --p-err-det-bd:#3a1a1a; --p-err-det-fg:#b5a8a8;
  --p-act-bg:#2a1a00; --p-act-bd:#5a3a00; --p-act-fg:#ffb347; --p-act-sub:#ccb;
  --p-act-in-bg:#1a1200; --p-act-in-fg:#ffe082; --p-act-in-bd:#7a5a10; --p-act-btn-bg:#ffb347; --p-act-btn-on:#000;
  --p-info-bg:#1a1a2e; --p-info-bd:#2a3a6a; --p-info-fg:#4a9eff; --p-info-sub:#8aa4dd;
  --p-info-tip-bg:#131a2e; --p-info-tip-bd:#2a3a6a; --p-info-tip-fg:#99aadd;
  --p-teal-bg:#1a2a2e; --p-teal-bd:#2a4a5a; --p-teal-fg:#8fc4d8;
  --p-card-bg:#1e1e1e; --p-card-bd:#2e2e2e; --p-card-fg:#eee; --p-card-dim:#a0a0a0; --p-card-mono:#7dcf9d;
  --p-opt-bg:#1a1a1a; --p-opt-bd:#2a2a2a; --p-opt-fg:#9a9a9a;
  --p-dis-bg:#333; --p-dis-fg:#bbb;
}

/* Build panel shared bits */
.bp-dl { display:block; width:100%; box-sizing:border-box; padding:10px; border-radius:7px; font-size:13px; font-weight:700; text-decoration:none; text-align:center; letter-spacing:.02em; }
.bp-dl.is-disabled { background:var(--p-dis-bg) !important; color:var(--p-dis-fg) !important; border:1px dashed var(--p-dis-fg) !important; }
.bp-rebuild { width:100%; padding:9px; border-radius:7px; font-size:12px; font-weight:600; background:transparent; border:1px solid var(--hairline-strong); color:var(--muted); cursor:pointer; transition:border-color .2s,color .2s; }
.bp-rebuild:hover { border-color:var(--ink); color:var(--ink); }

/* ---- APP ---- */
.app { display: flex; height: calc(100vh - 56px); }

/* Sidebar */
.sidebar {
  width: 268px; flex: 0 0 268px;
  border-right: 1px solid var(--hairline);
  background: var(--bg); padding: 18px 12px 18px 18px;
  overflow-y: auto;
  transition: width 0.28s cubic-bezier(.4,.0,.2,1), flex-basis 0.28s cubic-bezier(.4,.0,.2,1);
}
body.collapsed .sidebar { width: 56px; flex: 0 0 56px; padding: 18px 8px; }
body.collapsed .sidebar .nav-label,
body.collapsed .sidebar .nav-section-title,
body.collapsed .sidebar .tree-row .label,
body.collapsed .sidebar .tree-row .badge,
body.collapsed .sidebar .triangle { display: none; }
body.collapsed .sidebar .tree-row { justify-content: center; padding: 8px 0; }

.sidebar-toggle {
  background: transparent; border: 0; padding: 4px 6px; border-radius: 6px;
  color: var(--muted); cursor: pointer; margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px; font-size: 12px;
  transition: color 0.2s ease, background 0.2s ease;
}
.sidebar-toggle:hover { color: var(--ink); background: var(--row-hover); }

.nav-section-title {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.07em;
  color: var(--muted); text-transform: uppercase;
  margin: 18px 6px 6px 6px;
}
.tree-row {
  display:flex; align-items:center; gap:8px;
  padding: 5px 8px 5px 4px; border-radius: 6px;
  cursor: pointer; user-select: none;
  color: var(--ink); font-size: 12.5px;
  transition: background 0.16s ease, color 0.16s ease, transform 0.18s ease;
}
.tree-row:hover { background: var(--row-hover); }
.tree-row.active { background: var(--active-cell-bg); color: var(--sage); font-weight: 600; }
.triangle {
  width: 14px; height: 14px; display:inline-flex; align-items:center; justify-content:center;
  color: var(--muted); transition: transform 0.22s cubic-bezier(.4,.0,.2,1); flex-shrink: 0;
}
.triangle.open { transform: rotate(90deg); }
.nav-icon { width: 15px; height: 15px; color: var(--muted); flex-shrink: 0; }
.tree-row.active .nav-icon { color: var(--sage); }
.badge {
  margin-left: auto;
  background: var(--row-hover); color: var(--muted);
  padding: 1px 7px; border-radius: 99px;
  font-size: 10.5px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.badge.warn { background: rgba(217, 160, 91, 0.16); color: #7A4D14; }
.badge.err  { background: rgba(180, 116, 122, 0.18); color: #85484D; }
.badge.ok   { background: rgba(96, 130, 182, 0.16); color: #3A557E; }

/* Canvas */
.canvas { flex: 1; display: flex; min-width: 0; }

.ledger {
  flex: 1; min-width: 0;
  padding: 16px 12px 20px 16px;
  overflow: hidden; display: flex; flex-direction: column;
}
#ledger-pane { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
.swap-in { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
.ledger-head { display: flex; align-items: flex-end; gap: 18px; margin-bottom: 14px; }
.ledger-title h1 { margin: 0 0 4px 0; font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.ledger-title .ledger-meta { font-size: 12px; color: var(--muted); display:flex; gap:12px; align-items:center; }
.ledger-title .pill { padding: 2px 9px; border-radius: 99px; border: 1px solid var(--hairline-strong); font-size: 11px; }
.ledger-actions { margin-left: auto; display: flex; gap: 8px; }

.multi-year {
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: 10px; box-shadow: var(--shadow-md);
  overflow: hidden; display: flex; flex-direction: column;
  flex: 1; min-height: 0;
}
.ledger-toolbar {
  display:flex; align-items:center; gap:10px;
  padding: 10px 14px; border-bottom: 1px solid var(--hairline); background: var(--panel);
}
.ledger-toolbar .tool {
  font-size: 11.5px; color: var(--muted); background: transparent; font-family: inherit;
  padding: 3px 9px; border-radius: 6px; cursor: pointer;
  border: 1px solid transparent;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.ledger-toolbar .tool:hover { color: var(--ink); background: var(--row-hover); }
.ledger-toolbar .tool.active { color: var(--sage); border-color: var(--hairline); background: var(--active-cell-bg); }
.ledger-toolbar .add-year {
  margin-left: auto; font-size: 11.5px; color: var(--sage); cursor: pointer;
  padding: 3px 9px; border-radius: 6px;
  border: 1px dashed var(--hairline-strong); background: transparent;
  transition: background 0.18s ease;
}
.ledger-toolbar .add-year:hover { background: var(--active-cell-bg); }

.year-track-scroll { overflow-x:auto; overflow-y:auto; flex:1; min-height:0; scroll-behavior:smooth; }
.year-track-scroll::-webkit-scrollbar { height:8px; width:8px; }
.year-track-scroll::-webkit-scrollbar-thumb { background: var(--hairline-strong); border-radius: 4px; }

table.ledger-grid {
  border-collapse: separate; border-spacing: 0;
  width: 100%;            /* fill the pane — no horizontal scroll needed */
  font-variant-numeric: tabular-nums; font-size: 12.5px;
}
table.ledger-grid thead th {
  position: sticky; top: 0; z-index: 6;
  background: var(--panel);
  font-weight: 600; font-size: 11px; text-align: right;
  padding: 9px 12px 9px 8px; color: var(--muted);
  border-bottom: 1px solid var(--hairline-strong);
  text-transform: uppercase; letter-spacing: 0.05em;
}
table.ledger-grid thead th.label-col {
  text-align: left; width: 52%;
  min-width: 180px; padding-left: 16px;
}
table.ledger-grid thead th.year-col  {
  min-width: 100px; text-align: right; white-space: nowrap;
}
table.ledger-grid tbody td {
  text-align: right;
  padding: 5px 12px 5px 8px;
  border-bottom: 1px solid var(--hairline);
  font-variant-numeric: tabular-nums;
  cursor: cell; transition: background 0.12s ease;
}
table.ledger-grid tbody tr:hover { background: var(--row-hover); }
table.ledger-grid tbody td.label-col {
  text-align: left;
  word-break: break-word;
  padding-left: 16px; color: var(--ink);
  font-variant-numeric: normal; cursor: default;
}
table.ledger-grid tbody td.label-col.l1 { padding-left: 28px; }
table.ledger-grid tbody td.label-col.l2 { padding-left: 40px; }
table.ledger-grid tbody td.label-col.l3 { padding-left: 52px; }
table.ledger-grid tbody tr.abstract td { font-weight: 600; color: var(--ink); background: rgba(74, 107, 93, 0.03); }
html[data-theme="dark"] table.ledger-grid tbody tr.abstract td { background: rgba(125, 169, 146, 0.05); }
table.ledger-grid tbody tr.total td { border-top: 1px solid var(--hairline-strong); font-weight: 600; }
table.ledger-grid tbody td.warn { color: #85591A; }
html[data-theme="dark"] table.ledger-grid tbody td.warn { color: var(--warn); }
table.ledger-grid tbody td.err  { color: #B4747A; }
table.ledger-grid tbody td.active {
  background: var(--active-cell-bg);
  box-shadow: inset 0 0 0 1.5px var(--active-cell-border);
  border-radius: 4px; position: relative; z-index: 1;
}

/* Confidence dot inline on label */
.conf {
  display:inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok); margin-right: 8px; vertical-align: middle;
}
.conf.high  { background: var(--ok); }
.conf.good  { background: var(--success); }
.conf.review{ background: var(--warn); }
.conf.low   { background: #B4747A; }
.conf.unmapped { background: var(--hairline-strong); }

/* Helper / Audit panel — fixed narrow width so ledger gets max room */
.helper {
  flex: 0 0 320px; min-width: 320px; max-width: 320px;
  padding: 20px 14px 24px 6px;
  display: flex; flex-direction: column; gap: 14px; overflow: hidden;
  transition: flex-basis 0.22s ease, min-width 0.22s ease, max-width 0.22s ease;
}
body.helper-maximized .helper {
  flex: 0 0 70vw; min-width: 70vw; max-width: 70vw;
}
.helper-card {
  background: var(--panel); border: 1px solid var(--hairline);
  border-radius: 10px; box-shadow: var(--shadow-md);
  overflow: hidden; display: flex; flex-direction: column; min-height: 0;
}

/* login.html / signup.html -- full-viewport centered auth card. */
.login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--panel);
  border: 1px solid var(--hairline); border-radius: 14px;
  box-shadow: var(--shadow-lg); padding: 36px;
}
.helper-tabs { display: flex; padding: 3px; gap: 2px; border-bottom: 1px solid var(--hairline); background: var(--panel); flex-wrap: wrap; }
.helper-tabs button {
  flex: 1; padding: 5px 6px;
  background: transparent; border: 0; border-radius: 6px;
  color: var(--muted); font-size: 10.5px; font-weight: 600;
  cursor: pointer; letter-spacing: 0.01em; white-space: nowrap;
  transition: color 0.18s ease, background 0.18s ease;
}
.helper-tabs button.active { color: var(--sage); background: var(--active-cell-bg); }
.helper-body { padding: 14px 16px; overflow-y: auto; flex: 1; }
.helper-body h3 { font-size: 11px; letter-spacing: 0.06em; font-weight: 600; color: var(--muted); text-transform: uppercase; margin: 0 0 10px; }
.helper-body h4 { font-size: 13.5px; font-weight: 600; color: var(--ink); margin: 0 0 6px; }
.helper-body p  { color: var(--muted); font-size: 12px; line-height: 1.55; margin: 0 0 10px; }
.helper-body .concept-row { display:flex; flex-direction:column; gap: 4px; padding: 8px 0; border-bottom: 1px solid var(--hairline); }
.helper-body .qname { font-family: 'JetBrains Mono', 'Cascadia Mono', 'Cascadia Code', 'Consolas', monospace; font-size: 11.5px; color: #8F6322; }
html[data-theme="dark"] .helper-body .qname { color: var(--petrol); }

.issue {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 9px 10px; border-radius: 7px;
  border: 1px solid var(--hairline); background: var(--panel);
  margin-bottom: 8px;
  transition: border-color 0.18s ease, transform 0.18s ease; cursor: pointer;
}
.issue:hover { border-color: var(--hairline-strong); transform: translateY(-1px); }
.issue .sev { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.issue .sev.warn  { background: var(--warn); }
.issue .sev.error { background: #B4747A; }
.issue .sev.info  { background: var(--ok); }
.issue .body { flex: 1; min-width: 0; }
.issue .ttl  { font-weight: 600; font-size: 12px; color: var(--ink); margin-bottom: 2px; }
.issue .meta { font-size: 11px; color: var(--muted); font-family: 'JetBrains Mono', 'Cascadia Mono', 'Cascadia Code', 'Consolas', monospace; }
.issue .desc { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.5; }

/* Filing bar */
.filing-bar {
  flex-shrink: 0; background: var(--panel);
  border: 1px solid var(--hairline); border-radius: 10px;
  padding: 14px 16px; box-shadow: var(--shadow-md);
  display:flex; align-items:center; gap: 14px; margin-top: 14px;
}
.filing-bar .ring {
  width: 38px; height: 38px; border-radius: 50%;
  background: conic-gradient(var(--sage) calc(var(--p, 86) * 1%), var(--hairline) 0);
  display:flex; align-items:center; justify-content:center; position: relative; flex-shrink: 0;
}
.filing-bar .ring::before { content: ""; position: absolute; inset: 4px; background: var(--panel); border-radius: 50%; }
.filing-bar .ring span { position: relative; font-size: 10.5px; font-weight: 700; color: var(--sage); font-variant-numeric: tabular-nums; }
.filing-bar .stage { font-size: 11px; color: var(--muted); }
.filing-bar .stage strong { display:block; color: var(--ink); font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.filing-bar .spacer { flex: 1; }

/* Modal */
.modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.42);
  display:flex; align-items:center; justify-content:center; z-index: 900;
  opacity: 0; visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}
.modal.open { opacity: 1; visibility: visible; }
.modal-card {
  width: 460px; background: var(--panel);
  border-radius: 14px; box-shadow: var(--shadow-lg);
  padding: 26px 28px; transform: translateY(8px);
  transition: transform 0.22s ease;
}
.modal.open .modal-card { transform: translateY(0); }
.modal h3 { margin: 0 0 8px; font-size: 16px; font-weight: 700; }
.modal p  { color: var(--muted); font-size: 12.5px; margin: 0 0 16px; line-height: 1.55; }
.modal .summary {
  background: var(--bg); border-radius: 9px; padding: 14px 16px;
  border: 1px solid var(--hairline); margin-bottom: 18px; font-size: 12.5px;
}
.modal .summary .row { display:flex; justify-content:space-between; padding: 4px 0; }
.modal .summary .row strong { color: var(--ink); }
.modal .summary .row.tot { border-top: 1px solid var(--hairline-strong); margin-top: 6px; padding-top: 9px; font-weight: 700; }
.modal .actions { display:flex; gap: 10px; justify-content:flex-end; }

/* Loading shimmer for HTMX swaps */
.htmx-indicator { opacity: 0; transition: opacity 0.2s ease; }
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-request.htmx-indicator  { opacity: 1; }
.swap-in { animation: fadeUp 0.3s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }


/* ==== Phase 7c.1 view-mode CSS ==== */
/* As-reported (default): show label, hide raw qname suffix */
body.view-as-reported .ledger-grid .qname-suffix { display: none; }

/* Mapped-concepts: lead with the concept QName, hide the source label suffix details */
body.view-mapped-concepts .ledger-grid td.label-col .label-text { color: var(--muted); font-style: italic; }
body.view-mapped-concepts .ledger-grid .qname-suffix {
  display: inline-block;
  background: var(--active-cell-bg);
  color: var(--sage);
  padding: 1px 7px;
  border-radius: 4px;
  font-weight: 600;
  margin-right: 8px;
}

/* Calc-linkbase: highlight rows that begin with "Total " (subtotal candidates) */
body.view-calc-linkbase .ledger-grid tr.total { background: rgba(91, 122, 140, 0.08); }
body.view-calc-linkbase .ledger-grid tr.total td { font-weight: 700; }
body.view-calc-linkbase .ledger-grid td.label-col::before {
  content: ""; display: inline-block; width: 4px; height: 4px; border-radius: 50%;
  background: var(--ok); margin-right: 6px; vertical-align: middle;
}

/* Keyboard focus ring (WCAG 2.4.7) */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--sage); outline-offset: 2px;
}

/* Dark-mode text contrast (WCAG AA) */
html[data-theme="dark"] .badge.warn { color: #F0C27E; }
html[data-theme="dark"] .badge.err  { color: #F0A3A9; }
html[data-theme="dark"] .badge.ok   { color: #A9C4EE; }
html[data-theme="dark"] .helper-tabs button.active,
html[data-theme="dark"] .ledger-toolbar .tool.active { color: #F2967F; }
html[data-theme="dark"] .btn:not(.btn-ghost) { color: #1A1410; }
.btn-petrol { background: #8F6322; }
html[data-theme="dark"] .btn-petrol { background: var(--petrol); }

/* Narrow screens: stack sidebar / ledger / helper, no page-level horizontal scroll */
@media (max-width: 768px) {
  html, body { height: auto; }
  body, body.collapsed { overflow: auto; overflow-x: hidden; }
  .topbar { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .topbar .brand { min-width: 0; }
  .topbar .actions { flex-wrap: wrap; }
  .app { flex-direction: column; height: auto; }
  .sidebar, body.collapsed .sidebar { width: 100%; flex: none; max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--hairline); padding: 12px; }
  .canvas { min-width: 0; flex-direction: column; }
  .helper, body.helper-maximized .helper { flex: none; width: 100%; min-width: 0; max-width: 100%; padding: 12px; }
  .ledger { min-width: 0; max-width: 100%; }
  .year-track-scroll, .helper-body { overflow-x: auto; max-width: 100%; }
  .multi-year { min-height: 300px; }
  .so-wrap { padding: 0 12px 60px; }
}
.btn.btn-go { background: #2E7D32; border-color: #2E7D32; }
html[data-theme="dark"] .btn.btn-go { color: #fff; }

html[data-theme="dark"] .avatar { color: #1A1410; }

.guided-fix{margin-top:6px;display:flex;gap:6px;flex-wrap:wrap;align-items:center}
.guided-fix input{width:140px;padding:5px 8px;border:1px solid var(--hairline-strong);border-radius:6px;background:var(--panel);color:var(--ink);font-size:11.5px}
.guided-fix .desc{flex-basis:100%;margin:0}
