*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}

:root{
  /* Surfaces — warm-cool ink */
  --bg:        oklch(0.155 0.008 260);
  --surface-0: oklch(0.185 0.008 260);
  --surface-1: oklch(0.215 0.009 260);
  --surface-2: oklch(0.255 0.010 260);
  --hairline:  oklch(0.285 0.010 260);
  --hairline-strong: oklch(0.355 0.012 260);

  /* Text */
  --text:      oklch(0.965 0.005 260);
  --text-2:    oklch(0.74  0.010 260);
  --text-3:    oklch(0.56  0.012 260);
  --text-4:    oklch(0.42  0.012 260);

  /* Single accent — electric lime */
  --accent:    oklch(0.88 0.20 128);
  --accent-ink: oklch(0.22 0.05 128);
  --accent-soft: oklch(0.32 0.08 128);

  /* Semantic — only for data states */
  --pos:    oklch(0.82 0.16 150);
  --pos-bg: oklch(0.27 0.05 150);
  --neg:    oklch(0.72 0.18 25);
  --neg-bg: oklch(0.27 0.06 25);
  --warn:   oklch(0.82 0.14 75);
  --warn-bg: oklch(0.28 0.05 75);
  --info:   oklch(0.78 0.10 230);
  --info-bg: oklch(0.27 0.05 230);
  --violet: oklch(0.78 0.13 295);
  --violet-bg: oklch(0.27 0.05 295);

  --font-sans:'Geist','Inter',system-ui,sans-serif;
  --font-mono:'JetBrains Mono',ui-monospace,monospace;

  --r-sm:6px;--r-md:10px;--r-lg:14px;
}

html,body{background:var(--bg);color:var(--text);font-family:var(--font-sans);font-size:13px;line-height:1.5;-webkit-font-smoothing:antialiased;font-feature-settings:"cv11","ss01","ss03"}
body{min-height:100vh}

::selection{background:var(--accent);color:#000}

/* Scrollbar */
::-webkit-scrollbar{width:10px;height:10px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:var(--hairline);border-radius:10px;border:2px solid var(--bg)}
::-webkit-scrollbar-thumb:hover{background:var(--hairline-strong)}

/* === SHELL === */
.shell{display:grid;grid-template-columns:236px 1fr;grid-template-rows:56px 1fr;min-height:100vh}

/* === TOPBAR === */
.topbar{
  grid-column:1/-1;
  display:flex;align-items:center;
  border-bottom:1px solid var(--hairline);
  background:var(--bg);
  position:sticky;top:0;z-index:20;
}
.brand{
  width:236px;display:flex;align-items:center;gap:10px;
  padding:0 18px;height:100%;
  border-right:1px solid var(--hairline);
}
.brand-mark{
  width:26px;height:26px;border-radius:7px;
  background:var(--accent);color:#000;
  display:grid;place-items:center;
  font-family:var(--font-mono);font-weight:700;font-size:11px;
  letter-spacing:-0.02em;
}
.brand-name{font-weight:600;font-size:14px;letter-spacing:-0.01em}
.brand-name .v{color:var(--text-3);font-weight:400;margin-left:4px;font-family:var(--font-mono);font-size:11px}

.topbar-main{flex:1;display:flex;align-items:center;justify-content:space-between;padding:0 20px;gap:24px}
.ticker{display:flex;gap:18px;align-items:center}
.tick{display:flex;align-items:baseline;gap:6px;font-family:var(--font-mono);font-size:11.5px}
.tick-sym{color:var(--text-3);letter-spacing:0.02em}
.tick-px{color:var(--text);font-variant-numeric:tabular-nums;font-weight:500}
.tick-chg.up{color:var(--pos)}
.tick-chg.dn{color:var(--neg)}

.topbar-right{display:flex;align-items:center;gap:12px}
.search-input{
  width:240px;background:var(--surface-0);border:1px solid var(--hairline);
  border-radius:var(--r-sm);padding:6px 10px 6px 32px;color:var(--text);
  font-family:var(--font-sans);font-size:12.5px;outline:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23808699' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat:no-repeat;background-position:10px center;
}
.search-input:focus{border-color:var(--accent-soft)}
.kbd{
  position:absolute;right:10px;top:50%;transform:translateY(-50%);
  font-family:var(--font-mono);font-size:10px;color:var(--text-3);
  border:1px solid var(--hairline);border-radius:4px;padding:1px 5px;background:var(--surface-0);
  pointer-events:none;
}
.search-wrap{position:relative}
#global-search-results{
  position:absolute;top:calc(100% + 6px);left:0;right:0;z-index:50;
  background:var(--surface-0);border:1px solid var(--hairline-strong);border-radius:var(--r-sm);
  box-shadow:0 8px 24px rgba(0,0,0,.4);max-height:280px;overflow-y:auto;
}
.search-result-item{
  display:flex;flex-direction:column;gap:2px;padding:8px 12px;
  font-family:var(--font-sans);font-size:12.5px;color:var(--text);text-decoration:none;
  border-bottom:1px solid var(--hairline);
}
.search-result-item:last-child{border-bottom:none}
.search-result-item:hover{background:var(--surface-1)}

.icon-btn{width:32px;height:32px;display:grid;place-items:center;border:1px solid var(--hairline);background:var(--surface-0);border-radius:var(--r-sm);color:var(--text-2);cursor:pointer;position:relative}
.icon-btn:hover{color:var(--text);border-color:var(--hairline-strong)}
.icon-btn .dot{position:absolute;top:6px;right:7px;width:6px;height:6px;border-radius:50%;background:var(--accent);box-shadow:0 0 0 2px var(--bg)}

#notif-panel{
  position:absolute;top:calc(100% + 6px);right:0;width:320px;z-index:50;
  background:var(--surface-0);border:1px solid var(--hairline-strong);border-radius:var(--r-sm);
  box-shadow:0 8px 24px rgba(0,0,0,.4);max-height:360px;overflow-y:auto;
}
.notif-item{
  display:block;padding:10px 14px;font-size:12px;color:var(--text-2);
  border-bottom:1px solid var(--hairline);cursor:pointer;
}
.notif-item:last-child{border-bottom:none}
.notif-item:hover{background:var(--surface-1)}
.notif-item.unread{color:var(--text)}
.notif-item .notif-time{display:block;margin-top:3px;font-size:10px;color:var(--text-3)}
.notif-empty{padding:16px;text-align:center;font-size:12px;color:var(--text-3)}

.user-chip{display:flex;align-items:center;gap:8px;padding:4px 10px 4px 4px;border:1px solid var(--hairline);background:var(--surface-0);border-radius:99px;cursor:pointer;border:none}
.user-chip:hover{background:var(--surface-1)}
.avatar{width:24px;height:24px;border-radius:50%;background:linear-gradient(135deg,var(--accent),oklch(0.78 0.16 165));color:#000;display:grid;place-items:center;font-family:var(--font-mono);font-size:10px;font-weight:600}
.user-chip .name{font-size:12px;color:var(--text)}
.user-chip .role{font-size:10.5px;color:var(--text-3);font-family:var(--font-mono)}

/* === SIDEBAR === */
.sidebar{
  border-right:1px solid var(--hairline);
  background:var(--bg);
  padding:14px 10px 20px;
  overflow-y:auto;
  display:flex;flex-direction:column;gap:2px;
}
.nav-group-label{
  font-size:10px;color:var(--text-4);text-transform:uppercase;letter-spacing:0.12em;
  padding:14px 10px 6px;font-weight:500;
}
.nav-item{
  display:flex;align-items:center;gap:10px;
  padding:7px 10px;border-radius:var(--r-sm);
  color:var(--text-2);cursor:pointer;font-size:13px;
  transition:background .12s,color .12s;
  user-select:none;
  text-decoration:none;
}
.nav-item:hover{background:var(--surface-0);color:var(--text)}
.nav-item.active{background:var(--surface-1);color:var(--text)}
.nav-item.active .nav-ico{color:var(--accent)}
.nav-ico{width:16px;height:16px;color:var(--text-3);flex-shrink:0}
.nav-item .count{
  margin-left:auto;font-family:var(--font-mono);font-size:10.5px;
  color:var(--text-3);background:var(--surface-1);
  padding:1px 6px;border-radius:99px;
}
.nav-item.active .count{background:var(--surface-2);color:var(--text-2)}

.sidebar-foot{margin-top:auto;padding:10px 8px;font-family:var(--font-mono);font-size:10.5px;color:var(--text-4);display:flex;align-items:center;gap:8px;border-top:1px solid var(--hairline);margin:auto -10px 0;padding:14px 18px 4px}
.pulse{width:6px;height:6px;border-radius:50%;background:var(--pos);box-shadow:0 0 0 0 var(--pos);animation:pulse 1.6s infinite}
@keyframes pulse{
  0%{box-shadow:0 0 0 0 oklch(0.82 0.16 150 / 0.5)}
  70%{box-shadow:0 0 0 6px oklch(0.82 0.16 150 / 0)}
  100%{box-shadow:0 0 0 0 oklch(0.82 0.16 150 / 0)}
}

/* === MAIN === */
.main{padding:0;overflow-y:auto;display:flex;flex-direction:column}

.page{display:flex;flex-direction:column;flex:1}

.page-header{
  display:flex;align-items:flex-end;justify-content:space-between;gap:24px;
  padding:24px 28px 20px;
}
.crumbs{font-family:var(--font-mono);font-size:11px;color:var(--text-4);margin-bottom:6px;display:flex;gap:6px;align-items:center}
.crumbs .sep{color:var(--text-4)}
.crumbs .here{color:var(--text-2)}
.page-title{font-size:22px;font-weight:600;letter-spacing:-0.02em;color:var(--text)}
.page-desc{font-size:13px;color:var(--text-3);margin-top:4px;max-width:560px}

.header-actions{display:flex;gap:8px;align-items:center}

/* Buttons */
.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:6px;
  padding:7px 12px;border-radius:var(--r-sm);
  font-family:var(--font-sans);font-size:12.5px;font-weight:500;
  border:1px solid transparent;cursor:pointer;
  transition:background .12s,border-color .12s,color .12s;
  line-height:1;height:32px;text-decoration:none;
}
.btn-primary{background:var(--accent);color:#000;border-color:var(--accent)}
.btn-primary:hover{background:oklch(0.92 0.20 128)}
.btn-secondary{background:var(--surface-0);color:var(--text);border-color:var(--hairline)}
.btn-secondary:hover{border-color:var(--hairline-strong);background:var(--surface-1)}
.btn-ghost{background:transparent;color:var(--text-2);border-color:transparent}
.btn-ghost:hover{background:var(--surface-0);color:var(--text)}
.btn-danger-ghost{background:transparent;color:var(--neg);border-color:transparent}
.btn-danger-ghost:hover{background:var(--neg-bg)}
.btn svg{width:14px;height:14px}
.btn-sm{height:28px;padding:5px 10px;font-size:12px}
.btn-xs{height:24px;padding:3px 8px;font-size:11px}

.page-body{padding:0 28px 32px;display:flex;flex-direction:column;gap:20px}

/* Flash */
.flash-stack{display:flex;flex-direction:column;gap:10px;padding:0 28px;margin-bottom:4px;}
.flash{
  display:flex;align-items:center;gap:10px;
  padding:10px 14px;border-radius:var(--r-md);
  background:var(--pos-bg);border:1px solid oklch(0.4 0.08 150);
  color:var(--pos);font-size:12.5px;
}
.flash.flash-error{background:var(--neg-bg);border-color:oklch(0.4 0.1 25 / 0.4);color:var(--neg)}
.flash.flash-warning{background:var(--warn-bg);border-color:oklch(0.4 0.1 75 / 0.4);color:var(--warn)}
.flash.flash-info{background:var(--info-bg);border-color:oklch(0.4 0.08 230 / 0.4);color:var(--info)}
.flash.flash-success{background:var(--pos-bg);border-color:oklch(0.4 0.08 150 / 0.4);color:var(--pos)}
.flash.flash-pool-overallocated{background:var(--accent);border-color:var(--accent);color:var(--accent-ink);font-weight:600}
.flash.flash-pool-overallocated svg{color:var(--accent-ink)}
.flash svg{width:16px;height:16px;flex-shrink:0}
.flash .x{margin-left:auto;color:inherit;opacity:0.6;cursor:pointer}

/* === KPI cards === */
.kpi-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:14px}
.kpi{
  background:var(--surface-0);border:1px solid var(--hairline);
  border-radius:var(--r-md);padding:18px 18px 16px;
  display:flex;flex-direction:column;gap:14px;
  position:relative;overflow:hidden;
}
.kpi-head{display:flex;align-items:center;justify-content:space-between}
.kpi-label{font-size:11.5px;color:var(--text-3);font-weight:500;text-transform:uppercase;letter-spacing:0.05em}
.kpi-icon{width:28px;height:28px;display:grid;place-items:center;color:var(--text-3);background:var(--surface-1);border-radius:var(--r-sm)}
.kpi-icon svg{width:14px;height:14px}
.kpi-val{font-size:30px;font-family:var(--font-sans);font-weight:600;letter-spacing:-0.02em;line-height:1;font-variant-numeric:tabular-nums}
.kpi-foot{display:flex;align-items:center;gap:8px;font-size:11.5px;color:var(--text-3);font-family:var(--font-mono)}
.kpi-delta{display:inline-flex;align-items:center;gap:3px;padding:1px 6px;border-radius:99px;font-weight:500}
.kpi-delta.up{background:var(--pos-bg);color:var(--pos)}
.kpi-delta.dn{background:var(--neg-bg);color:var(--neg)}
.kpi-delta.flat{background:var(--surface-1);color:var(--text-3)}

/* Sparkline cell */
.kpi-spark{position:absolute;right:0;bottom:0;width:60%;height:46px;opacity:0.7;pointer-events:none}

/* === Cards === */
.card{background:var(--surface-0);border:1px solid var(--hairline);border-radius:var(--r-md);overflow:hidden}
.card-head{display:flex;align-items:center;justify-content:space-between;padding:14px 18px;border-bottom:1px solid var(--hairline);gap:12px;min-height:52px}
.card-title{font-size:13.5px;font-weight:600;letter-spacing:-0.005em;display:flex;align-items:center;gap:8px}
.card-title .pill{font-family:var(--font-mono);font-size:10.5px;color:var(--text-3);font-weight:400;background:var(--surface-1);padding:1px 7px;border-radius:99px;border:1px solid var(--hairline)}
.card-sub{font-size:11.5px;color:var(--text-3);margin-top:2px}
.card-actions{display:flex;align-items:center;gap:6px}

/* Two-column grid */
.grid-2{display:grid;grid-template-columns:1.4fr 1fr;gap:14px}
.grid-3{display:grid;grid-template-columns:repeat(3,1fr);gap:14px}

/* === Tables === */
.tbl-wrap{overflow-x:auto}
/* Hints that a data-dense table has more columns off-screen — mobile tables
   routinely don't fit, and overflow-x:auto alone gives no visual cue that
   swiping reveals more (confirmed: real columns were getting silently
   missed, not just clipped-but-reachable). JS (main.js) shows/hides this
   based on actual scroll position, so it disappears once scrolled to the
   end rather than sitting there permanently. */
.tbl-scroll-hint{
  display:none;align-items:center;justify-content:flex-end;gap:4px;
  padding:6px 18px;font-size:10.5px;color:var(--text-3);
  border-bottom:1px solid var(--hairline);
}
.tbl-scroll-hint.show{display:flex}
table.tbl{width:100%;border-collapse:collapse;font-size:12.5px}
.tbl thead th{
  text-align:left;font-size:10.5px;font-weight:500;
  color:var(--text-3);text-transform:uppercase;letter-spacing:0.07em;
  padding:9px 18px;border-bottom:1px solid var(--hairline);
  background:var(--bg);position:sticky;top:0;
  white-space:nowrap;
}
.tbl tbody td{
  padding:11px 18px;border-bottom:1px solid var(--hairline);
  color:var(--text-2);vertical-align:middle;
  white-space:nowrap;
}
.tbl tbody tr:last-child td{border-bottom:none}
.tbl tbody tr:hover td{background:var(--surface-1)}
.tbl td.num,.tbl th.num{text-align:right;font-family:var(--font-mono);font-variant-numeric:tabular-nums}
.tbl td.mono,.tbl th.mono{font-family:var(--font-mono);font-size:12px}
.tbl td.strong{color:var(--text);font-weight:500}
.tbl td.muted{color:var(--text-4)}
.tbl td.actions,.tbl th.actions{text-align:right}
.tbl tr.row-link{cursor:pointer}

.pair-cell{display:inline-flex;align-items:center;gap:8px;font-family:var(--font-mono);font-size:12px;color:var(--text);font-weight:500}
.pair-icon{width:18px;height:18px;border-radius:50%;background:var(--surface-2);display:grid;place-items:center;font-size:9px;color:var(--text-2);font-weight:600;border:1px solid var(--hairline)}

/* === Badges === */
.badge{
  display:inline-flex;align-items:center;gap:5px;
  height:20px;padding:0 7px;border-radius:5px;
  font-size:11px;font-family:var(--font-mono);font-weight:500;
  line-height:1;letter-spacing:0;
  border:1px solid transparent;
  white-space:nowrap;
}
.badge .d{width:5px;height:5px;border-radius:50%;background:currentColor;flex-shrink:0}
.b-pos{background:var(--pos-bg);color:var(--pos);border-color:oklch(0.4 0.08 150 / 0.4)}
.b-neg{background:var(--neg-bg);color:var(--neg);border-color:oklch(0.4 0.1 25 / 0.4)}
.b-warn{background:var(--warn-bg);color:var(--warn);border-color:oklch(0.4 0.1 75 / 0.4)}
.b-info{background:var(--info-bg);color:var(--info);border-color:oklch(0.4 0.08 230 / 0.4)}
.b-violet{background:var(--violet-bg);color:var(--violet);border-color:oklch(0.4 0.08 295 / 0.4)}
.b-muted{background:var(--surface-1);color:var(--text-3);border-color:var(--hairline)}
.b-accent{background:oklch(0.32 0.10 128);color:var(--accent);border-color:oklch(0.5 0.12 128 / 0.4)}

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

/* === Filter bar === */
.toolbar{
  display:flex;align-items:center;gap:8px;flex-wrap:wrap;
  padding:10px 14px;border-bottom:1px solid var(--hairline);
  background:var(--bg);
}
.filter-chip{
  display:inline-flex;align-items:center;gap:6px;
  padding:6px 10px;border:1px dashed var(--hairline-strong);border-radius:var(--r-sm);
  font-size:12px;color:var(--text-2);background:transparent;cursor:pointer;
  height:30px;
}
.filter-chip:hover{border-color:var(--text-3);color:var(--text)}
.filter-chip svg{width:13px;height:13px}
.filter-chip .val{color:var(--text);background:var(--surface-1);padding:2px 6px;border-radius:4px;font-family:var(--font-mono);font-size:11px;border:1px solid var(--hairline)}

.tabs{display:inline-flex;background:var(--surface-0);border:1px solid var(--hairline);border-radius:var(--r-sm);padding:2px}
.tab{padding:5px 12px;font-size:12px;color:var(--text-3);border-radius:5px;cursor:pointer;font-weight:500;display:inline-flex;align-items:center;gap:6px;text-decoration:none;}
.tab:hover{color:var(--text)}
.tab.active{background:var(--surface-2);color:var(--text)}
.tab .ct{font-family:var(--font-mono);font-size:10.5px;color:var(--text-3);background:var(--bg);padding:1px 5px;border-radius:99px}
.tab.active .ct{color:var(--text-2)}

/* Pagination */
.pag{display:flex;align-items:center;justify-content:space-between;padding:10px 18px;border-top:1px solid var(--hairline);gap:12px;font-size:12px;color:var(--text-3)}
.pag .pag-info{display:flex;align-items:center;gap:12px}
.pag .pag-ctrls{display:flex;gap:4px;align-items:center}
.pag-size{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--text-3)}
.pag-size-select{
  height:24px;padding:0 20px 0 6px;border:1px solid var(--hairline);background:var(--surface-0);
  color:var(--text-2);border-radius:4px;font-size:11px;font-family:var(--font-mono);
  cursor:pointer;min-width:48px;
  appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23808699' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat:no-repeat;background-position:right 5px center;
}
.pag-size-select:hover{border-color:var(--hairline-strong)}
.pag-size-select:focus{outline:2px solid var(--accent-soft);outline-offset:1px}
.pag-btn{
  min-width:28px;height:28px;padding:0 8px;
  border:1px solid var(--hairline);background:var(--surface-0);
  color:var(--text-2);border-radius:5px;cursor:pointer;font-size:12px;font-family:var(--font-mono);
  display:inline-flex;align-items:center;justify-content:center;
  text-decoration:none;
}
.pag-btn:hover{color:var(--text);border-color:var(--hairline-strong)}
.pag-btn.active{background:var(--surface-2);color:var(--text);border-color:var(--hairline-strong)}
.pag-btn[disabled]{opacity:0.4;cursor:not-allowed}

/* === Forms === */
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:18px 20px}
.form-grid .full{grid-column:1/-1}
.field{display:flex;flex-direction:column;gap:6px}
.field-label{font-size:11.5px;color:var(--text-2);font-weight:500;display:flex;align-items:center;justify-content:space-between}
.field-label .req{color:var(--accent);margin-left:3px}
.field-label .opt{font-size:10.5px;color:var(--text-4);font-weight:400}
.input,.select,.textarea{
  background:var(--bg);border:1px solid var(--hairline);
  border-radius:var(--r-sm);padding:8px 10px;color:var(--text);
  font-family:var(--font-sans);font-size:13px;outline:none;width:100%;
  transition:border-color .12s;height:36px;
}
.textarea{height:auto;min-height:80px;font-family:var(--font-mono);font-size:12px;line-height:1.55}
.input:focus,.select:focus,.textarea:focus{border-color:var(--accent-soft);box-shadow:0 0 0 3px oklch(0.32 0.10 128 / 0.4)}
.input.mono{font-family:var(--font-mono);font-size:12.5px}
.input::placeholder{color:var(--text-4)}
.field-hint{font-size:11px;color:var(--text-4);font-family:var(--font-mono)}
.field-hint.error{color:var(--neg)}
.input-suffix-wrap{position:relative}
.input-suffix{position:absolute;right:10px;top:50%;transform:translateY(-50%);font-size:11.5px;color:var(--text-4);font-family:var(--font-mono);pointer-events:none}

/* Toggle */
.toggle{position:relative;display:inline-flex;align-items:center;gap:9px;cursor:pointer;font-size:12.5px;color:var(--text-2)}
.toggle input{position:absolute;opacity:0;pointer-events:none}
.toggle .track{width:30px;height:18px;background:var(--surface-2);border-radius:99px;position:relative;transition:background .15s;border:1px solid var(--hairline)}
.toggle .track::after{content:"";position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:var(--text-3);transition:left .15s,background .15s}
.toggle input:checked + .track{background:oklch(0.32 0.10 128)}
.toggle input:checked + .track::after{left:14px;background:var(--accent)}

/* Segmented */
.seg{display:inline-flex;background:var(--surface-0);border:1px solid var(--hairline);border-radius:var(--r-sm);padding:3px}
.seg label{padding:5px 12px;font-size:12px;color:var(--text-3);border-radius:5px;cursor:pointer;font-weight:500;font-family:var(--font-mono)}
.seg input{display:none}
.seg label:has(input:checked){background:var(--surface-2);color:var(--text)}

/* Form card layouts */
.form-section{display:flex;flex-direction:column;gap:16px}
.form-section-title{font-size:11px;text-transform:uppercase;letter-spacing:0.08em;color:var(--text-3);font-weight:500;padding-bottom:8px;border-bottom:1px solid var(--hairline);margin-bottom:4px}

.form-aside{display:flex;flex-direction:column;gap:14px}
.aside-card{background:var(--surface-0);border:1px solid var(--hairline);border-radius:var(--r-md);padding:16px}
.aside-card h4{font-size:12.5px;font-weight:600;margin-bottom:8px;display:flex;align-items:center;gap:6px}
.aside-card h4 svg{width:14px;height:14px;color:var(--accent);flex-shrink:0}
.aside-card p{font-size:12px;color:var(--text-3);line-height:1.55}
.aside-card ul{list-style:none;display:flex;flex-direction:column;gap:6px;margin-top:8px}
.aside-card li{font-size:12px;color:var(--text-3);display:flex;gap:8px;align-items:flex-start}
.aside-card li svg{width:13px;height:13px;color:var(--accent);flex-shrink:0;margin-top:2px}

/* Detail page */
.detail-grid{display:grid;grid-template-columns:1fr 320px;gap:18px;align-items:flex-start}
.detail-single{display:flex;flex-direction:column;gap:20px;max-width:820px}
.kv{display:grid;grid-template-columns:160px 1fr;gap:6px 14px;font-size:12.5px}
.kv dt{color:var(--text-3);padding:7px 0;border-bottom:1px dashed var(--hairline)}
.kv dd{color:var(--text);padding:7px 0;border-bottom:1px dashed var(--hairline);font-family:var(--font-mono);font-size:12px;font-variant-numeric:tabular-nums;word-break:break-word;overflow-wrap:anywhere}
.kv dt:last-of-type,.kv dd:last-of-type{border-bottom:none}

/* JSON-ish pre */
.pre{
  background:var(--bg);border:1px solid var(--hairline);border-radius:var(--r-sm);
  padding:14px 16px;font-family:var(--font-mono);font-size:12px;line-height:1.6;
  color:var(--text-2);overflow-x:auto;
}
.pre .k{color:var(--info)}
.pre .s{color:var(--accent)}
.pre .n{color:var(--violet)}
.pre .b{color:var(--warn)}

/* Activity feed */
.feed{display:flex;flex-direction:column}
.feed-row{
  display:grid;grid-template-columns:auto 1fr auto;gap:12px;align-items:center;
  padding:11px 18px;border-bottom:1px solid var(--hairline);
}
.feed-row:last-child{border-bottom:none}
.feed-row:hover{background:var(--surface-1)}
.feed-marker{width:24px;height:24px;display:grid;place-items:center;border-radius:6px;flex-shrink:0}
.feed-marker svg{width:12px;height:12px}
.marker-long{background:var(--pos-bg);color:var(--pos)}
.marker-short{background:var(--neg-bg);color:var(--neg)}
.marker-close{background:var(--surface-1);color:var(--text-3)}
.feed-body{display:flex;flex-direction:column;gap:2px;min-width:0}
.feed-line1{display:flex;align-items:center;gap:8px;font-size:12.5px}
.feed-line1 .sym{font-family:var(--font-mono);color:var(--text);font-weight:500}
.feed-line1 .act{color:var(--text-3);font-family:var(--font-mono);font-size:11.5px}
.feed-line2{font-size:11px;color:var(--text-4);font-family:var(--font-mono)}
.feed-meta{text-align:right;font-family:var(--font-mono);font-size:11.5px;color:var(--text-3)}
.feed-meta .px{color:var(--text);font-weight:500}

/* Chart placeholder for sparkline */
.area-chart{padding:8px 18px 16px;height:160px}

/* Login */
.login-screen{
  display:flex;flex-direction:column;
  min-height:100vh;background:var(--bg);
  align-items:center;justify-content:center;
  padding:40px;
}
.login-card{
  width:380px;background:var(--surface-0);border:1px solid var(--hairline);
  border-radius:var(--r-lg);padding:28px;display:flex;flex-direction:column;gap:18px;
}
.login-brand{display:flex;align-items:center;gap:10px;justify-content:center;margin-bottom:6px}
.login-card h1{font-size:18px;font-weight:600;letter-spacing:-0.02em;text-align:center}
.login-card .sub{font-size:12.5px;color:var(--text-3);text-align:center;margin-top:-12px;margin-bottom:6px}
.login-foot{font-size:11px;color:var(--text-4);text-align:center;font-family:var(--font-mono);margin-top:6px}

/* Error pages */
.err-stage{display:flex;flex-direction:column;min-height:100vh;background:var(--bg);align-items:center;justify-content:center;padding:40px;text-align:center;gap:14px}
.err-code{font-family:var(--font-mono);font-size:80px;font-weight:600;letter-spacing:-0.05em;color:var(--accent);line-height:1}
.err-title{font-size:20px;font-weight:600;letter-spacing:-0.01em}
.err-desc{font-size:13px;color:var(--text-3);max-width:420px}

/* Helpers */
.row{display:flex;align-items:center;gap:8px}
.gap-12{gap:12px}
.text-xs-mono{font-family:var(--font-mono);font-size:11px;color:var(--text-3)}
.divider{height:14px;width:1px;background:var(--hairline)}
.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.right{margin-left:auto}
.scroll-x{overflow-x:auto}

.checkbox{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;border:1px solid var(--hairline-strong);border-radius:4px;background:var(--bg);cursor:pointer}
.checkbox.checked{background:var(--accent);border-color:var(--accent);color:#000}
.checkbox.checked::after{content:"";width:9px;height:5px;border-left:1.5px solid #000;border-bottom:1.5px solid #000;transform:rotate(-45deg);margin-bottom:2px}

/* Spark svg */
.spark{width:100%;height:100%}

/* === Toolbar filter controls === */
.toolbar-search,.toolbar-filter{
  height:30px;padding:0 10px;
  background:var(--surface-1);border:1px solid var(--hairline);
  border-radius:var(--r-sm);color:var(--text);font-family:var(--font-sans);
  font-size:12px;outline:none;flex-shrink:0;
}
.toolbar-search{width:200px}
.toolbar-filter{width:auto;min-width:0}
.toolbar-search:focus,.toolbar-filter:focus{border-color:var(--accent-soft);box-shadow:0 0 0 3px oklch(0.32 0.10 128 / 0.3)}
.toolbar-search::placeholder,.toolbar-filter::placeholder{color:var(--text-4)}
input[type="text"].toolbar-filter,input:not([type]).toolbar-filter{width:200px}
input[type="date"].toolbar-filter{width:130px;color-scheme:dark}
select.toolbar-filter{
  appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%23808699' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat:no-repeat;background-position:right 7px center;
  padding-right:24px;cursor:pointer;
}
.toolbar-spacer{flex:1}

/* === Form field errors === */
.field-error-msg{font-size:11px;color:var(--neg);font-family:var(--font-mono)}

/* === Inline select in toolbar === */
.select{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='%23808699' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 8px center;padding-right:26px;cursor:pointer}

/* === Table td helpers (complementary to .tbl scope) === */
td.muted{color:var(--text-4)}
td.mono{font-family:var(--font-mono);font-size:12px}
td.truncate{max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* Pill badge on card-title */
.pill{font-family:var(--font-mono);font-size:10.5px;color:var(--text-3);font-weight:400;background:var(--surface-1);padding:1px 7px;border-radius:99px;border:1px solid var(--hairline)}

/* Empty state */
.empty-state{padding:36px 20px;text-align:center;color:var(--text-4);font-size:12.5px;font-family:var(--font-mono)}

/* Danger button */
.btn-danger{background:var(--neg-bg);color:var(--neg);border-color:oklch(0.4 0.1 25 / 0.4)}
.btn-danger:hover{background:oklch(0.32 0.08 25);border-color:oklch(0.5 0.12 25 / 0.5)}

/* Utility */
.hidden{display:none!important}
a.tab{text-decoration:none}

/* ── Hamburger button (hidden on desktop) ──────────────────────── */
.ham-btn{display:none;width:36px;height:36px;place-items:center;background:transparent;border:none;color:var(--text-2);cursor:pointer;flex-shrink:0;border-radius:var(--r-sm)}
.ham-btn:hover{background:var(--surface-0);color:var(--text)}
.ham-btn svg{width:18px;height:18px}

/* Sidebar backdrop (mobile overlay) */
.sidebar-backdrop{display:none;position:fixed;inset:0;z-index:19;background:rgba(0,0,0,0.55)}
.sidebar-backdrop.open{display:block}

/* ── Responsive: Tablet (≤ 1024px) ────────────────────────────── */
@media(max-width:1023px){
  .ticker{display:none}
  .search-wrap{display:none}
  #today-pnl-badge{display:none}
  .kpi-grid{grid-template-columns:repeat(2,1fr)}
  .main{overflow-x:hidden}
  .detail-grid{grid-template-columns:1fr}
  .detail-single{max-width:100%}
}

/* ── Responsive: Mobile (≤ 767px) ─────────────────────────────── */
@media(max-width:767px){
  /* Login */
  .login-screen{padding:20px 16px}
  .login-card{width:100%;max-width:420px}

  /* Shell — collapse to single column */
  .shell{grid-template-columns:1fr;grid-template-rows:56px 1fr}

  /* Topbar */
  .topbar{padding:0}
  .brand{width:auto;border-right:none;padding:0 8px 0 12px;gap:8px}
  .brand-name{font-size:12px;white-space:nowrap;overflow:hidden;max-width:140px;text-overflow:ellipsis}
  .topbar-main{padding:0 8px;gap:8px}
  .topbar-right{gap:6px}
  /* .icon-btn (the notification bell) used to be hidden here — it was
   * purely decorative back when this rule was written. Now that it's
   * wired to real notifications (over-allocation alerts), hiding it on
   * mobile would mean mobile users can never see them. The actual
   * overflow culprit at this width was #today-pnl-badge (hidden above,
   * alongside .ticker/.search-wrap), but the panel's own desktop
   * positioning (anchored to the bell via `right:0` on its parent) still
   * doesn't fit at this width — verified directly: a 320px-wide box
   * anchored that way runs to x=-190, clipped well past the left edge.
   * Anchor to the viewport instead of the trigger button, the standard
   * pattern for a mobile dropdown — guaranteed to fit regardless of
   * where the bell sits in the topbar. */
  #notif-panel{position:fixed;top:56px;left:8px;right:8px;width:auto}

  /* Hamburger visible on mobile */
  .ham-btn{display:grid}

  /* Sidebar: off-canvas drawer */
  .sidebar{
    position:fixed;
    top:56px;left:0;
    width:240px;
    height:calc(100vh - 56px);
    z-index:20;
    transform:translateX(-100%);
    transition:transform .22s ease;
    box-shadow:4px 0 32px rgba(0,0,0,0.5);
  }
  .sidebar.open{transform:translateX(0)}

  /* Main occupies full row */
  .main{grid-column:1;overflow-x:hidden}

  /* Page layout */
  .page-header{flex-direction:column;align-items:flex-start;gap:10px;padding:16px 16px 12px}
  .header-actions{width:100%;justify-content:flex-start;flex-wrap:wrap}
  .page-body{padding:0 14px 24px}

  /* Cards & grids */
  .kpi-grid{grid-template-columns:repeat(2,1fr);gap:10px}
  .grid-2,.grid-3{grid-template-columns:1fr}
  .card-head{flex-wrap:wrap;min-height:auto}

  /* Forms */
  .form-grid{grid-template-columns:1fr}
  .form-grid .full{grid-column:1}

  /* KV: stack label above value */
  .kv{grid-template-columns:1fr;gap:0}
  .kv dt{border-bottom:none;padding-bottom:2px;padding-top:12px;font-size:10.5px;text-transform:uppercase;letter-spacing:0.06em}
  .kv dd{padding-top:2px;padding-bottom:10px}
  .kv dt:first-of-type{padding-top:0}
  .kv dd:last-of-type{border-bottom:none;padding-bottom:0}

  /* Toolbar wraps */
  .toolbar{flex-wrap:wrap;gap:6px;padding:8px 12px}
  .tabs{flex-wrap:wrap}

  /* Table scroll within wrapper (already has overflow-x:auto) */
  .tbl-wrap{-webkit-overflow-scrolling:touch}

  /* Pag */
  .pag{flex-direction:column;align-items:flex-start;gap:8px;padding:10px 14px}
  .pag .pag-info{flex-direction:column;align-items:flex-start;gap:6px}
  .pag-size{font-size:11px}
}

/* ── Very small (≤ 480px) ──────────────────────────────────────── */
@media(max-width:480px){
  .kpi-grid{grid-template-columns:1fr}
  .brand-name{display:none}
}

/* Crumb links */
.crumbs a.here{color:var(--text-2);text-decoration:none}
.crumbs a.here:hover{color:var(--text)}

/* btn-danger for confirm pages */
.btn-danger{background:var(--neg-bg);color:var(--neg);border-color:oklch(0.4 0.1 25 / 0.4)}
.btn-danger:hover{background:oklch(0.32 0.08 25);border-color:oklch(0.5 0.1 25 / 0.6)}

/* btn-xs size */
.btn-xs{height:24px;padding:3px 8px;font-size:11px}

/* Thin secondary button */
.btn-secondary{background:var(--surface-0);color:var(--text);border-color:var(--hairline)}
.btn-secondary:hover{border-color:var(--hairline-strong);background:var(--surface-1)}

/* === Django form widget class aliases === */
/* Forms use class="form-input" / "form-checkbox" — map them to design system styles */
.form-input{
  background:var(--bg);border:1px solid var(--hairline);
  border-radius:var(--r-sm);padding:8px 10px;color:var(--text);
  font-family:var(--font-sans);font-size:13px;outline:none;width:100%;
  transition:border-color .12s;height:36px;
}
.form-input:focus{border-color:var(--accent-soft);box-shadow:0 0 0 3px oklch(0.32 0.10 128 / 0.4)}
.form-input::placeholder{color:var(--text-4)}
select.form-input{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='%23808699' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 8px center;padding-right:26px;cursor:pointer}
.form-checkbox{width:15px;height:15px;accent-color:var(--accent);cursor:pointer}

