:root {
  --bg: #0b1220; --bg2: #0f1a2e; --card: #13203a; --card2: #182846; --line: #22355a;
  --text: #e6edf7; --muted: #8fa3c2; --accent: #2dd4bf; --accent2: #38bdf8;
  --up: #22c55e; --down: #ef4444; --warn: #f59e0b; --pending: #a78bfa;
  --radius: 12px; --shadow: 0 6px 24px rgba(0,0,0,.25);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
:root[data-theme="light"] {
  --bg: #f4f6fb; --bg2: #eef2f9; --card: #ffffff; --card2: #f6f8fc; --line: #dde3ee;
  --text: #0f172a; --muted: #5b6b85; --shadow: 0 4px 18px rgba(15,23,42,.08);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f6fb; --bg2: #eef2f9; --card: #ffffff; --card2: #f6f8fc; --line: #dde3ee;
    --text: #0f172a; --muted: #5b6b85; --shadow: 0 4px 18px rgba(15,23,42,.08);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
a { color: var(--accent2); }
.muted { color: var(--muted); }
.err { color: var(--down); min-height: 1.2em; }
.up { color: var(--up); } .down { color: var(--down); } .warn { color: var(--warn); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
#app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--bg2); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0;
  height: 100vh; display: flex; flex-direction: column; }
.brand { font-weight: 700; font-size: 16px; display: flex; gap: 8px; align-items: center; padding: 4px 10px 18px; }
.brand.big { font-size: 22px; justify-content: center; padding: 0 0 6px; }
.logo { color: var(--accent); font-size: 20px; }
#nav a { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 9px; color: var(--muted);
  text-decoration: none; font-weight: 500; margin-bottom: 2px; }
#nav a:hover { background: var(--card); color: var(--text); }
#nav a.active { background: var(--card2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.side-foot { margin-top: auto; font-size: 12px; padding: 10px; }
main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; gap: 10px; align-items: center;
  padding: 10px 18px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--card);
  border: 1px solid var(--line); font-size: 12px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--up); box-shadow: 0 0 8px var(--up); } .dot.off { background: var(--down); }
.dot.idle { background: var(--warn); }
.view { padding: 18px; max-width: 1400px; }
h1 { font-size: 20px; margin: 0 0 14px; } h2 { font-size: 15px; margin: 0 0 10px; } h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); min-width: 0; }
.kpi .label { color: var(--muted); font-size: 12px; } .kpi .value { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.btn { border: 1px solid var(--line); background: var(--card2); color: var(--text); border-radius: 9px; padding: 8px 14px;
  font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { filter: brightness(1.12); } .btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #032b26; border-color: transparent; }
.btn.ok { background: var(--up); color: #032b12; border-color: transparent; }
.btn.danger { background: var(--down); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; } .btn.sm { padding: 5px 10px; font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 7px 8px; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); white-space: nowrap; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; background: var(--card2); border: 1px solid var(--line); }
.badge.buy { background: color-mix(in srgb, var(--up) 18%, transparent); color: var(--up); border-color: transparent; }
.badge.sell { background: color-mix(in srgb, var(--down) 18%, transparent); color: var(--down); border-color: transparent; }
.badge.pending, .badge.candidate { color: var(--pending); } .badge.executed, .badge.active { color: var(--up); }
.badge.blocked, .badge.rejected, .badge.failed { color: var(--down); } .badge.expired, .badge.ignored, .badge.retired { color: var(--muted); }
.switch { position: relative; width: 46px; height: 26px; display: inline-block; }
.switch input { display: none; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--up); } .switch input:checked + span::after { transform: translateX(20px); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 7px 12px; font: inherit; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--accent); color: #032b26; }
.feed { max-height: 360px; overflow: auto; } .feed div { padding: 6px 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 50%, transparent); font-size: 13px; }
.feed time { color: var(--muted); font-size: 11px; margin-right: 6px; font-family: var(--mono); }
.signal { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; background: var(--card2); }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin: 8px 0; }
.kv div { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.kv b { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
.expl { font-size: 13px; color: var(--muted); margin: 6px 0; }
.banner { margin: 12px 18px 0; padding: 10px 14px; border-radius: 10px; border: 1px solid; font-weight: 600; }
.banner.warn { background: color-mix(in srgb, var(--warn) 12%, transparent); border-color: var(--warn); color: var(--warn); }
.banner.err { background: color-mix(in srgb, var(--down) 12%, transparent); border-color: var(--down); color: var(--down); }
.banner.info { background: color-mix(in srgb, var(--accent2) 10%, transparent); border-color: var(--accent2); color: var(--accent2); }
.gauge { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.gauge i { display: block; height: 100%; background: var(--up); }
.gauge i.mid { background: var(--warn); } .gauge i.hi { background: var(--down); }
.chart { width: 100%; height: auto; display: block; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button { border: 1px solid var(--line); background: var(--card); color: var(--muted); border-radius: 8px; padding: 6px 12px; cursor: pointer; font: inherit; font-weight: 600; }
.tabs button.on { color: var(--text); border-color: var(--accent); }
input, select { background: var(--card2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; font: inherit; width: 100%; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
label input, label select { margin-top: 4px; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); text-align: left; }
.login-card .btn { width: 100%; margin-top: 6px; }
.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: var(--card2); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); opacity: 0; transition: .25s; pointer-events: none; z-index: 50; max-width: 90vw; }
.toast.show { opacity: 1; }
.heat td { text-align: center; font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.empty { color: var(--muted); padding: 14px 0; text-align: center; }
.bottomnav { display: none; }
@media (max-width: 1100px) { .g6 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .view { padding: 14px 16px 90px; }
  .topbar { padding: 8px 16px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .g6 { grid-template-columns: repeat(2, 1fr); }
  .bottomnav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
    background: var(--bg2); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottomnav a { text-align: center; color: var(--muted); text-decoration: none; font-size: 11px; padding: 4px 0; }
  .bottomnav a span { display: block; font-size: 18px; }
  .bottomnav a.active { color: var(--accent); }
  .top-actions .btn { padding: 5px 8px; font-size: 12px; }
  .pill { font-size: 11px; padding: 3px 8px; }
  .banner { margin: 10px 16px 0; font-size: 12px; padding: 8px 10px; }
  h1 { font-size: 18px; }
  .kpi .value { font-size: 18px; }
}
