/* Northbar Terminal — styles
   Brand: Midnight #0A0F1C · Signal #2EE6A8 · Deep Signal #12B886 · Forest #0B7A5A · White · Cloud #EEF1F4
   Rule: green means the rise. Losses are neutral, never bright red. */

@font-face { font-family: "Poppins"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/poppins-400.woff") format("woff"); }
@font-face { font-family: "Poppins"; font-weight: 500; font-style: normal; font-display: swap; src: url("fonts/poppins-500.woff") format("woff"); }
@font-face { font-family: "Poppins"; font-weight: 600; font-style: normal; font-display: swap; src: url("fonts/poppins-500.woff") format("woff"); }
@font-face { font-family: "Poppins"; font-weight: 700; font-style: normal; font-display: swap; src: url("fonts/poppins-700.woff") format("woff"); }

:root {
  --bg: #0A0F1C;
  --surface: #0F1626;
  --surface-2: #141C2F;
  --line: #1E2638;
  --line-strong: #2A3449;
  --grid: #161D2E;
  --ink: #FFFFFF;
  --ink-2: #B8C0CC;
  --ink-3: #8B95A7;
  --ink-4: #5B6577;
  --rise: #2EE6A8;          /* green: wins, the key number, the call to action */
  --rise-ink: #2EE6A8;      /* green used as text */
  --rise-soft: rgba(46, 230, 168, .12);
  --rise-on: #0A0F1C;       /* text on a green button */
  --fall: #C3CAD6;          /* losses: neutral */
  --fall-soft: rgba(195, 202, 214, .14);
  --warn: #F2C14E;
  --warn-soft: rgba(242, 193, 78, .12);
  --logo-n: #FFFFFF;
  --logo-g: #2EE6A8;
  --logo-d: #2EE6A8;
  --shadow: 0 20px 60px rgba(0, 0, 0, .45);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar: 248px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #F6F8FA;
  --surface: #FFFFFF;
  --surface-2: #EEF1F4;
  --line: #E1E6EC;
  --line-strong: #D0D7E0;
  --grid: #EEF1F4;
  --ink: #0A0F1C;
  --ink-2: #2F3A4F;
  --ink-3: #4A5468;
  --ink-4: #8B95A7;
  --rise: #12B886;
  --rise-ink: #0B7A5A;
  --rise-soft: rgba(18, 184, 134, .12);
  --rise-on: #FFFFFF;
  --fall: #0A0F1C;
  --fall-soft: rgba(10, 15, 28, .08);
  --warn: #B7791F;
  --warn-soft: rgba(183, 121, 31, .12);
  --logo-n: #0A0F1C;
  --logo-g: #12B886;
  --logo-d: #0B7A5A;
  --shadow: 0 20px 50px rgba(10, 15, 28, .14);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px; line-height: 1.5;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  font-variant-numeric: tabular-nums lining-nums;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--rise-ink); }
:focus-visible { outline: 2px solid var(--rise); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Shell ---------- */
.shell { min-height: 100%; display: flex; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 26px 16px 18px; z-index: 20;
}
.sidebar .logo { width: 176px; height: auto; display: block; margin: 0 8px 30px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--ink-3); text-decoration: none; font-weight: 500; font-size: 14.5px;
}
.nav a svg { width: 20px; height: 20px; flex: none; }
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); }
.nav a[aria-current="page"] svg { color: var(--rise); }
.sidebar .cta { margin: 22px 4px 0; }
.sidebar-foot { margin-top: auto; padding: 0 8px; font-size: 12px; color: var(--ink-4); }
.sync-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-4); margin-right: 6px; vertical-align: 1px; }
.sync-dot.ok { background: var(--rise); }
.sync-dot.err { background: var(--warn); }

.main { flex: 1; margin-left: var(--sidebar); min-width: 0; }
.topbar { display: none; }
.view { max-width: 1180px; margin: 0 auto; padding: 34px 36px 80px; }
.tabbar { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -.01em; margin: 0; line-height: 1.2; }
.page-head p { margin: 4px 0 0; color: var(--ink-3); font-size: 14px; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

@media (max-width: 899px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    padding: calc(10px + var(--safe-t)) 16px 10px; border-bottom: 1px solid var(--line);
  }
  .topbar .logo { width: 150px; height: auto; display: block; }
  .view { padding: 20px 16px calc(110px + var(--safe-b)); }
  .page-head h1 { font-size: 22px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b));
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0;
    color: var(--ink-4); text-decoration: none; font-size: 11px; font-weight: 500;
  }
  .tabbar a svg { width: 22px; height: 22px; }
  .tabbar a[aria-current="page"] { color: var(--ink); }
  .tabbar a[aria-current="page"] svg { color: var(--rise); }
  .tabbar a.tab-log svg { color: var(--rise-on); background: var(--rise); border-radius: 10px; padding: 4px; width: 32px; height: 32px; margin: -5px 0 -3px; }
}

/* ---------- Buttons & controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink);
  padding: 10px 16px; border-radius: 10px; font-weight: 500; font-size: 14px; cursor: pointer;
  text-decoration: none; min-height: 42px; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-4); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--rise); border-color: var(--rise); color: var(--rise-on); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-3); }
.btn.ghost:hover { color: var(--ink); background: var(--surface-2); }
.btn.danger { color: var(--warn); }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.icon-btn { background: none; border: 0; padding: 8px; border-radius: 10px; color: var(--ink-3); cursor: pointer; display: inline-flex; }
.icon-btn:hover { color: var(--ink); background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--ink-3); cursor: pointer; min-height: 32px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 0 var(--line-strong); }
:root[data-theme="light"] .seg button[aria-pressed="true"] { box-shadow: 0 1px 3px rgba(10,15,28,.12); }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; }
.seg button.long[aria-pressed="true"] { color: var(--rise-ink); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .field > label.lbl { font-size: 12.5px; color: var(--ink-3); font-weight: 500; }
.field .hint { font-size: 12px; color: var(--ink-4); }
.input, select.input, textarea.input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 16px; min-height: 44px; color: var(--ink); appearance: none; -webkit-appearance: none;
}
select.input { background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
textarea.input { min-height: 96px; resize: vertical; line-height: 1.5; }
.input:focus { outline: none; border-color: var(--rise); box-shadow: 0 0 0 3px var(--rise-soft); }
.input.invalid { border-color: var(--warn); }
.input-wrap { position: relative; }
.input-wrap .suffix { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-4); font-size: 13px; pointer-events: none; }
.input-wrap .input { padding-right: 52px; }
input[type="datetime-local"].input { min-height: 44px; }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 640px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line-strong); background: transparent; color: var(--ink-2);
  padding: 6px 12px; border-radius: 999px; font-size: 13px; cursor: pointer; min-height: 34px;
}
.chip[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); border-color: var(--ink-3); }
.chip .x { margin-left: 6px; color: var(--ink-4); }

/* ---------- Panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-width: 0; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head h2 { font-size: 15.5px; font-weight: 600; margin: 0; }
.panel-head p { margin: 2px 0 0; font-size: 13px; color: var(--ink-3); }
.panel h3 { font-size: 14px; font-weight: 600; margin: 0 0 10px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.cols { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.cols-wide { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 980px) { .cols, .cols-wide { grid-template-columns: minmax(0, 1fr); } }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.tiny { font-size: 12px; color: var(--ink-4); }
.rise { color: var(--rise-ink); }
.fall { color: var(--ink-2); }
.divider { height: 1px; background: var(--line); margin: 18px 0; border: 0; }

/* ---------- Dashboard ---------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: end;
  padding: 24px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); margin-bottom: 16px;
}
.hero .lbl { color: var(--ink-3); font-size: 13.5px; font-weight: 500; }
.hero .big { font-size: 52px; font-weight: 700; line-height: 1.05; letter-spacing: -.02em; margin: 6px 0 4px; }
.hero .sub { color: var(--ink-3); font-size: 14px; }
.hero .guard { text-align: right; }
@media (max-width: 640px) { .hero { grid-template-columns: 1fr; } .hero .guard { text-align: left; } .hero .big { font-size: 42px; } }

.guard-card { display: inline-flex; flex-direction: column; gap: 4px; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); min-width: 220px; }
.guard-card .state { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.guard-card .state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--rise); }
.guard-card.stop { border-color: var(--warn); background: var(--warn-soft); }
.guard-card.stop .state::before { background: var(--warn); }
.guard-card .meta { font-size: 12.5px; color: var(--ink-3); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.kpi { background: var(--surface); padding: 16px 18px; min-width: 0; }
.kpi .k { font-size: 12.5px; color: var(--ink-3); font-weight: 500; display: flex; justify-content: space-between; gap: 6px; }
.kpi .v { font-size: 22px; font-weight: 600; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .s { font-size: 12px; color: var(--ink-4); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 760px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpi .v { font-size: 19px; } }

/* ---------- Charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text { fill: var(--ink-4); font-size: 11px; font-family: inherit; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .zero { stroke: var(--line-strong); stroke-width: 1; }
.chart .series { fill: none; stroke: var(--rise); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--rise); opacity: .08; }
.chart .xhair { stroke: var(--ink-4); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .dot { fill: var(--rise); stroke: var(--surface); stroke-width: 2; }
.chart .bar-up { fill: var(--rise); }
.chart .bar-down { fill: var(--fall); opacity: .75; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit-bar { fill: transparent; }
.chart .hit-bar:hover + .bar-up, .chart .hit-bar:hover + .bar-down { filter: brightness(1.15); }
.tip {
  position: absolute; pointer-events: none; z-index: 5; background: var(--surface-2); border: 1px solid var(--line-strong);
  border-radius: 10px; padding: 8px 11px; font-size: 12.5px; line-height: 1.45; box-shadow: var(--shadow);
  white-space: nowrap; transform: translate(-50%, -100%); margin-top: -12px; opacity: 0; transition: opacity .1s;
}
.tip.on { opacity: 1; }
.tip b { font-weight: 600; }
.tip .t { color: var(--ink-3); font-size: 11.5px; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-3); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.empty-chart { height: 200px; display: grid; place-items: center; color: var(--ink-4); font-size: 13.5px; border: 1px dashed var(--line-strong); border-radius: 12px; text-align: center; padding: 16px; }

/* breakdown table */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th { text-align: left; font-weight: 500; color: var(--ink-4); font-size: 12px; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 10px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; }
table.data td.name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.dbar { position: relative; width: 120px; height: 8px; display: inline-block; vertical-align: middle; }
.dbar::before { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--line-strong); }
.dbar i { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.dbar i.up { left: 50%; background: var(--rise); }
.dbar i.down { right: 50%; background: var(--fall); opacity: .75; }
@media (max-width: 640px) { .dbar { width: 64px; } }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .dow { font-size: 11px; color: var(--ink-4); text-align: center; padding-bottom: 4px; }
.cal .day {
  aspect-ratio: 1 / .82; border-radius: 8px; background: var(--surface-2); padding: 5px 6px; font-size: 11px;
  display: flex; flex-direction: column; justify-content: space-between; color: var(--ink-4); position: relative; min-width: 0; border: 0;
}
.cal .day.blank { background: transparent; }
.cal .day .r { font-weight: 600; font-size: 12px; color: var(--ink); text-align: right; white-space: nowrap; overflow: hidden; }
.cal .day.today { box-shadow: inset 0 0 0 1px var(--ink-3); }
.cal .day.has { cursor: pointer; }
@media (max-width: 520px) { .cal .day .r { font-size: 10px; } .cal .day { padding: 4px; } }

/* discipline compare */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.compare .side { border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.compare .side.good { border-color: color-mix(in srgb, var(--rise) 45%, var(--line)); }
.compare .side .t { font-size: 12.5px; color: var(--ink-3); }
.compare .side .v { font-size: 22px; font-weight: 600; margin: 4px 0 2px; }
.compare .side .s { font-size: 12px; color: var(--ink-4); }
.meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 10px; }
.meter i { display: block; height: 100%; background: var(--rise); border-radius: 3px; }

/* ---------- Journal ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters .input { width: auto; min-height: 40px; font-size: 14px; padding: 8px 12px; }
.filters .search { flex: 1 1 220px; }
.filters select.input { padding-right: 32px; background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px; }
.day-group { margin-bottom: 18px; }
.day-group .dh { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-4); padding: 0 4px 6px; font-weight: 500; }
.trade-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.trade {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; width: 100%;
  padding: 13px 16px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer;
}
.trade:last-child { border-bottom: 0; }
.trade:hover { background: var(--surface-2); }
.trade .sym { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.trade .meta { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trade .res { text-align: right; }
.trade .res .r { font-weight: 600; font-size: 16px; }
.trade .res .p { font-size: 12.5px; color: var(--ink-3); }
.pill { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--ink-3); line-height: 1.5; }
.pill.long { color: var(--rise-ink); border-color: color-mix(in srgb, var(--rise) 40%, var(--line)); }
.pill.gate { background: var(--rise-soft); border-color: transparent; color: var(--rise-ink); }
.pill.nogate { border-style: dashed; }
.pill.open { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, var(--line)); }

.empty { text-align: center; padding: 56px 20px; border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.empty h2 { font-size: 18px; margin: 14px 0 6px; font-weight: 600; }
.empty p { color: var(--ink-3); margin: 0 auto 18px; max-width: 420px; font-size: 14px; }
.empty svg.mark { width: 56px; height: 56px; }

/* ---------- Trade form ---------- */
.form-section + .form-section { margin-top: 16px; }
.form-actions {
  position: sticky; bottom: 0; display: flex; gap: 10px; justify-content: flex-end; padding: 14px 0 6px;
  background: linear-gradient(to top, var(--bg) 70%, transparent); margin-top: 8px; z-index: 5;
}
@media (max-width: 899px) { .form-actions { bottom: calc(64px + var(--safe-b)); } }
.derived { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.derived div { background: var(--surface-2); padding: 10px 12px; }
.derived span { display: block; font-size: 11.5px; color: var(--ink-4); }
.derived b { font-weight: 600; font-size: 16px; }
.gate-attached { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--rise-soft); font-size: 13.5px; }
.gate-attached.miss { background: var(--warn-soft); }
.gate-attached svg { width: 26px; height: 26px; flex: none; }
.stars { display: flex; gap: 4px; }
.stars button { border: 1px solid var(--line-strong); background: none; border-radius: 8px; width: 40px; height: 40px; cursor: pointer; color: var(--ink-3); font-weight: 600; }
.stars button[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); border-color: var(--ink-3); }

/* ---------- Gate (checklist) ---------- */
.gate-meter { display: flex; align-items: flex-end; gap: 6px; height: 92px; }
.gate-meter i { width: 18px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--line-strong); transition: background .25s, border-color .25s; display: block; }
.gate-meter i.on { background: var(--ink); border-color: var(--ink); }
.gate-meter .brk { position: relative; width: 18px; transition: background .25s; }
.gate-meter .brk.on { background: var(--rise); border-color: var(--rise); }
.gate-meter .arrow { position: absolute; left: 50%; transform: translateX(-50%); top: -15px; width: 0; height: 0; border-left: 13px solid transparent; border-right: 13px solid transparent; border-bottom: 15px solid var(--line-strong); transition: border-color .25s; }
.gate-meter .brk.on .arrow { border-bottom-color: var(--rise); }
@media (prefers-reduced-motion: reduce) { .gate-meter i, .gate-meter .arrow { transition: none; } }
.gate-status { font-size: 20px; font-weight: 700; margin: 0; }
.gate-status.cleared { color: var(--rise-ink); }
.rules { display: flex; flex-direction: column; }
.rule {
  display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; padding: 14px 4px; border-bottom: 1px solid var(--line);
  cursor: pointer; align-items: start;
}
.rule:last-child { border-bottom: 0; }
.rule input { position: absolute; opacity: 0; pointer-events: none; }
.rule .box { width: 24px; height: 24px; border-radius: 7px; border: 1.5px solid var(--ink-4); display: grid; place-items: center; margin-top: 1px; }
.rule .box svg { width: 16px; height: 16px; opacity: 0; color: var(--rise-on); }
.rule input:checked + .box { background: var(--rise); border-color: var(--rise); }
.rule input:checked + .box svg { opacity: 1; }
.rule input:focus-visible + .box { outline: 2px solid var(--rise); outline-offset: 2px; }
.rule .txt { font-size: 14.5px; }
.rule .grp { display: block; font-size: 11.5px; color: var(--ink-4); margin-bottom: 1px; font-weight: 500; }
.rule.locked { cursor: default; }
.rule.locked .box { border-style: dashed; }
.rule .auto { font-size: 12px; color: var(--ink-4); display: block; margin-top: 2px; }
.rule.fail .auto { color: var(--warn); }

/* ---------- Sizer ---------- */
.size-out { text-align: left; }
.size-out .lbl { font-size: 13px; color: var(--ink-3); }
.size-out .big { font-size: 44px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; margin: 4px 0 2px; }
.size-out .unit { font-size: 18px; color: var(--ink-3); font-weight: 500; }
.out-list { margin: 16px 0 0; padding: 0; list-style: none; }
.out-list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.out-list li:last-child { border-bottom: 0; }
.out-list li span { color: var(--ink-3); }
.out-list li b { font-weight: 600; text-align: right; }
.note { padding: 12px 14px; border-radius: 12px; font-size: 13px; background: var(--surface-2); color: var(--ink-2); }
.note.warn { background: var(--warn-soft); color: var(--ink); }
.note.warn::before { content: "! "; font-weight: 700; color: var(--warn); }

/* ---------- Settings ---------- */
.list-edit { display: flex; flex-direction: column; gap: 6px; }
.list-edit .row { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border-radius: 10px; padding: 6px 6px 6px 12px; }
.list-edit .row span { flex: 1; font-size: 14px; min-width: 0; }
.list-edit .add { display: flex; gap: 8px; margin-top: 4px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 4px 0; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 13px; background: var(--line-strong); position: relative; cursor: pointer; flex: none; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--rise); }
.switch input:checked::after { transform: translateX(18px); }
.compliance { font-size: 12.5px; color: var(--ink-4); line-height: 1.6; }

/* ---------- Sheet / modal / toast ---------- */
.scrim { position: fixed; inset: 0; background: rgba(4, 7, 14, .6); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; }
.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; box-shadow: var(--shadow); }
.sheet .sh { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 20px 0; }
.sheet .sh h2 { margin: 0; font-size: 19px; font-weight: 700; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sheet .sb { padding: 16px 20px 20px; }
.sheet .sf { display: flex; gap: 8px; padding: 0 20px 20px; flex-wrap: wrap; }
.sheet .sf .btn { flex: 1; }
@media (max-width: 640px) {
  .scrim { align-items: flex-end; padding: 0; }
  .sheet { border-radius: 18px 18px 0 0; max-height: 88vh; padding-bottom: var(--safe-b); }
}
.kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 10px; }
.kv div span { display: block; font-size: 11.5px; color: var(--ink-4); }
.kv div b { font-weight: 500; font-size: 14.5px; word-break: break-word; }
.notes-box { white-space: pre-wrap; font-size: 14px; color: var(--ink-2); background: var(--surface-2); border-radius: 10px; padding: 12px; }

.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; width: max-content; max-width: calc(100vw - 32px); }
@media (max-width: 899px) { .toasts { bottom: calc(84px + var(--safe-b)); } }
.toast { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line-strong); padding: 10px 14px; border-radius: 12px; font-size: 13.5px; box-shadow: var(--shadow); display: flex; gap: 12px; align-items: center; }
.toast button { background: none; border: 0; color: var(--rise-ink); font-weight: 600; cursor: pointer; padding: 0; }

.foot-compliance { margin-top: 36px; font-size: 12px; color: var(--ink-4); text-align: center; }

/* ---------- Refinements ---------- */
.sidebar .logo { width: 200px; }
.cal .day.has > span:first-child { color: var(--ink-2); opacity: .8; }
.meter-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-4); margin-top: 12px; }
.meter-label + .meter { margin-top: 6px; }
@media (max-width: 980px) {
  #gateSide { position: static !important; order: -1; display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 18px; align-items: center; }
  #gateSide .gate-meter { grid-row: span 2; margin: 14px 0 0 !important; height: 80px; }
  #gateSide .gate-meter i { width: 12px; }
  #gateSide .gate-meter .arrow { border-left-width: 9px; border-right-width: 9px; border-bottom-width: 11px; top: -11px; }
  #gateSide > .btn, #gateSide > .tiny { grid-column: 1 / -1; }
  #gateSide > .btn.primary { margin-top: 4px; }
  #sizeOut { position: static !important; }
}
@media (max-width: 640px) {
  .page-head .head-actions { margin-left: auto; }
  .page-head { align-items: center; }
}
#view:focus, #view:focus-visible { outline: none; }
/* Logo rule (27 Oct 2026): up bars are green — the first bar and the breakout */
.gate-meter i.on:first-child { background: var(--rise); border-color: var(--rise); }
@media (max-width: 640px) { .wm { grid-column: 1 / -1; } }
.seg.wide button { min-width: 0; padding-left: 6px; padding-right: 6px; }
