:root {
  --bg: #f5f6f8; --card: #ffffff; --text: #1d2129; --muted: #6b7280; --line: #e5e7eb;
  --accent: #2563eb; --accent-text: #ffffff; --up: #d4380d; --down: #16a34a; --warn: #b45309;
  --danger: #c0262d; --chip: #eef2f7; --grid: #eceef2; --hold: #9aa3af;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --card: #181b21; --text: #e6e8eb; --muted: #9aa1ab; --line: #2a2f37;
    --accent: #4f8cff; --accent-text: #0b0d10; --up: #ff6b4a; --down: #34d17a; --warn: #f0a640;
    --danger: #ff5a5f; --chip: #222731; --grid: #23272f; --hold: #6b7280;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif; }
[hidden] { display: none !important; }
h1 { font-size: 22px; margin: 0 0 8px; }
h2 { font-size: 16px; margin: 0 0 10px; }
a { color: var(--accent); }
code { background: var(--chip); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.muted { color: var(--muted); font-size: 13px; }
.fine { color: var(--muted); font-size: 12px; margin-top: 18px; }
.msg { min-height: 20px; color: var(--danger); font-size: 13px; }

button, input, select { font: inherit; color: inherit; }
button { border: 1px solid var(--line); background: var(--card); padding: 8px 14px; border-radius: 8px;
  cursor: pointer; min-height: 40px; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { border-color: var(--danger); color: var(--danger); }
button.wide { width: 100%; }
input, select { border: 1px solid var(--line); background: var(--bg); padding: 8px 10px; border-radius: 8px;
  min-height: 40px; width: 100%; }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 28px 22px;
  width: 100%; max-width: 380px; }
.login-card #code { font-size: 22px; letter-spacing: 6px; text-align: center; }
.stack { display: grid; gap: 10px; margin-top: 12px; }

.bar { position: sticky; top: 0; z-index: 5; }
.top { background: var(--card); border-bottom: 1px solid var(--line);
  padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.ticker .name { font-size: 13px; color: var(--muted); }
.ticker .price { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ticker .sub { font-size: 12px; color: var(--muted); }
.chg { font-size: 14px; font-weight: 500; }
.up { color: var(--up); } .down { color: var(--down); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; max-width: 55%; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--chip); white-space: nowrap; }
.badge.ok { color: var(--down); } .badge.bad { color: var(--danger); } .badge.warn { color: var(--warn); }

.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 8px 12px; background: var(--card);
  border-bottom: 1px solid var(--line); }
.tabs button { border: none; background: transparent; padding: 6px 12px; min-height: 36px; white-space: nowrap;
  color: var(--muted); border-radius: 8px; }
.tabs button.active { background: var(--chip); color: var(--text); font-weight: 600; }

main { max-width: 1100px; margin: 0 auto; padding: 12px 16px 40px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 12px; }
.grid .card { margin-bottom: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row input, .row select { width: auto; flex: 1 1 140px; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.form label.check { display: flex; align-items: center; gap: 8px; color: var(--text); grid-column: 1 / -1; }
.form label.check input { width: auto; min-height: auto; }
.form button { grid-column: 1 / -1; justify-self: start; }

.chart { width: 100%; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .wick-up, .chart .body-up { stroke: var(--up); fill: var(--up); }
.chart .wick-down, .chart .body-down { stroke: var(--down); fill: var(--down); }
.chart .line-main { stroke: var(--accent); fill: none; stroke-width: 2; }
.chart .line-hold { stroke: var(--hold); fill: none; stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .mark-buy { fill: var(--up); } .chart .mark-sell { fill: var(--down); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend .sw { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: 5px; }
.legend .sw-main { background: var(--accent); } .legend .sw-hold { background: var(--hold); }
.empty { color: var(--muted); font-size: 13px; padding: 16px 0; text-align: center; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; }

.signal { border-top: 1px solid var(--line); padding: 12px 0; }
.signal:first-child { border-top: none; padding-top: 0; }
.signal .title { font-weight: 600; }
.signal .meta { font-size: 12px; color: var(--muted); }
.signal .lines { font-size: 13px; margin: 6px 0; }
.state { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--chip); margin-left: 6px; }
.state.pending { color: var(--accent); } .state.filled { color: var(--down); }
.state.expired, .state.invalidated, .state.rejected { color: var(--muted); }

.token-new { background: var(--chip); border-radius: 8px; padding: 10px; margin: 10px 0; word-break: break-all;
  font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text);
  color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: 90vw; z-index: 20; }

@media (max-width: 560px) {
  .ticker .price { font-size: 20px; }
  .badges { max-width: 50%; }
  main { padding: 10px 12px 40px; }
  .card { padding: 12px; }
}
