/* Painite: Session Chronograph. One accent (amethyst) for "now" and live state; green/red only for P&L sign.
   Radius rule: controls 8-10px, panels 12px, segmented controls full. */
@font-face { font-family: "Barlow"; src: url("/static/fonts/Barlow-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("/static/fonts/Barlow-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("/static/fonts/Barlow-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("/static/fonts/Barlow-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --bg: #f2f3f5; --surface: #fbfbfc; --surface-2: #eceef1; --enamel: #fdfdfd;
  --line: rgba(20, 24, 31, 0.09); --line-2: rgba(20, 24, 31, 0.18); --tick: rgba(20, 24, 31, 0.32);
  --text: #14171c; --muted: #5c636e; --faint: #8b919b;
  --accent: #7b52c7; --accent-ink: #6a3fb8; --accent-soft: rgba(123, 82, 199, 0.11);
  --win: #0e8a5c; --loss: #d23b3b; --win-soft: rgba(14, 138, 92, 0.12); --loss-soft: rgba(210, 59, 59, 0.11);
  --warn: #b7791f; --warn-soft: rgba(183, 121, 31, 0.13);
  --shadow: 0 1px 2px rgba(20, 24, 31, 0.05), 0 8px 24px rgba(20, 24, 31, 0.06);
  --shadow-lg: 0 24px 64px rgba(20, 24, 31, 0.18);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --rail: 232px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d10; --surface: #111418; --surface-2: #171b21; --enamel: #0e1114;
    --line: rgba(232, 234, 238, 0.07); --line-2: rgba(232, 234, 238, 0.15); --tick: rgba(232, 234, 238, 0.34);
    --text: #e8eaee; --muted: #9aa1ad; --faint: #6b727d;
    --accent: #a983f0; --accent-ink: #bfa0f7; --accent-soft: rgba(169, 131, 240, 0.13);
    --win: #3ccf91; --loss: #f2655f; --win-soft: rgba(60, 207, 145, 0.13); --loss-soft: rgba(242, 101, 95, 0.13);
    --warn: #e2a33b; --warn-soft: rgba(226, 163, 59, 0.14);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0d10; --surface: #111418; --surface-2: #171b21; --enamel: #0e1114;
  --line: rgba(232, 234, 238, 0.07); --line-2: rgba(232, 234, 238, 0.15); --tick: rgba(232, 234, 238, 0.34);
  --text: #e8eaee; --muted: #9aa1ad; --faint: #6b727d;
  --accent: #a983f0; --accent-ink: #bfa0f7; --accent-soft: rgba(169, 131, 240, 0.13);
  --win: #3ccf91; --loss: #f2655f; --win-soft: rgba(60, 207, 145, 0.13); --loss-soft: rgba(242, 101, 95, 0.13);
  --warn: #e2a33b; --warn-soft: rgba(226, 163, 59, 0.14);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 76px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 15px/1.45 "Barlow", ui-sans-serif, system-ui, sans-serif;
  font-feature-settings: "tnum" 1; -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-soft); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; } ::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 18px; font-weight: 600; margin: 0 0 10px; }
.muted { color: var(--muted); font-weight: 400; }
.note { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; max-width: 60ch; }
.pos { color: var(--win); } .neg { color: var(--loss); }
.i { width: 18px; height: 18px; fill: currentColor; flex: none; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 12px; top: 12px; z-index: 50; background: var(--surface); padding: 8px 12px; }

/* ---------- shell */
.rail {
  position: fixed; inset: 0 auto 0 0; width: var(--rail); z-index: 30; display: flex; flex-direction: column;
  padding: 16px 12px; background: var(--bg); border-right: 1px solid var(--line);
}
.rail-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 18px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; letter-spacing: 0.01em; font-size: 17px; }
.brand .i { width: 15px; height: 24px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a, .nav-btn {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--muted);
  text-decoration: none; border: 0; background: none; cursor: pointer; width: 100%; text-align: left;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.nav a:hover, .nav-btn:hover { background: var(--surface-2); color: var(--text); }
.nav a.on { color: var(--text); background: var(--surface-2); }
.nav a.on .i { color: var(--text); }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--line); padding-top: 10px; }
.rail .rail-close { display: none; }

.app { margin-left: var(--rail); min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid var(--line);
}
.status { display: flex; align-items: center; gap: 14px; min-width: 0; }
.mode { font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; padding-right: 14px; border-right: 1px solid var(--line-2); }
.mode.dry { color: var(--accent-ink); }
.mode.live { color: var(--loss); }
.conn { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.led { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.conn.ok .led { background: var(--win); }
.conn.bad .led { background: var(--loss); }
.conn.bad { color: var(--loss); }
.clock { font: 500 14px/1 "Barlow", sans-serif; color: var(--muted); letter-spacing: 0.02em; }
.grow { flex: 1; }
.only-narrow { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-weight: 550;
  white-space: nowrap; text-decoration: none; transition: transform 0.15s var(--ease), background 0.2s, border-color 0.2s, color 0.2s;
}
.btn:hover { border-color: var(--tick); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn.ghost { background: transparent; }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.danger { color: var(--loss); border-color: color-mix(in srgb, var(--loss) 40%, transparent); background: transparent; }
.btn.danger.armed { background: var(--loss); color: #fff7f6; border-color: var(--loss); }
.btn.wide { width: 100%; height: 40px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn.paused { color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--accent-soft); }
.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 10px; border: 1px solid transparent;
  background: transparent; cursor: pointer; color: var(--muted); transition: background 0.2s, color 0.2s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

main { padding: 24px 32px 72px; max-width: 1480px; margin: 0 auto; display: flex; flex-direction: column; gap: 36px; }
.panel { border-top: 1px solid var(--line-2); padding: 16px 0 0; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.panel-head h2 { margin: 0; }
.split { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 40px; }

/* ---------- flags (problems only) */
.flags:empty { display: none; }
.flags { display: flex; flex-direction: column; gap: 8px; }
.flag {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 8px;
  background: var(--warn-soft); color: var(--text); animation: rise 0.35s var(--ease) both;
}
.flag .i { color: var(--warn); }
.flag.bad { background: var(--loss-soft); } .flag.bad .i { color: var(--loss); }

/* ---------- overview: now + session timeline, then three charts */
.overview { display: flex; flex-direction: column; gap: 36px; }
.hero { display: grid; grid-template-columns: minmax(300px, 0.8fr) minmax(0, 1.6fr); gap: 48px; align-items: start; }
.now { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.state-row { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.state { font-size: 15px; font-weight: 600; color: var(--muted); }
.state.alert { color: var(--loss); } .state.paused { color: var(--accent-ink); }
.state-meta { font-size: 14px; color: var(--muted); }
.state-meta b { color: var(--text); font-weight: 600; }
.big { font-size: clamp(44px, 5.4vw, 68px); font-weight: 600; line-height: 1; letter-spacing: -0.01em; display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.big small { font-size: 17px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.state-sub { color: var(--muted); margin: 6px 0 4px; max-width: 52ch; }
.meter { margin-top: 6px; min-height: 74px; }
.session { min-width: 0; }
.session .panel-head { margin-bottom: 4px; }
.viz3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px; }
.kv { font-size: 13.5px; color: var(--muted); }
.kv b { font-weight: 600; }
.viz { min-height: 150px; }
.vz { display: block; overflow: visible; }
.vz .lbl { fill: var(--muted); font: 500 11.5px "Barlow", sans-serif; }
.vz .lbl.strong { fill: var(--text); font-weight: 600; font-size: 12.5px; }
.vz .lbl.win { fill: var(--win); } .vz .lbl.loss { fill: var(--loss); } .vz .lbl.open { fill: var(--accent-ink); font-weight: 600; }
.vz .ax { stroke: var(--line-2); stroke-width: 1; }
.vz .pace { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; }
.vz .live { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.vz .mk { stroke: var(--text); stroke-width: 1.5; }
.vz .mkdot { fill: var(--accent); stroke: var(--bg); stroke-width: 2; }
.vz .stopnow { stroke: var(--loss); stroke-width: 1.5; stroke-dasharray: 3 3; }
.vz .z-loss { fill: var(--loss-soft); } .vz .z-win { fill: var(--win-soft); } .vz .z-chan { fill: var(--surface-2); }
.vz .cone { fill: var(--surface-2); }
.vz .px-area { fill: var(--surface-2); opacity: 0.7; }
.vz .px-line { fill: none; stroke: var(--text); stroke-width: 1.25; opacity: 0.85; stroke-linejoin: round; }
.vz .span.win { fill: var(--win-soft); } .vz .span.loss { fill: var(--loss-soft); } .vz .span.open { fill: var(--accent-soft); }
.vz .cap { stroke-width: 2; } .vz .cap.win { stroke: var(--win); } .vz .cap.loss { stroke: var(--loss); } .vz .cap.open { stroke: var(--accent); }
.vz .ck.quiet { stroke: var(--tick); stroke-width: 1.5; }
.vz .ck.signal { stroke: var(--text); stroke-width: 2; }
.vz .ck.traded { fill: var(--text); }
.vz .ck.next { fill: var(--bg); stroke: var(--accent); stroke-width: 2; }
.vz .now { stroke: var(--accent); stroke-width: 1.5; }
.bullets { display: flex; flex-direction: column; gap: 18px; padding-top: 6px; }
.bl-top { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; color: var(--muted); margin-bottom: 7px; }
.bl-top b { color: var(--text); font-weight: 600; }
.bl-bar { height: 6px; border-radius: 3px; background: var(--surface-2); position: relative; overflow: hidden; }
.bl-bar span { position: absolute; inset: 0; background: var(--text); transform-origin: left; transition: transform 0.9s var(--ease); border-radius: 3px; }
.bl-bar span.warn { background: var(--warn); } .bl-bar span.bad { background: var(--loss); } .bl-bar span.acc { background: var(--accent); }
.mt { margin-top: 22px; }

.checks { max-height: 404px; overflow: auto; margin: 0 -6px; scroll-behavior: smooth; }
.crow { display: grid; grid-template-columns: 56px 1fr 1fr 112px; gap: 8px; align-items: center; padding: 6px; border-radius: 8px; font-size: 13px; }
.crow.head { position: sticky; top: 0; background: var(--bg); color: var(--muted); font-size: 12px; z-index: 1; }
.crow .t { font-weight: 500; }
.crow .n { text-align: right; color: var(--muted); }
.crow.past { color: var(--muted); }
.crow.next { box-shadow: inset 2px 0 0 var(--accent); border-radius: 0; }
.crow.next .t { color: var(--accent-ink); font-weight: 600; }
.chip { font-size: 13px; color: var(--muted); justify-self: end; white-space: nowrap; }
.chip.next { color: var(--accent-ink); font-weight: 600; }
.chip.long, .chip.short { color: var(--text); }
.chip.traded { color: var(--text); font-weight: 600; }

/* ---------- chart panel */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--surface-2); }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 999px; cursor: pointer; color: var(--muted); font-size: 12.5px; font-weight: 550; transition: background 0.2s var(--ease), color 0.2s; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), inset 0 0 0 1px var(--line); }
.strip { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 10px; font-size: 12.5px; color: var(--muted); }
.strip b { color: var(--text); font-weight: 600; }
.strip .hl { color: var(--accent-ink); }
.chart-box { position: relative; height: 540px; }
.chart-box.small { height: 280px; }
.fill { position: absolute; inset: 0; }
.empty { position: absolute; inset: 0; display: none; place-items: center; color: var(--muted); font-size: 13px; pointer-events: none; text-align: center; padding: 20px; }
.empty.show { display: grid; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 11.5px; color: var(--muted); margin-top: 10px; }
.sw { display: inline-block; width: 14px; height: 2px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.sw.band { background: var(--muted); } .sw.vwap { background: var(--accent); height: 3px; } .sw.poc { background: var(--warn); } .sw.ib { background: var(--text); opacity: 0.5; }

/* ---------- tables */
.tablewrap { max-height: 340px; overflow: auto; margin: 0 -6px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { position: sticky; top: 0; background: var(--bg); text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 6px; }
.tbl td { padding: 7px 6px; border-top: 1px solid var(--line); white-space: nowrap; }
.tbl td.num, .tbl th.num { text-align: right; }
.tbl .tag { font-size: 12px; color: var(--muted); margin-left: 6px; }
.tbl .ev { color: var(--muted); }
.tbl .ev.open, .tbl .ev.exit { color: var(--text); font-weight: 600; }
.tbl .ev.error, .tbl .ev.skip, .tbl .ev.mismatch { color: var(--loss); font-weight: 600; }
.tbl td.detail { white-space: normal; color: var(--muted); }
.tbl-empty { color: var(--muted); padding: 18px 6px; }

/* ---------- drawer + sheet */
.scrim { position: fixed; inset: 0; z-index: 35; background: rgba(8, 10, 13, 0.42); opacity: 0; pointer-events: none; transition: opacity 0.28s var(--ease); }
.scrim.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; z-index: 40; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); background: var(--surface);
  border-left: 1px solid var(--line); box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  transform: translateX(104%); visibility: hidden; transition: transform 0.36s var(--ease), visibility 0s linear 0.36s;
}
.drawer.on { transform: none; visibility: visible; transition: transform 0.36s var(--ease), visibility 0s; }
.drawer.wide { width: min(880px, 100vw); }
.trade-img { width: 100%; height: auto; display: block; margin-top: 14px; border-radius: 8px; background: var(--surface-2); }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 24px; margin-top: 18px; }
.facts span { display: block; font-size: 12.5px; color: var(--muted); }
.facts b { font-weight: 600; }
.tbl tr.click { cursor: pointer; transition: background 0.15s; }
.tbl tr.click:hover { background: var(--surface-2); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 12px 22px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 22px; margin: 0; }
.drawer-body { overflow: auto; padding: 8px 22px 28px; overscroll-behavior: contain; }
.set { padding: 18px 0 20px; border-bottom: 1px solid var(--line); }
.set:last-of-type { border-bottom: 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 0; }
.row b { font-weight: 550; display: block; }
.row small, .field small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; line-height: 1.35; }
.switch { cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i { flex: none; width: 40px; height: 24px; border-radius: 999px; background: var(--line-2); position: relative; transition: background 0.25s var(--ease); }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.3s var(--ease); }
.switch input:checked + i { background: var(--text); }
.switch input:checked + i::after { transform: translateX(16px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.lbl { font-size: 12.5px; font-weight: 550; }
.field input {
  height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input:user-invalid { border-color: var(--loss); }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.pending { padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--text); font-size: 12.5px; margin: 6px 0 12px; }
.signout { margin-top: 22px; }

.toast {
  position: fixed; z-index: 60; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 13px; font-weight: 550;
  box-shadow: var(--shadow-lg); transition: transform 0.35s var(--ease), opacity 0.35s var(--ease);
}
.toast.on { transform: translate(-50%, 0); opacity: 1; }

.skeleton { border-radius: 10px; background: linear-gradient(90deg, var(--surface-2) 0, var(--line) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ---------- login */
.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-box { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login-box .brand { font-size: 20px; margin-bottom: 6px; }
.login-box p { color: var(--muted); margin: 0 0 6px; }
.login-box .err { color: var(--loss); font-size: 13px; min-height: 18px; margin: 0; }

/* ---------- responsive */
@media (max-width: 1180px) {
  .hero { grid-template-columns: 1fr; gap: 24px; }
  .viz3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 980px) {
  :root { --rail: 0px; }
  .rail { width: min(300px, 86vw); transform: translateX(-104%); visibility: hidden; box-shadow: var(--shadow-lg); background: var(--surface); transition: transform 0.36s var(--ease), visibility 0s linear 0.36s; z-index: 40; }
  .rail.on { transform: none; visibility: visible; transition: transform 0.36s var(--ease), visibility 0s; }
  .rail .rail-close { display: inline-grid; }
  .only-narrow { display: inline-flex !important; }
  .topbar { padding: 0 12px; gap: 8px; }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .hide-narrow { display: none !important; }
  .status { gap: 10px; }
  .clock { display: none; }
  main { padding: 14px 16px 48px; }
  .hide-sm { display: none; }
  .viz3 { grid-template-columns: 1fr; gap: 30px; }
  main { gap: 28px; }
  .crow { grid-template-columns: 48px 1fr 1fr 96px; font-size: 12.5px; }
  .chart-box { height: 400px; }

  .field-pair { grid-template-columns: 1fr; }
  .drawer { width: 100vw; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
