/* TradeX — flight recorder for an autonomous trading agent. One field, hairlines, one amber trace. */
@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wdth,wght@12..96,75..100,300..800&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

:root {
  --field: #0E2A31;
  --field-2: #123339;
  --field-3: #173D46;
  --line: #214B55;
  --line-soft: #1A3F48;
  --ink: #E9F1F1;
  --ink-2: #9DB7BC;
  --ink-3: #6E8A90;
  --trace: #D39A2B;
  --trace-soft: rgba(211, 154, 43, .12);
  --up: #2FB380;
  --down: #E86352;
  --danger: #C9402F;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --text: 'IBM Plex Sans', system-ui, sans-serif;
  --pad: clamp(16px, 3vw, 36px);
  --side: 196px;
  --bottom: 62px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--field); color: var(--ink); font-family: var(--text); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.up { color: var(--up); }
.down { color: var(--down); }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
:focus-visible { outline: 2px solid var(--trace); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---- shell: sidebar on desktop, bottom nav on mobile ------------------------- */
.shell { min-height: 100dvh; }
.side { display: none; }
.content { padding: 0 var(--pad) calc(var(--bottom) + 24px); max-width: 1180px; }
.bottom { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--bottom) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(5, 1fr); background: rgba(14, 42, 49, .92); backdrop-filter: blur(10px); border-top: 1px solid var(--line-soft); z-index: 5; }
.bottom a, .nav a { text-decoration: none; color: var(--ink-3); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11.5px; }
.bottom a .ic, .nav a .ic { font-size: 17px; line-height: 1; }
.bottom a[aria-current="page"], .nav a[aria-current="page"] { color: var(--ink); }
.bottom a[aria-current="page"] .ic, .nav a[aria-current="page"] .ic { color: var(--trace); }
.mobile-only { display: inline-flex; }
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: var(--side) 1fr; }
  .side { display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh; padding: 18px 16px; border-right: 1px solid var(--line-soft); }
  .nav { display: flex; flex-direction: column; gap: 2px; margin-top: 26px; }
  .nav a { flex-direction: row; justify-content: flex-start; gap: 10px; padding: 9px 10px; border-radius: 8px; font-size: 14px; }
  .nav a[aria-current="page"] { background: var(--field-2); }
  .side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
  .bottom { display: none; }
  .mobile-only { display: none !important; }
  .content { padding-bottom: 60px; }
}

/* ---- header ------------------------------------------------------------------ */
.wordmark { font-family: var(--display); font-weight: 800; font-size: 22px; letter-spacing: -0.03em; font-variation-settings: 'opsz' 96, 'wdth' 100; }
.wordmark b { color: var(--trace); font-weight: 700; }
.top { display: flex; align-items: center; gap: 14px; padding: 14px 0 0; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; }
.tab { background: transparent; border: 1px solid transparent; border-radius: 999px; padding: 5px 12px; color: var(--ink-2); }
.tab[aria-selected="true"] { color: var(--ink); border-color: var(--line); background: var(--field-2); }
.top .live { margin-left: auto; }
.live { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); font-size: 13px; }
/* the loop's heartbeat, literally */
.ecg { width: 44px; height: 14px; flex: none; }
.ecg path { fill: none; stroke: var(--ink-3); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; stroke-dasharray: 140; stroke-dashoffset: 0; }
.live.on .ecg path { stroke: var(--up); animation: ecg 1.6s linear infinite; }
.live.paused .ecg path { stroke: var(--trace); animation: ecg 3.2s linear infinite; }
.live.killed .ecg path, .live.dead .ecg path { stroke: var(--down); animation: none; }
@keyframes ecg { from { stroke-dashoffset: 140; } to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .ecg path { animation: none !important; } }
.hb { color: var(--ink-3); font-size: 12.5px; }
.linkbtn { background: none; border: 0; color: var(--ink-3); padding: 4px 0; text-decoration: underline; text-underline-offset: 3px; }

/* ---- hero ---------------------------------------------------------------------- */
.hero { padding-top: 22px; }
.hero-row { display: flex; align-items: flex-end; gap: 22px; flex-wrap: wrap; }
.equity { font-family: var(--display); font-weight: 600; font-size: clamp(52px, 9.5vw, 92px); line-height: .92; letter-spacing: -0.03em; font-variation-settings: 'opsz' 96, 'wdth' 78; }
.equity small { font-size: .42em; color: var(--ink-2); font-weight: 500; letter-spacing: 0; margin-left: 4px; }
.delta { font-family: var(--display); font-size: clamp(18px, 3vw, 24px); font-weight: 500; padding-bottom: 6px; }
.delta span { display: block; font-family: var(--text); font-size: 13px; color: var(--ink-2); font-weight: 400; }
.ranges { margin-left: auto; display: flex; gap: 2px; padding-bottom: 8px; }
.ranges button { background: none; border: 0; color: var(--ink-3); padding: 4px 9px; border-radius: 6px; }
.ranges button[aria-pressed="true"] { color: var(--ink); background: var(--field-2); }
.trace { position: relative; margin-top: 10px; height: clamp(160px, 30vw, 280px); }
.trace svg, .bars svg { width: 100%; height: 100%; display: block; overflow: visible; }
.trace .tip { position: absolute; top: 8px; left: 0; transform: translateX(-50%); background: var(--field-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 13px; pointer-events: none; white-space: nowrap; display: none; }
.trace .mk-buy { fill: var(--up); } .trace .mk-sell { fill: var(--trace); } .trace .mk-stop { fill: var(--down); } .trace .mk-flag { fill: var(--ink-3); }
.trace .band { fill: rgba(0, 0, 0, .16); }
.trace .mklab { font-size: 10px; fill: var(--ink-3); }
.trace .empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-3); font-size: 14px; text-align: center; padding: 0 20px; }

/* regime + mood */
.climate { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; font-size: 13px; color: var(--ink-2); }
.climate .reason { flex-basis: 100%; color: var(--ink-3); font-size: 12.5px; }
.badge { display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px 4px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); }
.badge i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; background: var(--ink-3); transform: rotate(45deg); }
.badge.on { border-color: var(--up); color: #9FE2C4; } .badge.on i { background: var(--up); }
.badge.off { border-color: var(--down); color: #FFB3A8; } .badge.off i { background: var(--down); }
.badge.mid { border-color: var(--trace); color: #F5D08A; } .badge.mid i { background: var(--trace); }
body[data-mood="risk-on"] .hero { background: radial-gradient(60% 50% at 0% 0%, rgba(211, 154, 43, .10), transparent 70%); }
body[data-mood="risk-off"] .hero { background: radial-gradient(60% 50% at 0% 0%, rgba(99, 160, 190, .14), transparent 70%); }

/* rubber stamp — only for the states that deserve one */
.stamp { display: inline-block; font-family: var(--display); font-weight: 800; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--down); border: 2.5px double var(--down); border-radius: 4px; padding: 3px 9px; transform: rotate(-4deg); opacity: .9; }
.stamp.warn { color: var(--trace); border-color: var(--trace); }

.voice { padding-top: 20px; margin-top: 16px; border-top: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 24px; align-items: start; }
.voice p { margin: 0; font-family: var(--display); font-weight: 400; font-size: clamp(19px, 2.4vw, 25px); line-height: 1.25; letter-spacing: -0.01em; max-width: 60ch; }
.voice .meta { color: var(--ink-2); font-size: 13px; white-space: nowrap; padding-top: 6px; text-align: right; }
.voice .meta b { color: var(--ink); font-weight: 500; }

/* ---- stats ------------------------------------------------------------------------ */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 20px; margin-top: 18px; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { padding: 12px 0 12px; border-top: 1px solid var(--line-soft); }
.stat .v { font-family: var(--display); font-weight: 600; font-size: 24px; letter-spacing: -0.02em; font-variation-settings: 'opsz' 96, 'wdth' 82; }
.stats.tight .stat .v { font-size: 20px; }
.stat .l { color: var(--ink-2); font-size: 13px; margin-top: 2px; }

/* ---- sections ----------------------------------------------------------------------- */
.view { padding-bottom: 20px; }
section { padding-top: 26px; }
.two { display: grid; grid-template-columns: 1fr; gap: 0 40px; }
@media (min-width: 900px) { .two { grid-template-columns: 1fr 1fr; } }
h2 { font-family: var(--display); font-weight: 600; font-size: 17px; letter-spacing: -0.01em; margin: 0 0 10px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
h2 .muted, h2 .more { font-family: var(--text); font-weight: 400; font-size: 13px; }
h2 .more { margin-left: auto; color: var(--ink-2); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th + th, td + td { padding-left: 12px; }
th { text-align: left; font-weight: 500; color: var(--ink-2); font-size: 12.5px; padding: 6px 0; border-bottom: 1px solid var(--line); }
td { padding: 9px 0; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th.r, td.r { text-align: right; }
td.num { white-space: nowrap; }
td .sub { display: block; color: var(--ink-2); font-size: 12.5px; margin-top: 2px; max-width: 52ch; }
tr.x { cursor: pointer; }
tr.x:hover td { background: var(--field-2); }
tr.detail td { background: var(--field-2); color: var(--ink-2); font-size: 13px; padding: 10px 12px; }
.empty { color: var(--ink-3); padding: 18px 0; font-size: 14px; }

/* key/value lists */
.kv { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.kv li { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.kv li span:first-child { color: var(--ink-2); }
.kv li span:last-child { text-align: right; max-width: 68%; overflow-wrap: anywhere; }

/* positions with stop→target track */
.positions { display: flex; flex-direction: column; }
.pos { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
.pos .sym { font-weight: 600; font-size: 16px; }
.pos .sym small { color: var(--ink-2); font-weight: 400; font-size: 13px; margin-left: 8px; }
.pos .pl { text-align: right; font-weight: 500; }
.pos .pl small { display: block; font-weight: 400; font-size: 12.5px; }
.pos .thesis { grid-column: 1 / -1; color: var(--ink-2); font-size: 13px; max-width: 70ch; }
.track { grid-column: 1 / -1; position: relative; height: 34px; margin-top: 6px; }
.track .rail { position: absolute; left: 0; right: 0; top: 15px; height: 4px; background: var(--field-3); border-radius: 2px; }
.track .fill { position: absolute; top: 15px; height: 4px; background: var(--trace); border-radius: 2px; opacity: .55; }
.track .mk { position: absolute; top: 10px; width: 14px; height: 14px; border-radius: 50%; background: var(--ink); border: 3px solid var(--field); transform: translateX(-50%); box-shadow: 0 0 0 1px var(--trace); }
.track .lab { position: absolute; top: 24px; font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }
.track .lab.l { left: 0; } .track .lab.r { right: 0; } .track .lab.c { transform: translateX(-50%); color: var(--ink-2); top: -4px; }
.track .tick { position: absolute; top: 11px; width: 2px; height: 12px; }
.track .tick.stop { left: 0; background: var(--down); } .track .tick.target { right: 0; background: var(--up); }
.track.nostop { opacity: .6; }

/* rules */
.rules { margin: 0; padding-left: 22px; font-size: 14.5px; }
.rules li { padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.rules li::marker { color: var(--trace); font-weight: 600; }

/* log (compact, expandable) */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 10px; }
.chips button, .chips a { border: 1px solid var(--line); background: transparent; color: var(--ink-2); border-radius: 999px; padding: 4px 11px; font-size: 13px; text-decoration: none; }
.chips button[aria-pressed="true"] { background: var(--field-2); color: var(--ink); }
.log { list-style: none; margin: 0; padding: 0; }
.log li { display: grid; grid-template-columns: 52px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.log li time { color: var(--ink-3); font-size: 12.5px; padding-top: 3px; }
.log .ph { color: var(--ink-3); font-size: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.log .ph b { color: var(--ink-2); font-weight: 500; }
.log .ph .err { color: var(--down); }
.log .ph .skip { color: var(--ink-3); font-style: italic; }
.log p { margin: 2px 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 14px; }
.log li.open p { display: block; -webkit-line-clamp: unset; }
.log li.skipped p { color: var(--ink-3); font-size: 13.5px; }
.full { display: none; white-space: pre-wrap; background: var(--field-2); border: 1px solid var(--line-soft); border-radius: 8px; padding: 10px 12px; margin-top: 8px; font-size: 12.5px; max-height: 460px; overflow: auto; color: var(--ink-2); }
.log li.open .full { display: block; }
.full .calls { margin: 0 0 10px; padding: 0; list-style: none; }
.full .calls li { display: flex; gap: 8px; padding: 2px 0; border: 0; cursor: default; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.full .calls li .ok { color: var(--up); } .full .calls li .bad { color: var(--down); }
.btn.ghost { background: transparent; margin-top: 12px; width: 100%; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; align-items: start; }
.timeline .k { font-size: 14px; line-height: 1.3; text-align: center; }
.timeline time { color: var(--ink-3); font-size: 12.5px; white-space: nowrap; padding-top: 2px; }
.timeline .t small { display: block; color: var(--ink-3); font-size: 12px; }
.timeline.compact li { padding: 7px 0; font-size: 13.5px; }
.k.order { color: var(--trace); } .k.stop, .k.kill, .k.err, .k.liq { color: var(--down); } .k.trail, .k.loop { color: var(--ink-3); } .k.breaker, .k.gate { color: var(--trace); }

/* cost bars */
.bars { position: relative; height: 150px; margin-top: 4px; }

/* controls */
.controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.btn { border: 1px solid var(--line); background: var(--field-2); border-radius: 10px; padding: 10px 16px; font-weight: 500; }
.btn:hover { border-color: var(--ink-3); }
.btn.danger { border-color: var(--danger); color: #FFD9D2; background: rgba(201, 64, 47, .16); }
.btn.danger:hover { background: rgba(201, 64, 47, .3); }
.btn.armed { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn:disabled { opacity: .45; cursor: default; }
.note { color: var(--ink-2); font-size: 13px; margin: 10px 0 0; max-width: 62ch; }
.flags { display: flex; gap: 8px; flex-wrap: wrap; }
.flag { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); font-size: 12.5px; color: var(--ink-2); }
.flag.warn { border-color: var(--trace); color: #F5D08A; }
.flag.bad { border-color: var(--down); color: #FFB3A8; }
.flag.ok { border-color: var(--up); color: #9FE2C4; }

/* ---- login -------------------------------------------------------------------------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login form, .login-box { width: min(360px, 100%); }
.login-box > .btn { display: block; text-align: center; text-decoration: none; margin-bottom: 14px; }
.login-box form { margin-bottom: 8px; }
.login .wordmark { font-size: 34px; margin-bottom: 26px; }
.login label { display: block; color: var(--ink-2); font-size: 13px; margin-bottom: 6px; }
.login input { width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--field-2); color: var(--ink); font: inherit; font-size: 16px; }
.login input:focus { outline: 2px solid var(--trace); outline-offset: 1px; border-color: transparent; }
.login .btn { width: 100%; margin-top: 12px; padding: 12px; }
.login .err { color: var(--down); font-size: 13px; margin-top: 10px; }
.login .hint { color: var(--ink-3); font-size: 13px; margin-top: 22px; max-width: 40ch; }

/* ---- kontroll ---------------------------------------------------------------------- */
.ccy { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.ccy button { background: transparent; border: 0; padding: 4px 10px; font-size: 12.5px; color: var(--ink-3); }
.ccy button[aria-pressed="true"] { background: var(--field-2); color: var(--ink); }
.top .ccy { margin-left: auto; } .top .ccy + .live { margin-left: 0; }
.actions { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.action { display: grid; grid-template-columns: 1fr; gap: 8px 18px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; color: var(--ink-2); line-height: 1.5; }
.action b { color: var(--ink); font-weight: 500; }
.action .btn { justify-self: start; white-space: nowrap; }
@media (min-width: 700px) { .action { grid-template-columns: 200px 1fr; align-items: start; } }
.cfg { display: grid; grid-template-columns: 1fr; gap: 0 36px; }
@media (min-width: 900px) { .cfg { grid-template-columns: 1fr 1fr; } }
.cfg h3 { grid-column: 1 / -1; font-family: var(--display); font-weight: 600; font-size: 15px; margin: 22px 0 4px; color: var(--ink-2); }
.cfg h3:first-child { margin-top: 6px; }
.field { display: grid; grid-template-columns: 1fr 120px; gap: 2px 14px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); align-items: center; }
.field label { font-size: 14px; display: flex; align-items: center; gap: 8px; }
.field .ov { font-size: 11px; color: var(--trace); border: 1px solid var(--trace); border-radius: 999px; padding: 0 7px; }
.field input[type="number"], .field input[type="text"], .field select, .field textarea { width: 100%; background: var(--field-2); border: 1px solid var(--line); color: var(--ink); border-radius: 8px; padding: 7px 10px; font: inherit; font-size: 14px; font-variant-numeric: tabular-nums; text-align: right; }
.field textarea { grid-column: 1 / -1; text-align: left; min-height: 64px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--trace); outline-offset: 1px; border-color: transparent; }
.field .help { grid-column: 1 / -1; color: var(--ink-3); font-size: 12.5px; line-height: 1.45; }
.field .eq { color: var(--ink-3); font-size: 12px; text-align: right; }
.field.bool { grid-template-columns: 1fr auto; }
.switch { position: relative; width: 40px; height: 22px; border-radius: 999px; background: var(--field-3); border: 1px solid var(--line); cursor: pointer; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch i { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--ink-3); transition: transform .15s; }
.switch input:checked + i { background: var(--up); transform: translateX(18px); }
.cfg-dirty .field input, .cfg-dirty .field select { border-color: var(--line); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: var(--field-2); padding: 1px 5px; border-radius: 4px; }
