:root {
  --bg: #f6f7f9; --panel: #fff; --text: #1a1f29; --muted: #5d6675; --line: #dfe3ea;
  --accent: #0b5cd6; --accent-text: #fff; --danger: #b3261e;
  --new: #0b5cd6; --contacted: #7a5200; --quoted: #6a3fb5; --won: #17713a; --lost: #5d6675; --spam: #b3261e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --panel: #1b2029; --text: #e8ebf0; --muted: #9aa4b5; --line: #2c3341;
    --accent: #6ea8ff; --accent-text: #0c1320; --danger: #ff8a80;
    --new: #6ea8ff; --contacted: #e0b25a; --quoted: #b79cf0; --won: #6fd193; --lost: #9aa4b5; --spam: #ff8a80;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .75rem; }
h2 { font-size: 1.05rem; margin: 1.25rem 0 .5rem; }
.card > h2:first-child, form.card > h1 { margin-top: 0; }
main { max-width: 60rem; margin: 0 auto; padding: 1rem; }

.top { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1rem; padding: .6rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line); }
.top .brand { font-weight: 700; color: var(--text); text-decoration: none; }
.top nav { display: flex; flex-wrap: wrap; gap: .25rem; flex: 1; }
.top nav a { padding: .35rem .6rem; border-radius: .4rem; text-decoration: none; color: var(--muted); }
.top nav a:hover { color: var(--text); }
.top nav a[aria-current] { color: var(--text); background: var(--bg); font-weight: 600; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: .6rem; padding: 1rem; margin: 0 0 1rem; }
.narrow { max-width: 24rem; margin: 3rem auto; }
.head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .75rem; }
.head h1 { margin: 0; }
.crumb, .sub { color: var(--muted); font-size: .875rem; }
.crumb { margin: 0 0 .25rem; }
.big { font-size: 1.5rem; font-weight: 700; margin: 0; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.empty { color: var(--muted); padding: 2rem 0; text-align: center; }
.flash { background: var(--panel); border: 1px solid var(--accent); border-radius: .5rem; padding: .6rem .8rem; overflow-wrap: anywhere; }
.error { color: var(--danger); margin: 0 0 .75rem; }
ul.error { padding-left: 1.2rem; }

label { display: block; margin: 0 0 .75rem; font-size: .9rem; color: var(--muted); }
input, select, textarea, button, .button { font: inherit; color: var(--text); }
input, select, textarea { display: block; width: 100%; margin-top: .2rem; padding: .5rem .6rem; background: var(--bg); border: 1px solid var(--line); border-radius: .4rem; }
input[type=checkbox], input[type=radio] { display: inline; width: auto; margin: 0 .4rem 0 0; }
label.check { color: var(--text); font-size: 1rem; }
textarea.code { font: .8rem/1.4 ui-monospace, Menlo, monospace; }
fieldset { border: 1px solid var(--line); border-radius: .4rem; margin: 0 0 .75rem; }
button, .button { display: inline-block; padding: .5rem .9rem; background: var(--panel); border: 1px solid var(--line); border-radius: .4rem; cursor: pointer; text-decoration: none; }
button:hover, .button:hover { border-color: var(--accent); }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.link { padding: 0; border: 0; background: none; color: var(--accent); text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0 1rem; align-items: end; }
.grid button { margin-bottom: .75rem; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.filters > * { width: auto; flex: 1 1 10rem; margin: 0; }
.filters button { flex: 0 0 auto; }
.danger { margin: 1.5rem 0; }
.danger .link { color: var(--danger); }

.list, .timeline { list-style: none; margin: 0; padding: 0; }
.list > li { border: 1px solid var(--line); border-bottom-width: 0; background: var(--panel); }
.list > li:first-child { border-radius: .6rem .6rem 0 0; }
.list > li:last-child { border-bottom-width: 1px; border-radius: 0 0 .6rem .6rem; }
.list > li:only-child { border-radius: .6rem; }
.item { display: grid; grid-template-columns: minmax(10rem, 1.2fr) 2fr auto; gap: .25rem 1rem; align-items: center; padding: .7rem .9rem; color: inherit; text-decoration: none; }
a.item:hover { background: var(--bg); }
.who, .meta { display: flex; flex-direction: column; min-width: 0; }
.who strong { overflow-wrap: anywhere; }
.what { color: var(--muted); min-width: 0; overflow-wrap: anywhere; }
.meta { align-items: flex-end; text-align: right; gap: .15rem; }
audio { display: block; width: 100%; max-width: 22rem; height: 2.25rem; margin-top: .35rem; }
.badge { display: inline-block; padding: .05rem .5rem; border: 1px solid currentColor; border-radius: 1rem; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.s-new, .c-voicemail { color: var(--new); } .s-contacted { color: var(--contacted); } .s-quoted { color: var(--quoted); }
.s-won, .c-answered { color: var(--won); } .s-lost, .c-ringing { color: var(--lost); } .s-spam, .c-missed { color: var(--spam); }
.pager { display: flex; gap: 1rem; margin: 1rem 0; }

.contact { display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: baseline; margin: 0 0 1rem; }
.contact .call { font-size: 1.25rem; font-weight: 700; }
.statuses { display: flex; flex-wrap: wrap; gap: .5rem; }
.statuses .on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.timeline .when { margin: 0 0 .35rem; color: var(--muted); }
.timeline .when strong { color: var(--text); }
.timeline p { margin: .35rem 0; }
details summary { cursor: pointer; color: var(--accent); }

.scroll { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: .6rem; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .5rem .75rem; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
th:first-child { text-align: left; }
thead th { color: var(--muted); font-size: .85rem; font-weight: 600; }
tbody th { font-weight: 500; }
tfoot th, tfoot td { font-weight: 700; border-bottom: 0; }

@media (max-width: 40rem) {
  .top { justify-content: space-between; }
  .top nav { order: 3; flex-basis: 100%; }
  .item { grid-template-columns: 1fr auto; }
  .item .what { grid-column: 1 / -1; grid-row: 2; }
}
