/* LEAN Dashboard. Colour roles are tokens; dark values are redefined for the OS setting and the
   theme switch. Series pairs (blue/orange, gain blue/loss red) were validated for colour-blind
   separation and contrast against these surfaces. */
:root {
  color-scheme: light;
  --page: #eef2f7;
  --page-glow: radial-gradient(1200px 600px at 10% -10%, #dbe7fb 0%, transparent 60%);
  --surface-1: #ffffff;
  --surface-2: #f6f8fb;
  --surface-3: #edf1f7;
  --border: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.16);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --label: #2563c9;
  --grid: #e6eaf1;
  --axis: #cbd5e1;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --gain: #2a78d6;
  --loss: #e34948;
  --accent: #2a78d6;
  --accent-soft: rgba(42, 120, 214, 0.10);
  --teal: #0f9d8a;
  --up: #0a7a2f;
  --down: #c62f2f;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --inactive: #8a94a6;
  --banner-bg: #fdecec;
  --topbar: rgba(255, 255, 255, 0.82);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0b1220;
    --page-glow: radial-gradient(1200px 600px at 10% -10%, #14254a 0%, transparent 60%);
    --surface-1: #121b2d;
    --surface-2: #172238;
    --surface-3: #1d2a44;
    --border: rgba(148, 170, 210, 0.12);
    --border-strong: rgba(148, 170, 210, 0.22);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.25);
    --text-primary: #e7ecf5;
    --text-secondary: #aab5c8;
    --text-muted: #7f8ba3;
    --label: #5ea2f0;
    --grid: #22304a;
    --axis: #31415f;
    --series-1: #3987e5;
    --series-2: #d95926;
    --gain: #3987e5;
    --loss: #e66767;
    --accent: #3987e5;
    --accent-soft: rgba(57, 135, 229, 0.16);
    --teal: #2dc4ae;
    --up: #3ccf6a;
    --down: #ff8080;
    --banner-bg: #3a1d26;
    --topbar: rgba(11, 18, 32, 0.78);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b1220;
  --page-glow: radial-gradient(1200px 600px at 10% -10%, #14254a 0%, transparent 60%);
  --surface-1: #121b2d;
  --surface-2: #172238;
  --surface-3: #1d2a44;
  --border: rgba(148, 170, 210, 0.12);
  --border-strong: rgba(148, 170, 210, 0.22);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.25);
  --text-primary: #e7ecf5;
  --text-secondary: #aab5c8;
  --text-muted: #7f8ba3;
  --label: #5ea2f0;
  --grid: #22304a;
  --axis: #31415f;
  --series-1: #3987e5;
  --series-2: #d95926;
  --gain: #3987e5;
  --loss: #e66767;
  --accent: #3987e5;
  --accent-soft: rgba(57, 135, 229, 0.16);
  --teal: #2dc4ae;
  --up: #3ccf6a;
  --down: #ff8080;
  --banner-bg: #3a1d26;
  --topbar: rgba(11, 18, 32, 0.78);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* component display rules must never un-hide */
html, body { margin: 0; }
body {
  background: var(--page-glow), var(--page);
  background-attachment: fixed;
  color: var(--text-primary);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1 { font-size: 17px; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
h3 { margin: 0; }
code { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.error { color: var(--down); min-height: 1.4em; }
.empty { margin: 10px 0; }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* Section label: small caps in the accent colour with an icon, as in a trading terminal. */
.label {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--label);
}
.label-note { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 12px; }

button, select, input {
  font: inherit; color: var(--text-primary); background: var(--surface-1);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 6px 10px;
}
button { cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s; }
button:hover { background: var(--surface-3); }
button:focus-visible, select:focus-visible, input:focus-visible, tr:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary { background: var(--accent); color: #fff; border-color: transparent; font-weight: 600; }
.primary:hover { background: var(--accent); filter: brightness(1.08); }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; background: var(--surface-1); font-size: 18px; line-height: 1; }
.icon-btn .i { width: 17px; height: 17px; }
.icon-btn:disabled { opacity: 0.35; cursor: default; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px max(16px, calc((100vw - 1240px) / 2 + 16px)); position: sticky; top: 0; z-index: 10;
  background: var(--topbar); backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { border-radius: 9px; box-shadow: 0 4px 14px rgba(31, 79, 154, 0.35); }
.brand-sub { display: block; font-size: 12px; color: var(--text-muted); }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.live { font-size: 12px; color: var(--text-muted); display: inline-flex; align-items: center; gap: 6px; }
.live:not(:empty)::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--good);
  box-shadow: 0 0 0 0 rgba(12, 163, 12, 0.5); animation: pulse 2.4s infinite;
}
.live.stale::before { background: var(--warning); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(12, 163, 12, 0.45); } 70% { box-shadow: 0 0 0 7px rgba(12, 163, 12, 0); } 100% { box-shadow: 0 0 0 0 rgba(12, 163, 12, 0); } }
@media (prefers-reduced-motion: reduce) { .live::before { animation: none; } }

main { max-width: 1240px; margin: 0 auto; padding: 20px 16px 32px; }
.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px;
  padding: 18px 20px; margin-bottom: 18px; min-width: 0; box-shadow: var(--shadow);
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.sub-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.sub-card + .sub-card { margin-top: 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }

.signin { max-width: 460px; margin: 64px auto; text-align: center; }
.signin h2 { font-size: 20px; margin: 10px 0 4px; }
.signin form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.signin input { flex: 1 1 220px; font-family: var(--mono); }
.banner { background: var(--banner-bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin: 0 0 16px; }

/* Summary tiles */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile {
  position: relative; overflow: hidden; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px 18px 14px; min-width: 0; box-shadow: var(--shadow);
}
.tile::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--tile-accent, var(--accent)); }
.tile::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 120px; height: 120px; border-radius: 50%;
  background: var(--tile-accent, var(--accent)); opacity: 0.07;
}
.accent-blue { --tile-accent: var(--accent); }
.accent-teal { --tile-accent: var(--teal); }
.accent-pnl { --tile-accent: var(--text-muted); }
.accent-pnl.pos { --tile-accent: var(--gain); }
.accent-pnl.neg { --tile-accent: var(--loss); }
.accent-attn { --tile-accent: var(--good); }
.accent-attn.warn { --tile-accent: var(--warning); }
.accent-attn.crit { --tile-accent: var(--critical); }
.tile-label { display: flex; align-items: center; gap: 7px; color: var(--text-secondary); font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.tile-label .i { color: var(--tile-accent, var(--accent)); }
.tile-value { font-family: var(--mono); font-size: 27px; font-weight: 650; margin-top: 6px; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.tile-sub { font-size: 12px; margin-top: 2px; color: var(--text-muted); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; vertical-align: middle; }
th { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
td.num, th.num { text-align: right; }
td.wrap { white-space: normal; min-width: 180px; max-width: 420px; overflow-wrap: anywhere; }
table.bots tbody tr { cursor: pointer; transition: background 0.12s; }
table.bots tbody tr:hover { background: var(--surface-2); }
table.bots tbody tr[aria-selected="true"] { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
table.bots tbody tr:last-child td { border-bottom: none; }
.bot-cell { display: flex; align-items: center; gap: 10px; }
.avatar {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; flex: none;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; letter-spacing: 0;
}
.bot-name { font-weight: 600; }
.sub { display: block; font-size: 12px; color: var(--text-muted); }
.up { color: var(--up); }
.down { color: var(--down); }
.spark-col { width: 120px; }
.spark { display: block; width: 110px; height: 28px; }
.spark .line { fill: none; stroke: var(--series-1); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.spark .area { fill: var(--series-1); opacity: 0.12; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; background: var(--surface-3); color: var(--text-secondary); border: 1px solid var(--border);
}
.chip.on { color: var(--text-primary); }
.chip.on::before, .chip.off::before { content: ""; width: 6px; height: 6px; border-radius: 50%; }
.chip.on::before { background: var(--good); }
.chip.off::before { background: var(--critical); }
.chip.running { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.conn { display: flex; gap: 6px; }

/* Health: colour always paired with an icon and a label. */
.badge { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.badge .icon { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; font-size: 11px; line-height: 1; color: #fff; font-weight: 700; }
.badge.HEALTHY .icon { background: var(--good); }
.badge.WARNING .icon { background: var(--warning); color: #3b2a00; }
.badge.CRITICAL .icon { background: var(--critical); }
.badge.INACTIVE .icon { background: transparent; border: 2px solid var(--inactive); color: var(--inactive); }
.issue-line { display: block; font-size: 12px; color: var(--text-secondary); white-space: normal; max-width: 280px; margin-top: 2px; }
.issues { list-style: none; padding: 0; margin: 0 0 12px; }
.issues:empty { display: none; }
.issues li { padding: 8px 12px; border-radius: 8px; background: var(--surface-2); color: var(--text-secondary); margin-bottom: 6px; }

/* Bot detail + tabs */
.detail-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.detail-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.detail-title h2 { font-size: 20px; letter-spacing: -0.01em; }
.tabs { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; flex-wrap: wrap; }
.tabs button { display: inline-flex; align-items: center; gap: 6px; border: none; background: transparent; color: var(--text-secondary); padding: 6px 12px; border-radius: 7px; font-weight: 500; }
.tabs button:hover { color: var(--text-primary); background: var(--surface-3); }
.tabs button[aria-selected="true"] { background: var(--surface-1); color: var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.seg-group { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; }
.seg { border: none; background: transparent; padding: 4px 10px; font-size: 12px; font-weight: 600; color: var(--text-secondary); border-radius: 6px; }
.seg[aria-pressed="true"] { background: var(--accent); color: #fff; }

/* Charts */
.chart-fig { margin: 0; position: relative; }
.chart { height: 280px; width: 100%; transition: opacity 0.2s; }
.chart.short { height: 210px; }
.chart.loading { opacity: 0.5; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline, .chart .zero { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--text-muted); font-size: 11px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--series-1); opacity: 0.12; }
.chart .line.s2 { stroke: var(--series-2); }
.chart .area.s2 { fill: var(--series-2); opacity: 0.10; }
.chart .end-dot, .chart .hover-dot { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; }
.sub-card .chart .end-dot, .sub-card .chart .hover-dot { stroke: var(--surface-2); }
.chart .end-dot.s2, .chart .hover-dot.s2 { fill: var(--series-2); }
.chart .end-label { fill: var(--text-primary); font-size: 12px; font-weight: 600; font-family: var(--mono); }
.chart .crosshair { stroke: var(--text-muted); stroke-width: 1; }
.chart .empty-msg { fill: var(--text-muted); font-size: 13px; }
.chart .bar.gain { fill: var(--gain); }
.chart .bar.loss { fill: var(--loss); }
.chart .bar.hover { opacity: 0.75; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 3; white-space: nowrap;
  background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 8px 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); font-size: 12px; color: var(--text-secondary);
}
.tooltip strong { display: block; font-size: 15px; color: var(--text-primary); font-family: var(--mono); }
.tooltip .row strong { display: inline; font-size: 13px; }
.tooltip .key { display: inline-block; width: 12px; height: 2px; background: var(--series-1); vertical-align: middle; margin-right: 6px; }
.tooltip .key.s2 { background: var(--series-2); }
.tooltip .row { display: block; }
.table-view { margin-top: 8px; }
.table-view summary { cursor: pointer; color: var(--text-muted); font-size: 12px; }
.table-view .table-wrap { max-height: 260px; overflow-y: auto; }
.legend { font-size: 12px; color: var(--text-secondary); }
.lkey { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin: 0 6px 0 14px; }
.lkey.s1 { background: var(--series-1); margin-left: 0; }
.lkey.s2 { background: var(--series-2); }

.grid2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 14px; margin-top: 16px; }
.grid2 .sub-card + .sub-card { margin-top: 0; }
.grid2 .label { margin-bottom: 8px; }
.alerts { list-style: none; padding: 0; margin: 0; }
.alerts li { padding: 9px 0; border-bottom: 1px solid var(--grid); display: grid; grid-template-columns: 96px 1fr; gap: 2px 12px; align-items: start; }
.alerts li:last-child { border-bottom: none; }
.alerts .when { grid-column: 2; font-size: 12px; color: var(--text-muted); }
.alerts .msg { grid-column: 2; grid-row: 1; overflow-wrap: anywhere; }
.alerts .badge { grid-row: 1 / span 2; }

/* Orders */
.side { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; }
.side.buy { background: var(--accent-soft); color: var(--gain); }
.side.sell { background: color-mix(in srgb, var(--loss) 14%, transparent); color: var(--down); }

/* Logs: a terminal pane */
.logs {
  list-style: none; margin: 0; padding: 6px 0; max-height: 520px; overflow-y: auto;
  font-family: var(--mono); font-size: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
}
.logs li { display: grid; grid-template-columns: 70px 96px 1fr; gap: 10px; padding: 3px 14px; }
.logs li:hover { background: var(--surface-3); }
.logs .lvl { font-weight: 700; }
.logs .lvl.INFO { color: var(--text-muted); }
.logs .lvl.ERROR, .logs .lvl.CRITICAL { color: var(--down); }
.logs .lvl.WARNING { color: var(--text-primary); }
.logs .lvl.WARNING::before { content: "▲ "; color: var(--warning); }
.logs .lvl.ERROR::before, .logs .lvl.CRITICAL::before { content: "✕ "; }
.logs .text { overflow-wrap: anywhere; white-space: pre-wrap; }
.logs .ts { color: var(--text-muted); }

/* Performance */
.perf > .small { margin: 0 0 12px; }
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin: 0 0 14px; }
.stats div { min-width: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.stats dt { font-size: 11px; color: var(--text-muted); font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; }
.stats dd { margin: 4px 0 0; font-family: var(--mono); font-size: 20px; font-weight: 650; overflow-wrap: anywhere; }
.stats .note { display: block; font-family: var(--font); font-size: 12px; font-weight: 400; color: var(--text-muted); }
.cal-nav { display: flex; gap: 4px; }
.cal-nav .icon-btn { width: 30px; height: 30px; }
table.calendar { table-layout: fixed; border-collapse: separate; border-spacing: 4px; }
table.calendar th { text-align: center; border: none; padding: 6px 4px; }
table.calendar td {
  height: 78px; border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px;
  white-space: normal; vertical-align: top; position: relative; background: var(--surface-1);
}
table.calendar td.out { border-color: transparent; background: transparent; }
table.calendar th.wk { color: var(--text-secondary); }
table.calendar td.wk { background: var(--surface-3); border-color: transparent; }
.cal-day { position: absolute; top: 5px; right: 9px; font-size: 11px; color: var(--text-muted); font-family: var(--mono); }
.cal-val { display: block; margin-top: 16px; font-weight: 650; font-family: var(--mono); font-size: 14px; white-space: nowrap; }
.cal-pos { display: block; font-size: 11px; color: var(--text-secondary); }
table.monthly { border-collapse: separate; border-spacing: 3px; margin-top: 10px; }
table.monthly th, table.monthly td { text-align: right; border: none; padding: 7px 8px; }
table.monthly td { font-family: var(--mono); border-radius: 6px; }
table.monthly th:first-child, table.monthly td:first-child { text-align: left; font-weight: 600; font-family: var(--font); }
table.monthly td.total { font-weight: 650; border-left: 1px solid var(--grid); }

.foot { text-align: center; padding: 8px 0 0; }

@media (max-width: 900px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  main { padding: 14px 16px 24px; }
  .topbar { padding: 10px 16px; }
  .brand-sub { display: none; }
  .card { padding: 14px; border-radius: 12px; }
  .sub-card { padding: 12px; }
  .tile { padding: 14px; }
  .tile-value { font-size: 21px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats dd { font-size: 17px; }
  .tabs { width: 100%; flex-wrap: nowrap; }
  .tabs button { flex: 1 1 0; justify-content: center; padding: 6px 4px; font-size: 13px; }
  .tabs button .i { display: none; }
  .chart { height: 230px; }
  .logs li { grid-template-columns: 1fr; gap: 0; padding: 4px 12px; }
  .alerts li { grid-template-columns: 1fr; }
  .alerts .msg, .alerts .when { grid-column: 1; grid-row: auto; }
  .alerts .badge { grid-row: auto; }
  table.calendar td { height: 58px; padding: 4px; }
  .cal-val { font-size: 12px; margin-top: 14px; }
  .cal-pos { display: none; }
}
@media (forced-colors: active) { .badge .icon { forced-color-adjust: none; } }

/* Alerts: compact one-line rows; the all-bots card is a collapsed summary by default. */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.alerts.compact li {
  display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 6px 0; font-size: 13px;
}
.alerts.compact .badge { grid-row: auto; }
.alerts.compact .badge .icon { width: 16px; height: 16px; font-size: 10px; }
.alerts.compact .msg { grid-column: auto; grid-row: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-secondary); }
.alerts.compact .when { grid-column: auto; font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.alerts-card { padding: 0; box-shadow: none; background: var(--surface-1); }
.alerts-card > summary {
  display: flex; align-items: center; gap: 12px; padding: 12px 20px; cursor: pointer; list-style: none;
}
.alerts-card > summary::-webkit-details-marker { display: none; }
.alerts-card > summary:hover { background: var(--surface-2); border-radius: 14px; }
.alerts-summary { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { color: var(--text-muted); font-size: 18px; line-height: 1; transition: transform 0.15s; }
.alerts-card[open] > summary .chev { transform: rotate(90deg); }
.alerts-card[open] > summary { border-bottom: 1px solid var(--grid); border-radius: 14px 14px 0 0; }
.alerts-card > .alerts, .alerts-card > .empty { padding: 4px 20px 10px; margin: 0; }
@media (max-width: 560px) {
  .alerts.compact li { grid-template-columns: 18px minmax(0, 1fr) auto; }
  .alerts.compact .msg, .alerts.compact .when { grid-column: auto; }
  .alerts-card > summary { padding: 12px 14px; }
  .alerts-card > .alerts { padding: 4px 14px 10px; }
}

/* Broker: name chip with connection dot, plus a PAPER / LIVE tag (LIVE stands out: real money). */
.chip.broker { font-weight: 600; }
.env {
  display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 6px; font-size: 10.5px;
  font-weight: 700; letter-spacing: 0.08em; border: 1px solid var(--border-strong); color: var(--text-muted);
}
.env.live { color: var(--text-primary); border: 1.5px solid var(--text-primary); }
.conn { align-items: center; flex-wrap: wrap; }
.detail-title .conn { gap: 6px; }
.positions-card { margin-top: 16px; }
.positions-card .label { margin-bottom: 8px; }

/* Sun / moon theme switch (as in meic-bot): the active one is tinted, the other muted. */
.theme-switch { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface-1); }
.theme-switch button {
  display: grid; place-items: center; width: 30px; height: 28px; padding: 0; border: none; border-radius: 7px;
  background: transparent; color: var(--text-muted);
}
.theme-switch button:hover { color: var(--text-secondary); background: transparent; }
.theme-switch button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.theme-switch svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* Market clock and event banner (display only) */
.market-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary);
  padding: 4px 10px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface-1); }
.market-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--text-muted); }
.market-pill.open::before { border-color: var(--good); background: var(--good); }
.events { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.event { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; padding: 6px 12px; border-radius: 10px;
  background: var(--accent-soft); color: var(--text-secondary); border: 1px solid transparent; }
.event strong { color: var(--text-primary); }
.event.high.today { border-color: var(--accent); }
/* Second stats row and weekday cells */
.stats-sm dd { font-size: 17px; }
.weekday { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.wd-cell { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--surface-1); min-width: 0; }
.wd-name { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); }
.wd-avg { display: block; font-family: var(--mono); font-weight: 650; font-size: 16px; margin-top: 2px; }
.wd-sub { display: block; font-size: 11px; color: var(--text-secondary); }
@media (max-width: 760px) { .market-pill { display: none; } }
@media (max-width: 560px) {
  .weekday { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
  .wd-cell { padding: 6px; }
  .wd-avg { font-size: 12px; }
  .wd-sub { display: none; }
}
