:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #16191f;
  --ink-2: #4b5260;
  --muted: #8a909c;
  --line: #e7e9ee;
  --line-2: #f0f1f4;
  --accent: #2f5bea;
  --accent-soft: #eef2ff;
  --up: #12955f;
  --up-soft: #e6f6ee;
  --down: #d6453d;
  --down-soft: #fdecea;
  --warn: #b7791f;
  --warn-soft: #fdf5e6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); }

/* top bar */
.top { position: sticky; top: 0; z-index: 10; background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1280px; margin: 0 auto; padding: 10px 16px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 16px; letter-spacing: -.01em; display: flex; gap: 8px; align-items: center; }
.brand-mark { color: var(--accent); }
nav.tabs { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
nav.tabs a { padding: 6px 12px; border-radius: 8px; color: var(--ink-2); white-space: nowrap; font-weight: 500; }
nav.tabs a.on { background: var(--accent-soft); color: var(--accent); }
.status-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2); white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--up); } .dot.bad { background: var(--down); } .dot.warn { background: var(--warn); }
.pill.off { border-color: #dfe3ff; color: var(--accent); background: var(--accent-soft); font-weight: 600; }

main { max-width: 1280px; margin: 0 auto; padding: 16px; }
h1 { font-size: 20px; margin: 4px 0 2px; letter-spacing: -.01em; }
h2 { font-size: 14px; margin: 0; font-weight: 600; }
.sub { color: var(--muted); margin: 0 0 14px; }

.grid { display: grid; gap: 12px; }
.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)); }
.kpis { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
@media (max-width: 900px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); } .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.section { margin-top: 12px; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 20px; font-weight: 650; letter-spacing: -.01em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .note { font-size: 12px; color: var(--muted); }

.quote .name { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.quote .px { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.quote .ts { font-size: 11px; color: var(--muted); }
@media (max-width: 640px) {
  .grid.quotes { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .quotes .card { padding: 10px; }
  .quotes .px { font-size: 15px; }
  .quotes .name { font-size: 10px; }
}

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--card); padding: 5px 11px; font: inherit; font-size: 12px; color: var(--ink-2); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.btn { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 8px; padding: 6px 12px;
  font: inherit; font-weight: 500; cursor: pointer; }
.btn:hover { border-color: #cfd3db; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: var(--down); border-color: var(--down); color: #fff; }
.btn.small { padding: 3px 9px; font-size: 12px; }
.btn.wide { width: 100%; padding: 10px; }
.btn[disabled] { opacity: .5; cursor: default; }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--card); }
td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; } tr.click:hover td { background: #fafbfc; }
td.r, th.r { text-align: right; }
.side { display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px; margin-left: 4px; }
.side.CE { background: var(--up-soft); color: var(--up); } .side.PE { background: var(--down-soft); color: var(--down); }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 4px; background: var(--line-2); color: var(--ink-2); }
.tag.OPEN { background: var(--accent-soft); color: var(--accent); }
.tag.TARGET, .tag.SIGNAL { background: var(--up-soft); color: var(--up); }
.tag.SL, .tag.TSL { background: var(--down-soft); color: var(--down); }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }

/* heatmap */
.heat-year { margin-bottom: 10px; }
.heat-year > .yr { font-weight: 600; margin: 4px 0 6px; }
.heat-months { display: flex; gap: 14px; flex-wrap: wrap; }
.heat-month { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.heat-cells { display: grid; grid-template-rows: repeat(5, 12px); grid-auto-flow: column; grid-auto-columns: 12px; gap: 3px; }
.heat-cells i { display: block; width: 12px; height: 12px; border-radius: 3px; background: var(--line-2); }
.heat-month .m { font-size: 10px; color: var(--muted); }
.legend { display: flex; gap: 3px; align-items: center; font-size: 11px; color: var(--muted); margin-top: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

.chart { width: 100%; height: 260px; }
.chart.tall { height: 360px; }
.banner { border: 1px solid #dfe3ff; background: var(--accent-soft); color: #23408f; border-radius: var(--radius); padding: 12px 14px; }
.banner.warn { border-color: #f3dfb4; background: var(--warn-soft); color: #7a5312; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.list li:last-child { border-bottom: 0; }
.list .t { color: var(--muted); width: 64px; flex: none; font-variant-numeric: tabular-nums; }
.lvl-warn { color: var(--warn); } .lvl-error { color: var(--down); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 16px; }
.detail-grid div span { display: block; color: var(--muted); font-size: 12px; }

/* login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  padding: 28px; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 10px; }
.login-card label { font-size: 12px; color: var(--muted); font-weight: 600; }
.login-card input { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.login-card input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.error { color: var(--down); margin: 0; font-size: 13px; }
