/* Layout: a trading-desk monitor — sticky header with range/timezone controls, tab strip, card grid.
   Gold is the single accent; up/down use their own semantic pair. */
:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --panel-2: #f0eee8;
  --fg: #1d1c19;
  --muted: #6b675e;
  --line: #e2ded4;
  --gold: #a87b1f;
  --gold-soft: #e9d9b0;
  --up: #1f7a4d;
  --down: #b4382f;
  --bar: #c9c3b5;
  --grid: #ebe7de;
  --font: "IBM Plex Sans Thai", "Leelawadee UI", Tahoma, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12110f; --panel: #1b1a17; --panel-2: #24221e; --fg: #ece8df; --muted: #a39d90; --line: #2f2c27;
    --gold: #d9ae55; --gold-soft: #4a3d22; --up: #4cc38a; --down: #ef7a6f; --bar: #4a463f; --grid: #2a2824;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12110f; --panel: #1b1a17; --panel-2: #24221e; --fg: #ece8df; --muted: #a39d90; --line: #2f2c27;
  --gold: #d9ae55; --gold-soft: #4a3d22; --up: #4cc38a; --down: #ef7a6f; --bar: #4a463f; --grid: #2a2824;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 15px/1.55 var(--font); padding-bottom: env(safe-area-inset-bottom, 0px); }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.top {
  position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px 20px; padding: calc(12px + env(safe-area-inset-top, 0px)) 20px 12px; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mark { width: 38px; height: 38px; border-radius: 8px; display: grid; place-items: center; font: 600 15px var(--mono); color: var(--bg); background: var(--gold); flex: none; }
.brand h1 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: .01em; }
.sub { margin: 0; color: var(--muted); font-size: 12.5px; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.seg button { border: 0; background: none; padding: 5px 10px; font-size: 13px; cursor: pointer; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--gold); color: var(--bg); }
.dates { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.dates input { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 3px 8px; font-size: 13px; }

.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 10px 20px 0; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.tabs button { border: 0; background: none; padding: 8px 12px 10px; cursor: pointer; color: var(--muted); white-space: nowrap; border-bottom: 2px solid transparent; font-size: 14px; }
.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--gold); font-weight: 600; }

main { padding: 20px; max-width: 1400px; margin: 0 auto; }
.state { padding: 60px 0; text-align: center; color: var(--muted); }
.tab { display: flex; flex-direction: column; gap: 18px; }
.lead { margin: 0; max-width: 85ch; color: var(--muted); }
.lead b { color: var(--fg); font-weight: 600; }
h2.sec { margin: 8px 0 0; font-size: 16px; font-weight: 600; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi .l { font-size: 12.5px; color: var(--muted); }
.kpi .v { font: 500 24px/1.2 var(--mono); letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kpi.hl { border-color: var(--gold); box-shadow: inset 3px 0 0 var(--gold); }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.card h3 { margin: 0; font-size: 15px; font-weight: 600; text-wrap: balance; }
.card .note { margin: 0; font-size: 12.5px; color: var(--muted); }
.card .row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.chart { position: relative; min-height: 200px; }
.chart svg { display: block; width: 100%; overflow: visible; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
svg text { font-family: var(--font); font-size: 11.5px; fill: var(--muted); }
svg text.val { fill: var(--fg); font-family: var(--mono); font-size: 11px; }

.tbox { overflow: auto; max-height: 460px; border-radius: 6px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th { position: sticky; top: 0; background: var(--panel); text-align: left; font-weight: 500; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; }
th[aria-sort="ascending"]::after { content: " ▲"; font-size: 10px; }
th[aria-sort="descending"]::after { content: " ▼"; font-size: 10px; }
td { padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td.n, th.n { text-align: right; font-family: var(--mono); }
tr.hot td { background: color-mix(in srgb, var(--gold-soft) 45%, transparent); }
.up { color: var(--up); } .down { color: var(--down); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--panel-2); color: var(--muted); }
.pill.k-nfp, .pill.k-fomc, .pill.k-cpi { background: var(--gold-soft); color: var(--fg); }
.inp { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.inp input { width: 80px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); padding: 3px 6px; font-family: var(--mono); }
.foot { padding: 20px; max-width: 1400px; margin: 0 auto; color: var(--muted); font-size: 12px; }

.tip { position: fixed; z-index: 20; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 24px rgb(0 0 0 / .18); padding: 8px 10px; font-size: 12.5px; min-width: 150px; max-width: 280px; }
.tip .h { color: var(--muted); margin-bottom: 2px; }
.tip .r { display: flex; justify-content: space-between; gap: 14px; }
.tip .r b { font-family: var(--mono); font-weight: 500; }

@media (max-width: 640px) {
  .top { padding-inline: 16px; position: static; }
  .tabs { padding-inline: 12px; }
  main { padding: 16px; }
  .kpi .v { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

#rg-days td:first-child, #rg-days th:first-child { position: sticky; left: 0; background: var(--panel); z-index: 1; }
#rg-days th:first-child { z-index: 2; }
#rg-days .tbox { max-height: 560px; }
