/* ============================================================
   Agum Screener — terminal-dense dark UI
   Design tokens first; every colour / space / size below is a
   token or a step on the 4px scale. No magic numbers in views.
   ============================================================ */

:root {
  /* --- surfaces: cool-tinted neutrals, never pure black --- */
  --bg:        #0a0d13;
  --bg-1:      #10151d;   /* panels                      */
  --bg-2:      #171d28;   /* raised: headers, thead      */
  --bg-3:      #1e2634;   /* hover / active row          */
  --line:      #212a39;
  --line-2:    #2f3b50;

  /* --- ink --- */
  --fg:        #e2e8f2;
  --fg-1:      #9aa7bc;
  --fg-2:      #66738c;

  /* --- semantics --- */
  --accent:    #ffb02e;   /* amber: the terminal's own voice */
  --accent-2:  #ffcf6e;   /* lighter amber for gradients */
  --accent-lo: #3b2c10;
  --up:        #17d193;
  --up-lo:     #0d2f26;
  --down:      #ff5264;
  --down-lo:   #381b21;
  --blue:      #57a4ff;
  --blue-lo:   #152844;
  --candle-up:   #9b59ff;   /* up candles — violet, desk preference */
  --candle-down: #f0f2f5;   /* down candles — white, desk preference */

  /* --- depth: shadows for raised/pop surfaces --- */
  --sh-1: 0 1px 2px rgba(0,0,0,.35), 0 1px 6px rgba(0,0,0,.22);
  --sh-2: 0 2px 8px rgba(0,0,0,.38), 0 6px 20px rgba(0,0,0,.25);
  --sh-3: 0 8px 24px rgba(0,0,0,.45), 0 16px 48px rgba(0,0,0,.3);
  --ring: 0 0 0 3px rgba(255,176,46,.22);

  /* --- type --- */
  --font-sans: "IBM Plex Sans", "Avenir Next", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --fs-xs: 10.5px; --fs-sm: 11.5px; --fs-md: 12.5px; --fs-lg: 13.5px; --fs-xl: 17px; --fs-2xl: 22px;

  /* --- rhythm --- */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --r1: 4px; --r2: 8px; --r3: 12px;

  --rail-w: 182px;
  --ease: cubic-bezier(.16,.84,.44,1);
  --ease-out: cubic-bezier(.2,0,0,1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

/* ============================ LIGHT THEME ============================ */
[data-theme="light"] {
  /* surfaces: cool whites, never pure white - keeps the panels alive */
  --bg:        #f2f4f8;
  --bg-1:      #ffffff;
  --bg-2:      #eef1f6;
  --bg-3:      #e3e8f0;
  --line:      #d7dde6;
  --line-2:    #c3cbd8;

  --fg:        #1b2331;
  --fg-1:      #4b586c;
  --fg-2:      #7c8aa0;

  --accent:    #c07f00;
  --accent-2:  #e09a1e;
  --accent-lo: #f6e7c3;
  --up:        #0e9f6e;
  --up-lo:     #d8f1e7;
  --down:      #d63a4c;
  --down-lo:   #f9dee1;
  --blue:      #2f7fe0;
  --blue-lo:   #dcebfa;
  /* light candles: green/red read better on white than violet/white */
  --candle-up:   #0e9f6e;
  --candle-down: #e03e4e;

  --sh-1: 0 1px 2px rgba(20,30,50,.08), 0 1px 5px rgba(20,30,50,.06);
  --sh-2: 0 2px 8px rgba(20,30,50,.10), 0 6px 18px rgba(20,30,50,.08);
  --sh-3: 0 8px 24px rgba(20,30,50,.16), 0 16px 44px rgba(20,30,50,.12);
  --ring: 0 0 0 3px rgba(192,127,0,.20);
}
[data-theme="light"] .rail {
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
}
[data-theme="light"] .brand-mark { text-shadow: none; }
[data-theme="light"] .topbar { background: color-mix(in srgb, var(--bg-2) 88%, transparent); }
[data-theme="light"] .hero,
[data-theme="light"] .gcard,
[data-theme="light"] .panel,
[data-theme="light"] .decision,
[data-theme="light"] .scoreboard {
  background: linear-gradient(180deg, var(--bg-1), color-mix(in srgb, var(--bg-1) 94%, var(--bg-2)));
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

html, body {
  height: 100%;
  margin: 0;
}
body {
  background: var(--bg);
  color: var(--fg);
  font: var(--fs-md)/1.45 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
h1, h2, dl, dd, dt, p { margin: 0; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line-2); border: 2px solid var(--bg); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #3f4d63; }

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

/* ============================ SHELL ============================ */

.app {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  grid-template-rows: auto 1fr;
  height: 100vh;
}

/* One persistent header: who we are, how fresh the data is, one action. */
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--s4);
  padding: var(--s2) var(--s4);
  background: color-mix(in srgb, var(--bg-1) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--sh-1);
  z-index: 30;
  min-width: 0;   /* let the grid track shrink on phones instead of the
                     topbar's content forcing horizontal overflow */
}
.topbar-brand { display: flex; align-items: baseline; gap: var(--s2); flex: 0 0 auto; }
.brand-mark {
  color: var(--accent); font: var(--fs-md)/1 var(--font-mono); letter-spacing: -2px;
  text-shadow: 0 0 14px rgba(255,176,46,.35);
}
.brand-name {
  font-size: var(--fs-lg); font-weight: 650; letter-spacing: .02em; white-space: nowrap;
  background: linear-gradient(100deg, var(--accent-2), var(--accent) 55%, var(--fg));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.topbar-mid {
  flex: 1 1 auto;
  display: flex; align-items: baseline; gap: var(--s2);
  flex-wrap: wrap;
  min-width: 0;
  font: var(--fs-sm)/1.4 var(--font-mono);
  color: var(--fg-2);
}
.greeting { color: var(--fg-1); }
.topbar-sep { color: var(--line-2); }
.hdr-clock {
  flex: 0 0 auto;
  font: var(--fs-sm)/1.6 var(--font-mono);
  color: var(--fg-1);
  font-variant-numeric: tabular-nums;
  letter-spacing: .03em;
}
.live-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font: 700 var(--fs-xs)/1.6 var(--font-sans);
  letter-spacing: .14em;
  color: var(--up);
  background: var(--up-lo);
  border: 1px solid #17553f;
}
.dot-live {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--up);
  box-shadow: 0 0 8px var(--up);
  animation: livepulse 1.4s var(--ease) infinite;
}
@keyframes livepulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.version-chip {
  flex: 0 0 auto;
  font: var(--fs-xs)/1.6 var(--font-mono);
  color: var(--fg-2);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 1px 8px;
  cursor: default;
  transition: color .15s var(--ease), border-color .15s var(--ease);
}
.version-chip.is-on { color: var(--accent); border-color: #6b4d15; background: var(--accent-lo); }
.version-chip.is-on:hover { color: var(--accent-2); }
.asof { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Session chip: who is logged in; second click logs out, armed in place. */
.userchip {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  max-width: 180px;
  flex: 0 0 auto;
}
.userchip-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 140px;
}
.userchip-caret { color: var(--fg-2); font-size: var(--fs-xs); }

/* personal menu: one level, no nesting */
.usermenu { position: relative; flex: 0 0 auto; }
.usermenu-dd {
  position: absolute; z-index: 60;
  top: calc(100% + 4px); right: 0;
  min-width: 230px;
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--s2);
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r2);
  box-shadow: 0 12px 32px rgba(0,0,0,.6);
}
.usermenu-head {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s2) var(--s3) var(--s3);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--s1);
}
.usermenu-name {
  font-weight: 600;
  letter-spacing: .02em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 140px;
}
.usermenu-item {
  display: block;
  width: 100%;
  padding: 5px var(--s3);
  background: none;
  border: 0;
  border-radius: var(--r1);
  color: var(--fg-1);
  font-size: var(--fs-sm);
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}
.usermenu-item:hover { background: var(--bg-3); color: var(--fg); }
.usermenu-item.is-danger { color: #ff8b96; }
.usermenu-item.is-danger:hover { background: var(--down-lo); }
.usermenu-item.is-armed { background: var(--down-lo); color: #ff8b96; font-weight: 600; }
.usermenu-pass {
  display: flex; align-items: center; gap: var(--s1);
  padding: var(--s2) var(--s3);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.usermenu-pass .input-sm { width: 108px; }
.usermenu-reveal {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--line);
  font: var(--fs-sm)/1.5 var(--font-mono);
  color: var(--fg-1);
}
.usermenu-reveal code { color: var(--accent); word-break: break-all; }

.rail {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  padding: var(--s3) var(--s2);
  background: linear-gradient(180deg, var(--bg-1), color-mix(in srgb, var(--bg-1) 92%, var(--accent-lo)));
  border-right: 1px solid var(--line);
  min-width: 0;
  box-shadow: inset -1px 0 0 rgba(0,0,0,.2);
}

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  background: none;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0 var(--r2) var(--r2) 0;
  color: var(--fg-1);
  text-align: left;
  cursor: pointer;
  font-weight: 500;
  transition: color .15s var(--ease), background .15s var(--ease), border-color .15s var(--ease);
}
.nav-item:hover { background: var(--bg-2); color: var(--fg); }
.nav-item.is-active {
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent-lo) 55%, transparent), var(--bg-2));
  border-left-color: var(--accent);
  color: var(--fg);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}
.nav-item.is-active::after {
  content: "";
  position: absolute;
  right: 6px; top: 50%;
  width: 4px; height: 4px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}
.nav-item.is-active kbd { color: var(--accent); border-color: var(--accent-lo); }

kbd {
  display: inline-block;
  min-width: 16px;
  padding: 1px 3px;
  border: 1px solid var(--line-2);
  border-radius: var(--r1);
  font: var(--fs-xs)/1.3 var(--font-mono);
  color: var(--fg-2);
  text-align: center;
  transition: color .15s var(--ease), border-color .15s var(--ease);
}

.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--s2); }
.rail-stat {
  display: flex; align-items: center; gap: var(--s2);
  font: var(--fs-sm)/1.3 var(--font-mono);
  color: var(--fg-1);
  min-width: 0;
}
.rail-stat-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-hint { font-size: var(--fs-xs); color: var(--fg-2); display: flex; align-items: center; gap: var(--s1); }

.dot { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 auto; background: var(--fg-2); }
.dot-ok   { background: var(--up);   box-shadow: 0 0 6px var(--up); }
.dot-bad  { background: var(--down); box-shadow: 0 0 6px var(--down); }
.dot-idle { background: var(--fg-2); }
.dot-warn { background: var(--accent); box-shadow: 0 0 6px var(--accent); }

/* ============================ MAIN ============================ */

.main { position: relative; min-width: 0; overflow: hidden; }

.busybar {
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: transparent; z-index: 40; pointer-events: none;
}
.busybar.is-busy::after {
  content: ""; position: absolute; inset: 0 auto 0 0;
  width: 30%; background: var(--accent);
  animation: slide 1s var(--ease) infinite;
}
@keyframes slide { 0% { left: -30%; } 100% { left: 100%; } }

/* =========================== LOGIN =========================== */

.loginview {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 500px at 70% -10%, rgba(255,176,46,.08), transparent 60%),
    radial-gradient(700px 420px at 15% 110%, rgba(87,164,255,.07), transparent 60%),
    var(--bg);
  padding: var(--s4);
}
.login-card {
  width: 336px; max-width: 100%;
  display: flex; flex-direction: column; gap: var(--s3);
  padding: var(--s6) var(--s5);
  background: color-mix(in srgb, var(--bg-1) 92%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line-2);
  border-radius: var(--r3);
  box-shadow: var(--sh-3), inset 0 1px 0 rgba(255,255,255,.04);
}
.login-brand { display: flex; align-items: baseline; gap: var(--s2); }
.login-brand .brand-mark { font-size: var(--fs-xl); }
.login-name {
  font-size: var(--fs-xl); font-weight: 650; letter-spacing: .02em;
  background: linear-gradient(100deg, var(--accent-2), var(--accent) 55%, var(--fg));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-sub {
  font: var(--fs-sm)/1.4 var(--font-mono);
  color: var(--fg-2);
  margin-top: -6px;
}
.login-btn {
  display: flex;
  justify-content: center;
  padding: 8px 10px;
  font-weight: 650;
}
.login-hint { font-size: var(--fs-sm); color: var(--fg-2); text-align: center; }

.view {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  min-width: 0;
  padding: var(--s4);
  gap: var(--s3);
}

.viewhead {
  display: flex;
  align-items: center;
  gap: var(--s3);
  flex-wrap: wrap;
  flex: 0 0 auto;
}
.viewhead-gap { flex: 1 1 auto; }
.viewtitle {
  font-size: var(--fs-md);
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--fg);
  padding-right: var(--s2);
  border-right: 1px solid var(--line);
  text-shadow: 0 0 18px rgba(255,176,46,.15);
}
.metaline {
  font: var(--fs-sm)/1.4 var(--font-mono);
  color: var(--fg-2);
  display: flex; gap: var(--s3); flex-wrap: wrap;
}
.metaline b { color: var(--fg-1); font-weight: 500; }

/* ------------------------- controls ------------------------- */

.btn {
  padding: 5px 11px;
  background: linear-gradient(180deg, var(--bg-3), var(--bg-2));
  border: 1px solid var(--line-2);
  border-radius: var(--r2);
  color: var(--fg);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: .02em;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--sh-1);
  transition: background .15s var(--ease), border-color .15s var(--ease),
              transform .08s var(--ease), box-shadow .15s var(--ease), color .15s var(--ease);
}
.btn:hover { background: linear-gradient(180deg, #232c3c, var(--bg-3)); border-color: #3d4a5e; }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-accent {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border-color: #8a6214;
  color: #241a04;
  font-weight: 650;
  box-shadow: var(--sh-1), 0 0 12px rgba(255,176,46,.18);
}
.btn-accent:hover {
  background: linear-gradient(180deg, #ffc75e, var(--accent));
  border-color: var(--accent-2);
  box-shadow: var(--sh-1), 0 0 18px rgba(255,176,46,.3);
}
.btn-ghost { background: transparent; border-color: var(--line); color: var(--fg-1); box-shadow: none; }
.btn-ghost:hover { color: var(--fg); background: var(--bg-2); }
.btn-danger { background: linear-gradient(180deg, #4a242e, var(--down-lo)); border-color: #5c2b34; color: #ff8b96; }
.btn-danger:hover { background: #48222a; border-color: var(--down); }
.btn-xs { padding: 2px 6px; font-size: var(--fs-xs); }
.field-suffix {
  font: var(--fs-sm)/1.3 var(--font-mono);
  color: var(--accent);
  white-space: nowrap;
}

.seg {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r2);
  padding: 2px;
  gap: 2px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.3);
}
.seg button {
  padding: 3px 12px;
  background: none;
  border: 0;
  border-radius: var(--r1);
  color: var(--fg-1);
  font-size: var(--fs-sm);
  letter-spacing: .04em;
  cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease);
}
.seg button:hover { color: var(--fg); }
.seg button.is-active {
  background: linear-gradient(180deg, var(--bg-3), var(--bg-2));
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--sh-1), inset 0 0 0 1px var(--line-2);
}

.input {
  width: 100%;
  padding: 5px 8px;
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: var(--r2);
  color: var(--fg);
  font: var(--fs-md)/1.4 var(--font-mono);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input:hover { border-color: #3a485e; }
.input:focus { border-color: var(--accent); outline: none; box-shadow: var(--ring); }
.input-sm { width: 74px; }
select.input { font-family: var(--font-sans); font-size: var(--fs-sm); }

.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field-inline { flex-direction: row; align-items: center; gap: var(--s2); }
.field-label {
  font: var(--fs-xs)/1.3 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--fg-2);
  white-space: nowrap;
}
.field-hint { font: var(--fs-xs)/1.3 var(--font-mono); color: var(--fg-2); height: 12px; }

/* -------------------------- panels -------------------------- */

.panel {
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg-1) 96%, var(--bg-2)), var(--bg-1));
  border: 1px solid var(--line);
  border-radius: var(--r3);
  padding: var(--s3);
  min-width: 0;
  box-shadow: var(--sh-1);
}
.panel-title {
  font-size: var(--fs-sm);
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--fg-1);
  margin-bottom: var(--s3);
  padding-bottom: var(--s2);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: baseline; gap: var(--s2);
}
.panel-title-note { font: var(--fs-xs)/1 var(--font-mono); color: var(--fg-2); letter-spacing: 0; text-transform: none; }

.params { flex: 0 0 auto; }
.paramgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: var(--s3);
}
.paramfoot {
  display: flex; align-items: center; gap: var(--s2);
  margin-top: var(--s3);
  padding-top: var(--s3);
  border-top: 1px solid var(--line);
}
.paramfoot-note { flex: 1 1 auto; font: var(--fs-xs)/1.4 var(--font-mono); color: var(--fg-2); }

/* ========================== TABLES ========================== */

.tablewrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r3);
  box-shadow: var(--sh-1);
}
.grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font: var(--fs-md)/1.35 var(--font-mono);
  white-space: nowrap;
}
.grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(180deg, var(--bg-3), var(--bg-2));
  border-bottom: 1px solid var(--line-2);
  padding: var(--s2) var(--s3);
  font: var(--fs-xs)/1.3 var(--font-mono);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--fg-1);
  text-align: left;
  user-select: none;
  box-shadow: 0 1px 0 rgba(0,0,0,.25);
}
.grid thead th.is-sortable { cursor: pointer; }
.grid thead th.is-sortable:hover { color: var(--fg); }
.grid thead th.is-sorted { color: var(--accent); }
.grid thead th .caret { opacity: .6; margin-left: 3px; }
.grid th.num, .grid td.num { text-align: right; font-variant-numeric: tabular-nums; }

.grid tbody td {
  padding: 5px var(--s3);
  border-bottom: 1px solid var(--line);
  color: var(--fg);
  transition: background .1s var(--ease);
}
.grid tbody tr.row { cursor: pointer; }
.grid tbody tr.row:hover td { background: var(--bg-3); }
.grid tbody tr.row.is-open td { background: var(--bg-2); }
.grid tbody tr:last-child td { border-bottom: 0; }

.c-sym { font-weight: 600; letter-spacing: .02em; }
.c-sym .sector { display: block; font-size: var(--fs-xs); color: var(--fg-2); font-weight: 400; letter-spacing: 0; }
.c-name {
  max-width: 210px; overflow: hidden; text-overflow: ellipsis;
  font-family: var(--font-sans); color: var(--fg-1);
}
.up   { color: var(--up); }
.down { color: var(--down); }
.zero { color: var(--fg-2); }
.nil  { color: var(--fg-2); }

.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font: var(--fs-xs)/1.5 var(--font-mono);
  letter-spacing: .06em;
  border: 1px solid transparent;
  transition: filter .12s var(--ease), transform .12s var(--ease);
}
.chip:hover { filter: brightness(1.25); }
.chip-up   { background: var(--up-lo);   color: var(--up);   border-color: #17553f; }
.chip-down { background: var(--down-lo); color: var(--down); border-color: #63303a; }
.chip-flat { background: var(--bg-3);    color: var(--fg-1); border-color: var(--line-2); }
.chip-warn { background: var(--accent-lo); color: var(--accent); border-color: #6b4d15; }
.chip-info { background: var(--blue-lo); color: var(--blue); border-color: #23446b; }

.expander {
  width: 18px; padding: 0 !important; text-align: center;
  color: var(--fg-2); cursor: pointer; user-select: none;
}
.expander:hover { color: var(--accent); }

tr.detail td { background: var(--bg-2) !important; padding: var(--s3) var(--s5) !important; }
.detailgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--s2) var(--s4);
  white-space: normal;
}
.detailgrid div { display: flex; justify-content: space-between; gap: var(--s2); border-bottom: 1px dotted var(--line-2); padding-bottom: 2px; }
.detailgrid span { color: var(--fg-2); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; }

/* percentile bar */
.pctcell { display: inline-flex; align-items: center; gap: var(--s2); justify-content: flex-end; vertical-align: middle; }
.pbar {
  position: relative;
  width: 46px; height: 5px;
  background: var(--bg-3);
  border-radius: 3px;
  overflow: hidden;
  flex: 0 0 auto;
}
.pbar > i { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 3px; display: block; }
.pbar-lg { width: 100%; height: 6px; }
.pbar-lg > i { background: var(--blue); transition: width .3s var(--ease); }
.pbar-ok > i { background: var(--up); }
.pbar-bad > i { background: var(--down); }

.placeholder {
  flex: 0 0 auto;
  padding: var(--s6) var(--s4);
  text-align: center;
  color: var(--fg-2);
  font-size: var(--fs-md);
  border: 1px dashed var(--line-2);
  border-radius: var(--r3);
}
.placeholder strong { display: block; color: var(--fg-1); font-size: var(--fs-lg); margin-bottom: var(--s2); font-weight: 600; }
.placeholder .btn { margin-top: var(--s3); }

/* ==================== SCREENER CONTROL BAR ==================== */

.ctlbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s2) var(--s4);
  padding: var(--s2) var(--s3);
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r3);
}
.ctl-count {
  font: var(--fs-sm)/1.4 var(--font-mono);
  color: var(--fg-2);
  white-space: nowrap;
}
.ctl-count b { color: var(--fg); font-weight: 600; }
.ctl-count i { color: var(--line-2); font-style: normal; margin: 0 var(--s2); }

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 108px;
  height: 4px;
  margin: 0;
  background: var(--bg-3);
  border-radius: 2px;
  cursor: pointer;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px; height: 12px;
  border: 0; border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
.slider::-moz-range-thumb {
  width: 12px; height: 12px;
  border: 0; border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
.slider:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }

/* ===================== SCREENER GALLERY ======================
   One chart card per stock across the whole universe. The match
   percentage is the loudest thing on the card; everything else
   exists to explain or qualify it. */

.gallery {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
.galgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--s3);
  align-content: start;
}
.galfoot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s3);
  min-height: 56px;
  padding: var(--s4) 0 var(--s2);
}
.galfoot-note { font: var(--fs-sm)/1.4 var(--font-mono); color: var(--fg-2); }

.gcard {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg-1) 96%, var(--bg-2)), var(--bg-1));
  border: 1px solid var(--line);
  border-radius: var(--r3);
  cursor: pointer;
  box-shadow: var(--sh-1);
  transition: border-color .15s var(--ease), background .15s var(--ease),
              transform .15s var(--ease), box-shadow .15s var(--ease);
}
.gcard:hover {
  background: var(--bg-2);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line-2));
  transform: translateY(-2px);
  box-shadow: var(--sh-2);
}
.gcard.is-converging { box-shadow: inset 3px 0 0 var(--accent), var(--sh-1); }
.gcard.is-pinned { box-shadow: inset 3px 0 0 var(--blue), var(--sh-1); }

/* Bookmark toggle: a bookmark glyph drawn in pure CSS (clip-path), no image. */
.bm-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 6px;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--r1);
  color: var(--fg-2);
  font-size: var(--fs-xs);
  cursor: pointer;
  flex: 0 0 auto;
}
.bm-toggle:hover { color: var(--fg); border-color: var(--line-2); }
.bm-toggle:disabled { opacity: .4; cursor: not-allowed; }
.bm-icon {
  width: 9px; height: 12px;
  display: inline-block;
  background: var(--fg-2);
  opacity: .45;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%);
  transition: opacity .12s var(--ease);
}
.bm-toggle:hover .bm-icon { opacity: .9; }
.bm-toggle.is-on { color: var(--accent); border-color: #6b4d15; }
.bm-toggle.is-on .bm-icon { background: var(--accent); opacity: 1; }

.gcard-top {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: baseline;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--line);
}
.gcard-sym { font: var(--fs-lg)/1.3 var(--font-mono); font-weight: 600; letter-spacing: .04em; }
.gcard-name {
  min-width: 0;
  font-size: var(--fs-sm);
  color: var(--fg-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gcard-px {
  display: flex; align-items: baseline; gap: var(--s2);
  font: var(--fs-sm)/1.3 var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.gcard-match { padding: var(--s3) var(--s3) var(--s2); }
.gm-head { display: flex; align-items: baseline; gap: var(--s2); }
.gm-num {
  font: 600 28px/1 var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.gm-num i { font-size: var(--fs-md); font-style: normal; opacity: .65; margin-left: 1px; }
.gm-lab {
  flex: 1 1 auto;
  min-width: 0;
  font: var(--fs-xs)/1.4 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--fg-2);
}
.gm-toggle {
  flex: 0 0 auto;
  padding: 1px 6px;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--r1);
  color: var(--fg-2);
  font-size: var(--fs-xs);
  cursor: pointer;
}
.gm-toggle:hover { color: var(--fg); border-color: var(--line-2); }
.gm-bar {
  height: 6px;
  margin-top: var(--s2);
  background: var(--bg-3);
  border-radius: 3px;
  overflow: hidden;
}
.gm-bar > i { display: block; height: 100%; border-radius: 3px; transition: width .3s var(--ease); }

.gm-parts { display: flex; flex-direction: column; gap: 3px; margin-top: var(--s2); }
.gm-part {
  display: grid;
  grid-template-columns: 96px 1fr 24px 26px;
  align-items: center;
  gap: var(--s2);
  font: var(--fs-xs)/1.5 var(--font-mono);
  color: var(--fg-2);
}
.gm-part-k { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-part-bar { height: 4px; background: var(--bg-3); border-radius: 2px; overflow: hidden; }
.gm-part-bar > i { display: block; height: 100%; border-radius: 2px; }
.gm-part-v { text-align: right; color: var(--fg-1); font-variant-numeric: tabular-nums; }
.gm-part-w { text-align: right; opacity: .65; }

.gcard-chips {
  display: flex; flex-wrap: wrap; gap: var(--s1) var(--s2);
  min-height: 18px;
  padding: 0 var(--s3) var(--s2);
  font-size: var(--fs-xs);
}

/* Reserved before the canvas mounts, so scrolling never reflows the grid. */
.gcard-cv {
  height: 164px;
  background: var(--bg);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.gcard-canvas { display: block; width: 100%; height: 100%; }

.gcard-foot {
  display: flex; flex-wrap: wrap; gap: var(--s1) var(--s2);
  padding: var(--s2) var(--s3);
  font: var(--fs-xs)/1.6 var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--fg-2);
}
/* fundamentals line: its own row under the trade stats */
.gcard-fund {
  flex-basis: 100%;
  color: var(--fg-1);
}

/* ========================= SEARCH ========================= */

.search { position: relative; width: 260px; }
.search-sm { width: 196px; }
.search-input { padding-left: 22px; }
.search::before {
  content: "/";
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  color: var(--fg-2); font: var(--fs-md)/1 var(--font-mono); pointer-events: none;
}
.dropdown {
  position: absolute; z-index: 30; top: calc(100% + 3px); left: 0; right: 0;
  max-height: 280px; overflow: auto;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r2);
  box-shadow: 0 8px 24px rgba(0,0,0,.6);
}
.dd-item {
  display: flex; align-items: baseline; gap: var(--s2);
  padding: var(--s2) var(--s3);
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.dd-item:last-child { border-bottom: 0; }
.dd-item:hover, .dd-item.is-cursor { background: var(--bg-3); }
.dd-sym { font: var(--fs-md)/1.3 var(--font-mono); font-weight: 600; }
.dd-name { flex: 1 1 auto; font-size: var(--fs-sm); color: var(--fg-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-meta { font: var(--fs-xs)/1.3 var(--font-mono); color: var(--fg-2); }
.dd-empty { padding: var(--s3); color: var(--fg-2); font-size: var(--fs-sm); }

/* ========================== CHART ========================== */

/* The chart never collapses below a usable height; the view scrolls instead. */
#view-chart { overflow-y: auto; }

.chartpanel {
  flex: 0 0 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r3);
  overflow: hidden;
}
.legend {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1) var(--s4);
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  font: var(--fs-sm)/1.4 var(--font-mono);
  color: var(--fg-1);
  min-height: 28px;
}
.legend .lg { display: inline-flex; gap: 5px; align-items: baseline; }
.legend .lg-k { color: var(--fg-2); text-transform: uppercase; letter-spacing: .08em; font-size: var(--fs-xs); }
.legend .lg-sym { font-weight: 700; color: var(--fg); letter-spacing: .04em; }
.legend .swatch { width: 8px; height: 2px; align-self: center; display: inline-block; }

.chartwrap {
  position: relative;
  flex: 0 0 auto;
  height: clamp(480px, 62vh, 860px);
  cursor: crosshair;
  touch-action: none;
}
.chartwrap.is-panning { cursor: grabbing; }
.cv { display: block; width: 100%; }
.cv-price { height: 62%; }
.cv-ind { height: 38%; border-top: 1px solid var(--line); }
.cv-overlay { position: absolute; inset: 0; height: 100%; pointer-events: none; }
.chartempty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: var(--s2);
  padding: var(--s4);
  text-align: center;
  color: var(--fg-2); font-size: var(--fs-md);
  background: var(--bg-1);
}

.statstrip {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 6px;
  background: transparent;
  border: 0;
  border-radius: 0;
  overflow: visible;
}
.stat {
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg-1) 96%, var(--bg-2)), var(--bg-1));
  padding: var(--s2) var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--r2);
  box-shadow: var(--sh-1);
  transition: border-color .12s var(--ease);
}
.stat:hover { border-color: var(--line-2); }
.stat-k {
  display: block;
  font: var(--fs-xs)/1.4 var(--font-mono);
  text-transform: uppercase; letter-spacing: .1em; color: var(--fg-2);
}
.stat-v { font: var(--fs-lg)/1.4 var(--font-mono); font-variant-numeric: tabular-nums; }

/* ======================== BEST PICKS ======================== */

.cards {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--s3);
  align-content: start;
}
.card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r3);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.card-head {
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  border-radius: var(--r3) var(--r3) 0 0;
}
.card-title {
  display: flex; align-items: baseline; gap: var(--s2);
  font-size: var(--fs-md); font-weight: 600;
  text-transform: uppercase; letter-spacing: .12em;
}
.card-title em { font: var(--fs-xs)/1 var(--font-mono); font-style: normal; color: var(--accent); letter-spacing: .06em; }
.card-params { margin-top: 3px; font: var(--fs-xs)/1.5 var(--font-mono); color: var(--fg-2); }

.pick {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  gap: 2px var(--s2);
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  align-items: baseline;
}
.pick:last-child { border-bottom: 0; }
.pick:hover { background: var(--bg-3); }
.pick-rank { font: var(--fs-xs)/1.6 var(--font-mono); color: var(--fg-2); }
.pick-sym { font: var(--fs-lg)/1.3 var(--font-mono); font-weight: 600; }
.pick-score { font: var(--fs-lg)/1.3 var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
.pick-name {
  grid-column: 2 / 3;
  font-size: var(--fs-sm); color: var(--fg-1);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pick-meta {
  grid-column: 2 / 4;
  display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3);
  font: var(--fs-xs)/1.6 var(--font-mono); color: var(--fg-2);
  margin-top: 2px;
}
.pick-meta b { font-weight: 500; }
.card-empty { padding: var(--s4); color: var(--fg-2); font-size: var(--fs-sm); text-align: center; }

/* ========================== JOBS =========================== */

.datagrid {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: var(--s3);
  align-content: start;
}
.kv { display: grid; grid-template-columns: auto 1fr; gap: var(--s2) var(--s3); font: var(--fs-md)/1.5 var(--font-mono); }
.kv dt { color: var(--fg-2); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .1em; align-self: center; }
.kv dd { text-align: right; overflow: hidden; text-overflow: ellipsis; }

.joblist { display: flex; flex-direction: column; gap: var(--s2); }
.job {
  border: 1px solid var(--line);
  border-radius: var(--r2);
  padding: var(--s2) var(--s3);
  background: var(--bg);
}
.job-head { display: flex; align-items: center; gap: var(--s2); font: var(--fs-sm)/1.5 var(--font-mono); }
.job-kind { font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.job-msg { flex: 1 1 auto; color: var(--fg-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-count { color: var(--fg-2); font-variant-numeric: tabular-nums; }
.job .pbar { width: 100%; margin-top: 5px; }
.job-err { margin-top: var(--s1); color: var(--down); font: var(--fs-xs)/1.5 var(--font-mono); white-space: pre-wrap; }

.jobcard { flex: 0 0 auto; }
.jobcard-head { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s2); font: var(--fs-sm)/1.5 var(--font-mono); }
.jobcard-msg { flex: 1 1 auto; color: var(--fg-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jobcard-count { color: var(--fg-2); font-variant-numeric: tabular-nums; }

/* ========================== TOASTS ========================== */

.toasts {
  position: fixed; z-index: 100; right: var(--s4); bottom: var(--s4);
  display: flex; flex-direction: column; gap: var(--s2);
  max-width: 380px;
}
.toast {
  display: flex; gap: var(--s2);
  padding: var(--s2) var(--s3);
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--fg-2);
  border-radius: var(--r2);
  box-shadow: var(--sh-2);
  font-size: var(--fs-sm);
  animation: toastin .2s var(--ease-out);
}
.toast.is-ok    { border-left-color: var(--up); }
.toast.is-error { border-left-color: var(--down); }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }
.toast-err  { border-left-color: var(--down); }
.toast-ok   { border-left-color: var(--up); }
.toast-info { border-left-color: var(--blue); }
.toast-tag {
  font: var(--fs-xs)/1.6 var(--font-mono);
  text-transform: uppercase; letter-spacing: .1em; color: var(--fg-2);
  flex: 0 0 auto;
}
.toast-msg { flex: 1 1 auto; word-break: break-word; }
.toast-x { background: none; border: 0; color: var(--fg-2); cursor: pointer; padding: 0 2px; line-height: 1; }
.toast-x:hover { color: var(--fg); }

/* ====================== DECISION PANEL ====================== */

.decision {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: var(--s3) var(--s5);
  align-items: start;
  padding: var(--s3) var(--s4);
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg-1) 96%, var(--bg-2)), var(--bg-1));
  border: 1px solid var(--line);
  border-left: 3px solid var(--fg-2);
  border-radius: var(--r3);
  box-shadow: var(--sh-1);
}
.decision.act-BUY,  .decision.act-WATCH { border-left-color: var(--up); }
.decision.act-SELL, .decision.act-AVOID { border-left-color: var(--down); }
.decision.act-HOLD  { border-left-color: var(--accent); }

.dc-action { min-width: 132px; }
.dc-word {
  display: block;
  font: 700 var(--fs-2xl)/1.1 var(--font-sans);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.act-BUY   .dc-word, .act-WATCH .dc-word { color: var(--up); }
.act-SELL  .dc-word, .act-AVOID .dc-word { color: var(--down); }
.act-HOLD  .dc-word { color: var(--accent); }
.dc-score { font: var(--fs-xs)/1.6 var(--font-mono); color: var(--fg-2); text-transform: uppercase; letter-spacing: .1em; }

.meter { margin-top: var(--s2); width: 132px; }
.meter-k { display: flex; justify-content: space-between; font: var(--fs-xs)/1.5 var(--font-mono); color: var(--fg-2); }
.meter-bar { height: 5px; background: var(--bg-3); border-radius: 3px; overflow: hidden; margin-top: 2px; }
.meter-bar > i { display: block; height: 100%; background: var(--accent); }

.dc-figs {
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: var(--s1) var(--s4);
  font: var(--fs-md)/1.5 var(--font-mono);
  white-space: nowrap;
}
.dc-figs dt { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .1em; color: var(--fg-2); align-self: center; }
.dc-figs dd { text-align: right; font-variant-numeric: tabular-nums; }

.dc-reasons { margin: 0; padding-left: 15px; font-size: var(--fs-sm); color: var(--fg-1); }
.dc-reasons li { margin-bottom: 2px; }
.dc-empty { color: var(--fg-2); font-size: var(--fs-sm); }
.dc-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-top: var(--s1);
  padding-top: var(--s2);
  border-top: 1px dotted var(--line);
}
.plan-name-input { width: 200px; }

/* ================== BANNERS / NOTICES / CALLOUTS ================== */

.banner {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s3);
  background: var(--accent-lo);
  border: 1px solid #6b4d15;
  border-radius: var(--r2);
  font-size: var(--fs-sm);
}
.banner-tag {
  font: var(--fs-xs)/1.6 var(--font-mono);
  text-transform: uppercase; letter-spacing: .12em; color: var(--accent);
  flex: 0 0 auto;
}
.banner-msg { flex: 1 1 auto; color: var(--fg); }

.notice {
  flex: 0 0 auto;
  padding: var(--s2) var(--s3);
  border-left: 2px solid var(--blue);
  background: var(--blue-lo);
  border-radius: 0 var(--r2) var(--r2) 0;
  font-size: var(--fs-sm);
  color: var(--fg-1);
}

.callout {
  flex: 0 0 auto;
  padding: var(--s3);
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-left: 3px solid var(--fg-2);
  border-radius: var(--r3);
}
.callout.v-adopt   { border-left-color: var(--up); }
.callout.v-reject  { border-left-color: var(--down); }
.callout.v-neutral { border-left-color: var(--accent); }
.callout-head { display: flex; align-items: baseline; gap: var(--s2); margin-bottom: var(--s1); }
.callout-label { font-size: var(--fs-lg); font-weight: 600; }
.callout-body { font-size: var(--fs-sm); color: var(--fg-1); }

/* ========================= LAB TABLE ========================= */

.grid tbody tr.is-baseline td {
  background: var(--bg-2);
  border-bottom: 1px solid var(--line-2);
  font-weight: 600;
}
.ov-label { font-family: var(--font-sans); font-weight: 600; }
.ov-desc {
  display: block; max-width: 340px;
  font: var(--fs-xs)/1.4 var(--font-sans); color: var(--fg-2);
  white-space: normal; font-weight: 400;
}
.ov-active { margin-left: var(--s2); }

/* signed uplift bar: centre line, growing left (red) or right (green) */
.upcell { display: flex; align-items: center; gap: var(--s2); justify-content: flex-end; }
.upbar {
  position: relative; width: 72px; height: 6px; flex: 0 0 auto;
  background: var(--bg-3); border-radius: 2px; overflow: hidden;
}
.upbar::before {
  content: ""; position: absolute; left: 50%; top: 0; bottom: 0;
  width: 1px; background: var(--line-2);
}
.upbar > i { position: absolute; top: 0; bottom: 0; display: block; }
.upbar > i.pos { left: 50%; background: var(--up); }
.upbar > i.neg { right: 50%; background: var(--down); }

/* ==================== CHART CANVAS TOOLTIP ==================== */

.canvastip {
  position: absolute; z-index: 12;
  max-width: 320px;
  padding: var(--s2) var(--s3);
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-left: 2px solid var(--blue);
  border-radius: var(--r2);
  box-shadow: 0 8px 22px rgba(0,0,0,.6);
  font-size: var(--fs-sm);
  color: var(--fg);
  pointer-events: none;
  white-space: normal;
}
.canvastip b {
  display: block;
  font: var(--fs-xs)/1.6 var(--font-mono);
  text-transform: uppercase; letter-spacing: .1em; color: var(--blue);
}
/* ========================= SIMULASI ========================= */

.input-md { width: 132px; }
.btn.is-on { border-color: #6b4d15; color: var(--accent); }

.simscroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

/* hero: one sentence of arithmetic, nothing else */
.hero {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s2) var(--s5);
  align-items: center;
  padding: var(--s4);
  background:
    radial-gradient(600px 120px at 20% 0%, rgba(255,176,46,.05), transparent 60%),
    linear-gradient(180deg, color-mix(in srgb, var(--bg-1) 96%, var(--bg-2)), var(--bg-1));
  border: 1px solid var(--line);
  border-radius: var(--r3);
  box-shadow: var(--sh-1);
}
.hero-main {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s2) var(--s3);
  font: var(--fs-2xl)/1.2 var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.hero-k {
  font: var(--fs-xs)/1.6 var(--font-mono);
  text-transform: uppercase; letter-spacing: .14em; color: var(--fg-2);
}
.hero-from { color: var(--fg-1); }
.hero-arrow { color: var(--fg-2); }
.hero-to { font-weight: 700; }
.hero-figs {
  display: flex; gap: var(--s5);
  margin: 0;
  font: var(--fs-md)/1.4 var(--font-mono);
}
.hero-figs div { text-align: right; }
.hero-figs dt {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .12em; color: var(--fg-2);
}
.hero-figs dd { margin: 0; font-size: var(--fs-xl); font-variant-numeric: tabular-nums; }
.hero-meta {
  grid-column: 1 / -1;
  font: var(--fs-sm)/1.5 var(--font-mono);
  color: var(--fg-2);
}

/* win / loss / draw scoreboard */
.scoreboard {
  flex: 0 0 auto;
  padding: var(--s3) var(--s4);
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg-1) 96%, var(--bg-2)), var(--bg-1));
  border: 1px solid var(--line);
  border-radius: var(--r3);
  box-shadow: var(--sh-1);
}
.sb-counts { display: flex; gap: var(--s6); align-items: flex-end; }
.sb { display: flex; flex-direction: column; }
.sb-n { font: 700 28px/1 var(--font-mono); font-variant-numeric: tabular-nums; }
.sb-k {
  font: var(--fs-xs)/1.8 var(--font-mono);
  text-transform: uppercase; letter-spacing: .18em; color: var(--fg-2);
}
.sb.up .sb-n { color: var(--up); }
.sb.down .sb-n { color: var(--down); }
.sb.flat .sb-n { color: var(--fg-1); }
.sb-rate { margin-left: auto; text-align: right; }
.sb-rate .sb-n { color: var(--accent); }

.sb-bar {
  display: flex;
  height: 10px;
  margin-top: var(--s3);
  border-radius: 2px;
  overflow: hidden;
  background: var(--bg-3);
}
.sb-bar > i { display: block; height: 100%; }
.sb-bar > i.w { background: var(--up); }
.sb-bar > i.l { background: var(--down); }
.sb-bar > i.d { background: var(--fg-2); }
.sb-legend {
  margin-top: var(--s2);
  font: var(--fs-sm)/1.5 var(--font-mono);
  color: var(--fg-2);
}
.sb-legend b { color: var(--fg-1); font-weight: 500; }

.chartpanel-sim { flex: 0 0 auto; height: 340px; }
.chartwrap-sim { cursor: crosshair; }
.cv-eq { height: 74%; }
.cv-dd { height: 26%; border-top: 1px solid var(--line); }

.simgrid {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: var(--s3);
  align-items: start;
}
.tablewrap-inline {
  max-height: 340px;
  border-radius: var(--r2);
}
.simgrid .panel { padding: var(--s3) var(--s3) var(--s2); min-width: 0; }

/* ======================= JURNAL (SIM VIEW) =======================
   Real fills, FIFO positions, holding-period maths. No sentiment. */

.journal { flex: 0 0 auto; }
.journal-form {
  display: flex; align-items: flex-end; gap: var(--s2) var(--s4);
  flex-wrap: wrap;
  padding: var(--s2) var(--s3);
  margin-bottom: var(--s3);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r2);
}
.journal-form .field-suffix { font-size: var(--fs-xs); }
.journal-note { flex: 1 1 160px; }
.journal-note .input { min-width: 120px; }
.journal-sub {
  margin: var(--s3) 0 var(--s2);
  font-size: var(--fs-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: .14em;
  color: var(--fg-1);
}
.jnote { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jdel-col { width: 64px; text-align: right; }
.jdel-col .jdel { padding: 1px 6px; }

/* the holding-period answer: "khas 5 hari · sisa 2 hari (~11 Agu)" + meter */
.holdplan { display: inline-flex; flex-direction: column; gap: 2px; min-width: 150px; }
.holdplan > span:first-child { font-size: var(--fs-xs); color: var(--fg-1); }
.holdplan .pbar { width: 120px; height: 4px; }
.holdplan .pbar > i.up { background: var(--up); }
.holdplan .pbar > i.down { background: var(--down); }

/* row emphasis for the pre-cross convergence setup */
.grid tbody tr.row.is-converging td:first-child {
  box-shadow: inset 2px 0 0 var(--accent);
}

/* ====================== MARKET CLOCK PILL ====================== */

.mkt {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font: var(--fs-xs)/1.6 var(--font-mono);
  color: var(--fg-1);
  white-space: nowrap;
  flex: 0 0 auto;
}
.mkt.is-open   { border-color: #17553f; color: var(--up); }
.mkt.is-soon   { border-color: #6b4d15; color: var(--accent); }
.mkt.is-closed { color: var(--fg-2); }

/* =================== MARKET-MODE REGIME PILL ===================
   One chip, two homes (top bar + Simulasi banner), painted from
   /api/health regime. Green = IHSG above its 200-day SMA (buying
   regime), amber = below it (the researched method stands down). */

.regime-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font: var(--fs-xs)/1.6 var(--font-mono);
  color: var(--fg-1);
  white-space: nowrap;
  flex: 0 0 auto;
}
.regime-pill.is-up   { background: var(--up-lo);   border-color: #17553f; color: var(--up); }
.regime-pill.is-down { background: var(--accent-lo); border-color: #6b4d15; color: var(--accent); }

/* The header copy is a squeeze-taker, like the as-of label: it ellipsizes
   before the top bar lets the grid overflow, so the chip never forces a
   horizontal scrollbar on its own. */
#hdrRegime {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
}

.regime-row {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.regime-note {
  flex: 0 0 auto;
  font: var(--fs-xs)/1.5 var(--font-mono);
  color: var(--fg-2);
}

/* ======================== NOTIFIKASI ======================== */

.notifygrid {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--s3);
  align-content: start;
}
.notifygrid-full { grid-column: 1 / -1; }

/* alert builder + list + history */
.alert-form {
  display: flex;
  align-items: flex-end;
  gap: var(--s2) var(--s4);
  flex-wrap: wrap;
  padding: var(--s2) var(--s3);
  margin-bottom: var(--s3);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r2);
}
.alert-list { display: flex; flex-direction: column; }
.alert-item {
  display: flex;
  align-items: center;
  gap: var(--s2) var(--s3);
  flex-wrap: wrap;
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--line);
  font: var(--fs-sm)/1.5 var(--font-mono);
}
.alert-item:last-child { border-bottom: 0; }
.alert-item.is-arming { background: var(--down-lo); }
.alert-item .a-sym { font-weight: 600; letter-spacing: .02em; }
.alert-item .a-kind {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--fg-2);
}
.alert-item .a-op { color: var(--fg-2); }
.alert-item .a-val { color: var(--fg-1); font-variant-numeric: tabular-nums; }
.alert-item .a-tf { color: var(--fg-2); }
.alert-item .a-grow { flex: 1 1 auto; }
.alert-empty { padding: var(--s3); color: var(--fg-2); font-size: var(--fs-sm); }

/* active switch — same shape language as the segmented control */
.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 26px; height: 14px;
  margin: 0;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background .12s var(--ease);
}
.switch::after {
  content: "";
  position: absolute; top: 1px; left: 1px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--fg-2);
  transition: left .12s var(--ease), background .12s var(--ease);
}
.switch:checked { background: var(--accent-lo); border-color: #6b4d15; }
.switch:checked::after { left: 13px; background: var(--accent); }
.switch:disabled { opacity: .55; cursor: not-allowed; }

.hist-item {
  display: flex;
  align-items: baseline;
  gap: var(--s3);
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--line);
  font: var(--fs-sm)/1.5 var(--font-mono);
}
.hist-item:last-child { border-bottom: 0; }
.hist-item .h-time { flex: 0 0 auto; color: var(--fg-2); font-size: var(--fs-xs); }
.hist-item .h-msg { color: var(--fg-1); }

.alertrow-actions {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin-top: var(--s2);
}

/* desk accounts (admin only) */
.user-form {
  display: flex;
  align-items: flex-end;
  gap: var(--s2) var(--s4);
  flex-wrap: wrap;
  padding: var(--s2) var(--s3);
  margin-bottom: var(--s3);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r2);
}
.reveal {
  display: flex;
  align-items: center;
  gap: var(--s2) var(--s3);
  flex-wrap: wrap;
  margin-bottom: var(--s3);
  padding: var(--s2) var(--s3);
  background: var(--blue-lo);
  border: 1px solid #23446b;
  border-radius: var(--r2);
  font: var(--fs-sm)/1.5 var(--font-mono);
}
.reveal-k {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--fg-2);
}
.reveal code {
  color: var(--accent);
  background: var(--bg);
  padding: 1px 6px;
  border-radius: var(--r1);
  word-break: break-all;
}
#ntUsersBody .pass-input { width: 118px; }
.notifyrow {
  display: flex; gap: var(--s4); align-items: flex-end; flex-wrap: wrap;
  margin-top: var(--s3);
}

/* multi-select: same visual language as .seg, but several can be on */
.multiseg {
  display: inline-flex; flex-wrap: wrap; gap: 2px;
  padding: 2px;
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: var(--r2);
}
.multiseg button {
  padding: 3px 10px;
  background: none; border: 0; border-radius: var(--r1);
  color: var(--fg-2);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.multiseg button:hover { color: var(--fg); }
.multiseg button.is-active { background: var(--accent-lo); color: var(--accent); font-weight: 600; }

.check {
  display: inline-flex; align-items: center; gap: var(--s2);
  font-size: var(--fs-sm);
  color: var(--fg-1);
  cursor: pointer;
  user-select: none;
}
.check input { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }

.statuslist { display: flex; flex-direction: column; gap: var(--s2); }
.statusrow {
  display: flex; align-items: center; gap: var(--s2);
  font: var(--fs-sm)/1.5 var(--font-mono);
}
.statusrow-k { flex: 1 1 auto; color: var(--fg-1); }
.setup {
  margin-top: var(--s3);
  padding-top: var(--s3);
  border-top: 1px solid var(--line);
  font-size: var(--fs-sm);
  color: var(--fg-1);
}
.setup code {
  font: var(--fs-sm)/1.4 var(--font-mono);
  color: var(--accent);
  background: var(--bg);
  padding: 1px 4px;
  border-radius: var(--r1);
}
.setup p { margin-top: var(--s2); color: var(--fg-2); }
.is-inert { opacity: .5; pointer-events: none; }

/* the hourly opt-in prompt, reused in several empty states */
.optin { display: flex; flex-direction: column; align-items: center; gap: var(--s2); }
.optin strong { color: var(--fg-1); font-size: var(--fs-lg); font-weight: 600; }
.optin span { color: var(--fg-2); font-size: var(--fs-md); max-width: 48ch; }
/* a job card living inside a panel: no second border, cards inside cards */
.jobcard-inline {
  margin-bottom: var(--s3);
  padding-bottom: var(--s3);
  border-bottom: 1px solid var(--line);
}

/* ===================== BERITA (CHART VIEW) =====================
   Headlines only — publisher, time, title. No sentiment anywhere. */

.news { flex: 0 0 auto; padding: 0; overflow: hidden; }
.news-head {
  display: flex; align-items: center; gap: var(--s2);
  width: 100%;
  padding: var(--s2) var(--s3);
  background: var(--bg-2);
  border: 0;
  cursor: pointer;
  text-align: left;
}
.news-head:hover { background: var(--bg-3); }
.news-head-title {
  flex: 1 1 auto;
  font-size: var(--fs-sm); font-weight: 600;
  text-transform: uppercase; letter-spacing: .14em; color: var(--fg-1);
}
.news-caret { color: var(--fg-2); transition: transform .15s var(--ease); }
.news-head[aria-expanded="false"] .news-caret { transform: rotate(-90deg); }
.news-body { padding: var(--s2) var(--s3) var(--s3); }
.news-note {
  margin: 0 0 var(--s2);
  padding: var(--s2) var(--s3);
  background: var(--bg);
  border-left: 2px solid var(--line-2);
  border-radius: 0 var(--r2) var(--r2) 0;
  font: var(--fs-xs)/1.5 var(--font-mono);
  color: var(--fg-2);
}
.news-list { display: flex; flex-direction: column; }
.news-item { padding: var(--s2) 0; border-bottom: 1px solid var(--line); }
.news-item:last-child { border-bottom: 0; }
.news-meta {
  display: flex; align-items: baseline; gap: var(--s2);
  font: var(--fs-xs)/1.5 var(--font-mono);
  color: var(--fg-2);
}
.news-meta b { color: var(--fg-1); font-weight: 600; }
.news-meta i { font-style: normal; color: var(--line-2); }
.news-title {
  display: block; margin-top: 1px;
  font-size: var(--fs-sm); color: var(--fg);
  text-decoration: none;
  line-height: 1.45;
}
a.news-title:hover { color: var(--accent); }
.news-empty { padding: var(--s3); color: var(--fg-2); font-size: var(--fs-sm); }
.news-foot { display: flex; align-items: center; gap: var(--s3); margin-top: var(--s2); }
.news-status { font: var(--fs-xs)/1.5 var(--font-mono); color: var(--fg-2); }

/* ================= RENCANA TERSIMPAN (CHART VIEW) =================
   Snapshots of the decision panel, one per user. */

.plans { flex: 0 0 auto; padding: 0; overflow: hidden; }
.plans-head {
  display: flex; align-items: center; gap: var(--s2);
  width: 100%;
  padding: var(--s2) var(--s3);
  background: var(--bg-2);
  border: 0;
  cursor: pointer;
  text-align: left;
}
.plans-head:hover { background: var(--bg-3); }
.plans-head[aria-expanded="false"] .news-caret { transform: rotate(-90deg); }
.plans-list { display: flex; flex-direction: column; }
.plan-item {
  display: flex; align-items: center; gap: var(--s2) var(--s3);
  flex-wrap: wrap;
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--line);
  font: var(--fs-sm)/1.5 var(--font-mono);
}
.plan-item:last-child { border-bottom: 0; }
.plan-item.is-arming { background: var(--down-lo); }
.plan-name { font-weight: 600; }
.plan-sym { color: var(--accent); letter-spacing: .02em; }
.plan-tf { color: var(--fg-2); }
.plan-when { flex: 1 1 auto; color: var(--fg-2); font-size: var(--fs-xs); text-align: right; }

/* ======================= MUSIMAN (CHART VIEW) =======================
   The symbol's own history: 12 months + 5 weekdays, past not prophecy. */

.season { flex: 0 0 auto; padding: 0; overflow: hidden; }
.season-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: var(--s2);
}
.season-cell {
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--s2);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r2);
  font: var(--fs-xs)/1.5 var(--font-mono);
}
.season-cell.is-best { border-color: #17553f; box-shadow: inset 2px 0 0 var(--up); }
.season-cell.is-worst { border-color: #63303a; box-shadow: inset 2px 0 0 var(--down); }
.season-m {
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: .06em;
}
.season-bar { height: 4px; background: var(--bg-3); border-radius: 2px; overflow: hidden; }
.season-bar > i { display: block; height: 100%; border-radius: 2px; }
.season-bar > i.pos { background: var(--up); }
.season-bar > i.neg { background: var(--down); }
.season-cell .season-avg { font-variant-numeric: tabular-nums; }
.season-meta { color: var(--fg-2); font-size: var(--fs-xs); }
.season-week {
  display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4);
  margin-top: var(--s3);
  padding-top: var(--s3);
  border-top: 1px solid var(--line);
  font: var(--fs-xs)/1.5 var(--font-mono);
  color: var(--fg-2);
}
.season-week > span { display: inline-flex; align-items: center; gap: 5px; }
.season-week b { color: var(--fg-1); font-weight: 500; font-variant-numeric: tabular-nums; }
.season-note {
  margin-top: var(--s3);
  padding-top: var(--s3);
  border-top: 1px solid var(--line);
  font-size: var(--fs-sm);
  color: var(--fg-2);
}

/* years x months heatmap, above the monthly cells */
.season-heat {
  display: grid;
  grid-column: 1 / -1;              /* span the whole .season-grid width */
  grid-template-columns: 4.6em repeat(12, minmax(0, 1fr));
  gap: 2px;
  margin-bottom: var(--s3);
  padding-bottom: var(--s3);
  border-bottom: 1px solid var(--line);
}
.season-heat .heat-cell {
  padding: 3px 4px;
  border-radius: 3px;
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  background: var(--bg);
}
.season-heat .heat-y {
  text-align: left;
  font-weight: 600;
  color: var(--fg-2);
}
.season-heat .heat-h {
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--fg-2);
}
.season-heat .is-up   { color: var(--up); }
.season-heat .is-down { color: var(--down); }

/* --- corporate actions calendar (Aksi tab) --- */
.actions-toolbar {
  display: flex;
  align-items: center;
  gap: var(--s3);
  flex-wrap: wrap;
  margin-bottom: var(--s3);
}
.actions-month {
  font-weight: 600;
  min-width: 9em;
  text-align: center;
}
.actions-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  color: var(--fg-1);
  font-size: var(--fs-sm);
  cursor: pointer;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}
.cal-head {
  padding: 2px 0;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--fg-2);
  text-align: center;
}
.cal-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-height: 64px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
}
.cal-cell.cal-off { border-color: transparent; background: transparent; }
.cal-day {
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  color: var(--fg-2);
}
.cal-day.is-hot { color: var(--accent); font-weight: 600; }
.cal-cell .chip {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ====================== BROKER FLOW (DATA VIEW) ====================== */

.broker-setup { display: flex; flex-direction: column; gap: var(--s2); }
.broker-note { font-size: var(--fs-sm); color: var(--fg-1); }
.broker-form {
  display: flex; align-items: flex-end; gap: var(--s2) var(--s4);
  flex-wrap: wrap;
  padding: var(--s2) var(--s3);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r2);
}
.broker-form .input { width: 240px; }
.broker-hint { font: var(--fs-xs)/1.5 var(--font-mono); color: var(--fg-2); }
.broker-hint code { color: var(--accent); background: var(--bg-2); padding: 1px 4px; border-radius: var(--r1); }
.broker-head {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  margin-bottom: var(--s2);
  font: var(--fs-sm)/1.5 var(--font-mono);
  color: var(--fg-1);
}
.flowtable { width: 100%; border-collapse: collapse; font: var(--fs-sm)/1.5 var(--font-mono); }
.flowtable th {
  padding: 3px var(--s2);
  background: var(--bg-2);
  color: var(--fg-2);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .08em;
  text-align: right;
}
.flowtable th:first-child, .flowtable td:first-child { text-align: left; }
.flowtable td {
  padding: 3px var(--s2);
  border-top: 1px solid var(--line);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.flowbar { position: relative; width: 110px; height: 8px; background: var(--bg-3); border-radius: 2px; overflow: hidden; }
.flowbar > i { position: absolute; top: 0; bottom: 0; }
.flowbar > i.pos { left: 50%; background: var(--up); }
.flowbar > i.neg { right: 50%; background: var(--down); }
.broker-lists {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s3);
  margin-top: var(--s3);
}
.broker-lists .bk { display: flex; justify-content: space-between; gap: var(--s2); padding: 2px 0; font: var(--fs-sm)/1.5 var(--font-mono); border-bottom: 1px dotted var(--line); }
.broker-lists .bk b { font-weight: 500; color: var(--fg-1); }

/* ================= INTEGRITAS + BOOTSTRAP (DATA VIEW) ================= */

.datagrid-full { grid-column: 1 / -1; }
.introw { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; margin-top: var(--s3); }
.intresult { margin-top: var(--s3); display: flex; flex-direction: column; gap: var(--s2); }
.intsum { font: var(--fs-sm)/1.5 var(--font-mono); color: var(--fg-1); }
.inttable {
  align-self: start;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  border-spacing: 0;
  font: var(--fs-sm)/1.5 var(--font-mono);
}
.inttable th {
  padding: 3px var(--s2);
  background: var(--bg-2);
  color: var(--fg-2);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .08em;
  text-align: left;
}
.inttable td { padding: 3px var(--s2); border-top: 1px solid var(--line); }
.intfatal {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: var(--s1) var(--s2);
}
.intfatal-k {
  font: var(--fs-xs)/1.5 var(--font-mono);
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--fg-2);
}
.bstate-line {
  display: flex; align-items: baseline; gap: var(--s2); flex-wrap: wrap;
  font-size: var(--fs-sm); color: var(--fg-1);
}
.kv-2col { margin-top: var(--s2); }
.bnotes {
  margin: var(--s2) 0 0;
  padding-left: 16px;
  display: flex; flex-direction: column; gap: 2px;
  font-size: var(--fs-sm); color: var(--fg-2);
}


/* ======================== RESPONSIVE ======================== */

@media (max-width: 1100px) {
  .simgrid { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; }
  .hero-figs { justify-content: space-between; gap: var(--s4); }
}
@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; }
  .rail {
    flex-direction: row; align-items: center; gap: var(--s3);
    border-right: 0; border-bottom: 1px solid var(--line);
    padding: var(--s2) var(--s3);
    overflow-x: auto;
  }
  .nav { flex-direction: row; }
  .nav-item { border-left: 0; border-bottom: 2px solid transparent; border-radius: var(--r2) var(--r2) 0 0; }
  .nav-item.is-active { border-left-color: transparent; border-bottom-color: var(--accent); }
  .nav-item kbd { display: none; }
  .rail-foot { margin-top: 0; margin-left: auto; flex-direction: row; align-items: center; gap: var(--s3); }
  .rail-hint { display: none; }
  .datagrid { grid-template-columns: 1fr; }
  .view { padding: var(--s3); }
  .decision { grid-template-columns: auto 1fr; }
  .dc-reasons { grid-column: 1 / -1; }
  .topbar-mid { font-size: var(--fs-xs); }
  .greeting { display: none; }
  .userchip { max-width: 130px; }
}
@media (max-width: 620px) {
  .search { width: 100%; max-width: 260px; min-width: 0; }
  .c-name { max-width: 120px; }
  .decision { grid-template-columns: 1fr; }
  .dc-figs { grid-template-columns: repeat(2, 1fr); }
  .greeting { display: none; }
  .sb-counts { gap: var(--s4); }
}

/* News: company line and language badge */
.news-item .news-company {
  font-size: 11px;
  color: var(--dim, #7c8797);
  margin-bottom: 2px;
  display: flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.news-lang {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--panel2, #1c2331);
  color: var(--accent, #e0a028);
  margin-left: 6px;
}

/* Chart context tabs */
.charttabs { margin-top: 14px; }
.tabbar {
  display: flex; gap: 2px; border-bottom: 1px solid var(--line, #1f2632);
}
.tabbtn {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--dim, #7c8797); padding: 8px 14px; cursor: pointer;
  font: inherit; font-size: 13px; border-radius: 4px 4px 0 0;
}
.tabbtn:hover { color: var(--fg, #d7dee9); }
.tabbtn.is-on { color: var(--accent, #e0a028); border-bottom-color: var(--accent, #e0a028); }
.tabbody { padding: 10px 2px; }

/* --- chart tools: drawing toolbar + indicator picker --- */
.toolbar { display: flex; gap: 2px; align-items: center; }
.toolbar .btn { font-size: 11px; padding: 2px 7px; }
.toolbar .btn.is-on { background: var(--accent-lo); color: var(--accent); }
.indwrap { position: relative; }
.indpanel {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 40;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r3);
  padding: var(--s2) var(--s3); width: 240px; max-height: 70vh; overflow: auto;
  box-shadow: 0 6px 24px rgba(0,0,0,.35);
}
.indgroup-title { margin: var(--s2) 0 2px; font-size: 11px; color: var(--fg-2); text-transform: uppercase; letter-spacing: .04em; }
.indgroup label { display: flex; align-items: center; gap: 6px; padding: 2px 0; font-size: 12px; cursor: pointer; }
.indgroup input { accent-color: var(--accent); }
.cv-osc { border-top: 1px solid var(--line); }

/* ======================= MOBILE (PHONES) ======================= */
/* Desktop-first app; below 700px the nav rail becomes an off-canvas drawer
 * (hamburger in the topbar), controls grow to touch size, and every layout
 * collapses to one column. The drawer keeps the full 12-item nav instead of
 * the horizontal scroll the 1000px breakpoint uses on tablets. */

.navtoggle { display: none; }   /* desktop: no hamburger */

@media (max-width: 700px) {
  .navtoggle { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 40px; font-size: var(--fs-xl); }

  /* --- the mobile top bar, reworked: two clean rows ---
   * Row 1: ☰ brand-name            ☀  user chip   (44px targets)
   * Row 2: a scrollable context strip: asof · regime pill · asset switch
   * Nothing is crammed or clipped any more. */
  .topbar {
    flex-wrap: wrap;
    gap: var(--s1) var(--s2);
    padding: var(--s2) var(--s3);
    overflow: visible;
  }
  .topbar > * { min-height: 44px; }
  #navToggle { order: 1; }
  #hdrUpdate { display: none; }  /* the manual refresh button: Data view does it */
  .topbar-brand { order: 2; flex: 0 1 auto; min-width: 0; align-items: center; gap: var(--s1); overflow: hidden; }
  .brand-mark { font-size: var(--fs-lg); }
  .brand-name { display: inline; font-size: var(--fs-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #hdrTheme { order: 3; min-width: 44px; }
  .usermenu { order: 4; }
  .topbar-mid {
    order: 5;
    flex: 1 1 100%;
    min-width: 0;
    gap: var(--s2);
    flex-wrap: nowrap;
    align-items: center;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: 6px;
    margin-top: 2px;
    border-top: 1px solid var(--line);
  }
  .topbar-mid > * { flex: 0 0 auto; min-width: 0; }
  .topbar-sep, .greeting { display: none; }
  .asof { max-width: 150px; }
  .regime-pill { white-space: normal; line-height: 1.3; }
  /* the asset switch lives inside the strip on mobile */
  #hdrAsset { flex: 0 0 auto; min-height: 40px; margin-left: auto; }
  .userchip { max-width: 110px; }

  /* --- drawer rail --- */
  .app { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; }
  .rail {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 70;
    width: min(268px, 84vw);
    flex-direction: column; align-items: stretch;
    border-right: 1px solid var(--line-2); border-bottom: 0;
    padding: var(--s3) var(--s2);
    overflow-y: auto;
    transform: translateX(-105%);
    transition: transform .22s var(--ease-out);
    box-shadow: none;
  }
  .app.rail-open .rail { transform: translateX(0); box-shadow: var(--sh-3); }
  .app.rail-open::before {
    content: ""; position: fixed; inset: 0; z-index: 65;
    background: rgba(4,6,10,.62); backdrop-filter: blur(2px);
  }
  .nav { flex-direction: column; gap: 4px; }
  .nav-item {
    min-height: 46px;
    padding: var(--s3) var(--s3);
    font-size: var(--fs-lg);
    border-left: 3px solid transparent; border-bottom: 0;
    border-radius: 0 var(--r2) var(--r2) 0;
  }
  .nav-item.is-active { border-left-color: var(--accent); border-bottom-color: transparent; }
  .nav-item kbd { display: inline-block; }
  .rail-foot { margin-top: auto; margin-left: 0; }
  .rail-hint { display: block; }

  /* --- touch sizing: 44px targets, 16px inputs (no iOS zoom-on-focus) --- */
  .btn { min-height: 40px; padding: 6px 12px; }
  .btn-xs { min-height: 32px; padding: 2px 8px; }
  .input, select.input { min-height: 42px; font-size: 16px; padding: 6px 10px; }
  .seg button { min-height: 38px; padding: 5px 12px; }
  .tabbtn { padding: 10px 12px; }
  .chip { padding: 4px 10px; font-size: var(--fs-sm); }
  .gcard { font-size: var(--fs-md); }

  /* --- one column everywhere --- */
  .view { padding: var(--s2); gap: var(--s2); }
  /* every view header becomes a swipeable strip: nothing wraps into a
   * ragged stack, every control keeps a 44px touch target */
  .viewhead {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: var(--s2);
    padding-bottom: 2px;
  }
  .viewhead > * { flex: 0 0 auto; min-height: 40px; }
  .viewhead .viewtitle { position: sticky; left: 0; z-index: 2; background: var(--bg); padding-right: var(--s2); }
  .viewhead .field-inline { flex: 0 0 auto; }
  .viewhead .field-inline { flex: 1 1 auto; }
  .decision { grid-template-columns: 1fr; gap: var(--s2); }
  .dc-figs { grid-template-columns: repeat(2, 1fr); gap: var(--s2); }
  .dc-actions { grid-column: 1 / -1; }
  .statstrip { grid-template-columns: repeat(2, 1fr); }
  .paramgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
  .hero { grid-template-columns: 1fr; }
  .hero-figs { flex-wrap: wrap; gap: var(--s3); justify-content: space-between; }
  .sb-counts { flex-wrap: wrap; gap: var(--s4); }
  .journal-form, .alert-form { flex-wrap: wrap; }
  .simgrid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .datagrid { grid-template-columns: 1fr; }
  .chartwrap { height: 56vh; min-height: 360px; }
  .tabbar { overflow-x: auto; }
  .tabbtn { white-space: nowrap; }
  .search { min-width: 0; }
  .login-card { padding: var(--s5) var(--s4); }
  .toasts { left: var(--s2); right: var(--s2); max-width: none; }
  .usermenu-dd { right: auto; left: 0; max-width: calc(100vw - 24px); }
  .indpanel { right: auto; left: 0; width: min(280px, calc(100vw - 24px)); }
}

/* --- take-profit modal: settle a position, see the exact profit --- */
.tp-overlay {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4,6,10,.65); backdrop-filter: blur(3px);
  padding: var(--s3);
}
.tp-card {
  width: min(420px, 100%);
  display: flex; flex-direction: column; gap: var(--s3);
  padding: var(--s4);
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r3);
  box-shadow: var(--sh-3);
  animation: toastin .2s var(--ease-out);
}
.tp-title { font-size: var(--fs-lg); font-weight: 650; display: flex; align-items: baseline; gap: var(--s2); }
.tp-symbol { font: var(--fs-md)/1 var(--font-mono); color: var(--accent); }
.tp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.tp-grid > div { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r2); padding: var(--s2) var(--s3); }
.tp-k { display: block; font: var(--fs-xs)/1.5 var(--font-mono); text-transform: uppercase; letter-spacing: .1em; color: var(--fg-2); }
.tp-v { display: block; font: var(--fs-md)/1.6 var(--font-mono); font-variant-numeric: tabular-nums; }
.tp-result {
  display: flex; align-items: baseline; gap: var(--s3);
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg-1) 96%, var(--bg-2)), var(--bg-1));
  border: 1px solid var(--line); border-radius: var(--r2);
  padding: var(--s3);
}
.tp-profit { font: 700 var(--fs-2xl)/1.1 var(--font-mono); font-variant-numeric: tabular-nums; }
.tp-profit-pct { font: var(--fs-md)/1 var(--font-mono); color: var(--fg-2); }
.tp-actions { display: flex; gap: var(--s2); justify-content: flex-end; }
.tp-actions .btn { min-height: 40px; }
@media (max-width: 700px) {
  .tp-grid { grid-template-columns: repeat(2, 1fr); }
  .tp-actions .btn { flex: 1 1 auto; }
}

/* --- fill-detail modal: why the algorithm picked the name + entry chart --- */
.smf-card { width: min(680px, 100%); }
.smf-why {
  display: grid; grid-template-columns: max-content 1fr;
  gap: var(--s1) var(--s3); align-items: baseline;
}
.smf-pnl {
  display: flex; flex-direction: column; gap: var(--s1);
  padding: var(--s3);
  border: 1px solid var(--line-2);
  border-left-width: 4px;
  border-radius: var(--r2);
  background: var(--bg-2);
}
.smf-pnl.up { border-left-color: var(--up); }
.smf-pnl.down { border-left-color: var(--down); }
.smf-pnl-value {
  font: 700 1.5rem/1.2 var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.smf-pnl.up .smf-pnl-value { color: var(--up); }
.smf-pnl.down .smf-pnl-value { color: var(--down); }
.smf-pnl-pct { font-size: 1rem; color: var(--fg-2); }
.smf-pnl-meta { font-size: var(--fs-sm); color: var(--fg-2); }
.smf-k {
  font: var(--fs-xs)/1.5 var(--font-mono); text-transform: uppercase;
  letter-spacing: .1em; color: var(--fg-2); white-space: nowrap;
}
.smf-note { grid-column: 1 / -1; font-size: var(--fs-sm); color: var(--fg-2); }
.smf-chartwrap {
  position: relative; height: 320px;
  border: 1px solid var(--line); border-radius: var(--r2); background: var(--bg);
}
.smf-chart { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
.smf-tip {
  position: absolute; top: 6px; z-index: 2; pointer-events: none;
  max-width: calc(100% - 12px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 4px 10px; border-radius: var(--r2);
  background: rgba(10, 13, 18, .92); border: 1px solid var(--line-2);
  font: 11px/1.5 var(--font-mono); color: var(--fg-1);
  font-variant-numeric: tabular-nums;
}
.smf-chartwrap .news-status { position: absolute; left: var(--s2); bottom: var(--s1); z-index: 1; }
.chip-accent { background: var(--accent-lo); color: var(--accent); border-color: #6b4d15; }
/* Trade log rows open the entry explainer. */
.smf-row { cursor: pointer; }
.smf-row:hover td { background: var(--bg-3); }
@media (max-width: 700px) {
  .smf-chartwrap { height: 240px; }
}

/* --- Model AI: chat bubbles + mobile-safe controls --- */
.chat-body {
  display: flex; flex-direction: column; gap: var(--s2);
  max-height: 420px; overflow-y: auto;
  padding: var(--s3);
  margin-bottom: var(--s2);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r2);
}
.chat-empty {
  font: var(--fs-sm)/1.5 var(--font-mono);
  color: var(--fg-2);
  text-align: center;
  padding: var(--s5) var(--s3);
}
.chat-bubble {
  max-width: min(82%, 560px);
  padding: var(--s2) var(--s3);
  border-radius: var(--r2);
  font-size: var(--fs-sm);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-bubble-user {
  align-self: flex-end;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #241a04;
}
.chat-bubble-ai {
  align-self: flex-start;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  color: var(--fg);
}
.chat-bubble-meta {
  margin-top: var(--s1);
  font: var(--fs-xs)/1.4 var(--font-mono);
  color: var(--fg-2);
  opacity: .9;
}
.chat-form {
  display: flex; flex-direction: column; gap: var(--s2);
  padding: var(--s2) 0 0;
}
.chat-form .input, .chat-form .btn { min-height: 40px; }
.chat-form .btn { width: 100%; }
@media (min-width: 900px) {
  .chat-form { display: grid; grid-template-columns: 1fr 200px 220px auto; align-items: center; }
  .chat-form #chatMessage { grid-column: 1 / -1; }
  .chat-form .btn { width: auto; }
}

/* ============ Workstream F: viewport-anchored overlays ============ */
/* The indicator panel must never be clipped by .main (overflow: hidden) or
 * hidden under the nav rail: anchor it to the VIEWPORT instead of .indwrap.
 * Guarded to desktop: the ≤700px media rule above keeps its left-anchored
 * drawer behavior, and a later unguarded .indpanel rule would override it
 * (equal specificity, later source order). */
@media (min-width: 701px) {
  .indpanel {
    position: fixed;
    top: 64px;              /* just below the topbar */
    right: var(--s4);
    left: auto;
    width: 260px;
    max-width: calc(100vw - 24px);
    max-height: 70vh;
    overflow: auto;
    z-index: 300;           /* above the rail (70), the topbar (30), everything app-level */
  }
}

/* Same failure family: the chart symbol-search dropdown (shared .dropdown
 * rule, absolute inside .search) can clip the same way near the left edge.
 * Scoped to the chart view only: the journal/alert modal search boxes also
 * match .search .dropdown but sit inside centered modals, where fixed
 * positioning would tear the dropdown away from its input. */
#chSearchBox .dropdown {
  position: fixed;
  top: 64px;
  left: var(--s4);
  right: auto;
  width: min(340px, calc(100vw - 24px));
  z-index: 300;
}

/* ============ Workstream C: UI polish (append-only) ============ */

/* Best Picks WATCH fallback cards (80-best.js cardHtml): when a timeframe has
 * no fresh BUY the card carries a WATCH chip in its head and an empty_reason
 * subtitle. A left accent marks the fallback state at a glance (same inset
 * shadow idiom as .gcard.is-converging/.is-pinned), and the reason line reads
 * as a muted subtitle instead of a loud error. Unguarded: desktop + mobile. */
.card:has(.card-head .chip.chip-warn) {
  box-shadow: inset 3px 0 0 var(--accent);
}
.card-empty[title="empty_reason"] {
  padding: var(--s1) var(--s3) var(--s3);
  font-size: var(--fs-xs);
  line-height: 1.5;
  color: var(--fg-2);
  text-align: left;
}

/* Potensi badge on gallery cards (10-screener.js cardHtml): chips already wrap
 * inside .gcard-chips, but on small screens a long chip must never burst the
 * card horizontally - clamp + ellipsis instead. */
@media (max-width: 700px) {
  .gcard-chips .chip {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Indicator panel on short viewports: cap the picker height so it never runs
 * off the bottom of the screen. Applies to both the fixed desktop variant
 * (>=701px wide) and the absolute mobile drawer; appended after the desktop
 * rule so the cap wins at equal specificity. */
@media (max-height: 699px) {
  .indpanel {
    max-height: 60vh;
  }
}
