:root {
  --page: #0d0d0d; --card: #1a1a19; --card2: #232321; --ink: #f0efec; --ink2: #c3c2b7; --muted: #8f8d86;
  --grid: #262624; --axis: #383835; --line: rgba(255, 255, 255, .08); --line2: rgba(255, 255, 255, .16);
  --gain: #3987e5; --gain-ink: #5a9df0; --gain-bg: rgba(57, 135, 229, .15);
  --loss: #e66767; --loss-ink: #ec8181; --loss-bg: rgba(230, 103, 103, .14);
  --good: #0ca30c; --warn: #fab219; --crit: #d03b3b; --stop: #ec835a;
  --badge-bg: rgba(250, 178, 25, .13); --badge-ink: #f6c45c;
  --radius: 14px;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --page: #f4f3ef; --card: #fcfcfb; --card2: #efeee9; --ink: #0b0b0b; --ink2: #52514e; --muted: #6f6e69;
  --grid: #ecebe6; --axis: #c3c2b7; --line: rgba(11, 11, 11, .08); --line2: rgba(11, 11, 11, .16);
  --gain: #2a78d6; --gain-ink: #1d5fb0; --gain-bg: rgba(42, 120, 214, .11);
  --loss: #e34948; --loss-ink: #b8302f; --loss-bg: rgba(227, 73, 72, .10);
  --badge-bg: rgba(250, 178, 25, .18); --badge-ink: #7a5200;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { font-size: 15px; }
@media (min-width: 1700px) { html { font-size: 17px; } }
@media (min-width: 2200px) { html { font-size: 21px; } }
body { margin: 0; background: var(--page); color: var(--ink); font: 400 1rem/1.5 var(--sans);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
.wrap { max-width: 112rem; margin: 0 auto; padding: 16px 16px 28px; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.gain { color: var(--gain-ink); }
.loss { color: var(--loss-ink); }
.flat { color: var(--ink); }
svg { width: 1.1rem; height: 1.1rem; fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round; display: block; }

/* header */
.top { display: flex; align-items: center; gap: .75rem 1.25rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 500; font-size: 1.05rem; }
.logo { width: 1.3rem; height: 1.3rem; border-radius: 50%; border: .17rem solid var(--ink); position: relative; flex: none; }
.logo::after { content: ""; position: absolute; inset: .2rem; border-radius: 50%; background: var(--gain); }
.badge { font-size: .72rem; font-weight: 400; padding: .16rem .6rem; border-radius: 999px; background: var(--badge-bg);
  color: var(--badge-ink); white-space: nowrap; }
.status { display: flex; align-items: center; gap: .55rem; font-size: .85rem; color: var(--ink2); margin-left: auto;
  font-variant-numeric: tabular-nums; }
.dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--muted); position: relative; flex: none; }
.dot.ok { background: var(--good); }
.dot.amber { background: var(--warn); }
.dot.red { background: var(--crit); }
.dot.ok::after { content: ""; position: absolute; inset: -.3rem; border-radius: 50%; border: 1px solid var(--good);
  opacity: 0; animation: pulse 2.4s ease-out infinite; }
@keyframes pulse { 0% { transform: scale(.5); opacity: .8; } 100% { transform: scale(1.5); opacity: 0; } }
.actions { display: flex; gap: .5rem; align-items: center; }
.actions button, .actions a { font: inherit; font-size: .8rem; color: var(--ink2); background: none; cursor: pointer;
  padding: .3rem .7rem; border: 1px solid var(--line2); border-radius: .5rem; text-decoration: none; }
.actions button:hover, .actions a:hover { color: var(--ink); border-color: var(--ink2); }
.actions :focus-visible, .tabs button:focus-visible { outline: 2px solid var(--gain); outline-offset: 2px; }
@media (max-width: 700px) {
  .status { order: 3; margin-left: 0; width: 100%; }
  .actions { margin-left: auto; }
}
.alert { margin: 12px 0 0; padding: .7rem 1rem; border-radius: .7rem; font-size: .88rem; border: 1px solid; }
.alert[hidden] { display: none; }
.alert.warn { background: rgba(250, 178, 25, .10); border-color: rgba(250, 178, 25, .35); color: var(--badge-ink); }
.alert.crit { background: rgba(208, 59, 59, .12); border-color: rgba(208, 59, 59, .45); color: var(--loss-ink); }

/* money */
.money { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 16px 0 14px; }
.money .big, .money .compare { grid-column: 1 / -1; }
@media (min-width: 980px) {
  .money { grid-template-columns: 1.2fr 1fr 1fr 1.7fr; }
  .money .big, .money .compare { grid-column: auto; }
}
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.15rem; min-width: 0; }
.label { font-size: .78rem; color: var(--muted); }
.value { font-size: 1.6rem; font-weight: 500; letter-spacing: -.01em; margin-top: .15rem; font-variant-numeric: tabular-nums;
  white-space: nowrap; }
.big .value { font-size: 2.2rem; line-height: 1.25; }
.sub { font-size: .8rem; color: var(--muted); margin-top: .15rem; }
.cmp-list { margin-top: .45rem; display: grid; gap: .4rem; }
.cmp { display: grid; grid-template-columns: 7.2rem minmax(0, 1fr) 4.4rem; align-items: center; gap: .7rem;
  font-size: .82rem; font-variant-numeric: tabular-nums; }
.cmp-n { color: var(--ink2); line-height: 1.25; }
.cmp-note { display: block; font-size: .7rem; color: var(--muted); }
.cmp-bar { position: relative; height: .45rem; background: var(--card2); border-radius: .25rem; }
.cmp-bar::before { content: ""; position: absolute; left: 50%; top: -.2rem; bottom: -.2rem; width: 1px; background: var(--axis); }
.cmp-bar i { position: absolute; top: 0; bottom: 0; border-radius: .25rem; background: var(--muted); }
.cmp-bar i.gain { background: var(--gain); }
.cmp-bar i.loss { background: var(--loss); }
.cmp-v { text-align: right; font-weight: 500; }

/* layout */
.grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "chart" "pos" "feed"; }
@media (min-width: 1100px) {
  .grid { grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); grid-template-areas: "chart feed" "pos feed"; }
}
.chart-card { grid-area: chart; }
.positions-card { grid-area: pos; }
.feed-card { grid-area: feed; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.15rem; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .7rem; flex-wrap: wrap; }
h2 { font-size: .95rem; font-weight: 500; margin: 0; }

/* chart */
.chart { height: 24rem; }
@media (max-width: 700px) { .chart { height: 17rem; } }
@media (min-width: 1100px) { .chart { height: clamp(24rem, calc(100vh - 46rem), 60rem); } }   /* wall screens: fill the height */
.tabs { display: flex; gap: .2rem; background: var(--card2); padding: .2rem; border-radius: .6rem; }
.tabs button { font: inherit; font-size: .85rem; color: var(--ink2); background: none; border: 0; cursor: pointer;
  padding: .3rem .85rem; border-radius: .45rem; }
.tabs button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 0 0 1px var(--line2); }
.tab-n { margin-left: .45rem; font-size: .72rem; color: var(--muted); }
.quote { display: flex; align-items: baseline; gap: .6rem; font-variant-numeric: tabular-nums; }
#q-price { font-size: 1.25rem; font-weight: 500; }
.q-age { font-size: .75rem; }
.q-age.is-live { color: var(--good); }
.q-age.is-stale { color: var(--warn); }
.legend { display: flex; gap: .4rem 1.1rem; flex-wrap: wrap; font-size: .75rem; color: var(--muted); margin-top: .6rem; }
.legend span { display: inline-flex; align-items: center; }
.sw { display: inline-block; margin-right: .4rem; }
.sw.entry { width: 0; height: 0; border-left: .3rem solid transparent; border-right: .3rem solid transparent;
  border-top: .45rem solid var(--ink); }
.sw.exit-gain { width: .55rem; height: .55rem; border-radius: 50%; background: var(--gain); }
.sw.exit-loss { width: .5rem; height: .5rem; background: var(--loss); }
.sw.stop, .sw.locked { width: 1rem; border-top: 2px dashed var(--stop); }
.sw.locked { border-top-color: var(--gain); }

/* positions */
.pos { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
.pos th { font-weight: 400; color: var(--muted); font-size: .75rem; text-align: left; padding: .35rem .5rem;
  border-bottom: 1px solid var(--line); white-space: nowrap; }
.pos td { padding: .6rem .5rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.pos tr:last-child td { border-bottom: 0; }
.pos .num { text-align: right; }
.pos b { font-weight: 500; }
.side { display: inline-block; font-size: .7rem; padding: .06rem .45rem; border-radius: .35rem; background: var(--card2);
  color: var(--ink2); text-transform: capitalize; margin-right: .3rem; }
.r { margin-left: .4rem; color: var(--muted); font-size: .78rem; }
.lock { font-size: .68rem; color: var(--gain-ink); background: var(--gain-bg); padding: .05rem .4rem; border-radius: .35rem;
  margin-left: .35rem; display: inline-block; white-space: nowrap; }
.crossed { color: var(--badge-ink); background: var(--badge-bg); font-size: .72rem; padding: .05rem .45rem; border-radius: .35rem; }
.empty { color: var(--muted); font-size: .9rem; margin: .3rem 0 .2rem; }
@media (max-width: 760px) {
  .pos thead { display: none; }
  .pos, .pos tbody { display: block; }
  .pos tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35rem .8rem; padding: .75rem 0;
    border-bottom: 1px solid var(--line); }
  .pos tr:last-child { border-bottom: 0; }
  .pos td { border: 0; padding: 0; white-space: normal; }
  .pos .num { text-align: left; }
  .pos td::before { content: attr(data-label); display: block; font-size: .7rem; color: var(--muted); }
  .pos td:first-child { grid-column: 1 / -1; }
  .pos td:first-child::before { display: none; }
}

/* feed */
.feed-card { display: flex; flex-direction: column; }
.feed-wrap { position: relative; flex: 1; }
.feed { list-style: none; margin: 0; padding: 0; }
@media (min-width: 1100px) {
  .feed-wrap { min-height: 22rem; }
  .feed { position: absolute; inset: 0; overflow-y: auto; padding-right: .35rem; scrollbar-width: thin;
    scrollbar-color: var(--line2) transparent; }
}
.ev { display: grid; grid-template-columns: 3rem 1.4rem minmax(0, 1fr); gap: .55rem; padding: .65rem .3rem;
  border-top: 1px solid var(--line); align-items: start; border-radius: .4rem; }
.ev time { font: 500 .8rem/1.55 var(--mono); color: var(--muted); }
.ev .ic { color: var(--muted); padding-top: .1rem; }
.ev .tx p { margin: 0; font-size: .9rem; line-height: 1.45; color: var(--ink2); }
.ev.k-entry .tx p, .ev.k-exit .tx p, .ev.k-stop .tx p, .ev.k-refused .tx p { color: var(--ink); }
.ev.k-entry .ic { color: var(--ink); }
.ev.t-gain .ic { color: var(--gain); }
.ev.t-loss .ic { color: var(--loss); }
.ev.k-refused .ic { color: var(--warn); }
.ev .tx b { font-weight: 500; }
.ev .tx .meta { margin-top: .15rem; font-size: .76rem; color: var(--muted); }
.feed .day { padding: .9rem .3rem .35rem; font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.feed .day + .ev { border-top: 0; }
.feed > .ev:first-child { border-top: 0; }
.fresh { animation: fresh 2.6s ease-out; }
@keyframes fresh { from { background: var(--gain-bg); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .fresh, .dot.ok::after { animation: none; } }

.foot { margin-top: 16px; font-size: .75rem; color: var(--muted); }

/* sign-in pages */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 24rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.6rem 1.5rem; }
.auth-card h1 { font-size: 1.35rem; font-weight: 500; margin: 1.3rem 0 .35rem; }
.auth-card .lead { color: var(--ink2); font-size: .9rem; margin: 0 0 .6rem; }
.auth-card label { display: block; font-size: .8rem; color: var(--ink2); margin: .9rem 0 .3rem; }
.auth-card input { width: 100%; font: inherit; color: var(--ink); background: var(--card2); border: 1px solid var(--line2);
  border-radius: .55rem; padding: .65rem .75rem; }
.auth-card input:focus { outline: 2px solid var(--gain); outline-offset: 1px; }
.auth-card button { margin-top: 1.2rem; width: 100%; font: inherit; font-weight: 500; color: #fff; background: var(--gain);
  border: 0; border-radius: .55rem; padding: .7rem; cursor: pointer; }
.auth-card button:hover { filter: brightness(1.08); }
.auth-card .msg { background: var(--loss-bg); color: var(--loss-ink); padding: .55rem .75rem; border-radius: .55rem;
  font-size: .85rem; margin: .8rem 0 0; }
.auth-card .note { color: var(--muted); font-size: .78rem; margin: 1.2rem 0 0; }

/* view switch */
.nav { display: flex; gap: .2rem; background: var(--card2); padding: .2rem; border-radius: .6rem; }
.nav a { font-size: .82rem; color: var(--ink2); text-decoration: none; padding: .28rem .85rem; border-radius: .45rem; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { background: var(--card); color: var(--ink); box-shadow: 0 0 0 1px var(--line2); }
.nav a:focus-visible { outline: 2px solid var(--gain); outline-offset: 2px; }

/* system map */
.map-card { margin-top: 16px; }
.states { display: flex; gap: .4rem 1.1rem; flex-wrap: wrap; font-size: .75rem; color: var(--muted); }
.states span { display: inline-flex; align-items: center; gap: .4rem; }
.map { position: relative; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2.6rem; padding: .3rem 0 .4rem; }
.wires { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.col h3 { font-size: .7rem; font-weight: 400; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; margin: 0 0 .65rem; }
.part { display: block; width: 100%; text-align: left; font: inherit; color: var(--ink); background: var(--card2);
  border: 1px solid var(--line2); border-radius: .7rem; padding: .6rem .7rem; margin-bottom: .75rem; cursor: pointer;
  position: relative; z-index: 1; }
.part:hover { border-color: var(--ink2); }
.part:focus-visible { outline: 2px solid var(--gain); outline-offset: 2px; }
.part.open { box-shadow: 0 0 0 2px var(--gain); }
.pname { display: flex; align-items: center; gap: .45rem; font-size: .86rem; font-weight: 500; line-height: 1.3; }
.pline { display: block; font-size: .76rem; color: var(--ink2); margin-top: .25rem; font-variant-numeric: tabular-nums; line-height: 1.35; }
.pdot { width: .5rem; height: .5rem; border-radius: 50%; flex: none; background: var(--muted); display: inline-block; }
.lv-ok .pdot, .pdot.k-run { background: var(--good); }
.lv-amber .pdot { background: var(--warn); }
.lv-red .pdot { background: var(--crit); }
.st-idle { background: transparent; }
.st-idle .pname, .st-idle .pline { color: var(--ink2); }
.st-idle .pdot, .pdot.k-idle { background: transparent; border: 1px solid var(--muted); }
.st-planned { background: transparent; border-style: dashed; }
.st-planned .pname { font-weight: 400; color: var(--muted); }
.st-planned .pline { color: var(--muted); }
.st-planned .pdot { display: none; }
.pdot.k-plan { background: transparent; border: 1px dashed var(--muted); border-radius: .15rem; }
.part.act { animation: act 1.4s ease-out; }
@keyframes act { from { border-color: var(--gain); box-shadow: 0 0 0 3px var(--gain-bg); } to { } }
.wire { fill: none; stroke: var(--muted); stroke-width: 1.2; stroke-linejoin: round; }
.wire.running { stroke: var(--ink2); opacity: .5; }
.wire.idle { stroke-dasharray: 4 4; opacity: .45; }
.wire.planned { stroke-dasharray: 1.5 4; opacity: .4; }
.pulse { fill: var(--gain); }
.pulse.tick { fill: var(--good); opacity: .8; }
.hint { font-size: .75rem; color: var(--muted); margin: .3rem 0 0; }
@media (max-width: 999px) {
  .map { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .wires { display: none; }
  .col:not(:last-child)::after { content: "\2193"; display: block; text-align: center; color: var(--muted); margin: -.2rem 0 .5rem; }
}
.detail { margin-top: .6rem; padding: 1rem 1.1rem; border: 1px solid var(--line2); border-radius: .8rem; background: var(--card2); }
.detail[hidden] { display: none; }
.detail-head { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.detail-head h3 { margin: 0; font-size: 1rem; font-weight: 500; }
.detail .chip { font-size: .72rem; padding: .08rem .5rem; border-radius: 999px; border: 1px solid var(--line2); color: var(--ink2); }
.detail .chip.st-running { color: var(--good); border-color: currentColor; }
.detail .chip.st-planned { border-style: dashed; }
.detail .close { margin-left: auto; font: inherit; font-size: .78rem; color: var(--ink2); background: none; border: 1px solid var(--line2);
  border-radius: .45rem; padding: .2rem .6rem; cursor: pointer; }
.detail p { margin: .55rem 0 0; font-size: .88rem; color: var(--ink2); line-height: 1.5; max-width: 60rem; }
.detail .dline { color: var(--ink); font-variant-numeric: tabular-nums; }
.detail dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .3rem 1rem; margin: .8rem 0 0; font-size: .84rem; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; color: var(--ink); }
.reports { list-style: none; margin: .8rem 0 0; padding: 0; display: grid; gap: .35rem; font-size: .84rem; }
.reports li { display: flex; gap: .6rem; align-items: baseline; }
.vk { font-size: .68rem; padding: .02rem .45rem; border-radius: .35rem; flex: none; min-width: 3.6rem; text-align: center; }
.vk-fail { background: var(--loss-bg); color: var(--loss-ink); }
.vk-pass { background: var(--gain-bg); color: var(--gain-ink); }
.vk-study { background: var(--card); color: var(--ink2); border: 1px solid var(--line2); }

/* last run */
.run-card { margin-top: 14px; }
.countdown { display: flex; align-items: center; gap: .7rem; font-size: .82rem; color: var(--ink2); font-variant-numeric: tabular-nums; }
.countdown .late { color: var(--badge-ink); }
.cbar { width: 8rem; height: .35rem; background: var(--card2); border-radius: .2rem; overflow: hidden; }
.cbar i { display: block; height: 100%; width: 0; background: var(--gain); transition: width .9s linear; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1rem; }
@media (max-width: 900px) { .steps { grid-template-columns: minmax(0, 1fr); } }
.step { border-top: 3px solid var(--line2); padding-top: .65rem; border-radius: 0; }
.step.s-ok { border-top-color: var(--good); }
.step.s-warn { border-top-color: var(--warn); }
.step.s-fail { border-top-color: var(--crit); }
.step.s-skip { opacity: .55; }
.step b { display: flex; gap: .5rem; align-items: center; font-weight: 500; font-size: .9rem; }
.snum { display: inline-grid; place-items: center; width: 1.3rem; height: 1.3rem; border-radius: 50%; background: var(--card2);
  font-size: .72rem; color: var(--ink2); flex: none; }
.step p { margin: .4rem 0 0; font-size: .84rem; color: var(--ink2); line-height: 1.5; }
.step.fresh { animation: fresh 2.6s ease-out; }
@media (prefers-reduced-motion: reduce) { .part.act, .step.fresh { animation: none; } }
