/* RC'sTradeWatch - Rockin Watches palette: ink and graphite surfaces, cyan for the brand, stone/oak for gold, teal for oil.
   Layout: fixed left rail of desks, content in a 12-col grid that collapses to one column on phones. */
:root {
  --bg: #F7F8FA; --panel: #FFFFFF; --panel-2: #EEF1F3; --line: #DFE3E7; --fg: #0B0F14; --muted: #5B6168;
  --gold: #8A6440; --gold-soft: #F1E9DD; --oil: #006A7C; --oil-soft: #DCEEF1;
  --up: #1D7F55; --up-soft: #DDEFE5; --down: #B8433A; --down-soft: #F6E0DD; --warn: #9A6400; --warn-soft: #F5E8CC;
  --rail: #0B0F14; --rail-fg: #F7F8FA; --rail-muted: #A9B0B7; --brand: #00D1FF; --focus: #006A7C;
  --display: "Archivo", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --body: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0B0F14; --panel: #161A20; --panel-2: #11151A; --line: #2E3237; --fg: #F7F8FA; --muted: #A9B0B7;
  --gold: #C9B8A0; --gold-soft: #2A251E; --oil: #35BCD0; --oil-soft: #0E2A30;
  --up: #46B886; --up-soft: #14302A; --down: #E2685F; --down-soft: #3A1F1F; --warn: #E2A640; --warn-soft: #3A2D15;
  --rail: #06090C; --rail-fg: #F7F8FA; --rail-muted: #A9B0B7; --brand: #00D1FF; --focus: #00D1FF; color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #0B0F14; --panel: #161A20; --panel-2: #11151A; --line: #2E3237; --fg: #F7F8FA; --muted: #A9B0B7;
  --gold: #C9B8A0; --gold-soft: #2A251E; --oil: #35BCD0; --oil-soft: #0E2A30;
  --up: #46B886; --up-soft: #14302A; --down: #E2685F; --down-soft: #3A1F1F; --warn: #E2A640; --warn-soft: #3A2D15;
  --rail: #06090C; --rail-fg: #F7F8FA; --rail-muted: #A9B0B7; --brand: #00D1FF; --focus: #00D1FF; color-scheme: dark; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.5 var(--body); }
a { color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -0.015em; text-wrap: balance; margin: 0; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.05rem; } h3 { font-size: 0.95rem; }
.num, td.n, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.label { font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---- shell ---- */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100%; }
.rail { background: var(--rail); color: var(--rail-fg); padding: 20px 14px; display: flex; flex-direction: column; gap: 18px;
        position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 9px; padding: 0 4px; text-decoration: none; }
.brand-mark { width: 46px; height: 32px; display: block; flex: none; }
.brand-name { font: 800 1.08rem/1 var(--display); letter-spacing: -0.02em; color: var(--rail-fg); white-space: nowrap; }
.brand-name b { color: var(--brand); font-weight: 800; } .brand-name span { font-weight: 500; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--rail-muted); padding: 12px 8px 4px; }
.nav a { text-decoration: none; padding: 7px 10px; border-radius: 4px; color: var(--rail-fg); display: flex; justify-content: space-between; align-items: center; }
.nav a:hover { background: rgba(255,255,255,0.06); }
.nav a[aria-current="page"] { background: rgba(0,209,255,0.12); color: var(--brand); box-shadow: inset 2px 0 0 var(--brand); }
.nav .pill { font: 600 0.68rem var(--mono); background: var(--brand); color: #0B0F14; border-radius: 10px; padding: 1px 7px; }
.rail-foot { margin-top: auto; font-size: 0.75rem; color: var(--rail-muted); display: flex; flex-direction: column; gap: 8px; padding: 0 6px; }
.rail-foot button { background: none; border: 1px solid #2E3237; color: var(--rail-fg); border-radius: 4px; padding: 6px 10px; cursor: pointer; font: inherit; text-align: left; }

main { padding-block: 22px 60px; padding-inline: clamp(16px, 3vw, 36px); min-width: 0; }
.topline { display: flex; flex-wrap: wrap; gap: 12px; align-items: baseline; justify-content: space-between; margin-bottom: 18px; }
.status { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.78rem; color: var(--muted); align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--up); margin-right: 6px; vertical-align: 1px; }
.dot.off { background: var(--down); } .dot.warn { background: var(--warn); }
.preview-banner { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn); border-radius: 6px; padding: 8px 12px; margin-bottom: 16px; font-size: 0.82rem; }

.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.c12 { grid-column: span 12; } .c8 { grid-column: span 8; } .c7 { grid-column: span 7; } .c6 { grid-column: span 6; }
.c5 { grid-column: span 5; } .c4 { grid-column: span 4; } .c3 { grid-column: span 3; }
@media (max-width: 1100px) { .c3 { grid-column: span 6; } .c4, .c5, .c7, .c8 { grid-column: span 12; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: sticky; top: env(safe-area-inset-top, 0px); height: auto; z-index: 5; padding: 10px 12px; flex-direction: row; align-items: center; gap: 10px; overflow-x: auto; }
  .nav { flex-direction: row; } .nav-group, .rail-foot { display: none; } .brand-name { display: none; }
  .nav a { white-space: nowrap; }
  .c3, .c6 { grid-column: span 12; }
}

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.scroll { overflow-x: auto; }

/* ---- market card ---- */
.mkt { border-top: 3px solid var(--gold); }
.mkt.oil { border-top-color: var(--oil); }
.mkt-price { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.mkt-price .big { font: 600 2.1rem/1 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.chg { font: 600 0.85rem var(--mono); padding: 2px 8px; border-radius: 4px; }
.chg.up { color: var(--up); background: var(--up-soft); } .chg.down { color: var(--down); background: var(--down-soft); }
.range { position: relative; height: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; }
.range i { position: absolute; top: -4px; width: 2px; height: 12px; background: var(--fg); }
.range-l { display: flex; justify-content: space-between; font: 0.72rem var(--mono); color: var(--muted); }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.kv div { display: flex; flex-direction: column; gap: 2px; }
.kv b { font: 600 0.95rem var(--mono); font-variant-numeric: tabular-nums; }

/* zone ladder: price against today's approved zones */
.ladder { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 4px 10px; font: 0.76rem var(--mono); }
.ladder-track { position: relative; height: 150px; border-left: 1px solid var(--line); }
.zone-band { position: absolute; left: 0; right: 0; border-radius: 0 3px 3px 0; padding: 2px 8px; font: 600 0.7rem var(--body);
             display: flex; justify-content: space-between; align-items: center; gap: 10px; overflow: hidden; white-space: nowrap; min-height: 14px; }
.zone-band.buy { background: var(--up-soft); color: var(--up); border-left: 3px solid var(--up); }
.zone-band.sell { background: var(--down-soft); color: var(--down); border-left: 3px solid var(--down); }
.price-line { position: absolute; left: -6px; right: 0; height: 0; border-top: 2px dashed var(--fg); }
.price-line span { position: absolute; left: -66px; width: 64px; text-align: center; top: -9px; background: var(--fg); color: var(--bg); font: 600 0.7rem var(--mono); padding: 1px 6px; border-radius: 3px; }
.ladder-axis { position: relative; height: 150px; color: var(--muted); }
.ladder-axis span { position: absolute; right: 0; transform: translateY(-50%); }

.lean { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; }
.lean-bar { flex: 1; height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--down) 0 var(--s), var(--up) var(--s) 100%); opacity: 0.85; }

/* ---- generic ---- */
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.n, th.n { text-align: right; }
tr:last-child td { border-bottom: none; }
.tag { display: inline-block; font: 600 0.68rem var(--body); letter-spacing: 0.04em; padding: 2px 7px; border-radius: 10px; white-space: nowrap; }
.tag.buy, .tag.ok, .tag.approved, .tag.win { background: var(--up-soft); color: var(--up); }
.tag.sell, .tag.bad, .tag.rejected, .tag.loss { background: var(--down-soft); color: var(--down); }
.tag.proposed, .tag.warn, .tag.paused { background: var(--warn-soft); color: var(--warn); }
.tag.archived, .tag.neutral { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.tag.gold { background: var(--gold-soft); color: var(--gold); } .tag.oil { background: var(--oil-soft); color: var(--oil); }
.btn { font: 600 0.82rem var(--body); border-radius: 5px; padding: 7px 14px; cursor: pointer; border: 1px solid var(--line); background: var(--panel); color: var(--fg); }
.btn.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn.good { background: var(--up); color: #fff; border-color: var(--up); }
.btn.bad { color: var(--down); border-color: var(--down); background: transparent; }
.btn:disabled { opacity: 0.5; cursor: default; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.note { border-left: 3px solid var(--line); padding: 2px 0 2px 12px; display: flex; flex-direction: column; gap: 3px; }
.note.analysis { border-left-color: var(--gold); } .note.alert { border-left-color: var(--down); } .note.system { border-left-color: var(--oil); }
.note p { margin: 0; max-width: 72ch; white-space: pre-wrap; }
.chart { height: 380px; width: 100%; }
.chart.short { height: 220px; }
.empty { color: var(--muted); font-size: 0.85rem; padding: 18px; text-align: center; border: 1px dashed var(--line); border-radius: 6px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { font: 600 0.78rem var(--body); padding: 5px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); cursor: pointer; }
.tabs button[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.zone-card { border: 1px solid var(--line); border-radius: 6px; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--panel-2); }
.zone-card.approved { border-color: var(--up); background: var(--panel); }
.zone-card.proposed { border-color: var(--warn); background: var(--panel); }
.log { font: 0.74rem/1.55 var(--mono); background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 10px; max-height: 320px; overflow: auto; white-space: pre-wrap; }
.map-frame { width: 100%; height: 78vh; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.md { max-height: 520px; overflow: auto; font-size: 0.85rem; }
.md h1, .md h2, .md h3 { margin: 14px 0 6px; }
.md pre { white-space: pre-wrap; font: 0.78rem var(--mono); }
.spark { width: 100%; height: 46px; display: block; }
.statline { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font: 600 1.25rem var(--mono); font-variant-numeric: tabular-nums; }
.pos { color: var(--up); } .neg { color: var(--down); }

main:focus { outline: none; }
td.clip { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shock-banner { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; text-decoration: none; margin-bottom: 14px;
  padding: 10px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); font-size: 0.85rem; }
.shock-banner.esc { border-color: var(--up); background: var(--up-soft); color: var(--up); }
.shock-banner span { color: var(--muted); }
.guest .owner-only { display: none !important; }
.thread { display: flex; flex-direction: column; gap: 12px; max-height: 60vh; overflow-y: auto; padding-right: 4px; }
.msg { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; max-width: 92%; }
.msg.user { align-self: flex-end; background: var(--panel-2); }
.msg.assistant { align-self: flex-start; border-left: 3px solid var(--brand); }
.msg-who { font-size: 0.72rem; color: var(--muted); margin-bottom: 4px; }
.msg-body { font-size: 0.9rem; } .msg-body ul { margin: 4px 0; padding-left: 18px; }
.askform { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.askform textarea { font: 0.95rem var(--body); padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); color: var(--fg); resize: vertical; }
