:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface-1: #ffffff;
  --line: #e3e5e9;
  --line-strong: #cfd3d9;
  --text-primary: #191919;
  --text-secondary: #666666;
  --series-1: #257de0;
  --seq-250: #84b9f3;
  --seq-100: #cce3fd;
  --accent: #1757ac;
  --critical: #c62828;
  --good: #1f7a33;
  --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text-primary); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-secondary); }
.hidden { display: none !important; }

/* Layout */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: #12161c; color: #d9dde3; padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .logo { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 17px; color: #fff; padding: 0 8px 18px; text-decoration: none; }
.side .logo img { width: 26px; height: 26px; }
.side h4 { font-size: 12px; font-weight: 600; color: #8b93a0; margin: 18px 8px 6px; }
.side a.item { display: block; padding: 7px 10px; border-radius: 6px; color: #d9dde3; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side a.item:hover { background: #1d232c; }
.side a.item.on { background: #263040; color: #fff; }
.side .spacer { flex: 1; }
.side .who { font-size: 13px; color: #8b93a0; padding: 10px 8px 0; border-top: 1px solid #252c36; margin-top: 12px; }
.side .who button { background: none; border: 0; color: #b9c0ca; padding: 0; cursor: pointer; text-decoration: underline; font-size: 13px; }
main { padding: 28px 32px 60px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.topbar h1 { font-size: 22px; margin: 0; font-weight: 650; }
.topbar .site-url { color: var(--text-secondary); font-size: 14px; }
.topbar .grow { flex: 1; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--text-secondary); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs a.on { color: var(--text-primary); border-bottom-color: var(--series-1); }
.btn.menu-btn { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .btn.menu-btn { display: inline-flex; }
  main { padding: 20px 16px 48px; }
}

/* Controls */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--surface-1); color: var(--text-primary); cursor: pointer; text-decoration: none; font-weight: 500; }
.btn:hover { background: #f0f2f5; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #134a91; }
.btn.danger { color: var(--critical); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; background: var(--surface-1); }
.seg button { border: 0; background: none; padding: 6px 12px; cursor: pointer; color: var(--text-secondary); font-weight: 500; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: #e8f1fc; color: var(--accent); }
select, input[type=text], input[type=email], input[type=password], input[type=url], textarea {
  border: 1px solid var(--line-strong); border-radius: 6px; padding: 7px 10px; background: var(--surface-1); color: var(--text-primary); max-width: 100%;
}
label.f { display: block; margin-bottom: 14px; }
label.f span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
label.f small { display: block; color: var(--text-secondary); font-size: 12.5px; margin-top: 3px; }
label.f input:not([type=checkbox]), label.f select, label.f textarea { width: 100%; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.err { color: var(--critical); font-size: 14px; min-height: 1.2em; }
.ok { color: var(--good); font-size: 14px; }

/* Cards */
.card { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card h2 { font-size: 15px; font-weight: 650; margin: 0 0 12px; }
.card h2 .muted { font-weight: 400; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.grid2 > *, .grid3 > * { min-width: 0; }
@media (max-width: 1100px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.stack > * + * { margin-top: 16px; }

/* Stat tiles */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
@media (max-width: 900px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.tile .label { font-size: 13px; color: var(--text-secondary); }
.tile .value { font-size: 28px; font-weight: 650; letter-spacing: -0.01em; margin-top: 2px; }

/* Tables with inline bars */
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12.5px; color: var(--text-secondary); font-weight: 600; padding: 0 8px 8px; border-bottom: 1px solid var(--line); }
table.list td { padding: 8px; border-bottom: 1px solid #f0f1f3; vertical-align: middle; }
table.list th.r, table.list td.r { text-align: right; white-space: nowrap; }
table.list tr:last-child td { border-bottom: 0; }
.barcell { position: relative; }
.barcell .bar { position: absolute; left: 0; top: 5px; bottom: 5px; background: var(--seq-100); border-radius: 0 4px 4px 0; }
.barcell .txt { position: relative; padding-left: 6px; word-break: break-all; }
.empty { color: var(--text-secondary); padding: 24px 0; text-align: center; }

/* Chart */
.chart svg { display: block; width: 100%; height: 220px; overflow: visible; }
.chart .axis text { fill: var(--text-secondary); font-size: 11.5px; }
.chart .grid line { stroke: #eceef1; }
.chart .baseline { stroke: var(--line-strong); }
.chart rect.hit { fill: transparent; cursor: default; }
.tip { position: fixed; z-index: 100; background: #191919; color: #fff; padding: 7px 10px; border-radius: 6px; font-size: 13px; pointer-events: none; box-shadow: 0 4px 14px rgba(0,0,0,.18); white-space: nowrap; }
.tip b { font-weight: 650; }

/* Images */
.imgrow { display: grid; grid-template-columns: 72px 1fr; gap: 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid #f0f1f3; }
.imgrow:last-child { border-bottom: 0; }
.imgrow img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; background: #eceef1; }
.imgrow .meta { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.imgrow .meta b { color: var(--text-primary); font-weight: 600; }
.imgrow .name { font-size: 13.5px; word-break: break-all; }
.attn { height: 8px; background: #eef0f3; border-radius: 4px; margin-top: 6px; overflow: hidden; }
.attn i { display: block; height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.rank { font-size: 12px; color: var(--text-secondary); }

/* Heatmap */
.hm-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.hm-controls select { min-width: 220px; }
.hm-wrap { background: #e9ebef; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; position: relative; padding: 10px 0; }
.hm-box { position: relative; overflow: hidden; margin: 0 auto; }
.hm-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.hm-stage iframe { border: 0; display: block; background: #fff; }
.hm-status { font-size: 13px; color: var(--text-secondary); margin: 8px 0 0; min-height: 1.2em; }
.legend-ramp { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-secondary); }
.legend-ramp i { width: 120px; height: 10px; border-radius: 3px; background: linear-gradient(90deg, #cce3fd, #6aabf1, #257de0, #1757ac, #0e3d7e); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.login h1 { font-size: 22px; margin: 0 0 4px; display: flex; gap: 10px; align-items: center; }
.login h1 img { width: 28px; }
.login p { margin: 0 0 20px; }

/* Setup */
pre.snippet { background: #12161c; color: #e6e9ee; padding: 14px 16px; border-radius: 6px; overflow-x: auto; font-size: 13px; margin: 0 0 10px; white-space: pre-wrap; word-break: break-all; }
.site-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.site-cards a { text-decoration: none; color: inherit; }
.site-cards .card:hover { border-color: var(--seq-250); }
.site-cards .big { font-size: 24px; font-weight: 650; }
dialog { border: 1px solid var(--line); border-radius: 10px; padding: 22px; width: min(460px, 92vw); }
dialog::backdrop { background: rgba(10,14,20,.45); }
dialog h3 { margin: 0 0 14px; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
