:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1d2330;
  --muted: #6b7280;
  --line: #e2e5ea;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
main { max-width: 1400px; margin: 0 auto; padding: 16px; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.topbar .brand { font-weight: 700; text-decoration: none; color: var(--ink); font-size: 17px; }
.topbar nav { display: flex; gap: 16px; align-items: center; }
.topbar nav a { color: var(--muted); text-decoration: none; }
.topbar nav a.active { color: var(--accent); font-weight: 600; }
form.inline { display: inline; }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; margin-bottom: 16px; }
.card.narrow { max-width: 380px; margin: 60px auto; }
h1 { font-size: 22px; margin: 0 0 8px; }
h2 { font-size: 17px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: var(--bad); }
.saved { color: var(--ok); }
label { display: block; font-weight: 600; margin: 8px 0 4px; }
input, textarea, select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; width: 100%; background: #fff; }
textarea { resize: vertical; }
button, .button { font: inherit; padding: 8px 14px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; text-decoration: none; color: var(--ink); display: inline-block; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.space-between { justify-content: space-between; margin-top: 0; }
.filters { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin: 10px 0 6px; }
.filters label { margin: 0; min-width: 130px; }
.filters input[type=search] { min-width: 220px; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
table.compact td, table.compact th { padding: 6px 8px; }
td.wrap { max-width: 260px; }
td.num { text-align: right; }
.table-wrap { overflow-x: auto; }
.board td.name { min-width: 180px; }
.board td.phone { white-space: nowrap; }
.board td.notes { min-width: 220px; }
.board td.notes textarea { padding: 6px 8px; font-size: 13.5px; }
.board td.status select { min-width: 130px; }
.board tr.agent:focus, .board tr.agent.current { outline: 2px solid var(--accent); outline-offset: -2px; background: #f0f6ff; }
button.copy { font-variant-numeric: tabular-nums; font-weight: 600; border-color: transparent; background: #eef3ff; color: var(--accent); padding: 4px 8px; }
button.copy.small { font-weight: 500; background: #f3f4f6; color: var(--ink); }
button.copy.copied { background: #dcfce7; color: var(--ok); }
.zip { font-weight: 600; }
kbd { font: 12px ui-monospace, Menlo, monospace; background: #f3f4f6; border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: #eef0f3; color: var(--muted); }
.pill-running { background: #e0ecff; color: var(--accent); }
.pill-finished, .pill-done { background: #dcfce7; color: var(--ok); }
.pill-failed { background: #fee2e2; color: var(--bad); }
.bar { height: 8px; background: #eef0f3; border-radius: 999px; margin: 10px 0 14px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); transition: width .4s; }
@media (max-width: 700px) {
  main { padding: 10px; }
  .card { padding: 14px; }
}

/* --- board v2: copied marker, callbacks, stats, pager --- */
.hidden { display: none !important; }
label.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; margin: 8px 12px 4px 0; }
label.check input { width: auto; }
.filters label.check { min-width: 0; padding-bottom: 8px; }
button.small, .button.small { padding: 4px 10px; font-size: 13px; }
button.copy.was-copied { background: #e6f4ea; color: #166534; box-shadow: inset 0 0 0 1px #bbf7d0; }
button.copy.was-copied::after { content: " \2713"; font-size: 11px; }
/* A copied number means the row was (probably) dialed: tint the whole row and add a
   left bar. Status tints (declared last) still win on background; the bar stays. */
tr.agent.copied-before { background: #eaf3ff; box-shadow: inset 4px 0 0 var(--accent); }
tr.agent.copied-before td.name::before { content: "\2713 "; color: var(--accent); font-weight: 700; }
a.dial { display: inline-block; margin-left: 4px; text-decoration: none; color: var(--accent); font-size: 16px; vertical-align: middle; }
a.plain { color: inherit; text-decoration: none; }
a.plain:hover { text-decoration: underline; }
td.stats, td.calls { white-space: nowrap; font-size: 13.5px; }
.callback { color: var(--warn); font-weight: 600; }
.status-form { display: flex; flex-direction: column; gap: 4px; }
.callback-date { padding: 4px 6px; font-size: 13px; }
.card.due { border-color: #fcd34d; background: #fffbeb; }
.due-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.due-list li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pager { justify-content: center; margin-top: 14px; }
.ok { color: var(--ok); }
.result { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px; padding: 10px 14px; margin: 10px 0; }
.profile { display: flex; gap: 20px; align-items: flex-start; }
.profile .photo { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; }
.profile dl { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; margin: 0; }
.profile dt { color: var(--muted); font-size: 13px; }
.profile dd { margin: 0; }
td.actions form { margin-right: 6px; }
@media (max-width: 700px) {
  .profile { flex-direction: column; }
  .filters label { min-width: 45%; }
}

.kv { display: grid; grid-template-columns: 90px 1fr; gap: 6px 12px; margin: 10px 0; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; word-break: break-all; }
code { background: #f3f4f6; padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.settings-form { max-width: 520px; }
td.areas { max-width: 200px; }
.county-group { margin-bottom: 4px; }
.county-group .county { display: block; font-weight: 600; font-size: 13.5px; }
.county-group .zips { display: block; font-size: 11.5px; color: var(--muted); letter-spacing: .01em; line-height: 1.3; }

/* status tints, after the copied tint on purpose */
tr.status-picked_up { background: #f0fdf4; }
tr.status-do_not_call { background: #fef2f2; color: var(--muted); }
tr.status-callback { background: #fffbeb; }
.board tr.agent.current { background: #e0ecff; }

/* live "on a call" state: strongest highlight on the board */
.calling-banner { position: sticky; top: 0; z-index: 5; background: #fff7ed; border: 1px solid #fdba74; border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.calling-item { display: inline-flex; align-items: center; gap: 8px; }
.calling-item .dot { width: 10px; height: 10px; border-radius: 50%; background: #ea580c; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.8); } }
.board tr.agent.calling { background: #ffedd5 !important; box-shadow: inset 5px 0 0 #ea580c; }
.board tr.agent.calling td.name strong::after { content: " · on a call"; color: #c2410c; font-weight: 600; font-size: 12.5px; }
details.advanced { margin: 10px 0; }
details.advanced summary { cursor: pointer; }
