/* Dashboard styling: dense trading-infrastructure console, dark by default,
   readable down to phone width. Colour is carried by tokens so the whole
   palette can be re-themed from :root.

   The lime accent (--accent-lime) is reserved for a handful of deliberate
   spots (active nav item, live indicator, positive P&L, primary CTA) — it is
   not a general-purpose interactive colour. Everyday interactive chrome
   (links, focus rings, secondary highlights) uses --accent (info blue)
   instead, so the UI doesn't read as "everything green". */

:root {
  --bg: #0b0c0e;
  --bg-surface: #121416;
  --bg-raised: #181a1d;
  --bg-raised-hover: #1d2023;
  --bg-input: #121416;
  --border: #292d31;
  --border-strong: #3a3f44;
  --text: #f1f3f5;
  --text-dim: #8e949b;
  --text-faint: #626870;
  --accent: #7c9cff;
  --accent-dim: #1f2740;
  --accent-lime: #b7ff00;
  --accent-lime-dim: #26330a;
  --up: #b7ff00;
  --down: #ff5d67;
  --warn: #f5c451;
  --info: #7c9cff;
  --radius: 10px;
  --radius-sm: 6px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  --display: "Space Grotesk", var(--sans);
  --sidebar-width: 220px;

  /* Layered shadows give raised surfaces real depth instead of a flat card
     with a border. Two layers: a tight contact shadow + a soft ambient one. */
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.55);
  --shadow-card-hover: 0 2px 4px rgba(0, 0, 0, 0.45), 0 16px 36px -14px rgba(0, 0, 0, 0.6);
  --shadow-btn: 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  --sheen: linear-gradient(155deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0) 40%);
}

:root[data-theme="light"] {
  --bg: #f5f6f7;
  --bg-surface: #ffffff;
  --bg-raised: #ffffff;
  --bg-raised-hover: #f2f3f4;
  --bg-input: #ffffff;
  --border: #dfe2e5;
  --border-strong: #c3c8cd;
  --text: #16181a;
  --text-dim: #565c62;
  --text-faint: #8a9096;
  --accent-dim: #e4eaff;
  --accent-lime-dim: #eaffb0;
  /* Positive P&L on a light surface: full lime reads as pale/illegible, so
     light mode uses a darker olive tone instead while dark mode keeps the
     pure accent. */
  --up: #6a8f00;
  --shadow-card: 0 1px 2px rgba(20, 24, 28, 0.06), 0 8px 24px -12px rgba(20, 24, 28, 0.16);
  --shadow-card-hover: 0 2px 6px rgba(20, 24, 28, 0.08), 0 16px 32px -14px rgba(20, 24, 28, 0.2);
  --shadow-btn: 0 1px 2px rgba(20, 24, 28, 0.08);
  --sheen: linear-gradient(155deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0) 40%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(ellipse 1100px 600px at 15% -10%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 60%),
    radial-gradient(ellipse 900px 500px at 100% 0%, color-mix(in srgb, var(--accent-lime) 4%, transparent), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.boot { padding: 48px; color: var(--text-dim); text-align: center; }

/* ---------------------------------------------------------------- login */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card p { margin: 0 0 20px; color: var(--text-dim); font-size: 13px; }
.login-card code {
  font-family: var(--mono);
  background: var(--bg-input);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

/* ----------------------------------------------------------------- shell */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  width: var(--sidebar-width);
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  z-index: 20;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px 18px 14px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.06em;
  color: var(--text);
  white-space: nowrap;
}
.sidebar-brand .brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent-lime);
  box-shadow: 0 0 10px 1px color-mix(in srgb, var(--accent-lime) 70%, transparent);
  flex: 0 0 auto;
}

.sidebar-nav {
  flex: 1 1 auto;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.nav-item {
  appearance: none;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  padding: 9px 12px;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-item { transition: color 0.1s ease, background 0.1s ease; }
.nav-item:hover { color: var(--text); background: var(--bg-raised-hover); }
.nav-item[aria-selected="true"] {
  color: var(--text);
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent-lime) 10%, transparent), transparent 70%), var(--bg-raised);
  box-shadow: inset 2px 0 0 var(--accent-lime), 0 0 16px -6px color-mix(in srgb, var(--accent-lime) 65%, transparent);
}

.sidebar-status {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.sidebar-actions {
  padding: 0 10px 10px;
  display: flex;
  gap: 6px;
}
.sidebar-actions .btn { flex: 1 1 auto; }

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-faint);
  white-space: nowrap;
}
.status-line .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.status-line.on { color: var(--text-dim); }
.status-line.on .dot { background: var(--up); box-shadow: 0 0 0 2px color-mix(in srgb, var(--up) 20%, transparent); }
.status-line.off .dot { background: var(--down); }
.status-line.warn .dot { background: var(--warn); }

.topbar-spacer { flex: 1 1 auto; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}
.pill.live { color: var(--up); border-color: color-mix(in srgb, var(--up) 45%, transparent); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.pill.bad { color: var(--down); border-color: color-mix(in srgb, var(--down) 45%, transparent); }
.pill.warn.pulse .dot { animation: pulse-dot-warn 1.4s ease-in-out infinite; }

/* A real alert, not decoration: real money is on the line while this is
   mode, so it gets the loudest treatment on the page — a breathing red
   glow — instead of blending in with the other status pills. */
.pill.live-money {
  color: #fff;
  font-weight: 700;
  background: linear-gradient(135deg, var(--down), #c23540);
  border-color: transparent;
  animation: pulse-glow-danger 1.6s ease-in-out infinite;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.content-col { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 16px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar-titles h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.topbar-titles p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--mono);
}
.brand { font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }

main { flex: 1 1 auto; padding: 20px 24px 32px; }

/* ----------------------------------------------------------------- cards */

.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  margin-bottom: 16px;
}
.card {
  background: var(--sheen), var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-card-hover); border-color: var(--border-strong); }
.card-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 6px;
}
.card-value { font-family: var(--display); font-size: 24px; font-weight: 600; letter-spacing: -0.01em; }
.card-sub { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.panel {
  background: var(--sheen), var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.panel-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.panel-head .spacer { flex: 1 1 auto; }
.panel-body { padding: 16px; }
.panel-body.flush { padding: 0; }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  font-weight: 600;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
td.num, th.num { text-align: right; font-family: var(--mono); }
td.wrap { white-space: normal; min-width: 240px; }

.empty { padding: 28px 16px; text-align: center; color: var(--text-faint); }

/* --------------------------------------------------------------- inline */

.up { color: var(--up); }
.down { color: var(--down); }
.warn { color: var(--warn); }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--mono); }

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
}
.tag.buy { color: var(--up); border-color: color-mix(in srgb, var(--up) 45%, transparent); }
.tag.sell { color: var(--down); border-color: color-mix(in srgb, var(--down) 45%, transparent); }
.tag.manual { color: var(--accent); border-color: var(--accent); }

.tp-ladder { display: inline-flex; gap: 3px; }
.tp-step {
  width: 22px;
  text-align: center;
  font-size: 10px;
  font-family: var(--mono);
  border-radius: 3px;
  border: 1px solid var(--border-strong);
  color: var(--text-faint);
}
.tp-step.hit { background: color-mix(in srgb, var(--up) 22%, transparent); color: var(--up); border-color: transparent; }
.tp-step.none { opacity: 0.35; }

.bar { height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; min-width: 60px; }
.bar > span { display: block; height: 100%; background: var(--accent); }

/* --------------------------------------------------------------- controls */

button, input, select {
  font: inherit;
  color: inherit;
}
.btn {
  appearance: none;
  background: linear-gradient(180deg, color-mix(in srgb, var(--text) 4%, var(--bg-input)), var(--bg-input));
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-btn);
  transition: transform 0.1s ease, box-shadow 0.1s ease, border-color 0.1s ease;
}
.btn:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-card); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(180deg, color-mix(in srgb, #fff 15%, var(--accent)), var(--accent));
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-btn), 0 4px 14px -4px color-mix(in srgb, var(--accent) 60%, transparent);
}
.btn.danger { color: var(--down); border-color: color-mix(in srgb, var(--down) 50%, transparent); }
.btn.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--down) 15%, transparent); border-color: var(--down); }
.btn.sm { padding: 3px 9px; font-size: 12px; }

input[type="text"], input[type="number"], input[type="password"], select {
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 7px 10px;
  width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent-dim); border-color: var(--accent); }
input:disabled, select:disabled { opacity: 0.5; cursor: not-allowed; }

.field { margin-bottom: 14px; }
.field-label { display: block; margin-bottom: 4px; font-weight: 500; }
.field-help { font-size: 12px; color: var(--text-dim); margin-top: 3px; }
.field-row { display: flex; gap: 8px; align-items: center; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  width: 38px;
  height: 21px;
  border-radius: 999px;
  background: var(--border);
  border: 1px solid var(--border-strong);
  position: relative;
  transition: background 0.12s;
  flex: 0 0 auto;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.12s, background 0.12s;
}
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(17px); background: #fff; }
.switch input:disabled + .switch-track { opacity: 0.45; }

.form-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

/* ------------------------------------------------------- zone editor */

.zone-editor {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 14px;
  align-items: stretch;
}

.zone-rail {
  position: relative;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: linear-gradient(
    to bottom,
    color-mix(in srgb, var(--accent) 16%, transparent),
    transparent
  );
  min-height: 190px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.zone-edge {
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-family: var(--mono);
}

.zone-slots {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.zone-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 5px;
  border: 1px solid transparent;
  cursor: pointer;
}
.zone-slot:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.zone-slot.on {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.zone-slot input[type="checkbox"] { width: auto; margin: 0; accent-color: var(--accent); }
.zone-slot-label {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}
.zone-slot.on .zone-slot-label { color: var(--text); }

.zone-weights { display: flex; flex-direction: column; gap: 6px; }
.zone-weight-row {
  display: grid;
  grid-template-columns: 1fr 92px 64px;
  gap: 8px;
  align-items: center;
}
.zone-weight-row.off { opacity: 0.35; }
.zone-weight-row input { width: 100%; }
.zone-preview {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  text-align: right;
  white-space: nowrap;
}
.zone-total {
  margin-top: 8px;
  font-size: 12px;
  font-family: var(--mono);
}

@media (max-width: 640px) {
  .zone-editor { grid-template-columns: 1fr; }
  .zone-rail { min-height: 0; }
  .zone-weight-row { grid-template-columns: 1fr 80px 56px; }
}

.locked-note {
  font-size: 12px;
  color: var(--warn);
  margin-top: 3px;
}

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input { width: auto; min-width: 120px; }

/* ------------------------------------------------------------- calendar */

.cal-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  padding: 4px 2px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.cal-summary-stat { display: flex; flex-direction: column; gap: 4px; }
.cal-summary-stat .mono { font-family: var(--display); font-size: 18px; font-weight: 600; }

.cal-dow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 6px;
}
.cal-dow-cell {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
  text-align: center;
  padding-bottom: 2px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.cal-cell {
  appearance: none;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 74px;
  padding: 8px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--sheen), var(--bg-raised);
  box-shadow: var(--shadow-btn);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.cal-cell:hover { transform: translateY(-1px); box-shadow: var(--shadow-card); border-color: var(--border-strong); }
.cal-cell-pad { visibility: hidden; pointer-events: none; box-shadow: none; }

.cal-cell-date {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}
.cal-cell-today .cal-cell-date {
  color: var(--accent);
  font-weight: 700;
}
.cal-cell-pnl { font-family: var(--display); font-size: 14px; font-weight: 600; }
.cal-cell-count { font-family: var(--sans); font-size: 10.5px; color: var(--text-faint); }

.cal-cell-up { border-color: color-mix(in srgb, var(--up) 40%, var(--border)); background: linear-gradient(155deg, color-mix(in srgb, var(--up) 10%, transparent), transparent 55%), var(--bg-raised); }
.cal-cell-down { border-color: color-mix(in srgb, var(--down) 40%, var(--border)); background: linear-gradient(155deg, color-mix(in srgb, var(--down) 10%, transparent), transparent 55%), var(--bg-raised); }
.cal-cell-dim { border-color: var(--border-strong); }

.cal-cell-selected {
  border-color: var(--accent-lime);
  box-shadow: var(--shadow-btn), 0 0 0 1px var(--accent-lime), 0 0 14px -4px color-mix(in srgb, var(--accent-lime) 60%, transparent);
}

/* ----------------------------------------------------------------- toast */

#toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 32px));
}
.toast {
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-left-width: 3px;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.toast.ok { border-left-color: var(--up); }
.toast.err { border-left-color: var(--down); }
.toast.info { border-left-color: var(--accent); }

/* ---------------------------------------------------------------- charts */

/* An SVG with width:100% and height:auto keeps its viewBox ratio, so a
   720x150 chart becomes ~230px tall inside a full-width panel on a wide
   monitor. The cap keeps a glanceable chart glanceable. */
.chart { width: 100%; height: auto; display: block; max-height: 200px; }
.chart-axis { fill: var(--text-faint); font-size: 10px; font-family: var(--mono); }
.chart-grid { stroke: var(--border); stroke-width: 1; }

/* ----------------------------------------------------------------- feed */

.feed { max-height: 460px; overflow-y: auto; }
.feed-item {
  display: flex;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.feed-item:last-child { border-bottom: none; }
.feed-time { font-family: var(--mono); font-size: 11px; color: var(--text-faint); flex: 0 0 auto; }
.feed-type { font-size: 11px; font-weight: 600; letter-spacing: 0.03em; flex: 0 0 auto; }
.feed-text { color: var(--text-dim); word-break: break-word; }

pre.raw {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-dim);
  background: var(--bg-input);
  border-radius: 6px;
  padding: 10px;
  max-height: 200px;
  overflow: auto;
}

/* ------------------------------------------------------------- live pill */

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px 5px 9px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent-lime) 40%, transparent);
  background: var(--accent-lime-dim);
  color: var(--accent-lime);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--mono);
  white-space: nowrap;
}
.live-indicator {
  box-shadow: var(--shadow-btn), 0 0 14px -4px color-mix(in srgb, var(--accent-lime) 55%, transparent);
}
.live-indicator .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse-dot 1.8s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent-lime) 55%, transparent); }
  50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent-lime) 0%, transparent); }
}
@keyframes pulse-dot-warn {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--warn) 55%, transparent); }
  50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--warn) 0%, transparent); }
}
@keyframes pulse-glow-danger {
  0%, 100% { box-shadow: var(--shadow-btn), 0 0 8px -2px color-mix(in srgb, var(--down) 70%, transparent); }
  50% { box-shadow: var(--shadow-btn), 0 0 18px 1px color-mix(in srgb, var(--down) 85%, transparent); }
}

/* ------------------------------------------------------------- kpi cards */

.kpi-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--sheen), var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--border-strong);
}
.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  margin-bottom: 8px;
}
.kpi-value {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.kpi-sub { font-size: 12px; color: var(--text-dim); margin-top: 5px; }

/* --------------------------------------------------------------- section */

.section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 28px 0 12px;
}
.section-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.section-head .section-sub { font-size: 12px; color: var(--text-faint); }
.section-head:first-child { margin-top: 0; }

/* --------------------------------------------------------------- pipeline */

.pipeline {
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 20px;
}
.pipeline-step {
  flex: 1 1 0;
  min-width: 116px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  padding: 0 6px;
  position: relative;
}
.pipeline-connector {
  flex: 0 0 auto;
  width: 28px;
  align-self: center;
  height: 1px;
  background: var(--border-strong);
  margin-top: -22px;
}
.pipeline-node {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  color: var(--text-faint);
  background: var(--bg-input);
  font-family: var(--mono);
  font-size: 12px;
  box-shadow: var(--shadow-btn);
}
.pipeline-step.success .pipeline-node {
  border-color: color-mix(in srgb, var(--accent-lime) 55%, transparent);
  color: var(--accent-lime);
  background: var(--accent-lime-dim);
  box-shadow: var(--shadow-btn), 0 0 10px -3px color-mix(in srgb, var(--accent-lime) 60%, transparent);
}
.pipeline-step.active .pipeline-node {
  border-color: var(--info);
  color: var(--info);
  background: var(--accent-dim);
  animation: pulse-node-info 1.6s ease-in-out infinite;
}
.pipeline-step.error .pipeline-node {
  border-color: color-mix(in srgb, var(--down) 55%, transparent);
  color: var(--down);
  background: color-mix(in srgb, var(--down) 12%, transparent);
  box-shadow: var(--shadow-btn), 0 0 10px -3px color-mix(in srgb, var(--down) 60%, transparent);
}

@keyframes pulse-node-info {
  0%, 100% { box-shadow: var(--shadow-btn), 0 0 0 0 color-mix(in srgb, var(--info) 45%, transparent); }
  50% { box-shadow: var(--shadow-btn), 0 0 0 6px color-mix(in srgb, var(--info) 0%, transparent); }
}
.pipeline-label { font-size: 12px; font-weight: 500; color: var(--text); }
.pipeline-status {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}
.pipeline-step.success .pipeline-status { color: var(--accent-lime); }
.pipeline-step.active .pipeline-status { color: var(--info); }
.pipeline-step.error .pipeline-status { color: var(--down); }

/* ------------------------------------------------------------ trader row */

.trader-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  margin-bottom: 16px;
}
.trader-card {
  background: var(--sheen), var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.trader-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-card-hover); border-color: var(--border-strong); }
.trader-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.trader-name { font-weight: 600; font-size: 13.5px; flex: 1 1 auto; }
.trader-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 14px;
}
.trader-stat-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}
.trader-stat-value { font-family: var(--mono); font-size: 14px; margin-top: 2px; }
.trader-pending {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 11px;
  color: var(--text-faint);
  font-style: italic;
}

.session-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.session-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  flex: 1 1 160px;
}
.session-badge .session-name { font-weight: 500; flex: 1 1 auto; }
.session-count {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-dim);
}

/* ----------------------------------------------------------- status badge */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.status-badge.success { color: var(--accent-lime); background: var(--accent-lime-dim); }
.status-badge.active { color: var(--info); background: var(--accent-dim); }
.status-badge.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); }
.status-badge.error { color: var(--down); background: color-mix(in srgb, var(--down) 14%, transparent); }
.status-badge.neutral { color: var(--text-dim); background: var(--bg-input); border: 1px solid var(--border-strong); }

/* -------------------------------------------------------- diagnostics */

.diag-intro { font-size: 12.5px; margin: 0 0 14px; max-width: 62ch; }
.diag-meta { font-size: 12px; }

.diag-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.diag-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.diag-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-input);
}
.diag-card-title { font-size: 13px; font-weight: 600; }

.diag-checks { display: flex; flex-direction: column; }
.diag-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
}
.diag-check:last-child { border-bottom: none; }
.diag-check-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex: 0 0 auto;
  background: var(--text-faint);
}
.diag-ok .diag-check-dot { background: var(--up); }
.diag-warn .diag-check-dot { background: var(--warn); }
.diag-fail .diag-check-dot { background: var(--down); }
.diag-skip .diag-check-dot { background: var(--text-faint); }

.diag-check-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.diag-check-label { font-size: 12.5px; font-weight: 500; color: var(--text); }
.diag-check-detail { font-size: 12px; color: var(--text-dim); word-break: break-word; }
.diag-fail .diag-check-detail { color: var(--down); }
.diag-check-latency { font-size: 11px; color: var(--text-faint); flex: 0 0 auto; padding-top: 2px; }

/* -------------------------------------------------------- system feed */

.sys-feed { max-height: 420px; overflow-y: auto; font-family: var(--mono); }
.sys-feed-item {
  display: flex;
  gap: 10px;
  padding: 7px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  align-items: baseline;
}
.sys-feed-item:last-child { border-bottom: none; }
.sys-feed-time { color: var(--text-faint); flex: 0 0 auto; }
.sys-feed-source {
  flex: 0 0 auto;
  color: var(--text-dim);
  min-width: 92px;
}
.sys-feed-msg { color: var(--text); font-family: var(--sans); word-break: break-word; }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; bottom: 0; top: auto; width: 100%; height: auto;
    flex-direction: row; border-right: none; border-top: 1px solid var(--border); z-index: 30; }
  .sidebar-brand, .sidebar-status, .sidebar-actions { display: none; }
  .sidebar-nav { flex-direction: row; overflow-x: auto; padding: 6px; }
  .nav-item[aria-selected="true"] { box-shadow: inset 0 2px 0 var(--accent-lime); }
  .content-col { padding-bottom: 56px; }
  .pipeline { flex-direction: column; }
  .pipeline-connector { display: none; }
}

@media (max-width: 640px) {
  main { padding: 12px; }
  .topbar { padding: 12px 14px; }
  .grid { grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 8px; }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
  .card { padding: 10px 12px; }
  .card-value { font-size: 17px; }
  .topbar { padding: 8px 12px; gap: 6px; }
  .brand { font-size: 13px; }
  .panel-head { padding: 10px 12px; }
  .panel-body { padding: 12px; }
  .filters { width: 100%; }
  .filters select, .filters input { flex: 1 1 130px; min-width: 0; }

  .cal-grid, .cal-dow { gap: 4px; }
  .cal-cell { min-height: 56px; padding: 5px 6px; gap: 2px; }
  .cal-cell-pnl { font-size: 11.5px; }
  .cal-cell-count { display: none; }
  .cal-dow-cell { font-size: 9.5px; }
  .cal-summary { gap: 14px 20px; }
}

/* ------------------------------------------------------ analytics layout */

/* Two panels side by side on a wide screen, stacked below it. Used where
   neither panel needs full width and stacking them just adds scrolling. */
.split-2 {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
  margin-bottom: 16px;
}
@media (min-width: 1100px) {
  .split-2 { grid-template-columns: 1fr 1fr; }
}
.split-2 > .panel { margin-bottom: 0; min-width: 0; }

/* Denser KPI row: these cards carry one number each and do not need the
   default card width to stay readable. */
.grid.grid-tight { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.grid.grid-tight .card { padding: 11px 13px; }
.grid.grid-tight .card-value { font-size: 20px; }

/* A quiet caption next to a panel title, for context that is not a control. */
.panel-hint { font-size: 12px; color: var(--text-faint); }

select.sm { padding: 3px 8px; font-size: 12px; width: auto; }
