/* Trading Buddy dashboard. Built on tasteskill's app.css, set to its "data terminal" style:
   cards darker than the ground, figures in a mono that stacks, signs in the text instead of
   colour, and one 1px accent line as the only selection mark. */

:root {
  --ground: #171719; --surface: #131217; --raised: #212023; --active: #212023;
  --border: #222224; --rule: #1b1a1f; --control: #3a3a3e;
  --text: #ffffff; --muted: #8a8c92; --faint: #8a8c92;
  --accent: #4a8ad6;
  --primary: #ffffff; --primary-ink: #131217;
  --positive: #44a282; --negative: #e5566f; --warning: #d9a441;
  --pill-positive-bg: #1b2828; --pill-positive-ink: #5fc39c;
  --pill-negative-bg: #2c1a20; --pill-negative-ink: #e5566f;
  --pill-warning-bg: #2a2416; --pill-warning-ink: #d9a441;
  --pill-neutral-bg: #212023; --pill-neutral-ink: #bdbdc0;
  --chart-1: #4a8ad6; --chart-2: #e5566f; --chart-3: #4a8ad6; --chart-muted: #4a4a4e;
  --chart-mark: var(--text); --chart-span: 0.12;
  --grid: #26252a; --axis-ink: var(--muted); --ink: var(--text);

  --font: "Public Sans", Inter, system-ui, sans-serif;
  /* the style's decision: every figure in a mono, so prices, counts and times stack */
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --fs-title: 26px; --fs-section: 16px; --fs-kpi: 20px; --fs-body: 13px; --fs-small: 12px;
  --rail: 56px; --pad: 32px; --gap: 24px; --card-pad: 20px;
  --radius-card: 6px; --radius-control: 999px; --control-height: 34px; --row-height: 42px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1); --t-hover: 150ms; --t-ui: 200ms;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; color-scheme: dark; }
body { margin: 0; background: var(--ground); color: var(--text); font: var(--fs-body)/20px var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, ol, ul, dl, dd, figure, fieldset { margin: 0; }
ol, ul { padding: 0; list-style: none; }
fieldset { border: 0; padding: 0; min-width: 0; }
svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
code { font-family: var(--mono); font-size: 12px; background: var(--raised); padding: 1px 5px; border-radius: 4px; }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.num, td.n, .kpi-value, table time { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.down { color: var(--negative); }
.warn-text { color: var(--warning); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.hint { color: var(--muted); font-size: var(--fs-small); }

/* ---------- shell: an unlabelled icon rail ---------- */
.app { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100svh; }
.rail { position: sticky; top: 0; height: 100svh; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 0; border-right: 1px solid var(--border); }
.rail .mark { display: grid; place-items: center; width: 34px; height: 34px; margin-bottom: 18px; border-radius: 8px; background: var(--text); color: var(--ground); }
.rail svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.rail-item { position: relative; display: grid; place-items: center; width: var(--rail); height: 42px; border: 0; background: none; color: var(--muted); cursor: pointer; transition: color var(--t-hover) ease; }
.rail-item span { position: absolute; left: calc(100% - 4px); padding: 4px 8px; border-radius: 4px; background: var(--raised); color: var(--text); font-size: var(--fs-small); white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity var(--t-hover) ease; z-index: 5; }
.rail-item:hover, .rail-item:focus-visible { color: var(--text); }
.rail-item:hover span, .rail-item:focus-visible span { opacity: 1; }
.rail-item[aria-current="page"] { color: var(--text); }
.rail-item[aria-current="page"]::after { content: ""; position: absolute; right: -1px; top: 9px; bottom: 9px; width: 1px; background: var(--accent); }
.rail-bottom { margin-top: auto; }
.canvas { min-width: 0; padding: 28px var(--pad) 48px; max-width: 1440px; }

/* ---------- title and messages ---------- */
.title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.title-row h1 { font-size: var(--fs-title); line-height: 1.2; font-weight: 600; letter-spacing: -0.015em; }
.title-row .sub { margin-top: 6px; color: var(--muted); }
.title-row .mode { color: var(--text); font-weight: 500; }
.actions { display: flex; gap: 8px; }
.crumb { margin-bottom: 12px; }
.flash { margin-bottom: 16px; padding: 10px 14px; border-left: 1px solid var(--accent); background: var(--surface); }
.alerts { display: grid; gap: 8px; margin-bottom: var(--gap); }
.alert { padding: 10px 14px; border-radius: var(--radius-card); background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); }
.alert b { color: var(--text); font-weight: 600; margin-right: 4px; }
.alert.warn { background: var(--pill-warning-bg); } .alert.warn b { color: var(--pill-warning-ink); }
.alert.neg { background: var(--pill-negative-bg); } .alert.neg b { color: var(--pill-negative-ink); }
.error { color: var(--negative); }
.alert-action { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; }
form.inline { display: inline; }
button.card-link { border: 0; background: none; padding: 0; font: inherit; cursor: pointer; }

/* ---------- panels ---------- */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); }
.grid.top { align-items: start; }
.canvas > .panel + .kpis, .canvas > .kpis + .grid, .canvas > .grid + .panel, .canvas > .panel + .grid, .canvas > .panel + .panel, .canvas > .kpis + .tabs, .canvas > .grid + details, .canvas > .panel + details { margin-top: var(--gap); }
.legend { margin-top: 4px; }
.span-4 { grid-column: span 4; } .span-6 { grid-column: span 6; } .span-8 { grid-column: span 8; } .span-12 { grid-column: 1 / -1; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--card-pad); min-width: 0; }
.panel.flush { padding: 4px 8px; }
.panel > header { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 16px; }
.panel h2 { font-size: var(--fs-section); line-height: 1.3; font-weight: 600; }
.meta { color: var(--muted); font-size: var(--fs-small); }
.sub-h { margin: 16px 0 6px; font-size: var(--fs-body); font-weight: 600; }
.plain li { padding: 2px 0; } .plain li::before { content: "– "; color: var(--muted); }
.card-link { display: inline-flex; align-items: center; gap: 4px; color: var(--text); font-weight: 500; text-underline-offset: 3px; }
.card-link::after { content: "›"; color: var(--muted); }
.card-link.back::after { content: none; } .card-link.back::before { content: "‹"; color: var(--muted); }
.card-link:hover { text-decoration: underline; }
.empty { display: grid; place-items: center; min-height: 88px; padding: 16px; border: 1px dashed var(--control); border-radius: var(--radius-card); color: var(--muted); text-align: center; }
.panel.flush .empty { margin: 12px; }

/* key-value lists */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 0 16px; }
.kv dt { color: var(--muted); padding: 8px 0; border-bottom: 1px solid var(--rule); }
.kv dd { padding: 8px 0; text-align: right; border-bottom: 1px solid var(--rule); }
.kv dt:nth-last-of-type(1), .kv dd:last-of-type { border-bottom: 0; }
.kv.tight dt, .kv.tight dd { padding: 3px 0; border: 0; }
.kv.tight dd { text-align: left; }
.kv.inline { display: flex; gap: 6px 20px; flex-wrap: wrap; }
.kv.inline dt, .kv.inline dd { padding: 0; border: 0; }
.kv.inline dd { margin-right: 4px; }

/* ---------- Today: P&L, the limit, the day strip ---------- */
.pnl { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 24px; }
.pnl-figure { font-size: 44px; line-height: 1.05; font-weight: 500; letter-spacing: -0.03em; }
.pnl + .chart-head { margin-top: 24px; }
.limit { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--rule); }
.limit-head { flex-wrap: wrap; }
.limit-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; color: var(--muted); }
.limit-head .num { color: var(--text); }
.bar { height: 6px; border-radius: 3px; background: var(--raised); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--text); }
.limit .hint { margin-top: 6px; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 8px; }
.chart-head h3 { font-size: var(--fs-body); font-weight: 500; }
.chart { position: relative; min-width: 0; }

.strip { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 3px; padding-bottom: 22px; }
.slot { position: relative; }
.slot > a, .slot > span { display: block; height: 36px; border-radius: 3px; background: var(--raised); }
.slot > a:hover { outline: 1px solid var(--accent); outline-offset: 1px; }
.slot time { position: absolute; left: 0; top: 42px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.slot:last-child time { left: auto; right: 0; }
.slot.traded > a, i.slot.traded { background: var(--text); }
.slot.closing > a, i.slot.closing { background: var(--surface); outline: 1.5px solid var(--text); outline-offset: -1.5px; }
.slot.rejected > a, i.slot.rejected { background: var(--negative); }
.slot.jev > a, .slot.dropped > a, .slot.none > a, i.slot.none { background: #4a4a4e; }
.slot.error > a, i.slot.error { background: var(--warning); }
.slot.missed > span, i.slot.missed { background: transparent; outline: 1px dashed var(--muted); outline-offset: -1px; }
.slot.later > span { background: var(--rule); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; color: var(--muted); font-size: var(--fs-small); }
.legend li { display: inline-flex; align-items: center; gap: 8px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; }

/* the decision chain: Claude → Jev → Risk Engine → Order */
.chain { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
.step { position: relative; padding: 0 20px; display: grid; align-content: start; gap: 4px; }
.step:first-child { padding-left: 0; }
.step + .step { border-left: 1px solid var(--border); }
.step + .step::before { content: "›"; position: absolute; left: -5px; top: -1px; width: 9px; background: var(--surface); color: var(--muted); text-align: center; line-height: 18px; }
.step h3 { font-size: var(--fs-small); font-weight: 500; color: var(--muted); }
.step-head { font-size: 15px; font-weight: 600; }
.step.skipped .step-head, .step.skipped p { color: var(--muted); }
.stopped { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--rule); color: var(--warning); }
.thesis-text { margin-top: 16px; max-width: 80ch; font-size: 14px; line-height: 22px; }
.panel > .thesis-text:first-of-type { margin-top: 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { height: 36px; padding: 0 12px; text-align: left; font-weight: 400; font-size: var(--fs-small); color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--rule); vertical-align: baseline; }
tbody tr:last-child td { border-bottom: 0; }
th.n, td.n { text-align: right; }
td b { font-weight: 600; }
td .sub { display: block; margin-top: 2px; font-size: var(--fs-small); color: var(--muted); font-family: var(--font); }
td .sub .num { font-family: var(--mono); }
.truncate { max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.linked td a { text-decoration: underline; text-decoration-color: var(--control); text-underline-offset: 3px; }
table.linked td a:hover { text-decoration-color: var(--accent); }
tr.thesis td { padding-top: 0; color: var(--muted); font-size: var(--fs-small); }
tr:has(+ tr.thesis) td { border-bottom: 0; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions form { display: inline-flex; gap: 6px; margin-left: 6px; }
.row-actions .input { width: 110px; height: var(--control-height); }
.rows .row { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 8px 0; }
.rows .row + .row { border-top: 1px solid var(--rule); }

.pill { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; font-size: var(--fs-small); font-weight: 500; background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); white-space: nowrap; font-family: var(--font); }
.pill.pos { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.pill.neg { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
.pill.warn { background: var(--pill-warning-bg); color: var(--pill-warning-ink); }

.kpis { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); }
.kpi { padding: 16px var(--card-pad); }
.kpi + .kpi { border-left: 1px solid var(--border); }
.kpi-label { color: var(--muted); }
.kpi-value { margin-top: 6px; font-size: var(--fs-kpi); line-height: 1.2; font-weight: 500; }
.kpi-value small { font-size: 0.65em; color: var(--muted); font-weight: 400; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; height: var(--control-height); padding: 0 16px; border-radius: var(--radius-control); border: 1px solid var(--control); background: transparent; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background-color var(--t-hover) ease, border-color var(--t-hover) ease; }
.btn:hover { background: var(--raised); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn.primary:hover { background: #e4e4e6; }
.field { display: grid; gap: 8px; }
.field label, .field legend { font-weight: 500; }
.field legend { margin-bottom: 8px; }
.input { height: 38px; padding: 0 12px; border: 1px solid var(--control); border-radius: var(--radius-card); background: var(--ground); width: 100%; }
textarea.input { height: auto; padding: 10px 12px; line-height: 20px; resize: vertical; }
.input::placeholder { color: var(--muted); }
.input:focus { border-color: var(--accent); outline: none; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.checks label { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; }
input[type="checkbox"] { accent-color: var(--text); width: 15px; height: 15px; }
.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--border); margin-bottom: var(--gap); overflow-x: auto; }
.tabs a { position: relative; padding: 10px 0; color: var(--muted); white-space: nowrap; transition: color var(--t-hover) ease; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-selected="true"] { color: var(--text); }
.tabs a[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: var(--accent); }

/* ---------- Performance ---------- */
.section-h { padding-top: 8px; }
.section-h h2 { font-size: var(--fs-section); font-weight: 600; }
.section-h .meta { margin-top: 4px; }
.stack { display: grid; gap: var(--gap); align-content: start; }
.funnel-note { margin: -8px 0 14px; }
tr.none td { color: var(--muted); }
td.n { white-space: nowrap; }
.funnel { display: grid; gap: 10px; }
.stack .funnel li { grid-template-columns: minmax(0, 1fr) 40px; gap: 4px 12px; }
.stack .f-bar { grid-column: 1 / -1; grid-row: 2; }
.funnel li { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr) 48px; align-items: center; gap: 16px; min-height: 28px; }
.f-label { color: var(--muted); }
.f-bar { height: 10px; background: var(--raised); border-radius: 2px; overflow: hidden; }
.f-bar i { display: block; height: 100%; background: var(--accent); }
.f-n { text-align: right; }

/* ---------- Daily report ---------- */
.day-nav { align-items: center; }
.day-nav .input { width: 160px; height: var(--control-height); }
.summary-lines { display: grid; gap: 4px; font-size: 14px; line-height: 22px; }
.summary .alert { margin-top: 12px; }
.panel.flush > .flush-head { padding: 16px 12px 0; }
.truncate.wide { max-width: 60ch; }
.two-line { display: grid; gap: 2px; }

/* ---------- Settings: label column beside a panel ---------- */
.settings, .setting-row { max-width: 1152px; }
.setting-row { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 32px; padding: 32px 0; border-top: 1px solid var(--border); }
.settings .setting-row:first-of-type { border-top: 0; padding-top: 8px; }
.setting-label h2 { font-size: var(--fs-section); font-weight: 500; }
.setting-label p { margin-top: 6px; color: var(--muted); max-width: 40ch; }
.setting-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); }
.setting-panel:has(textarea) { grid-template-columns: minmax(0, 1fr); }
.setting-panel .field:has(fieldset), .setting-panel fieldset { grid-column: 1 / -1; }
.setting-panel.flush { display: block; padding: 4px 8px; }
.save-bar { position: sticky; bottom: 0; display: flex; justify-content: flex-end; padding: 12px 0; background: var(--ground); border-top: 1px solid var(--border); }

/* ---------- decision detail ---------- */
details.raw summary { cursor: pointer; font-weight: 500; }
details.raw pre { margin: 16px 0 0; max-height: 520px; overflow: auto; font: 12px/18px var(--mono); color: var(--muted); }

/* ---------- login ---------- */
.login { display: grid; place-items: center; min-height: 100svh; padding: 16px; }
.login-card { display: grid; gap: 16px; width: min(380px, 100%); padding: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); }
.login-card h1 { font-size: 22px; font-weight: 600; }
.login-card .muted { margin-top: -8px; }
.login-card .btn { width: 100%; margin-top: 4px; }

/* ---------- narrower ---------- */
@media (max-width: 1100px) {
  .span-4, .span-6, .span-8 { grid-column: 1 / -1; }
  .chain { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 20px; }
  .step:nth-child(3) { padding-left: 0; border-left: 0; }
  .step:nth-child(3)::before { content: none; }
}
@media (max-width: 860px) {
  :root { --pad: 16px; --gap: 16px; }
  .app { grid-template-columns: minmax(0, 1fr); padding-bottom: 64px; }
  /* the rail becomes a bottom bar with labels */
  .rail { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: 60px; flex-direction: row; justify-content: space-around; padding: 0 4px; border-right: 0; border-top: 1px solid var(--border); background: var(--ground); z-index: 10; }
  .rail .mark { display: none; }
  .rail-bottom { margin-top: 0; }
  .rail-item { width: auto; min-width: 60px; height: 60px; align-content: center; gap: 3px; }
  .rail-item span { position: static; padding: 0; opacity: 1; background: none; color: inherit; font-size: 11px; }
  .rail-item[aria-current="page"]::after { right: 14px; left: 14px; top: -1px; bottom: auto; width: auto; height: 1px; }
  .canvas { padding: 20px var(--pad) 32px; }
  .title-row { flex-wrap: wrap; align-items: flex-start; }
  .pnl-figure { font-size: 36px; }
  .strip { gap: 2px; }
  .slot > a, .slot > span { height: 30px; }
  .slot time { display: none; }
  .slot:first-child time, .slot:last-child time { display: block; top: 34px; }
  .setting-row { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 24px 0; }
  .setting-panel { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-auto-flow: row; }
  .funnel li { grid-template-columns: minmax(0, 1fr) 40px; gap: 4px 12px; }
  .f-bar { grid-column: 1 / -1; grid-row: 2; }
  .kpi + .kpi { border-left: 0; border-top: 1px solid var(--border); }
  .chain { grid-template-columns: minmax(0, 1fr); }
  .step { padding: 0 0 16px; }
  .step + .step { border-left: 0; border-top: 1px solid var(--border); padding-top: 16px; }
  .step + .step::before { content: none; }
  .row-actions { text-align: left; }
  /* open trades: one card per trade instead of a table that scrolls sideways */
  table.cards thead { display: none; }
  table.cards tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; padding: 14px 4px; border-bottom: 1px solid var(--rule); }
  table.cards tr.thesis { padding-top: 0; }
  table.cards td { display: block; padding: 0; border: 0; text-align: left; }
  table.cards td[data-label]::before { content: attr(data-label); display: block; font: var(--fs-small)/16px var(--font); color: var(--muted); }
  table.cards td:first-child, table.cards td.row-actions, table.cards tr.thesis td { grid-column: 1 / -1; }
  .row-actions form { margin: 4px 6px 0 0; }
}
@media (max-width: 480px) { .opt { display: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0.01ms !important; } }
