html, body { height: 100%; overflow: hidden; }
body { display: flex; flex-direction: column; }
.muted { color: var(--text-muted); }
.spacer { flex: 1; }
.topbar { height: 56px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 12px 0 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 600; white-space: nowrap; }
.topbar .sep { color: var(--border); }
.topbar h1 { font-size: 15px; font-weight: 600; margin: 0; white-space: nowrap; }
#listBtn { display: none; }

.workspace { flex: 1; display: flex; min-height: 0; }
.list-pane { width: 340px; flex: none; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); min-height: 0; }
.search { padding: 10px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.search input[type=search] { height: 34px; border: 1px solid var(--border); border-radius: 6px; padding: 0 10px; background: var(--surface); color: var(--text); font: 13px var(--font-ui); }
.filters { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--text-muted); }
.filters label { display: flex; align-items: center; gap: 4px; }
.filters input, .filters select { height: 26px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); color: var(--text); padding: 0 6px; font: 12px var(--font-mono); }
.filters input { width: 52px; }
.count { font-size: 12px; color: var(--text-muted); }
.list { flex: 1; overflow-y: auto; }
.item { display: grid; grid-template-columns: 18px 84px 1fr; gap: 2px 8px; padding: 7px 10px; border-bottom: 1px solid var(--border); cursor: pointer; align-items: center; }
.item:hover { background: var(--surface-2); }
.item.on { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.item input { grid-row: span 2; accent-color: var(--accent); margin: 0; }
.item canvas { width: 84px; height: 30px; grid-row: span 2; }
.item b { font: 500 12px var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item span { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }

.main { flex: 1; min-width: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.block { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.block-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.block-head h2 { font-size: 15px; margin: 0; }
.inl { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }
.inl input, .chk input[type=number] { height: 28px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); padding: 0 6px; font-size: 12px; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.chk input[type=checkbox] { accent-color: var(--accent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 14px; padding: 2px 4px 2px 10px; font: 12px var(--font-mono); }
.chip i { width: 10px; height: 10px; border-radius: 3px; }
.chip button { border: 0; background: none; color: var(--text-muted); cursor: pointer; padding: 0 4px; font-size: 13px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; border-right: 1px solid var(--border); background: var(--surface); color: var(--text); font: 12px var(--font-ui); padding: 0 10px; height: 28px; cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: var(--on-accent); }
.overlay-wrap { position: relative; height: 300px; border: 1px solid var(--border); border-radius: 6px; background: var(--background); }
.overlay-wrap canvas { width: 100%; height: 100%; display: block; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-muted); font-size: 13px; pointer-events: none; }
.table-wrap { overflow-x: auto; margin-top: 10px; }
.stats { border-collapse: collapse; width: 100%; font-size: 12px; }
.stats th, .stats td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
.stats th { color: var(--text-muted); font-weight: 500; }
.stats td:first-child, .stats th:first-child { text-align: left; }
.stats td { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.stats .dl { display: flex; gap: 4px; justify-content: flex-end; }
.stats .dl a, .stats .dl button { font: 11px var(--font-ui); border: 1px solid var(--border); border-radius: 5px; padding: 2px 7px; color: var(--text); text-decoration: none; background: var(--surface); cursor: pointer; }
.stats .dl a:hover, .stats .dl button:hover { background: var(--surface-2); }
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; }
.chart { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px 6px; position: relative; background: var(--surface); }
.chart h4 { margin: 0 0 4px; font-size: 13px; font-weight: 600; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .tip { position: absolute; pointer-events: none; background: var(--text); color: var(--background); font: 11px var(--font-mono); padding: 4px 6px; border-radius: 4px; white-space: nowrap; display: none; z-index: 5; }
.chart .legend { display: flex; gap: 12px; font-size: 11px; color: var(--text-muted); flex-wrap: wrap; }
.chart .legend i { display: inline-block; width: 16px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 5px; }
.note { font-size: 12px; color: var(--text-muted); line-height: 1.5; margin: 10px 0 0; max-width: 900px; }
.re-note { font-size: 12px; color: var(--warn); }
#reList.warn { border-color: var(--warn); }
.item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.backdrop { position: fixed; inset: 56px 0 0 0; background: #0005; z-index: 39; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(80px); background: var(--text); color: var(--background); padding: 9px 16px; border-radius: 8px; font-size: 13px; transition: transform .2s; z-index: 100; }
.toast.show { transform: translateX(-50%) translateY(0); }

@media (max-width: 900px) {
  #listBtn { display: inline-flex; }
  .list-pane { position: fixed; top: 56px; bottom: 0; left: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); width: min(340px, 90vw); }
  .list-pane.open { transform: none; }
  .charts { grid-template-columns: 1fr; }
  .main { padding: 10px; }
  .topbar .sep, .topbar h1 + .spacer + a { display: none; }
}
@media (max-width: 560px) { .brand span { display: none; } }
