:root {
  --bg: #0d1421; --panel: #151e2e; --panel-2: #1b2638; --line: #263248;
  --text: #e6ecf5; --muted: #8a97ad; --accent: #ff8c32;
  --up: #ef4444; --down: #22c55e; --flat: #64748b; --warn: #f59e0b;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.up { color: var(--up); } .down { color: var(--down); }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center;
  justify-content: space-between; padding: 10px 16px; background: rgba(13,20,33,.95);
  border-bottom: 1px solid var(--line); backdrop-filter: blur(6px); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.brand img { width: 24px; height: 24px; border-radius: 6px; }
nav { display: flex; gap: 14px; align-items: center; }
nav a { color: var(--muted); padding: 4px 2px; }
nav a.active { color: var(--text); border-bottom: 2px solid var(--accent); }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }
h1 { font-size: 20px; margin: 4px 0 2px; } h2 { font-size: 16px; margin: 22px 0 10px; }
.foot { max-width: 1100px; margin: 24px auto; padding: 0 16px 24px; color: var(--muted); font-size: 12px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.card { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; transition: border-color .15s; }
.card:hover { border-color: var(--accent); }
.card .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card .name { font-weight: 600; font-size: 16px; }
.card .price { font-size: 20px; font-variant-numeric: tabular-nums; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.badge.target { border-color: var(--accent); color: var(--accent); }

.stack { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--panel-2); margin: 10px 0 6px; }
.stack span { display: block; height: 100%; }
.stack .s-up { background: var(--up); } .stack .s-down { background: var(--down); } .stack .s-flat { background: var(--flat); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: 0; }

.scenario { background: var(--panel-2); border-radius: var(--radius); padding: 10px 14px; margin: 10px 0 16px; font-size: 13.5px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.kpi .v { font-size: 22px; font-variant-numeric: tabular-nums; }
.kpi .k { font-size: 12.5px; color: var(--muted); }

#chart { height: 420px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0 8px; }
.seg button { background: var(--panel); color: var(--muted); border: 1px solid var(--line); padding: 4px 10px; cursor: pointer; font: inherit; font-size: 13px; }
.seg button:first-child { border-radius: 6px 0 0 6px; } .seg button:last-child { border-radius: 0 6px 6px 0; }
.seg button.on { color: var(--text); border-color: var(--accent); }
label.chk { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 500; }
td .stack { margin: 0; width: 120px; display: inline-flex; vertical-align: middle; }
.chip { font-size: 12px; padding: 1px 8px; border-radius: 99px; }
.chip.UP_FIRST { background: rgba(239,68,68,.15); color: var(--up); }
.chip.DOWN_FIRST { background: rgba(34,197,94,.15); color: var(--down); }
.chip.TIMEOUT { background: rgba(100,116,139,.2); color: #cbd5e1; }
.chip.CENSORED, .chip.AMBIGUOUS { background: rgba(245,158,11,.15); color: var(--warn); }
.ok { color: var(--down); } .bad { color: var(--up); }

.login { max-width: 380px; margin: 60px auto; }
.login input { width: 100%; padding: 10px 12px; margin: 10px 0; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font: inherit; }
.btn { background: var(--accent); color: #111; border: 0; padding: 9px 16px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; }
.error { color: var(--up); font-size: 13.5px; }
.note { font-size: 12.5px; color: var(--muted); margin-top: 8px; }

@media (max-width: 600px) {
  main { padding: 12px; }
  #chart { height: 320px; }
  .hide-sm { display: none; }
}
