/* ============================================================
   LEDGER — Tools LuxGap design system
   Document-grade, audit-precise. IBM Plex Sans + Mono.
   ============================================================ */

:root {
  /* paper & ink */
  --paper:       oklch(0.991 0.003 95);
  --surface:     oklch(1 0 0);
  --surface-2:   oklch(0.975 0.004 95);
  --surface-3:   oklch(0.958 0.005 95);
  --ink:         oklch(0.245 0.012 262);
  --ink-2:       oklch(0.42 0.011 262);
  --muted:       oklch(0.575 0.009 262);
  --faint:       oklch(0.70 0.007 262);
  --line:        oklch(0.905 0.004 262);
  --line-2:      oklch(0.845 0.006 262);
  --line-strong: oklch(0.78 0.007 262);

  /* regulatory accent (single, restrained) */
  --accent:      oklch(0.46 0.105 248);
  --accent-2:    oklch(0.40 0.11 248);
  --accent-tint: oklch(0.955 0.022 248);
  --accent-line: oklch(0.86 0.05 248);

  /* semantic status — matched chroma/lightness, varied hue */
  --erase:       oklch(0.55 0.155 27);
  --erase-tint:  oklch(0.962 0.028 27);
  --erase-line:  oklch(0.87 0.06 27);

  --anon:        oklch(0.60 0.115 72);
  --anon-tint:   oklch(0.962 0.038 72);
  --anon-line:   oklch(0.86 0.07 72);

  --archive:     oklch(0.52 0.10 252);
  --archive-tint:oklch(0.96 0.028 252);
  --archive-line:oklch(0.86 0.05 252);

  --keep:        oklch(0.50 0.085 152);
  --keep-tint:   oklch(0.955 0.035 152);
  --keep-line:   oklch(0.85 0.055 152);

  --r:   3px;
  --r-lg: 5px;
  --shadow-panel: 0 1px 2px oklch(0.2 0.02 262 / 0.04), 0 12px 32px oklch(0.2 0.02 262 / 0.10);
  --shadow-card:  0 1px 1px oklch(0.2 0.02 262 / 0.03);
  --sidebar-w: 232px;
  --topbar-h: 56px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; font-feature-settings: "zero" 1; }

::selection { background: var(--accent-tint); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border: 3px solid var(--paper); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--line-strong); }

/* ---------- type helpers ---------- */
.eyebrow {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); font-weight: 500;
}
.h-page { font-size: 21px; font-weight: 600; letter-spacing: -0.01em; margin: 0; color: var(--ink); }
.h-sec  { font-size: 14.5px; font-weight: 600; letter-spacing: -0.005em; margin: 0; }
.sub    { color: var(--muted); font-size: 12.5px; }
.num    { font-family: "IBM Plex Mono", monospace; font-variant-numeric: tabular-nums; }

/* ---------- demo banner ---------- */
.demobar {
  flex: none; display: flex; align-items: center; gap: 14px; padding: 9px 22px;
  background: linear-gradient(100deg, var(--accent-2), var(--accent) 62%, oklch(0.46 0.105 232));
  color: #fff; font-size: 12.5px; line-height: 1.45;
}
.demobar-mark { width: 26px; height: 26px; border-radius: var(--r); background: rgba(255,255,255,.16); display: grid; place-items: center; flex: none; }
.demobar-text { flex: 1; min-width: 0; }
.demobar-text b { font-weight: 600; }
.demobar-x { width: 28px; height: 28px; flex: none; border: none; background: transparent; color: rgba(255,255,255,.8); border-radius: var(--r); cursor: pointer; display: grid; place-items: center; transition: background .12s; }
.demobar-x:hover { background: rgba(255,255,255,.16); color: #fff; }

/* ---------- app frame ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; overflow: hidden; }

.sidebar {
  background: var(--surface-2);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px 14px; border-bottom: 1px solid var(--line); }
.brand-mark {
  width: 26px; height: 26px; border-radius: var(--r); background: var(--ink);
  display: grid; place-items: center; color: var(--paper); flex: none;
  font-family: "IBM Plex Mono", monospace; font-weight: 600; font-size: 13px;
}
.brand-name { font-weight: 600; font-size: 13.5px; letter-spacing: -0.01em; line-height: 1.1; }
.brand-sub  { font-family: "IBM Plex Mono", monospace; font-size: 9.5px; letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; }

.nav { padding: 10px 10px; overflow-y: auto; flex: 1; min-height: 0; }
.nav-group-label { padding: 14px 8px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: var(--r);
  color: var(--ink-2); cursor: pointer; font-size: 13px; font-weight: 450;
  border: 1px solid transparent; margin-bottom: 1px; user-select: none;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface-3); color: var(--ink); }
.nav-item.active { background: var(--surface); border-color: var(--line); color: var(--ink); font-weight: 550; box-shadow: var(--shadow-card); }
.nav-item.active .nav-ic { color: var(--accent); }
.nav-item > span:not(.nav-badge) { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-ic { width: 16px; height: 16px; flex: none; color: var(--faint); }
.nav-badge { margin-left: auto; font-family: "IBM Plex Mono", monospace; font-size: 10px; background: var(--surface-3); border: 1px solid var(--line); padding: 1px 5px; border-radius: 20px; color: var(--muted); }
.nav-item.active .nav-badge { background: var(--accent-tint); border-color: var(--accent-line); color: var(--accent-2); }

.sidebar-foot { border-top: 1px solid var(--line); padding: 12px 14px; }

/* ---------- main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--paper); }
.topbar {
  height: var(--topbar-h); flex: none; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 22px; background: var(--surface);
}
.content { flex: 1; overflow-y: auto; min-height: 0; }
.page { padding: 26px 28px 60px; max-width: 1280px; }
.page-wide { max-width: none; }

/* ---------- chips / pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px;
  border-radius: 20px; font-size: 11.5px; font-weight: 500; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink-2); white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.pill.sq { border-radius: var(--r); height: 21px; }

.st { --c: var(--muted); --t: var(--surface-2); --l: var(--line-2);
  display: inline-flex; align-items: center; gap: 6px; height: 21px; padding: 0 8px;
  border-radius: var(--r); font-size: 11px; font-weight: 550; letter-spacing: 0.005em;
  background: var(--t); color: var(--c); border: 1px solid var(--l); white-space: nowrap;
}
.st .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--c); flex: none; }
.st.erase   { --c: var(--erase);   --t: var(--erase-tint);   --l: var(--erase-line); }
.st.anon    { --c: var(--anon);    --t: var(--anon-tint);    --l: var(--anon-line); }
.st.archive { --c: var(--archive); --t: var(--archive-tint); --l: var(--archive-line); }
.st.keep    { --c: var(--keep);    --t: var(--keep-tint);    --l: var(--keep-line); }
.st.accent  { --c: var(--accent-2);--t: var(--accent-tint);  --l: var(--accent-line); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 32px; padding: 0 13px; border-radius: var(--r); font-size: 13px; font-weight: 500;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  cursor: pointer; white-space: nowrap; font-family: inherit; transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.primary:hover { background: oklch(0.32 0.014 262); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.accent:hover { background: var(--accent-2); }
.btn.danger { background: var(--erase); border-color: var(--erase); color: #fff; }
.btn.danger:hover { background: oklch(0.48 0.16 27); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn.sm { height: 27px; padding: 0 10px; font-size: 12px; }
.btn.icon { width: 32px; padding: 0; }
.btn.icon.sm { width: 27px; }

/* ---------- cards / panels ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-card); }
.card-h { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.card-b { padding: 16px; }

/* ---------- table ---------- */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.tbl thead th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 10.5px;
  letter-spacing: 0.06em; text-transform: uppercase; padding: 9px 12px;
  border-bottom: 1px solid var(--line-2); background: var(--surface-2);
  position: sticky; top: 0; z-index: 2; white-space: nowrap;
}
.tbl tbody td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr { cursor: pointer; transition: background .1s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr.sel { background: var(--accent-tint); }
.tbl tbody tr.sel:hover { background: oklch(0.94 0.026 248); }
.tbl tbody tr.active-row { background: var(--surface-3); box-shadow: inset 2px 0 0 var(--ink); }

/* checkbox */
.cbx { width: 15px; height: 15px; border: 1.5px solid var(--line-strong); border-radius: 3px; background: var(--surface); cursor: pointer; display: grid; place-items: center; flex: none; transition: background .1s, border-color .1s; }
.cbx.on { background: var(--ink); border-color: var(--ink); }
.cbx.on svg { color: var(--paper); width: 11px; height: 11px; }
.cbx svg { opacity: 0; }
.cbx.on svg { opacity: 1; }

/* confidence meter */
.conf { display: flex; align-items: center; gap: 8px; }
.conf-bar { width: 54px; height: 5px; border-radius: 4px; background: var(--surface-3); overflow: hidden; flex: none; border: 1px solid var(--line); }
.conf-fill { height: 100%; border-radius: 4px; }
.conf-val { font-family: "IBM Plex Mono", monospace; font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--ink-2); width: 30px; }

/* select / input */
.field { display: flex; flex-direction: column; gap: 5px; }
.field-lbl { font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0.02em; }
.inp, .sel {
  height: 32px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface);
  padding: 0 10px; font-family: inherit; font-size: 13px; color: var(--ink); outline: none; transition: border-color .12s, box-shadow .12s;
}
.inp:focus, .sel:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-tint); }
.sel { appearance: none; 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='%23888' stroke-width='2.4'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; padding-right: 28px; cursor: pointer; }

/* ---------- detail drawer ---------- */
.scrim { position: fixed; inset: 0; background: oklch(0.2 0.02 262 / 0.28); z-index: 40; animation: fade .15s ease both; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 540px; max-width: 92vw; z-index: 41;
  background: var(--surface); border-left: 1px solid var(--line-2); box-shadow: var(--shadow-panel);
  display: flex; flex-direction: column; animation: slideIn .22s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes slideIn { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.drawer-h { display: flex; align-items: flex-start; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); flex: none; }
.drawer-b { overflow-y: auto; flex: 1; min-height: 0; }
.drawer-f { border-top: 1px solid var(--line); padding: 12px 16px; flex: none; background: var(--surface-2); display: flex; gap: 8px; align-items: center; }

.section-blk { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.section-blk:last-child { border-bottom: none; }
.kv { display: grid; grid-template-columns: 132px 1fr; gap: 4px 14px; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); }

/* AI block */
.ai-card { border: 1px solid var(--accent-line); background: linear-gradient(180deg, var(--accent-tint), var(--surface) 70%); border-radius: var(--r-lg); padding: 14px; }
.ai-engine { display: inline-flex; align-items: center; gap: 6px; font-family: "IBM Plex Mono", monospace; font-size: 11px; color: var(--accent-2); }

/* correlation rows */
.corr { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.corr:last-child { border-bottom: none; }
.corr-ic { width: 26px; height: 26px; border-radius: var(--r); border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted); flex: none; background: var(--surface-2); }

/* ---------- bulk action bar ---------- */
.bulkbar {
  position: sticky; bottom: 0; z-index: 10; margin: 0 -28px -60px; padding: 12px 28px;
  background: var(--surface); border-top: 1px solid var(--line-2); box-shadow: 0 -8px 24px oklch(0.2 0.02 262 / 0.06);
  display: flex; align-items: center; gap: 14px; animation: slideUp .18s ease both;
}
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- modal ---------- */
.modal-scrim { position: fixed; inset: 0; background: oklch(0.2 0.02 262 / 0.35); z-index: 50; display: grid; place-items: center; animation: fade .15s ease both; padding: 24px; }
.modal { width: 560px; max-width: 96vw; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: var(--shadow-panel); animation: pop .2s cubic-bezier(.2,.8,.2,1) both; max-height: 90vh; display: flex; flex-direction: column; }
@keyframes pop { from { transform: scale(.97); opacity: .5; } to { transform: none; opacity: 1; } }

/* ---------- toast / banner ---------- */
.banner { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: var(--r-lg); border: 1px solid var(--keep-line); background: var(--keep-tint); font-size: 12.5px; }
.banner.warn { border-color: var(--anon-line); background: var(--anon-tint); }

.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { display: flex; align-items: center; gap: 12px; background: var(--ink); color: var(--paper); padding: 11px 14px; border-radius: var(--r-lg); font-size: 12.5px; box-shadow: var(--shadow-panel); animation: slideUp .2s ease both; }
.toast .toast-link { color: var(--paper); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; font-weight: 500; }

/* ---------- misc ---------- */
.divider { height: 1px; background: var(--line); border: none; margin: 0; }
.dot-sep { color: var(--faint); }
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat-v { font-size: 25px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-l { font-size: 11.5px; color: var(--muted); }
.grid-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.grid-stats > div { padding: 15px 18px; border-right: 1px solid var(--line); }
.grid-stats > div:last-child { border-right: none; }
.trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flex { display: flex; }  .ac { align-items: center; }  .jc { justify-content: center; }
.gap6 { gap: 6px; } .gap10 { gap: 10px; } .gap14 { gap: 14px; }
.mt { margin-top: 14px; } .mt-s { margin-top: 8px; }
[hidden] { display: none !important; }
