:root {
  --brand: #2f6fed;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #16191f;
  --ink-2: #4a515e;
  --ink-3: #8a909c;
  --line: #e3e6eb;
  --line-2: #eef0f3;
  --good: #1f9d55;
  --warn: #c77700;
  --bad: #d64545;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  font-size: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --panel: #171a21; --ink: #eceef2; --ink-2: #b4bac6; --ink-3: #7c8391;
    --line: #2a2f39; --line-2: #20242c; --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }

/* top bar */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; color: var(--ink); font-size: 15px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--brand); display: inline-grid; place-items: center; overflow: hidden; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-mark svg { width: 16px; height: 16px; }
.site-pick select { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); min-width: 200px; }
.site-pick .site-name { font-weight: 600; }
.filters { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.seg button, .seg a { border: 0; background: none; padding: 6px 11px; cursor: pointer; color: var(--ink-2); text-decoration: none; }
.seg > * + * { border-left: 1px solid var(--line) !important; }
.seg button.on, .seg a.on { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); font-weight: 600; }

/* shell */
.shell { display: grid; grid-template-columns: 200px 1fr; min-height: calc(100vh - 53px); }
.side { border-right: 1px solid var(--line); padding: 16px 10px; background: var(--panel); }
.side a {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; color: var(--ink-2); margin-bottom: 2px;
}
.side a:hover { background: var(--line-2); text-decoration: none; }
.side a.on { background: color-mix(in srgb, var(--brand) 11%, transparent); color: var(--brand); font-weight: 600; }
.side svg { width: 17px; height: 17px; flex: none; }
.side .sep { height: 1px; background: var(--line); margin: 12px 8px; }
.view { padding: 22px 24px 60px; min-width: 0; }
.head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.head .grow { flex: 1; }

/* panels and tiles */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.grid { display: grid; gap: 14px; }
.tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 14px; }
.tile .k { color: var(--ink-3); font-size: 12px; margin-bottom: 6px; }
.tile .v { font-size: 24px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.two { grid-template-columns: 2fr 1fr; }
.empty { padding: 50px 20px; text-align: center; color: var(--ink-3); }

/* tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 550; color: var(--ink-3); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--line-2); }
td.r, th.r { text-align: right; }
.path { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; word-break: break-all; }
.tbl-wrap { overflow-x: auto; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: var(--line-2); color: var(--ink-2); }
.badge.paid { background: #e5f4ec; color: #17733f; }
.badge.comp { background: #ede9fe; color: #5b3fc4; }
.badge.trial { background: #fff3dc; color: #8a5a00; }
.badge.paused { background: #fde8e8; color: #a12b2b; }
.badge.rage { background: #fde8e8; color: #a12b2b; }
.bar { height: 6px; background: var(--line-2); border-radius: 99px; overflow: hidden; min-width: 70px; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.bar.hot i { background: var(--warn); }
.bar.full i { background: var(--bad); }

/* buttons and forms */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); padding: 7px 12px; border-radius: 8px; cursor: pointer; color: var(--ink); }
.btn:hover { border-color: var(--ink-3); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
label.f { display: block; margin-bottom: 12px; }
label.f span { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 5px; font-weight: 550; }
input[type=text], input[type=number], input[type=password], select.in {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
}
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
pre.code { background: #0f1115; color: #e6e9ef; padding: 12px 14px; border-radius: 8px; overflow-x: auto; font-size: 12.5px; white-space: pre-wrap; word-break: break-all; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(15, 17, 21, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { background: var(--panel); border-radius: 12px; width: min(560px, 100%); max-height: 90vh; overflow: auto; padding: 22px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-card .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* chart */
.chart svg { width: 100%; height: 170px; display: block; }
.chart .b { fill: color-mix(in srgb, var(--brand) 75%, transparent); }
.chart .b:hover { fill: var(--brand); }
.chart text { fill: var(--ink-3); font-size: 10px; }

/* heatmap stage */
.hm-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 14px; align-items: start; }
.hm-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.hm-tools select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); max-width: 380px; }
.stage { position: relative; background: var(--line-2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.stage .scaler { position: relative; transform-origin: 0 0; }
/* rrweb-player's stylesheet centres every .replayer-wrapper; the heatmap needs it at 0,0 */
.stage .replayer-wrapper { position: relative; float: none; left: 0 !important; top: 0 !important; transform: none !important; }
.stage iframe { border: 0; display: block; background: #fff; pointer-events: none; }
.stage .replayer-mouse, .stage .replayer-mouse-tail { display: none !important; }
.stage canvas.layer { position: absolute; left: 0; top: 0; pointer-events: none; }
.stage .marks { position: absolute; left: 0; top: 0; right: 0; pointer-events: none; }
.mark { position: absolute; left: 0; right: 0; border-top: 2px dashed rgba(0,0,0,.55); }
.mark span { position: absolute; right: 10px; top: -13px; background: rgba(15,17,21,.85); color: #fff; font-size: 13px; padding: 3px 9px; border-radius: 6px; white-space: nowrap; }
.mark.fold { border-top-color: #fff; border-top-style: solid; }
.mark.fold span { left: 10px; right: auto; background: #fff; color: #111; }
.legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-3); margin-top: 8px; }
.legend .ramp { height: 8px; width: 160px; border-radius: 99px; background: linear-gradient(90deg, #2c7bb6, #00c2d1, #7ad151, #fde725, #f46d43, #d7191c); }
.list-mini { list-style: none; padding: 0; margin: 0; }
.list-mini li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.list-mini li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* recordings */
.player-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 14px; align-items: start; }
.player-box { background: #0f1115; border-radius: var(--radius); padding: 0; overflow: hidden; }
.player-box .rr-player { box-shadow: none !important; border-radius: 0; background: #0f1115 !important; }
.timeline li { cursor: pointer; }
.timeline li:hover { color: var(--brand); }
.dev-ico svg { width: 15px; height: 15px; vertical-align: -3px; color: var(--ink-3); }

.notice { padding: 10px 12px; border-radius: 8px; background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--ink); margin-bottom: 14px; font-size: 13px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: flex; overflow-x: auto; padding: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side a { white-space: nowrap; }
  .side .sep { display: none; }
  .two, .hm-layout, .player-layout { grid-template-columns: 1fr; }
  .view { padding: 16px; }
  .filters { margin-left: 0; }
}
