:root {
  --bg: #f4f6fa; --surface: #ffffff; --surface-2: #f8f9fc; --text: #141a26; --muted: #667085; --line: #e4e8f0;
  --accent: #2563eb; --accent-2: #1d4ed8; --accent-soft: #e8efff; --good: #067647; --good-soft: #e7f6ee;
  --bad: #c0362c; --bad-soft: #fdecea; --info: #6941c6; --info-soft: #f1ecfd; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.06);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117; --surface: #151b24; --surface-2: #1a212c; --text: #e7ebf2; --muted: #96a0b0; --line: #262f3c;
    --accent: #4d8dff; --accent-2: #6aa0ff; --accent-soft: #18284a; --good: #4ade80; --good-soft: #13301f;
    --bad: #ff7a6e; --bad-soft: #3a1714; --info: #b39dfa; --info-soft: #261d42; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
.sprite { display: none; }
svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
h1, h2 { margin: 0; letter-spacing: -.01em; }
.muted { color: var(--muted); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 1px; }

/* ---------- sign in ---------- */
.signin { min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), transparent 60%), var(--bg); }
.signin-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: var(--shadow); padding: 36px 32px 28px; text-align: center; }
.brand-mark { width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 16px; display: grid; place-items: center;
  color: #fff; background: linear-gradient(135deg, var(--accent), #7c5cff); box-shadow: 0 6px 18px rgba(37,99,235,.35); }
.brand-mark svg { width: 26px; height: 26px; }
.brand-mark.small { width: 30px; height: 30px; border-radius: 9px; margin: 0; box-shadow: none; }
.brand-mark.small svg { width: 16px; height: 16px; }
.signin h1 { font-size: 24px; }
.lead { color: var(--muted); margin: 8px 0 24px; }
form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.field input { height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2);
  font-size: 15px; font-weight: 400; color: var(--text); transition: border-color .15s, box-shadow .15s; }
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--surface); }
.primary { height: 44px; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 600; transition: background .15s, transform .05s; }
.primary:hover { background: var(--accent-2); }
.primary:active { transform: translateY(1px); }
.primary:disabled { opacity: .65; cursor: progress; }
.wide { width: 100%; margin-top: 4px; }
.alert { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--bad-soft); color: var(--bad); font-size: 14px; }
.fineprint { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 20px 0 0; font-size: 12.5px; color: var(--muted); }
.fineprint svg { width: 14px; height: 14px; }

/* ---------- app ---------- */
.app { min-height: 100%; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.topbar-inner, .content, .playerbar-inner { max-width: 1160px; margin: 0 auto; padding-left: 20px; padding-right: 20px; }
.topbar-inner { height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.user { display: flex; align-items: center; gap: 14px; min-width: 0; }
.user-text { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; min-width: 0; }
.user-text strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.user-text span { font-size: 12px; color: var(--muted); }
.ghost { height: 34px; padding: 0 14px; border: 1px solid var(--line); border-radius: 9px; font-weight: 600; font-size: 13.5px; }
.ghost:hover { background: var(--surface-2); }
.content { width: 100%; padding-top: 22px; padding-bottom: 120px; flex: 1; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 16px; }
.segmented { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: 11px; background: var(--surface);
  border: 1px solid var(--line); }
.segmented button { height: 32px; padding: 0 12px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.segmented button:hover { color: var(--text); }
.segmented button.on { background: var(--accent-soft); color: var(--accent); }
.date-pick input { height: 32px; border: 0; background: none; padding: 0 8px; border-radius: 8px; font-size: 13.5px; color: var(--muted); }
.date-pick.on input { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.search { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.search input { width: 100%; height: 40px; padding: 0 12px 0 36px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 16px; }
.panel-head .muted { font-size: 13px; }
.table-wrap { overflow-x: auto; }
table.calls { width: 100%; border-collapse: collapse; }
.calls th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  padding: 10px 20px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.calls td { padding: 12px 20px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
.calls tbody tr:last-child td { border-bottom: 0; }
.calls tbody tr:hover { background: var(--surface-2); }
.calls tr.playing { background: var(--accent-soft); }
.right { text-align: right !important; }
.when strong { display: block; font-weight: 600; font-variant-numeric: tabular-nums; }
.when span { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
.kind { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.kind i { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; }
.kind i svg { width: 15px; height: 15px; }
.kind.in i { background: var(--good-soft); color: var(--good); }
.kind.out i { background: var(--accent-soft); color: var(--accent); }
.kind.int i { background: var(--info-soft); color: var(--info); }
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.badge.missed { background: var(--bad-soft); color: var(--bad); }
.badge.legacy { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); margin-top: 4px; }
.actions { display: inline-flex; gap: 6px; justify-content: flex-end; }
.play, .download { height: 34px; display: inline-flex; align-items: center; gap: 6px; border-radius: 9px; font-weight: 600; font-size: 13px; text-decoration: none; }
.play { padding: 0 12px; background: var(--accent); color: #fff; }
.play:hover { background: var(--accent-2); }
.play svg { width: 14px; height: 14px; }
.download { width: 34px; justify-content: center; border: 1px solid var(--line); color: var(--muted); }
.download:hover { color: var(--text); background: var(--surface-2); }
.none { color: var(--muted); }
.empty { padding: 56px 20px; text-align: center; color: var(--muted); }
.empty-icon { width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); }
.empty-icon svg { width: 22px; height: 22px; }
.footnote { color: var(--muted); font-size: 12.5px; margin: 14px 4px 0; }
.loading tbody { opacity: .45; }

.playerbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); border-top: 1px solid var(--line); box-shadow: 0 -8px 24px rgba(16,24,40,.08); }
.playerbar-inner { display: flex; align-items: center; gap: 16px; padding-top: 10px; padding-bottom: 10px; }
.now { display: flex; flex-direction: column; min-width: 0; font-size: 12px; line-height: 1.3; }
.now strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32vw; }
.playerbar audio { flex: 1; height: 40px; min-width: 0; }
.icon-button { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; color: var(--muted); }
.icon-button:hover { background: var(--surface-2); color: var(--text); }

/* ---------- phones ---------- */
@media (max-width: 720px) {
  .topbar-inner, .content, .playerbar-inner { padding-left: 14px; padding-right: 14px; }
  .user-text { display: none; }
  .toolbar { gap: 10px; }
  .search { max-width: none; order: -1; flex-basis: 100%; }
  .segmented { overflow-x: auto; max-width: 100%; }
  .calls thead { display: none; }
  .calls, .calls tbody, .calls tr, .calls td { display: block; width: 100%; }
  .calls tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .calls td { padding: 0; border: 0; }
  .calls td.c-when { grid-column: 1; }
  .calls td.c-kind { grid-column: 2; grid-row: 1; justify-self: end; }
  .calls td.c-route { grid-column: 1 / -1; }
  .calls td.c-talk { grid-column: 1; align-self: center; }
  .calls td.c-rec { grid-column: 2; justify-self: end; }
  .calls td.c-from, .calls td.c-to { display: none; }
  .calls td.c-route { display: block !important; }
  .playerbar-inner { flex-wrap: wrap; gap: 8px; }
  .now { flex: 1; }
  .now strong { max-width: 70vw; }
  .playerbar audio { flex-basis: 100%; order: 3; }
}
@media (min-width: 721px) { .calls td.c-route { display: none; } }
