/* Crypto Analyzer, "meja trading". Decisions and reasons live in DESIGN.md.
   One accent (amber): active tab, primary button, live signal count. Nothing else. */

@font-face { font-family: "Plex Sans"; src: url("/static/fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Plex Sans"; src: url("/static/fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Plex Sans"; src: url("/static/fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("/static/fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("/static/fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }

:root {
  color-scheme: light;
  --page: #f2f2ee;
  --surface: #fafaf8;
  --sunken: #e8e8e3;
  --ink: #141414;
  --ink-2: #45453f;
  --muted: #66655f;
  --rule: #d9d8d0;
  --rule-strong: #b4b3a9;
  --accent: #e39a1b;
  --accent-text: #8a5400;
  --on-accent: #141414;
  --pos: #0b6b2a;
  --neg: #b3261e;
  --pos-bg: #e3f1e6;
  --neg-bg: #f8e3e1;
  --warn-bg: #f7ecd2;
  --focus: #141414;

  --tape: #0f1011;
  --tape-ink: #ecebe6;
  --tape-muted: #9d9c95;
  --tape-rule: #2b2c2f;
  --tape-pos: #4cc46f;
  --tape-neg: #f07068;
  --tape-accent: #f5a623;

  /* chart series: validated dataviz palette (data identity, not brand) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-muted: #898781;
  --diverge-neg: #e34948;

  --radius: 3px;
  --radius-panel: 4px;
  --sans: "Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Plex Mono", ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #111214;
    --surface: #18191c;
    --sunken: #202125;
    --ink: #ecebe6;
    --ink-2: #c2c1ba;
    --muted: #8f8e88;
    --rule: #2a2b2f;
    --rule-strong: #44454a;
    --accent: #f5a623;
    --accent-text: #f5a623;
    --pos: #3ccb63;
    --neg: #f07a72;
    --pos-bg: #133020;
    --neg-bg: #3a1816;
    --warn-bg: #3a2e12;
    --focus: #ecebe6;
    --tape: #08090a;
    --tape-rule: #26272a;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --diverge-neg: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #111214;
  --surface: #18191c;
  --sunken: #202125;
  --ink: #ecebe6;
  --ink-2: #c2c1ba;
  --muted: #8f8e88;
  --rule: #2a2b2f;
  --rule-strong: #44454a;
  --accent: #f5a623;
  --accent-text: #f5a623;
  --pos: #3ccb63;
  --neg: #f07a72;
  --pos-bg: #133020;
  --neg-bg: #3a1816;
  --warn-bg: #3a2e12;
  --focus: #ecebe6;
  --tape: #08090a;
  --tape-rule: #26272a;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --diverge-neg: #e66767;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  font-variant-numeric: tabular-nums;
}
a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1 { font-size: 22px; line-height: 1.25; margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
h3 { font-size: 13px; margin: 0 0 6px; font-weight: 600; color: var(--ink-2); }
p { margin: 0 0 10px; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
pre {
  background: var(--sunken);
  border-radius: var(--radius);
  padding: 12px;
  overflow: auto;
  max-height: 480px;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -40px; background: var(--accent); color: var(--on-accent); padding: 6px 10px; z-index: 30; }
.skip:focus { top: 8px; }

/* ================================================================ market tape */
.tape {
  background: var(--tape);
  color: var(--tape-ink);
  border-bottom: 1px solid var(--tape-rule);
  font-size: 12.5px;
}
.tape-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 20px;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 6px 22px;
  flex-wrap: wrap;
}
.wordmark {
  color: var(--tape-ink);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
  padding-right: 18px;
  border-right: 1px solid var(--tape-rule);
}
.wordmark:hover { color: #ffffff; }
.quotes { display: flex; gap: 6px 20px; flex-wrap: wrap; align-items: baseline; }
.quote { display: inline-flex; gap: 7px; align-items: baseline; white-space: nowrap; }
.quote .sym { color: var(--tape-muted); }
.quote .px { font-family: var(--mono); font-weight: 500; color: var(--tape-ink); }
.quote .chg { font-family: var(--mono); }
.quote .chg.pos { color: var(--tape-pos); }
.quote .chg.neg { color: var(--tape-neg); }
.tape-asof { color: var(--tape-muted); white-space: nowrap; }
.tape-state { display: flex; gap: 6px 18px; flex-wrap: wrap; align-items: center; color: var(--tape-muted); }
.tape-state .item { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.tape-state strong { color: var(--tape-ink); font-weight: 500; font-family: var(--mono); }
.tape-state .hot { color: var(--tape-accent); }
.tape-state .alarm { color: var(--tape-neg); }
/* The dot marks a real state only: worker alive / stalled / never ran. No glow, no pulse. */
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; }
.dot.ok { background: var(--tape-pos); }
.dot.bad { background: var(--tape-neg); }
.dot.idle { background: var(--tape-muted); }
.tape-account { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.tape-account .who { color: var(--tape-muted); margin-right: 6px; }
.tape button.link { color: var(--tape-ink); }
.tape button.link:hover { background: var(--tape-rule); color: #ffffff; }
.tape :focus-visible { outline-color: var(--tape-ink); }

/* ================================================================ tabs */
.tabs {
  background: var(--page);
  border-bottom: 1px solid var(--rule);
}
.tabs-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
}
.tabs a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  color: var(--ink-2);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tabs a:first-child { padding-left: 0; }
.tabs a:hover { color: var(--ink); border-bottom-color: var(--rule-strong); }
.tabs a[aria-current="page"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }

/* ================================================================ page */
.page { max-width: 1320px; margin: 0 auto; padding: 26px 20px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 28px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin: 4px 0 0; max-width: 760px; }
.grid { display: grid; gap: 36px 44px; }
.grid-2 { grid-template-columns: minmax(0, 7fr) minmax(0, 4fr); }
.grid-2e { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1000px) { .grid-2, .grid-2e { grid-template-columns: minmax(0, 1fr); } }
.stack { display: flex; flex-direction: column; gap: 36px; min-width: 0; }

/* A sheet is a ledger section: heading, rule, content. No box around it. */
.sheet { min-width: 0; }
.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 16px;
  flex-wrap: wrap;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--ink);
}
.sheet-head .meta { color: var(--muted); font-size: 12.5px; }
.sheet-head .meta a { color: var(--muted); }
.sheet.focal { margin-bottom: 44px; }
.sheet.focal .sheet-head h2 { font-size: 17px; }
.sheet.focal .sheet-head { border-bottom-width: 2px; }
.count { font-family: var(--mono); font-weight: 500; }
.count.hot { color: var(--accent-text); }

/* Panels are reserved for chart canvases and forms, which need a defined area. */
.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-panel);
  padding: 16px;
  min-width: 0;
}
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 12px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head .meta { color: var(--muted); font-size: 12.5px; }

/* ================================================================ tables */
.table-wrap { overflow-x: auto; position: relative; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--rule); white-space: nowrap; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
.panel th:first-child, .panel td:first-child { padding-left: 10px; }
.panel th:last-child, .panel td:last-child { padding-right: 10px; }
th { font-weight: 500; color: var(--muted); font-size: 12px; }
td.num, th.num { text-align: right; }
tbody tr:hover { background: var(--sunken); }
td.wrap { white-space: normal; min-width: 240px; }
th a { color: inherit; text-decoration: none; }
th a:hover { color: var(--ink); text-decoration: underline; }
th a[aria-current="true"] { color: var(--ink); font-weight: 600; }
th a[aria-current="true"]::after { content: " \2193"; }
td a { text-decoration: none; font-weight: 500; }
td a:hover { text-decoration: underline; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.dim { color: var(--muted); }
.small { font-size: 12.5px; }
.truncate { max-width: 250px; overflow: hidden; text-overflow: ellipsis; }
.name-cell a { display: inline-block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.flag { color: var(--muted); font-size: 12px; margin-left: 6px; }

/* ================================================================ labels */
.side { display: inline-block; min-width: 50px; padding: 1px 6px; border-radius: var(--radius); font-size: 12px; font-weight: 600; text-align: center; }
.side.long { background: var(--pos-bg); color: var(--pos); }
.side.short { background: var(--neg-bg); color: var(--neg); }
.state { font-weight: 600; }
.state.ok { color: var(--pos); }
.state.err { color: var(--neg); }
.state.idle { color: var(--muted); font-weight: 500; }

.notice { padding: 10px 12px; border-radius: var(--radius); margin-bottom: 16px; background: var(--sunken); }
.notice.ok { background: var(--pos-bg); }
.notice.err { background: var(--neg-bg); }
.notice.warn { background: var(--warn-bg); }

/* ================================================================ forms */
label { display: block; font-weight: 500; font-size: 13px; margin-bottom: 4px; }
.hint { color: var(--muted); font-size: 12.5px; font-weight: 400; margin-top: 4px; }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--page);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  padding: 8px 10px;
  min-height: 40px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }
.field { margin-bottom: 16px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.check input { width: 16px; height: 16px; accent-color: var(--ink); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 16px; }

button, .btn {
  font: inherit;
  font-weight: 500;
  border-radius: var(--radius);
  padding: 7px 14px;
  min-height: 36px;
  border: 1px solid var(--rule-strong);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
button:hover, .btn:hover { border-color: var(--ink); text-decoration: none; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
button.primary:hover { filter: brightness(0.95); }
button.link { border: 0; background: none; color: var(--ink-2); padding: 6px 8px; min-height: 32px; }
button.link:hover { color: var(--ink); background: var(--sunken); }
button:disabled { opacity: 0.6; cursor: progress; }
.inline-form { display: inline; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ================================================================ filters */
.filters { display: flex; gap: 8px 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: var(--radius); overflow: hidden; }
.seg a { padding: 6px 12px; color: var(--ink-2); border-right: 1px solid var(--rule); text-decoration: none; min-height: 34px; display: inline-flex; align-items: center; }
.seg a:last-child { border-right: 0; }
.seg a:hover { background: var(--sunken); color: var(--ink); }
.seg a[aria-current="true"] { background: var(--ink); color: var(--page); }
.filters .label { color: var(--muted); font-size: 12.5px; }

/* ================================================================ AI note */
.note { padding-top: 12px; }
.note .text { font-size: 15px; line-height: 1.65; white-space: pre-wrap; max-width: 68ch; margin: 0; }
.note .byline { color: var(--muted); font-size: 12.5px; margin-top: 10px; }

/* ================================================================ charts */
.chart-box { position: relative; }
.chart { height: 320px; }
.chart.short { height: 200px; }
.chart-legend { display: flex; gap: 6px 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; min-height: 20px; }
.chart-legend .item { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .key { width: 14px; height: 2px; border-radius: 1px; display: inline-block; }
.chart-legend .val { color: var(--ink); font-weight: 600; }
.chart-legend .time { color: var(--muted); margin-left: auto; }
.lagbars svg { width: 100%; height: 190px; display: block; }
.lagbars .bar:hover rect.mark, .lagbars .bar:focus rect.mark { opacity: 0.75; }
.lagbars .bar:focus { outline: none; }
.lagbars .bar:focus rect:last-child { stroke: var(--focus); stroke-width: 1.5; }
.lagbars text { fill: var(--muted); font-size: 11px; font-family: var(--sans); }
/* The only shadow in the UI: the tooltip floats above the plot. */
.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  padding: 6px 9px;
  font-size: 12.5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
  white-space: nowrap;
  z-index: 5;
}

/* ================================================================ auth */
.auth { max-width: 400px; margin: 0 auto; padding: 56px 20px; }
.auth h1 { margin-bottom: 6px; }
.auth .sub { color: var(--muted); margin-bottom: 24px; }
.auth button.primary { width: 100%; justify-content: center; min-height: 44px; }
.qr { background: #ffffff; border-radius: var(--radius); padding: 10px; width: 220px; margin: 0 0 12px; border: 1px solid var(--rule); }
.qr svg { width: 100%; height: auto; display: block; }
.secret { font-family: var(--mono); background: var(--sunken); padding: 8px 10px; border-radius: var(--radius); margin-bottom: 18px; word-break: break-all; }
.code-input { font-family: var(--mono); font-size: 22px !important; letter-spacing: 0.25em; }

/* ================================================================ misc */
.empty { color: var(--muted); padding: 16px 0; max-width: 70ch; }
.empty strong { color: var(--ink); display: block; margin-bottom: 2px; font-weight: 500; }
.footer-note { color: var(--muted); font-size: 12px; margin-top: 48px; padding-top: 12px; border-top: 1px solid var(--rule); }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 12px 0 0; font-size: 13px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }
.pager { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
hr.sep { border: 0; border-top: 1px solid var(--rule); margin: 18px 0; }

@media (max-width: 640px) {
  .page { padding: 20px 14px 48px; }
  .tape-inner, .tabs-inner { padding-left: 14px; padding-right: 14px; }
  .tape-inner { padding-top: 8px; padding-bottom: 8px; }
  .wordmark { border-right: 0; padding-right: 0; }
  .hide-sm { display: none; }
  .chart { height: 260px; }
}
.tape-state a.item { color: inherit; text-decoration: none; min-height: 32px; }
.tape-state a.item:hover { color: var(--tape-ink); text-decoration: underline; }
