/* Steadfast - desktop portal styles
   Principle: the agent speaks in a serif voice (its reasoning, thoughts, lessons);
   everything the machine measures is set in a crisp sans with aligned figures. */

/* Fonts are bundled in frontend/fonts (SIL Open Font License) so the portal works offline. */
@font-face { font-family: "Instrument Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("/static/fonts/instrument-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("/static/fonts/instrument-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("/static/fonts/instrument-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-style: normal; font-weight: 700; font-display: swap; src: url("/static/fonts/instrument-sans-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Instrument Serif"; font-style: normal; font-weight: 400; font-display: swap; src: url("/static/fonts/instrument-serif-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Instrument Serif"; font-style: italic; font-weight: 400; font-display: swap; src: url("/static/fonts/instrument-serif-latin-400-italic.woff2") format("woff2"); }

:root {
  --bg: #EEF2F6;
  --rail: #E5EAF1;
  --panel: #FFFFFF;
  --panel-2: #F6F8FB;
  --panel-3: #EDF1F7;
  --ink: #13213A;
  --ink-2: #34425C;
  --muted: #5C6880;
  --faint: #8A95A9;
  --rule: #DCE3EC;
  --rule-2: #C7D1DE;
  --accent: #3355D8;
  --accent-ink: #FFFFFF;
  --accent-soft: #E4EAFD;
  --profit: #0E7C5E;
  --profit-soft: #DCF2EA;
  --loss: #C8432F;
  --loss-soft: #FAE3DE;
  --warn: #A26A0C;
  --warn-soft: #F7EDD6;
  --chart-line: #3355D8;
  --chart-fill: rgba(51, 85, 216, 0.10);
  --chart-grid: #E4E9F0;
  --shadow: 0 1px 2px rgba(19, 33, 58, .05), 0 6px 24px -12px rgba(19, 33, 58, .10);
  --radius-l: 14px;
  --radius-m: 10px;
  --radius-s: 7px;
  --font-ui: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-voice: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D1524; --rail: #0A111E; --panel: #131E33; --panel-2: #18253F; --panel-3: #1D2C49;
    --ink: #E8EDF6; --ink-2: #B7C2D6; --muted: #8593AD; --faint: #63708A; --rule: #22314F; --rule-2: #2E4066;
    --accent: #8AA4FF; --accent-ink: #0D1524; --accent-soft: #1E2C52;
    --profit: #34C79A; --profit-soft: #10352E; --loss: #FF7B6B; --loss-soft: #3B1D22; --warn: #F2B652; --warn-soft: #3A2D14;
    --chart-line: #8AA4FF; --chart-fill: rgba(138, 164, 255, 0.12); --chart-grid: #1E2B45;
    --shadow: 0 1px 0 rgba(255, 255, 255, .02), 0 10px 30px -18px rgba(0, 0, 0, .6); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D1524; --rail: #0A111E; --panel: #131E33; --panel-2: #18253F; --panel-3: #1D2C49;
  --ink: #E8EDF6; --ink-2: #B7C2D6; --muted: #8593AD; --faint: #63708A; --rule: #22314F; --rule-2: #2E4066;
  --accent: #8AA4FF; --accent-ink: #0D1524; --accent-soft: #1E2C52;
  --profit: #34C79A; --profit-soft: #10352E; --loss: #FF7B6B; --loss-soft: #3B1D22; --warn: #F2B652; --warn-soft: #3A2D14;
  --chart-line: #8AA4FF; --chart-fill: rgba(138, 164, 255, 0.12); --chart-grid: #1E2B45;
  --shadow: 0 1px 0 rgba(255, 255, 255, .02), 0 10px 30px -18px rgba(0, 0, 0, .6); color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { background: var(--bg); }
body {
  margin: 0; min-width: 1180px; color: var(--ink);
  font: 14.5px/1.5 var(--font-ui); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.012em; }
h1 { font-size: 30px; line-height: 1.15; letter-spacing: -0.02em; }
h2 { font-size: 17px; line-height: 1.3; }
h3 { font-size: 15px; }
p { margin: 0; }
code, .code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; background: var(--panel-3); padding: 1px 5px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.voice { font-family: var(--font-voice); font-style: italic; font-weight: 400; letter-spacing: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pos { color: var(--profit); }
.neg { color: var(--loss); }

/* ================================================================ shell */
.shell { --nav-w: 256px; display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: 100vh;
  background: linear-gradient(90deg, var(--rail) 0 calc(var(--nav-w) - 1px), var(--rule) calc(var(--nav-w) - 1px) var(--nav-w), transparent var(--nav-w)); }
:root[data-nav="narrow"] .shell { --nav-w: 72px; }
.nav {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  padding: 22px 16px 18px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 10px 22px; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.brand-sub { display: block; font-weight: 400; font-size: 12px; color: var(--muted); letter-spacing: 0; }
.nav-group { margin-top: 14px; }
.nav-group-label { padding: 0 12px 6px; font-size: 12px; color: var(--faint); font-weight: 500; }
.nav a.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 8px 12px; margin: 1px 0; border-radius: var(--radius-s);
  color: var(--ink-2); text-decoration: none; font-weight: 500;
}
.nav a.nav-link svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.nav a.nav-link:hover { background: var(--panel-3); color: var(--ink); }
.nav a.nav-link[aria-current="page"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.nav a.nav-link[aria-current="page"] svg { color: var(--accent); opacity: 1; }
.nav-foot { margin-top: auto; padding: 14px 12px 0; border-top: 1px solid var(--rule); display: grid; gap: 10px; }
.nav-status { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
.nav-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.nav-status.running .dot { background: var(--profit); box-shadow: 0 0 0 3px var(--profit-soft); }
.nav-status.paused .dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.nav-status.error .dot { background: var(--loss); box-shadow: 0 0 0 3px var(--loss-soft); }
.theme-toggle { justify-self: start; }

main { padding: 34px 40px 72px; max-width: 1680px; width: 100%; }
main:focus { outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.page-head p { color: var(--muted); margin-top: 7px; max-width: 72ch; }
.section { margin-top: 28px; }
.section > h2 { margin-bottom: 12px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.section-head p { color: var(--muted); font-size: 13.5px; margin-top: 3px; }

/* grids for wide screens */
.grid { display: grid; gap: 20px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(340px, 1fr); }
.g-main-wide { grid-template-columns: minmax(0, 1fr) 380px; }
.stack { display: grid; gap: 20px; align-content: start; }
.grid > .section, .instr-pair > .section { margin-top: 0; }
.instr-pair { margin-top: 28px; }

/* ================================================================ controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 0 15px;
  border: 1px solid var(--rule-2); border-radius: var(--radius-s); background: var(--panel); color: var(--ink);
  font: 500 13.5px/1 var(--font-ui); cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .12s, border-color .12s;
}
.btn:hover { border-color: var(--ink-2); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--loss); }
.btn.danger:hover { border-color: var(--loss); background: var(--loss-soft); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ink-2); padding: 0 9px; }
.btn.quiet:hover { background: var(--panel-3); color: var(--ink); }
.btn.small { min-height: 30px; padding: 0 11px; font-size: 13px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

input[type="text"], input[type="password"], input[type="number"], input[type="search"], select, textarea {
  width: 100%; min-height: 38px; padding: 8px 11px; border: 1px solid var(--rule-2); border-radius: var(--radius-s);
  background: var(--panel); color: var(--ink); font: 14px/1.4 var(--font-ui);
}
textarea { min-height: 160px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
label.field { display: grid; gap: 6px; font-weight: 500; font-size: 13.5px; }
label.field .help { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 11px; background: var(--rule-2); position: relative; margin: 0; cursor: pointer; flex: none; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters select, .filters input { width: auto; min-width: 170px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--panel-3); border-radius: 9px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 0 12px; min-height: 28px; border-radius: 6px; font: 500 13px var(--font-ui); cursor: pointer; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ================================================================ surfaces */
.panel { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius-l); box-shadow: var(--shadow); }
.panel.pad { padding: 22px 24px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 18px 22px 0; }
.panel-head h2 { font-size: 15.5px; }
.panel-head .sub { color: var(--muted); font-size: 12.5px; }
.panel-body { padding: 14px 22px 20px; }
.callout { border: 1px solid var(--warn-soft); background: var(--warn-soft); padding: 14px 18px; border-radius: var(--radius-m); color: var(--ink); }
.callout.bad { border-color: var(--loss-soft); background: var(--loss-soft); }
.callout.good { border-color: var(--profit-soft); background: var(--profit-soft); }
.empty { padding: 34px 24px; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

/* ================================================================ overview */
.status-band {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 28px;
  padding: 20px 24px; margin-bottom: 20px;
}
.state { display: flex; align-items: center; gap: 13px; }
.state-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--faint); flex: none; }
.state-running .state-dot { background: var(--profit); box-shadow: 0 0 0 5px var(--profit-soft); }
.state-paused .state-dot { background: var(--warn); box-shadow: 0 0 0 5px var(--warn-soft); }
.state-error .state-dot { background: var(--loss); box-shadow: 0 0 0 5px var(--loss-soft); }
.state-word { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.state-facts { display: flex; flex-wrap: wrap; gap: 6px 40px; color: var(--muted); font-size: 13px; border-left: 1px solid var(--rule); padding-left: 26px; }
.state-facts b { display: block; color: var(--ink); font-weight: 600; font-size: 13.5px; }
.state-desc { grid-column: 1 / -1; margin-top: -8px; color: var(--ink-2); font-size: 13.5px; }

.pairs { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 14px; margin-bottom: 20px; }
.pair { padding: 16px 18px; display: grid; gap: 10px; }
.pair-top { display: flex; align-items: center; justify-content: space-between; }
.pair-sym { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.pair-mid { display: flex; align-items: center; gap: 10px; }
.pair-foot { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--rule); padding-top: 9px; }
.pair-foot b { color: var(--ink); font-weight: 600; }

.equity-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; padding: 20px 24px 4px; }
.equity-num { font-size: 40px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.05; }
.equity-num .cur { font-size: 16px; font-weight: 500; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.equity-label { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.kpis { display: grid; grid-template-columns: repeat(5, auto); gap: 6px 32px; padding: 14px 24px 2px; }
.kpi-label { font-size: 12.5px; color: var(--muted); }
.kpi-value { font-size: 20px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.3; }
.kpi-sub { font-size: 12px; color: var(--faint); }

.thought { padding: 22px 24px 24px; display: flex; flex-direction: column; gap: 14px; min-height: 100%; }
.thought-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; }
.thought-text { font-family: var(--font-voice); font-style: italic; font-size: 25px; line-height: 1.32; color: var(--ink); }
.thought-text::before { content: "\201C"; color: var(--accent); }
.thought-text::after { content: "\201D"; color: var(--accent); }
.thought-outcome { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--ink-2); }
.thought-label { font-size: 13px; color: var(--muted); font-weight: 500; }

.meter { display: grid; gap: 6px; }
.meter + .meter { margin-top: 16px; }
.meter-top { display: flex; justify-content: space-between; font-size: 13px; }
.meter-top span { color: var(--muted); }
.meter-top b { font-weight: 600; }
.meter-bar { height: 8px; border-radius: 4px; background: var(--panel-3); overflow: hidden; }
.meter-bar span { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.meter-bar.warn span { background: var(--warn); }
.meter-bar.bad span { background: var(--loss); }

.mix { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.mix-cell { padding: 12px 12px 10px; border-radius: var(--radius-m); background: var(--panel-2); }
.mix-cell b { display: block; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.mix-note { margin-top: 12px; font-size: 12.5px; color: var(--muted); }

.feed-mini { list-style: none; margin: 0; padding: 0; }
.feed-mini li { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 12px; padding: 11px 0; border-top: 1px solid var(--rule); font-size: 13px; }
.feed-mini li:first-child { border-top: 0; padding-top: 2px; }
.feed-mini time { color: var(--faint); font-size: 12.5px; }
.feed-mini p { color: var(--ink-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.bottom-row { align-items: start; }
.thought .feed-mini li { grid-template-columns: 64px minmax(0, 1fr); padding: 9px 0; }

/* ================================================================ tags */
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel-3); color: var(--ink-2); white-space: nowrap; line-height: 1.5; }
.tag.buy, .tag.good { background: var(--profit-soft); color: var(--profit); }
.tag.sell, .tag.bad { background: var(--loss-soft); color: var(--loss); }
.tag.hold { background: var(--panel-3); color: var(--muted); }
.tag.close, .tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }

/* ================================================================ tables */
.table-wrap { overflow-x: auto; position: relative; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 12px 16px; border-bottom: 1px solid var(--rule); white-space: nowrap; background: var(--panel); position: sticky; top: 0; z-index: 1; }
td { padding: 12px 16px; border-bottom: 1px solid var(--rule); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--panel-2); }
td.num, th.num { text-align: right; }
tr.clickable { cursor: pointer; }
tr.detail td { background: var(--panel-2); color: var(--ink-2); }
tr.detail:hover td { background: var(--panel-2); }
.panel > .table-wrap:first-child th:first-child { border-top-left-radius: var(--radius-l); }
.panel > .table-wrap:first-child th:last-child { border-top-right-radius: var(--radius-l); }

/* ================================================================ charts */
.chart-box { position: relative; padding: 8px 20px 4px; }
.chart-box svg { display: block; width: 100%; height: 300px; overflow: visible; }
.chart-box.short svg { height: 170px; }
.chart-tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); padding: 8px 11px; border-radius: var(--radius-s); font-size: 12.5px; line-height: 1.45; white-space: nowrap; transform: translate(-50%, calc(-100% - 14px)); opacity: 0; transition: opacity .1s; z-index: 5; }
.chart-tip.show { opacity: 1; }
.chart-tip strong { font-weight: 600; }
details.data-table summary { cursor: pointer; color: var(--muted); font-size: 12.5px; padding: 6px 24px 16px; }

/* ================================================================ decisions (master / detail) */
.md { display: grid; grid-template-columns: minmax(380px, 460px) minmax(0, 1fr); gap: 20px; align-items: start; }
.md-list { max-height: calc(100vh - 210px); overflow: auto; padding: 6px; }
.md-item { display: grid; gap: 6px; width: 100%; text-align: left; border: 0; background: transparent; color: inherit; font: inherit; padding: 12px 14px; border-radius: var(--radius-m); cursor: pointer; }
.md-item + .md-item { margin-top: 2px; }
.md-item:hover { background: var(--panel-2); }
.md-item[aria-selected="true"] { background: var(--accent-soft); }
.md-item-top { display: flex; align-items: center; gap: 8px; }
.md-item-top .sym { font-weight: 600; }
.md-item-top time { margin-left: auto; color: var(--faint); font-size: 12.5px; }
.md-item p { color: var(--muted); font-size: 13px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.md-detail { position: sticky; top: 24px; padding: 28px 32px 30px; }
.md-detail .reason { font-family: var(--font-voice); font-style: italic; font-size: 26px; line-height: 1.36; margin: 18px 0 22px; max-width: 46em; }
.md-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px 24px; padding: 18px 0; border-top: 1px solid var(--rule); }
.md-facts div span { display: block; font-size: 12.5px; color: var(--muted); }
.md-facts div b { font-weight: 600; font-size: 15px; }
.conf { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); }
.conf-bar { width: 52px; height: 5px; border-radius: 3px; background: var(--panel-3); overflow: hidden; }
.conf-bar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.snapshot { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 20px; font-size: 13px; padding: 16px 18px; background: var(--panel-2); border-radius: var(--radius-m); }
.snapshot div span { display: block; color: var(--muted); font-size: 12px; }

/* ================================================================ lessons */
.lessons { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.lessons li { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius-l); box-shadow: var(--shadow); padding: 20px 24px; font-family: var(--font-voice); font-style: italic; font-size: 21px; line-height: 1.38; }
.lessons.plain { display: block; }
.lessons.plain li { border: 0; border-bottom: 1px solid var(--rule); border-radius: 0; box-shadow: none; background: transparent; font-size: 17px; padding: 14px 22px; }
.lessons .when { display: block; font-family: var(--font-ui); font-style: normal; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }

/* ================================================================ keys & models */
.key-row td { vertical-align: middle; }
.key-label { font-weight: 600; }
.key-masked code { background: transparent; padding: 0; color: var(--muted); }
.order-btns { display: inline-flex; flex-direction: column; }
.order-btns button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 4px; line-height: 1; font-size: 11px; }
.order-btns button:hover { color: var(--ink); }
.order-btns button[disabled] { visibility: hidden; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px 22px; }
.add-key-grid { grid-template-columns: minmax(160px, 1fr) minmax(240px, 2fr) auto !important; align-items: end; }
.conn-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.conn-row { display: grid; gap: 8px; padding: 18px 22px; border-bottom: 1px solid var(--rule); }
.conn-grid .conn-row:nth-child(odd) { border-right: 1px solid var(--rule); }
.conn-grid .conn-row:nth-last-child(-n+2) { border-bottom: 0; }
.key-last { max-width: 420px; }
.key-last .small { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.page-head .filters { flex-wrap: nowrap; }
.conn-name { display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.conn-name span.help { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; }
.conn-input { display: flex; gap: 8px; align-items: center; }
.model-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; }
.model { display: grid; grid-template-rows: auto 1fr auto; gap: 10px; padding: 20px 22px; background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius-l); box-shadow: var(--shadow); }
.model.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.model-name { font-weight: 600; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.model-id { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.model-id code { background: transparent; padding: 0; }
.model-desc { color: var(--ink-2); font-size: 13.5px; }
.model-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.model-actions { display: flex; gap: 8px; align-items: center; justify-content: space-between; border-top: 1px solid var(--rule); padding-top: 12px; }
.model-result { font-size: 12.5px; }

.steps { margin: 0; padding: 0 22px 18px 44px; display: grid; gap: 10px; color: var(--ink-2); max-width: 90ch; }
.steps li { padding-left: 4px; }

/* ================================================================ settings */
.settings-grid { column-count: 2; column-gap: 20px; }
.settings-grid .settings-group { break-inside: avoid; display: block; margin-bottom: 20px; }
@media (min-width: 1800px) { .settings-grid { column-count: 3; } }
.settings-group { padding: 22px 24px; }
.settings-group h3 { margin-bottom: 16px; font-size: 16px; }
.settings-group .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.source { font-size: 11.5px; font-weight: 500; color: var(--warn); margin-left: 4px; }
.sticky-save { position: sticky; bottom: 0; z-index: 3; display: flex; gap: 10px; justify-content: flex-end; align-items: center; padding: 14px 0; margin-top: 16px; background: var(--bg); border-top: 1px solid var(--rule); }

/* ================================================================ logs */
.log { margin: 0; padding: 18px 22px; max-height: 72vh; overflow: auto; font: 12.5px/1.6 ui-monospace, "SF Mono", Menlo, monospace; white-space: pre-wrap; word-break: break-word; color: var(--ink-2); }
.log .lvl-warning { color: var(--warn); }
.log .lvl-error { color: var(--loss); font-weight: 600; }
.log .lvl-notify { color: var(--accent); }
.check-out { max-height: 320px; margin-top: 12px; border-radius: var(--radius-m); background: var(--panel-2); }

/* ================================================================ instructions */
.instr-text { min-height: 360px; font: 14px/1.65 var(--font-ui); padding: 14px 16px; }
.instr[data-key="owner_notes"] .instr-text { min-height: 140px; }
.instr-bar { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-top: 12px; }
.instr-note { max-width: 520px; }

/* ================================================================ database */
.db-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 12px; }
.db-name { font-size: 22px; letter-spacing: -0.02em; }
.db-head p { margin-top: 4px; }
.crumbs { color: var(--muted); margin-bottom: 10px; font-size: 13px; }
.crumbs a { color: var(--ink-2); }
.col-list { display: flex; flex-wrap: wrap; gap: 6px; margin: -8px 0 18px; }
.db-grid table { width: max-content; min-width: 100%; }
.db-grid td { max-width: 320px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 10px 14px; }
.db-grid th { padding: 10px 14px; }
.db-grid td:last-child, .db-grid th:last-child { position: sticky; right: 0; background: var(--panel); box-shadow: -1px 0 0 var(--rule); }
dialog.wide { max-width: 860px; }
.row-fields { display: grid; grid-template-columns: minmax(130px, auto) minmax(0, 1fr); gap: 10px 18px; margin: 14px 0 0; max-height: 65vh; overflow: auto; font-size: 13.5px; }
.row-fields dt { color: var(--muted); font-weight: 500; }
.row-fields dd { margin: 0; overflow-wrap: anywhere; }
.row-fields pre.log { padding: 12px; max-height: 300px; background: var(--panel-2); border-radius: var(--radius-s); }
.row-fields .long-text { white-space: pre-wrap; background: var(--panel-2); padding: 12px; border-radius: var(--radius-s); max-height: 260px; overflow: auto; }

/* ================================================================ charts */
.chart-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.chart-toolbar .small-switch { margin-left: auto; font-size: 13.5px; color: var(--ink-2); }
.chart-panel { overflow: hidden; }
.chart-head { display: flex; align-items: baseline; gap: 10px 26px; flex-wrap: wrap; padding: 18px 22px 12px; min-height: 64px; }
.chart-sym { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.chart-price { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.chart-facts { display: flex; gap: 22px; align-items: baseline; color: var(--muted); font-size: 13px; }
.chart-facts b { color: var(--ink); font-weight: 600; margin-left: 5px; }
.live { display: inline-flex; align-items: center; gap: 7px; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.live.on i { background: var(--profit); box-shadow: 0 0 0 3px var(--profit-soft); }
.chart-ohlc { margin-left: auto; display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.chart-ohlc b { color: var(--ink); font-weight: 600; margin-left: 3px; }
.chart-canvas { height: max(460px, calc(100vh - 330px)); margin: 0 8px; position: relative; }
.chart-empty { display: grid; place-content: center; text-align: center; height: 100%; max-width: 520px; margin: 0 auto; }
.chart-legend { display: flex; gap: 8px 24px; flex-wrap: wrap; padding: 12px 22px 16px; border-top: 1px solid var(--rule); font-size: 12.5px; color: var(--muted); }
.lg { display: inline-flex; align-items: center; gap: 7px; }
.lg i { display: inline-block; flex: none; }
.lg-up { width: 0; height: 0; border: 5px solid transparent; border-bottom: 8px solid var(--profit); border-top: 0; }
.lg-down { width: 0; height: 0; border: 5px solid transparent; border-top: 8px solid var(--loss); border-bottom: 0; }
.lg-dot { width: 9px; height: 9px; border-radius: 50%; background: linear-gradient(90deg, var(--profit) 50%, var(--loss) 50%); }
.lg-idea { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.lg-line { width: 18px; border-top: 2px dashed var(--loss); }
.lg-rej { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.lg-hold { width: 6px; height: 6px; background: var(--muted); }
.chart-hint { padding: 0 22px 14px; margin: 0; }
.chart-ai { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 22px 10px; font-size: 13px;
  border-bottom: 1px solid var(--rule); min-height: 40px; }
.chart-ai-when { color: var(--muted); font-size: 12.5px; }
.chart-ai-why { flex-basis: 100%; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.chart-ai-result { font-weight: 600; }
.chart-ai-result.traded { color: var(--profit); }
.chart-ai-result.rejected { color: var(--warn); }
.chart-ai-result.idea { color: var(--accent); }
.chart-ai-result.hold, .chart-ai-result.pending { color: var(--muted); font-weight: 500; }
.reason-cell { max-width: 520px; white-space: normal; }

/* ================================================================ calendar */
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-nav .btn.quiet { font-size: 22px; min-height: 36px; width: 36px; padding: 0; }
.cal-month { font-size: 20px; min-width: 180px; text-align: center; }
.g-cal { grid-template-columns: minmax(0, 1fr) 400px; align-items: start; }
@media (min-width: 1700px) { .g-cal { grid-template-columns: minmax(0, 1fr) 460px; } }
.cal-panel { overflow: hidden; }
.cal-summary { display: grid; grid-template-columns: repeat(4, auto); justify-content: start; gap: 6px 44px; padding: 18px 22px 16px; }
.cal-dows, .cal-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-dows { border-top: 1px solid var(--rule); }
.cal-dows span { padding: 9px 12px 7px; font-size: 12px; font-weight: 500; color: var(--muted); }
.cal-day {
  display: flex; flex-direction: column; gap: 4px; min-width: 0; min-height: 118px; padding: 8px 10px 10px;
  border: 0; border-top: 1px solid var(--rule); border-right: 1px solid var(--rule); background: transparent;
  color: var(--ink); font: inherit; text-align: left; cursor: pointer; position: relative;
}
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.weekend { background: var(--panel-2); }
.cal-day:hover { background: var(--panel-3); }
.cal-day.out > * { opacity: .45; }
.cal-day[aria-pressed="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); z-index: 1; }
.cal-day:focus-visible { outline-offset: -3px; }
.cal-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.cal-num { display: grid; place-items: center; width: 26px; height: 26px; margin-left: -4px; border-radius: 50%; font-weight: 600; font-size: 13.5px; }
.cal-day.today .cal-num { background: var(--accent); color: var(--accent-ink); }
.cal-pnl { font-size: 13px; font-weight: 600; }
.cal-meta { font-size: 11.5px; color: var(--muted); }
.cal-note { display: block; font-size: 12px; line-height: 1.35; color: var(--ink-2); padding-left: 7px; border-left: 2px solid var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-note[data-tag="idea"], .note[data-tag="idea"] { border-left-color: var(--profit); }
.cal-note[data-tag="mistake"], .note[data-tag="mistake"] { border-left-color: var(--loss); }
.cal-note[data-tag="news"], .note[data-tag="news"] { border-left-color: var(--warn); }
.cal-more { font-size: 11.5px; color: var(--faint); }

.day-panel { position: sticky; top: 24px; padding: 22px 24px 24px; max-height: calc(100vh - 48px); overflow: auto; }
.day-dow { font-size: 13px; color: var(--muted); }
.day-date { font-size: 24px; letter-spacing: -0.02em; margin-top: 2px; }
.day-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 16px 0 8px; }
.day-stats b { font-size: 20px; }
.day-h { margin: 24px 0 10px; font-size: 14.5px; }
.notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.note { padding: 11px 14px 12px; border-radius: var(--radius-m); background: var(--panel-2); border-left: 3px solid var(--accent); }
.note-top { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--faint); min-height: 30px; }
.note-actions { margin-left: auto; display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.note:hover .note-actions, .note:focus-within .note-actions { opacity: 1; }
.note-text { margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); line-height: 1.5; }
.note-empty { color: var(--muted); font-size: 13.5px; padding: 4px 0; }
.note-form { margin-top: 14px; }
.note-form textarea, .note textarea { min-height: 96px; font: 14px/1.5 var(--font-ui); }
.note-form-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; }
.note .note-form-bar { justify-content: flex-end; }
.tag-pick { display: flex; gap: 6px; margin-bottom: 8px; }
.tag-btn { border: 1px solid var(--rule-2); background: var(--panel); color: var(--muted); border-radius: 999px; padding: 3px 11px; font: 600 12px var(--font-ui); cursor: pointer; }
.tag-btn:hover { color: var(--ink); border-color: var(--ink-2); }
.tag-btn[aria-checked="true"][data-tag="note"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.tag-btn[aria-checked="true"][data-tag="idea"] { background: var(--profit-soft); color: var(--profit); border-color: var(--profit); }
.tag-btn[aria-checked="true"][data-tag="mistake"] { background: var(--loss-soft); color: var(--loss); border-color: var(--loss); }
.tag-btn[aria-checked="true"][data-tag="news"] { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.day-trades { list-style: none; margin: 0; padding: 0; }
.day-trades li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 0; border-top: 1px solid var(--rule); font-size: 13.5px; }
.day-trades li:first-child { border-top: 0; }
.day-trades li > .small { grid-column: 1 / -1; }

/* ================================================================ security */
.nav-foot-row { display: flex; justify-content: space-between; gap: 6px; margin: 0 -9px; }
.section-gap { margin-bottom: 20px; }
.sec-grid { align-items: start; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.sec-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 20px; margin: 18px 0 4px; padding: 16px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
#sec-2fa .sec-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sec-facts dt { font-size: 12.5px; color: var(--muted); }
.sec-facts dd { margin: 2px 0 0; font-weight: 600; font-size: 15px; }
.sec-form { display: grid; gap: 14px; margin-top: 20px; }
.sec-form h3 { font-size: 15px; }
.sec-form .btn-row { justify-content: space-between; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sec-actions { margin-top: 18px; }
.sec-steps { padding: 4px 0 0 20px; margin-top: 14px; }
.sec-foot { margin-top: 18px; }
.tfa-setup { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; align-items: start; margin: 8px 0 14px; }
.qr { background: #fff; border-radius: var(--radius-m); padding: 6px; border: 1px solid var(--rule); line-height: 0; }
.qr svg { width: 100%; height: auto; display: block; }
.tfa-side { display: grid; gap: 12px; }
.setup-key { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.setup-key code { font-size: 15px; letter-spacing: .06em; padding: 6px 10px; }
.code-field { font-family: ui-monospace, "SF Mono", Menlo, monospace !important; letter-spacing: .2em; }
.code-field.big { font-size: 22px !important; text-align: center; min-height: 50px !important; }
.recovery-box { display: grid; gap: 10px; margin-top: 14px; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 18px; margin: 4px 0; padding-left: 26px; }
.recovery-codes code { font-size: 14.5px; letter-spacing: .06em; background: var(--panel); }
dialog .ask-fields { display: grid; gap: 14px; margin-top: 16px; }

/* ================================================================ telegram */
.page-head h1 .tag { vertical-align: middle; margin-left: 8px; font-size: 12.5px; }
.tg-steps { margin: 18px 0 0; padding-left: 22px; display: grid; gap: 18px; color: var(--ink-2); }
.tg-steps li { padding-left: 4px; }
.tg-steps li b { color: var(--ink); }
.tg-token { display: flex; gap: 8px; margin-top: 10px; max-width: 560px; }
.tg-pairing { margin-top: 18px; display: grid; gap: 10px; }
.tg-cand { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; border-radius: var(--radius-m); background: var(--panel-2); border: 1px solid var(--rule); }
.tg-code { font-size: 14px; letter-spacing: .14em; font-weight: 600; }
.tg-waiting { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-radius: var(--radius-m); border: 1px dashed var(--rule-2); }
.tg-preview h2 { margin-bottom: 14px; }
.tg-phone { display: grid; gap: 8px; padding: 18px; border-radius: var(--radius-m); background: linear-gradient(160deg, #1d3045, #17293b); font-size: 13px; line-height: 1.45; color: #E9F1F8; }
.tg-bubble { background: #22374d; padding: 9px 12px 10px; border-radius: 12px 12px 12px 4px; max-width: 92%; box-shadow: 0 1px 1px rgba(0,0,0,.2); }
.tg-bubble i { color: #A9C1D6; }
.tg-bubble.me { justify-self: end; background: #2B5278; border-radius: 12px 12px 4px 12px; }
.tg-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; max-width: 92%; margin-top: -4px; }
.tg-buttons span { text-align: center; background: rgba(255,255,255,.1); border-radius: 8px; padding: 6px; font-weight: 600; font-size: 12.5px; }
.tg-status { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 22px; margin-bottom: 20px; }
.tg-status-main { display: flex; align-items: center; gap: 14px; }
.tg-avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: #2AABEE; color: #fff; font-size: 19px; flex: none; }
.tg-who { font-weight: 600; font-size: 16px; }
.tg-muted { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.tg-kinds { list-style: none; margin: 4px 0 0; padding: 0; }
.tg-kinds li { padding: 12px 0; border-top: 1px solid var(--rule); }
.tg-kinds li:first-child { border-top: 0; }
.tg-kinds .switch { align-items: flex-start; font-weight: 400; }
.tg-kinds .switch input { margin-top: 1px; }
.tg-kinds .switch b { display: block; font-weight: 600; }
.tg-kinds .help { display: block; color: var(--muted); font-size: 12.5px; }
.tg-report { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: end; padding: 16px 0; border-top: 1px solid var(--rule); }
.tg-report p { padding-bottom: 10px; }
.tg-commands { margin: 0; display: grid; gap: 8px; }
.tg-commands div { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 10px; font-size: 13.5px; }
.tg-commands dd { margin: 0; color: var(--ink-2); }
.feed-mini.tg-activity li { grid-template-columns: 118px minmax(0, 1fr); }

/* ================================================================ broker choice */
.broker-switch { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 22px; margin-bottom: 22px; }
.broker-switch .help { display: block; color: var(--muted); font-size: 12.5px; }
.conn-row .btn-row { margin-top: 4px; }

/* ================================================================ AI models */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); margin-bottom: 18px; }
.tabs button { border: 0; background: none; padding: 10px 14px; font: 600 14px var(--font-ui); color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.or-top { margin-bottom: 18px; align-items: stretch; }
.or-facts { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; margin: 12px 0 0; border-bottom: 0; padding-bottom: 0; }
.or-cost { display: flex; align-items: baseline; gap: 8px; }
.or-cost b { font-size: 22px; letter-spacing: -0.02em; }
.or-cost span { color: var(--muted); font-size: 13px; }
.or-desc { margin-top: 10px; font-size: 13px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }

/* ================================================================ statistics */
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat-tile { display: grid; gap: 3px; align-content: start; padding: 12px 14px; border-radius: var(--radius-m); background: var(--panel-2); border-left: 3px solid var(--rule-2); }
.stat-tile.accent { border-left-color: var(--accent); }
.stat-tile.warn { border-left-color: var(--warn); }
.stat-tile.wide { margin-top: 10px; }
.stat-title { font-size: 12px; color: var(--muted); }
.stat-tile > b { display: block; font-size: 15px; }
.stat-tile > b::first-letter { text-transform: uppercase; }
.stat-line { font-size: 12.5px; color: var(--ink-2); }
.stat-line b { font-size: inherit; }

/* ================================================================ dialog & toast */
dialog { border: 1px solid var(--rule); border-radius: var(--radius-l); padding: 24px 26px; background: var(--panel); color: var(--ink); max-width: 460px; width: calc(100% - 40px); box-shadow: 0 30px 80px -20px rgba(5, 10, 25, .45); }
dialog::backdrop { background: rgba(8, 14, 28, .5); backdrop-filter: blur(2px); }
dialog h2 { margin-bottom: 8px; font-size: 18px; }
dialog p { color: var(--ink-2); }
dialog .btn-row { justify-content: flex-end; margin-top: 22px; }
.toast { position: fixed; right: 28px; bottom: 28px; background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: var(--radius-m); font-size: 13.5px; opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: 460px; box-shadow: 0 12px 30px -10px rgba(0,0,0,.4); }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.bad { background: var(--loss); color: #fff; }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: .01ms !important; }
}
.conn-grid .conn-row:last-child:nth-child(odd) { grid-column: 1 / -1; border-right: 0; }
.conn-grid .conn-row:nth-last-child(2):nth-child(even) { border-bottom: 1px solid var(--rule); }
.warn-text { color: var(--warn); margin-top: 10px; }

/* ---------------------------------------------------------------- Tools page */
.tools-note { margin-bottom: 18px; }
.tools-bar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.now-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 1500px) { .now-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.now-tile { display: grid; gap: 3px; align-content: start; padding: 12px 14px; border-radius: var(--radius-m); background: var(--panel-2);
  border-left: 3px solid var(--rule-2); color: var(--ink); text-decoration: none; }
.now-tile:hover { background: var(--panel-3); }
.now-tile.accent { border-left-color: var(--accent); }
.now-tile.warn { border-left-color: var(--warn); }
.now-tile > b { font-size: 15px; }
.now-tile > b::first-letter { text-transform: uppercase; }
.now-read { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--rule); }
.now-read p { margin: 4px 0 0; max-width: 95ch; }
.tool-k { display: block; font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.tools-table td, .tools-table th { vertical-align: top; }
.tools-table tr.group-start td { border-top: 1px solid var(--rule-2); }
.tools-table a { font-weight: 600; text-decoration: none; }
.tools-group .section-head p { max-width: 90ch; }
.stack { display: grid; gap: 16px; }
.tool { padding: 20px 24px 22px; scroll-margin-top: 16px; transition: box-shadow .4s; }
.tool.flash { box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.tool-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.tool-head h3 { margin: 0; font-size: 17px; }
.tool-head p { margin: 3px 0 0; color: var(--muted); }
.tool-tags { display: flex; gap: 6px; flex-shrink: 0; }
.tool-body { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 28px; margin-top: 14px; }
.tool-main h4 { margin: 16px 0 6px; font-size: 13px; color: var(--ink-2); }
.tool-main h4:first-child { margin-top: 0; }
.tool-main p { margin: 0; }
.tool-main ul { margin: 0; padding-left: 18px; display: grid; gap: 5px; }
.tool-told { font-style: italic; color: var(--ink-2); border-left: 3px solid var(--rule-2); padding-left: 10px; }
.tool-side { display: grid; gap: 14px; align-content: start; }
.tool-now, .tool-example { background: var(--panel-2); border-radius: var(--radius-m); padding: 14px 16px; }
.tool-now { border: 1px solid var(--accent-soft); }
.tool-example p { margin: 8px 0 0; }
.now-line { margin: 8px 0 0; font-size: 13.5px; }
table.zones { border-collapse: collapse; width: 100%; }
table.zones td { padding: 4px 8px 4px 0; vertical-align: top; border: 0; font-size: 13.5px; }
table.zones td:first-child { width: 1%; white-space: nowrap; }
.gauge { padding: 26px 0 18px; }
.g-track { position: relative; display: flex; height: 10px; border-radius: 5px; overflow: visible; }
.g-seg { position: relative; height: 100%; background: var(--panel-3); border-right: 2px solid var(--panel-2); }
.g-seg:first-child { border-radius: 5px 0 0 5px; }
.g-seg:last-child { border-radius: 0 5px 5px 0; border-right: 0; }
.g-seg.accent { background: var(--accent-soft); }
.g-seg.warn { background: var(--warn-soft); }
.g-seg em { position: absolute; top: 14px; left: 0; right: 0; text-align: center; font-style: normal; font-size: 11px; color: var(--muted); white-space: nowrap; }
.g-mark { position: absolute; top: -5px; width: 3px; height: 20px; margin-left: -1.5px; background: var(--ink); border-radius: 2px; }
.g-mark b { position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 12px; background: var(--ink); color: var(--panel); padding: 1px 6px; border-radius: 5px; }
.sketch { margin: 0; }
.sketch svg { display: block; width: 100%; height: auto; }
.sketch figcaption { font-size: 12px; color: var(--muted); margin-top: 2px; }
.sk-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sk-line { fill: none; stroke: var(--chart-line); stroke-width: 1.8; stroke-linejoin: round; }
.sk-line.fit { stroke: var(--warn); stroke-dasharray: 5 4; stroke-width: 1.6; }
.sk-band { fill: var(--chart-fill); }
.sk-guide { stroke: var(--faint); stroke-width: 1; stroke-dasharray: 4 4; }
.sk-guide.res { stroke: var(--loss); stroke-width: 1.4; }
.sk-dot { fill: var(--ink); }
.sk-label { font: 600 10.5px var(--font-ui); fill: var(--muted); paint-order: stroke; stroke: var(--panel-2); stroke-width: 3px; }
.sk-label.strong { fill: var(--ink); }
.hb { fill: var(--rule-2); }
.hb.asia, .lg-chip.asia { fill: #8A95A9; background: #8A95A9; }
.hb.london, .lg-chip.london { fill: #6F8CF0; background: #6F8CF0; }
.hb.overlap, .lg-chip.overlap { fill: #3355D8; background: #3355D8; }
.hb.ny, .lg-chip.ny { fill: #0E9C74; background: #0E9C74; }
.hb.roll, .lg-chip.roll { fill: #C8432F; background: #C8432F; }
.hb.now { stroke: var(--ink); stroke-width: 1.5; }
.lg-chip { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin: 0 3px 0 6px; vertical-align: -1px; }
.lg-chip:first-child { margin-left: 0; }
table.mini { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 12.5px; }
table.mini th, table.mini td { padding: 5px 6px; border-bottom: 1px solid var(--rule); text-align: left; }
table.mini th { color: var(--muted); font-weight: 600; }
table.mini .num { text-align: right; }
.range-cell { white-space: nowrap; font-size: 12px; color: var(--muted); }
.rbar { position: relative; display: inline-block; width: 90px; height: 10px; margin-right: 6px; vertical-align: -1px; background: var(--panel-3); border-radius: 5px; }
.rbar span { position: absolute; top: 2px; height: 6px; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 3px; box-sizing: border-box; }
.rbar i { position: absolute; top: 1px; width: 8px; height: 8px; margin-left: -4px; background: var(--accent); border-radius: 50%; }
.rbar u { position: absolute; top: -2px; width: 1px; height: 14px; background: var(--ink); opacity: .45; }
.corr-table { font-size: 12.5px; }
.corr-table th, .corr-table td { padding: 5px 7px; }
td.corr.hi { background: var(--warn-soft); color: var(--warn); font-weight: 700; }
td.corr.hineg { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
td.corr.mid { font-weight: 600; }
.g-mark.edge-l b { left: -2px; transform: none; }
.g-mark.edge-r b { left: auto; right: -2px; transform: none; }

/* ---------------------------------------------------------------- narrow (icons only) menu */
.nav { overflow-y: auto; overflow-x: hidden; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.brand { position: relative; }
.nav-toggle { margin-left: auto; flex: none; display: grid; place-items: center; width: 30px; height: 30px; padding: 0;
  border: 1px solid transparent; border-radius: var(--radius-s); background: transparent; color: var(--muted); cursor: pointer; }
.nav-toggle:hover { background: var(--panel-3); color: var(--ink); border-color: var(--rule); }
.nav-toggle svg, .nav-foot-row .btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nav-foot-row .btn svg { display: none; }
.nt-arrow { transition: transform .2s; transform-origin: 14px 12px; }
:root[data-nav="narrow"] .nt-arrow { transform: scaleX(-1); }

:root[data-nav="narrow"] .nav { padding: 22px 12px 18px; }
:root[data-nav="narrow"] .brand { flex-direction: column; gap: 14px; padding: 2px 0 14px; }
:root[data-nav="narrow"] .brand-name,
:root[data-nav="narrow"] .nav-text { display: none; }
:root[data-nav="narrow"] .nav-toggle { margin-left: 0; }
:root[data-nav="narrow"] .nav-group { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--rule); }
:root[data-nav="narrow"] .nav-group-label { display: none; }
:root[data-nav="narrow"] .nav a.nav-link { justify-content: center; padding: 10px 0; position: relative; }
:root[data-nav="narrow"] .nav a.nav-link svg { width: 20px; height: 20px; }
:root[data-nav="narrow"] .nav-foot { padding: 12px 0 0; justify-items: center; }
:root[data-nav="narrow"] .nav-status { justify-content: center; }
:root[data-nav="narrow"] .nav-foot-row { flex-direction: column; align-items: center; margin: 0; gap: 4px; }
:root[data-nav="narrow"] .nav-foot-row .btn { width: 40px; height: 34px; padding: 0; display: grid; place-items: center; }
:root[data-nav="narrow"] .nav-foot-row .btn svg { display: block; }
/* name of the page beside each icon on hover (fixed, so the narrow menu does not clip it) */
:root[data-nav="narrow"] .nav a.nav-link:hover::after, :root[data-nav="narrow"] .nav a.nav-link:focus-visible::after {
  content: attr(data-label); position: fixed; left: 70px;
  background: var(--ink); color: var(--panel); font-size: 12.5px; font-weight: 600; padding: 4px 9px; border-radius: 6px;
  white-space: nowrap; pointer-events: none; z-index: 50; box-shadow: var(--shadow); }

/* ---------------------------------------------------------------- economic news */
.cal-econ { display: block; font-size: 11.5px; font-weight: 600; color: var(--loss); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-econ::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--loss); margin-right: 5px; vertical-align: 1px; }
.econ-list { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 6px; }
.econ-list li { display: grid; grid-template-columns: 70px auto 1fr; gap: 8px; align-items: baseline; font-size: 13.5px; padding: 6px 10px;
  border-radius: var(--radius-s); background: var(--panel-2); }
.econ-list li.high { background: var(--loss-soft); }
.econ-list time { white-space: nowrap; font-weight: 600; font-variant-numeric: tabular-nums; }
.econ-table tr.high td:nth-child(3) { font-weight: 600; }

/* ---------------------------------------------------------------- backtest */
.bt-dl { display: grid; gap: 16px; }
.bt-src { padding: 12px 14px; border-radius: var(--radius-m); background: var(--panel-2); line-height: 2.4; }
.bt-src label, .bt-src .btn { margin-right: 10px; vertical-align: middle; }
.bt-src .bt-results { line-height: 1.5; margin-top: 8px; }
.bt-dl .meter { flex: 1; min-width: 320px; }
.bt-dl select, .bt-form select, .bt-form input { width: auto; }
.bt-results { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 6px; width: 100%; font-size: 13px; }
.bt-form { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-top: 4px; }
.bt-form + .bt-form { margin-top: 14px; }
.bt-form label { display: grid; gap: 5px; font-size: 12.5px; color: var(--muted); }
.bt-form label select, .bt-form label input { min-width: 150px; }
.bt-form input[type=number] { min-width: 110px; max-width: 130px; }
.bt-label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.bt-about { margin: 12px 0 0; color: var(--ink-2); max-width: 100ch; }
.bt-kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); padding-bottom: 16px; }
.bt-h { margin: 0 0 8px; font-size: 15px; }
.bt-list { margin: 0; padding-left: 18px; display: grid; gap: 7px; font-size: 13.5px; }

/* ---------------------------------------------------------------- learning */
.learn-cycle ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; counter-reset: step; }
.learn-cycle li { position: relative; padding: 12px 14px 12px 44px; background: var(--panel-2); border-radius: var(--radius-m); counter-increment: step; display: grid; gap: 3px; }
.learn-cycle li::before { content: counter(step); position: absolute; left: 12px; top: 12px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.learn-cycle li span { font-size: 12.5px; color: var(--ink-2); }
.learn-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 16px; padding: 14px 18px;
  border: 1px solid var(--rule); border-radius: var(--radius-l); background: var(--panel); font-size: 13.5px; }
.lesson-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.lesson-card { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius-l); box-shadow: var(--shadow); padding: 16px 20px; }
.lesson-card p { margin: 6px 0 0; }
.lesson-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lesson-top .btn { margin-left: auto; }
.lesson-text { font-family: var(--font-voice); font-style: italic; font-size: 19px; line-height: 1.35; margin-top: 10px !important; }
.drop-list { margin: 0; padding: 0 22px 16px 40px; display: grid; gap: 6px; font-size: 13.5px; }
.teach-form .teach-text { display: grid; gap: 5px; font-size: 12.5px; color: var(--muted); }
.teach-form textarea { min-height: 70px; }
.teach-form .bt-form { margin-top: 12px; }
.teach-form .bt-form label select { min-width: 120px; }
.bt-verdict { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.bt-verdict .btn { flex-shrink: 0; }

/* ================================================================ trading styles page */
:root { --style-swing: var(--accent); --style-day: var(--warn); }
.tag.style-swing { background: var(--accent-soft); color: var(--accent); }
.tag.style-day { background: var(--warn-soft); color: var(--warn); }
.style-mode h2 { margin-bottom: 4px; }
.mode-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.mode-pick button { text-align: left; border: 1px solid var(--rule-2); background: var(--panel); color: var(--ink); border-radius: var(--radius-m);
  padding: 12px 14px; cursor: pointer; font: inherit; display: grid; gap: 3px; }
.mode-pick button b { font-weight: 600; font-size: 14.5px; }
.mode-pick button span { color: var(--muted); font-size: 12.5px; }
.mode-pick button:hover { border-color: var(--accent); }
.mode-pick button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.style-verdict { margin-top: 20px; }
.style-verdict p { margin: 6px 0 0; max-width: 95ch; }
.style-progress { display: grid; grid-template-columns: repeat(2, minmax(0, 220px)); gap: 8px 28px; margin-top: 12px; }
table.cmp th[scope="row"] { position: static; color: var(--ink); font-weight: 500; font-size: 13.5px; white-space: normal; border-bottom: 1px solid var(--rule); }
table.cmp th[scope="row"] .help { display: block; color: var(--muted); font-weight: 400; font-size: 12px; margin-top: 2px; }
table.cmp thead th { position: static; }
table.cmp td.better { background: var(--profit-soft); font-weight: 600; }
table.cmp tr.cmp-group th { position: static; padding-top: 18px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
table.cmp tr.cmp-group:first-child th { padding-top: 8px; }
.seg.small-seg button { font-size: 12px; padding: 0 9px; min-height: 26px; }
.style-legend { display: flex; gap: 18px; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; padding: 0; }
.lg-swing { width: 18px; border-top: 2.5px solid var(--style-swing); }
.lg-day { width: 18px; border-top: 2.5px dashed var(--style-day); }
#style-chart { width: 100%; height: 260px; display: block; }
.style-card .panel-head h2 .tag { margin-right: 6px; vertical-align: 1px; }
.style-facts { display: grid; gap: 0; margin: 0; }
.style-facts div { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.style-facts div:last-child { border-bottom: 0; }
.style-facts dt { color: var(--muted); font-size: 13px; }
.style-facts dd { margin: 0; font-size: 13.5px; }
@media (max-width: 1100px) {
  .style-grid { grid-template-columns: minmax(0, 1fr); }
  .mode-pick { grid-template-columns: minmax(0, 1fr); }
  .style-facts div { grid-template-columns: 120px minmax(0, 1fr); }
}
table.cmp td .small { white-space: nowrap; }
.style-card .style-facts div { grid-template-columns: 120px minmax(0, 1fr); }
