:root {
  --bg: #F3F6F9; --surface: #FFFFFF; --ink: #14202B; --muted: #5B6B78; --line: #D9E1E8;
  --accent: #0A5C8A; --accent-ink: #FFFFFF; --chip: #E6EEF4; --danger: #B3261E; --warn-bg: #FFF4D6; --warn: #7A5300;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1820; --surface: #17232D; --ink: #E8EEF3; --muted: #93A4B2; --line: #2A3A47;
    --accent: #6BBEEF; --accent-ink: #0B1A24; --chip: #22323F; --danger: #FF8A80; --warn-bg: #3A3016; --warn: #F2CF79;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1820; --surface: #17232D; --ink: #E8EEF3; --muted: #93A4B2; --line: #2A3A47;
  --accent: #6BBEEF; --accent-ink: #0B1A24; --chip: #22323F; --danger: #FF8A80; --warn-bg: #3A3016; --warn: #F2CF79;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.grow { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; }
.wrap { flex-wrap: wrap; }

.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 6px; }
.logo { font-weight: 800; font-size: 20px; letter-spacing: .5px; font-style: italic; }
.logo .dash { color: var(--accent); }
.web { font-size: 12px; color: var(--muted); }
.trx {
  border: 1px solid var(--line); background: var(--chip); border-radius: 999px; padding: 4px 12px;
  font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 14px;
}

.tabs { display: flex; gap: 4px; padding: 8px 16px 0; max-width: 980px; margin: 0 auto; }
.tabs button {
  border: 0; background: none; padding: 8px 14px; border-radius: 10px 10px 0 0; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
main { max-width: 980px; margin: 0 auto; padding: 8px 16px; }
h2 { font-size: 17px; margin: 22px 0 8px; }

button {
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
  border-radius: 10px; padding: 8px 14px; cursor: pointer; min-height: 40px;
}
button.ghost, .btn.ghost { background: transparent; color: var(--accent); border-color: var(--line); }
button.small { min-height: 32px; padding: 4px 10px; font-size: 14px; }
button.icon { min-width: 40px; padding: 4px; }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
.btn { display: inline-flex; align-items: center; border: 1px solid; border-radius: 10px; padding: 8px 14px; min-height: 40px; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input, select {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-height: 40px;
}
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); min-width: 0; }
label > input, label > select { font-size: 16px; color: var(--ink); }
label.check { flex-direction: row; align-items: center; font-size: 15px; color: var(--ink); }
label.check input { width: auto; min-height: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 8px 0; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } .grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.toolbar { display: flex; gap: 8px; margin: 6px 0; }
.toolbar input { flex: 1; }
.toolbar select { width: auto; max-width: 30%; }
#count { font-size: 13px; margin: 4px 2px 6px; }
.list { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.list li { display: grid; grid-template-columns: 7.5em 1fr auto; gap: 4px 12px; padding: 9px 12px; border-top: 1px solid var(--line); cursor: pointer; }
.list li:first-child { border-top: 0; }
.list li:hover, .list li:focus-visible { background: var(--chip); }
.list .when { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.list .call { font-weight: 700; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .3px; }
.list .who { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; grid-column: 2; }
.list .bm { text-align: right; font-size: 13px; white-space: nowrap; }
.list .bm b { font-weight: 600; }
.empty { text-align: center; padding: 40px 12px; }

.fab {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 6;
  border-radius: 16px; padding: 12px 20px; font-weight: 700; font-size: 17px; box-shadow: 0 4px 14px rgba(0,0,0,.2);
}

dialog.card {
  width: min(720px, calc(100vw - 16px)); max-height: calc(100vh - 16px); border: 1px solid var(--line); border-radius: 16px;
  background: var(--surface); color: var(--ink); padding: 14px 16px; box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
dialog::backdrop { background: rgba(10, 20, 30, .45); }
.card-head { display: flex; gap: 8px; align-items: center; }
.card-head .call {
  font: 700 26px/1.2 ui-monospace, "SF Mono", Menlo, Consolas, monospace; text-transform: uppercase; letter-spacing: 1px; min-height: 52px;
}
.info { min-height: 22px; margin: 6px 2px 2px; font-size: 14px; color: var(--muted); }
.info b { color: var(--ink); font-weight: 600; }
.dupe { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 6px 10px; margin: 6px 0; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chips button {
  background: var(--chip); color: var(--ink); border: 1px solid transparent; border-radius: 999px; min-height: 34px; padding: 4px 12px; font-size: 14px;
}
.chips button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }
.actions { margin-top: 12px; }
.qsl { margin-top: 8px; gap: 18px; }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 8px 0 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat .n { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 13px; color: var(--muted); }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: 14px; }
th, td { padding: 6px 10px; text-align: right; border-top: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { border-top: 0; color: var(--muted); font-weight: 600; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 20;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; max-width: calc(100vw - 32px);
  display: flex; gap: 12px; align-items: center;
}
.toast button { min-height: 30px; padding: 2px 10px; background: transparent; color: var(--bg); border-color: var(--bg); }
.toast[hidden], [hidden] { display: none !important; }
@media (max-width: 560px) {
  .toolbar { flex-wrap: wrap; }
  .toolbar input { flex-basis: 100%; }
  .toolbar select { flex: 1; max-width: none; }
  .list li { grid-template-columns: 1fr auto; }
  .list .call { grid-column: 1; grid-row: 1; }
  .list .bm { grid-column: 2; grid-row: 1; }
  .list .when { grid-column: 2; grid-row: 2; text-align: right; }
  .list .who { grid-column: 1; grid-row: 2; }
}
