:root {
  /* neutrals */
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #14213d;
  --ink-2: #3a4560;
  --muted: #5d6883;          /* 4.5:1+ on white, --bg and --brand-soft */
  --line: #e2e7f0;           /* dividers */
  --line-btn: #cfd6e2;       /* button outlines (the label carries the meaning) */
  --line-strong: #808a9e;    /* input borders, 3.3:1 on white */
  --tint: #eef1f6;
  /* brand: the main action that isn't calling */
  --brand: #1463ff;
  --brand-ink: #0b4fd6;
  --brand-soft: #e8efff;
  /* semantic: green = call / success, red = end / danger / do-not-call, amber = waiting / callback / warning */
  --green: #12a150;
  --green-dark: #0d7f3f;
  --green-ink: #0b6b35;
  --green-soft: #e3f6ea;
  --red: #d93b3b;
  --red-dark: #b82e2e;
  --red-ink: #b42323;
  --red-soft: #fde8e8;
  --amber: #c98200;
  --amber-ink: #835500;
  --amber-soft: #fff3d6;
  /* shape and spacing (4px scale) */
  --radius: 12px;
  --r-sm: 8px;
  --pad: 16px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
h1, h2, h3 { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.topbar :focus-visible { outline-color: #fff; }

/* ---------- Top bar: one row, never wraps ---------- */
.topbar {
  flex: none; height: 56px; display: flex; align-items: center; gap: var(--s3);
  padding: 0 var(--pad); background: var(--ink); color: #fff; white-space: nowrap; position: relative; z-index: 20;
}
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 10px; }
.logo {
  background: var(--brand); color: #fff; border-radius: var(--r-sm); width: 30px; height: 30px;
  display: grid; place-items: center; font-size: 13px; flex: none;
}
.stats { display: flex; align-items: center; gap: var(--s4); margin-left: var(--s3); }
.goal { display: flex; flex-direction: column; gap: 4px; min-width: 120px; }
.goal-text { font-size: 13px; color: rgba(255,255,255,.85); }
.goal-text b, .stat b { font-size: 15px; color: #fff; font-variant-numeric: tabular-nums; }
.goal-bar { display: block; height: 4px; border-radius: 2px; background: rgba(255,255,255,.18); overflow: hidden; }
.goal-bar span { display: block; height: 100%; background: #7aa7ff; border-radius: 2px; }
.stat { font-size: 13px; color: rgba(255,255,255,.85); }
.call-chip { font-size: 13px; font-weight: 600; border-radius: 999px; padding: 5px 12px; display: inline-flex; align-items: center; gap: 6px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.call-chip.live { background: var(--green); color: #fff; }
.call-chip.live b { font-variant-numeric: tabular-nums; }
.call-chip.wrap { background: var(--amber-soft); color: var(--amber-ink); }
.chip.practice { background: #f0b429; color: var(--ink); font-size: 12px; font-weight: 600; border-radius: 999px; padding: 4px 10px; }
.rc-status {
  font-size: 12px; color: #fff; background: transparent; border: 1px solid rgba(255,255,255,.3); border-radius: 999px;
  padding: 5px 10px; cursor: pointer; display: inline-flex; align-items: center;
}
.rc-status:hover { background: rgba(255,255,255,.08); }
.rc-status.on::before, .rc-status.off::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; flex: none;
}
.rc-status.on::before { background: #3ddc84; }
.rc-status.off::before { background: #f0b429; }
.topbar .btn.ghost { color: #fff; border-color: rgba(255,255,255,.3); }
.topbar .btn.ghost:hover { background: rgba(255,255,255,.08); filter: none; }

/* More menu */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(20,33,61,.18); padding: 6px;
  display: flex; flex-direction: column; z-index: 60;
}
.menu-list button {
  border: 0; background: none; text-align: left; padding: 8px 12px; border-radius: 6px; cursor: pointer; font-size: 14px;
  display: flex; justify-content: space-between; align-items: center; min-height: 36px;
}
.menu-list button:hover { background: var(--bg); }
.menu-list hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }
.menu-who { font-size: 12px; color: var(--muted); padding: 6px 12px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--line-btn); background: var(--panel); color: var(--ink); border-radius: var(--r-sm);
  min-height: 36px; padding: 6px 14px; cursor: pointer; font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { filter: brightness(.96); }
a.btn { text-decoration: none; color: var(--ink); }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.btn.ghost { background: transparent; }
.btn.primary, a.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.danger { color: var(--red-ink); border-color: #efb3b3; background: transparent; }
.btn.link { border: 0; background: none; color: var(--brand-ink); padding: 4px; min-height: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
kbd {
  font: 600 11px/1 inherit; border: 1px solid currentColor; border-radius: 4px;
  padding: 2px 4px; opacity: .75; font-family: inherit;
}

/* ---------- Layout ---------- */
.layout {
  flex: 1; min-height: 0; display: grid; grid-template-columns: 300px minmax(0, 1fr) 360px; grid-template-rows: minmax(0, 1fr);
  gap: var(--pad); padding: var(--pad);
}
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; min-height: 0;
}
.panel-head { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 16px; }
.panel-head select { margin-left: auto; border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 4px 6px; font-size: 13px; max-width: 170px; }

/* ---------- RingCentral phone: docked under the queue ---------- */
/* the adapter adds an inline transform: translate(-15px, -15px), so the offsets make up for it */
body.has-rc #rc-widget { left: calc(var(--pad) + 15px) !important; right: auto !important; bottom: calc(var(--pad) - 15px) !important; top: auto !important; }
body.has-rc .queue { margin-bottom: calc(var(--rc-h, 0px) + var(--s3)); }
#rc-widget.rc-attn { animation: rcAttn .7s ease-out 2; }
@keyframes rcAttn { 40% { box-shadow: 0 0 0 6px rgba(20,99,255,.55); } }

/* ---------- Queue ---------- */
.queue-tools { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s3); border-bottom: 1px solid var(--line); }
.queue-tools input { border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 7px 10px; width: 100%; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tabs button {
  border: 1px solid var(--line-btn); background: var(--panel); border-radius: 999px; padding: 2px 8px; font-size: 12px;
  font-weight: 600; color: var(--ink-2); cursor: pointer; min-height: 28px;
}
.tabs button.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); }
.tabs .n { font-variant-numeric: tabular-nums; font-weight: 700; }
.queue-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; min-height: 0; }
.q-row {
  width: 100%; border: 0; background: none; text-align: left; cursor: pointer; padding: 8px 10px; border-radius: var(--r-sm);
  display: flex; justify-content: space-between; align-items: center; gap: var(--s2);
}
.q-row:hover { background: var(--bg); }
.q-row.active { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
.q-main { display: flex; flex-direction: column; min-width: 0; }
.q-name { font-weight: 600; font-size: 14px; }
.q-company { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-side { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex: none; }
.q-when { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.q-when.wait { color: var(--amber-ink); font-weight: 600; }
.queue-empty { padding: 20px; text-align: center; color: var(--muted); font-size: 14px; }

/* Status tags: red only for do-not-call */
.tag { font-size: 12px; border-radius: 999px; padding: 2px 8px; white-space: nowrap; background: var(--tint); color: var(--ink-2); font-weight: 600; }
.tag.meeting { background: var(--green-soft); color: var(--green-ink); }
.tag.callback { background: var(--amber-soft); color: var(--amber-ink); }
.tag.dnc { background: var(--red-soft); color: var(--red-ink); }
.tag.maxed { background: var(--ink-2); color: #fff; }
.tag.test { background: var(--amber-soft); color: var(--amber-ink); font-size: 11px; }
.fit { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 1px 8px; background: var(--tint); color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------- Center column ---------- */
.dialer { overflow-y: auto; display: flex; flex-direction: column; gap: var(--s3); min-height: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }

/* Emails to send */
.emails { background: var(--brand-soft); border: 1px solid #c9d8ff; border-radius: var(--radius); padding: var(--s2) var(--s3); flex: none; }
.emails-head { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; font-size: 14px; }
.emails-title { font-weight: 700; }
.emails-title .n, .tabs .n { margin-left: 2px; }
.emails-title .n { background: var(--brand); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; }
.emails-next { flex: 1; min-width: 160px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.emails-list { list-style: none; margin: var(--s2) 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.emails-list li { display: flex; align-items: center; gap: var(--s2); background: var(--panel); border-radius: var(--r-sm); padding: 6px 6px 6px 10px; font-size: 13px; }
.emails-who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Contact focus card */
.focus-card { overflow: hidden; flex: none; }
.state-band {
  min-height: 40px; display: flex; align-items: center; gap: var(--s2); padding: 6px 20px; font-size: 14px;
  background: var(--tint); color: var(--ink-2); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.state-band b { color: inherit; }
.band-note { font-size: 13px; opacity: .9; }
.state-band .timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 16px; }
.s-ready .state-band b { color: var(--ink); }
.s-oncall { border-color: var(--green); box-shadow: 0 0 0 1px var(--green); }
.s-oncall .state-band { background: var(--green-soft); color: var(--green-ink); border-bottom-color: #b9e3c9; }
.s-wrap { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
.s-wrap .state-band, .s-warn .state-band, .s-test .state-band { background: var(--amber-soft); color: var(--amber-ink); border-bottom-color: #f0d9a6; }
.s-blocked .state-band { background: var(--red-soft); color: var(--red-ink); border-bottom-color: #f3c0c0; }
.ext-chip { background: var(--amber-soft); color: var(--amber-ink); border-radius: 6px; padding: 2px 8px; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ext-chip.big { background: var(--panel); color: var(--ink); border: 1px solid var(--green); font-size: 14px; }

.focus-body { padding: 20px 24px; }
.who { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s3); }
.who-main { min-width: 0; }
.contact-name { font-size: 28px; font-weight: 700; line-height: 1.2; }
.contact-role { font-size: 16px; color: var(--ink-2); margin-top: 2px; }
.contact-role b { color: var(--ink); font-weight: 600; }
.fit-chip { flex: none; font-size: 12px; color: var(--ink-2); background: var(--tint); border-radius: 999px; padding: 4px 10px; cursor: help; }
.fit-chip b { font-size: 14px; font-variant-numeric: tabular-nums; }
.local-time { margin-top: var(--s2); font-size: 14px; color: var(--ink-2); }
.local-time b { font-size: 16px; color: var(--ink); font-variant-numeric: tabular-nums; }
.local-time.warn, .local-time.warn b { color: var(--amber-ink); }
.local-time.blocked, .local-time.blocked b { color: var(--red-ink); }
.local-time.unknown { color: var(--muted); }
.contact-meta { display: flex; flex-wrap: wrap; gap: 2px 0; margin-top: 4px; font-size: 13px; color: var(--muted); }
.contact-meta span:not(:first-child)::before { content: "·"; margin: 0 8px; }
.last-line { margin-top: var(--s2); font-size: 13px; color: var(--ink-2); }
.reasons { font-size: 12px; color: var(--muted); margin-top: 4px; }
.phone-row { margin-top: var(--s3); display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.phone { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: .3px; }
.phone-label { font-size: 12px; color: var(--muted); }
.alt-phones { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; font-size: 13px; }
.meeting-info { margin-top: var(--s2); font-size: 13px; color: var(--green-ink); font-weight: 600; }

.call-row { margin-top: var(--s4); display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.call-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-width: 280px; height: 52px; padding: 0 24px;
  border-radius: 999px; border: 0; background: var(--green); color: #fff; font-size: 18px; font-weight: 700; cursor: pointer;
}
.call-btn:hover { background: var(--green-dark); }
.call-btn svg { width: 20px; height: 20px; flex: none; }
.call-btn kbd { border-color: rgba(255,255,255,.8); opacity: .9; }
.call-btn.end { background: var(--red); }
.call-btn.end:hover { background: var(--red-dark); }
.call-btn.signin { background: var(--brand); font-size: 16px; }
.call-btn.signin:hover { background: var(--brand-ink); }
.call-btn:disabled { background: var(--tint); color: var(--muted); cursor: not-allowed; font-size: 15px; }
.call-btn.wait:disabled { background: var(--amber-soft); color: var(--amber-ink); }
.secondary-actions { display: flex; gap: var(--s2); flex-wrap: wrap; }

/* Notes and results */
.wrap-card { padding: var(--s4) 20px; flex: none; }
.wrap-card.attn { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
.notes-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s2); }
.section-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); }
.hint kbd { margin: 0 2px; }
textarea.notes {
  display: block; width: 100%; margin-top: 6px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  padding: 8px 10px; resize: vertical; line-height: 1.5; font-size: 14px;
}
.result-label { margin-top: var(--s4); }
.outcome-groups { display: grid; gap: var(--s2); margin-top: var(--s2); }
.og { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: var(--s3); align-items: center; }
.og-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.og-btns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); }
.outcome {
  display: flex; align-items: center; gap: var(--s2); min-height: 44px; padding: 6px 12px; text-align: left; cursor: pointer;
  border-radius: var(--r-sm); border: 1px solid #d5dbe6; background: var(--bg); color: var(--ink); font-weight: 600; font-size: 14px;
}
.outcome:hover { filter: brightness(.97); }
.outcome kbd { opacity: 1; background: var(--panel); color: var(--ink); border-color: #c3cad8; min-width: 20px; text-align: center; padding: 3px 5px; }
.outcome.o-callback { background: var(--amber-soft); border-color: #efd49a; color: var(--amber-ink); }
.outcome.o-meeting { background: var(--green-soft); border-color: #b5e0c5; color: var(--green-ink); }
.outcome.o-dnc { background: var(--red-soft); border-color: #f3c0c0; color: var(--red-ink); }
.outcome.o-dnc.armed { background: var(--red); border-color: var(--red); color: #fff; }
.outcome.selected { outline: 2px solid var(--brand); outline-offset: 1px; }
.btn.outcome { min-height: 36px; }
.expand-row {
  margin-top: var(--s3); padding: var(--s3); background: var(--bg); border-radius: var(--r-sm);
  display: flex; flex-wrap: wrap; gap: var(--s3); align-items: flex-end;
}
.expand-row p { margin: 0; flex-basis: 100%; font-size: 14px; }
.expand-row .field { min-width: 200px; }
.expand-row .field.grow { flex: 1; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.eq { flex-basis: 100%; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; min-height: 1em; }
.history { margin-top: var(--s4); font-size: 13px; }
.history summary { cursor: pointer; font-weight: 600; color: var(--muted); padding: 4px 0; }
.history ul { list-style: none; padding: 0; margin: 4px 0 0; color: var(--ink-2); }
.history li { padding: 6px 0; border-top: 1px dashed var(--line); }

.empty-state { text-align: center; padding: 48px 24px; }
.empty-state h1 { font-size: 20px; margin-bottom: var(--s2); }
.empty-state p { max-width: 520px; margin: 8px auto; }
.next-open { font-size: 16px; }
.empty-actions { display: flex; gap: var(--s2); justify-content: center; flex-wrap: wrap; margin-top: var(--s4); }

/* AI notes */
.ai-row { display: flex; gap: 10px; align-items: center; margin-top: var(--s2); font-size: 12px; flex-wrap: wrap; }
.ai-result { margin-top: 10px; background: var(--brand-soft); border-radius: 10px; padding: 12px 14px; font-size: 14px; }
.ai-result p { margin: 4px 0; }
.ai-result ul { margin: 2px 0 6px; padding-left: 20px; }
.ai-result .modal-actions { margin: 8px 0 4px; }

/* ---------- Company brief ---------- */
.brief { margin: var(--s2) var(--s4) 0; border-radius: var(--r-sm); font-size: 13px; line-height: 1.45; }
.brief.note { background: var(--tint); color: var(--ink-2); padding: 8px 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.brief.note.warn { background: var(--amber-soft); color: var(--amber-ink); }
details.brief { border: 1px solid var(--line); background: var(--panel); }
details.brief > summary { cursor: pointer; padding: 8px 12px; font-weight: 700; font-size: 14px; }
.brief-body { padding: 0 12px 10px; max-height: 38vh; overflow-y: auto; }
.brief-body p { margin: 4px 0; }
.brief-body h4 { margin: 10px 0 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.brief-body ul { margin: 2px 0; padding-left: 18px; }
.brief-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px 12px; margin: 8px 0 0; }
.brief-facts dt { font-size: 11px; color: var(--muted); }
.brief-facts dd { margin: 0; font-weight: 600; color: var(--ink); }
.brief-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.brief-tags span { background: var(--brand-soft); color: var(--brand-ink); border-radius: 999px; padding: 1px 8px; font-size: 12px; }
.brief-foot { margin-top: 8px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.brief-foot a { color: var(--brand-ink); }
.spinner { width: 12px; height: 12px; border: 2px solid var(--line-strong); border-top-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* ---------- Call script ---------- */
.script-jump { display: flex; flex-wrap: wrap; gap: 6px; padding: var(--s2) var(--s4); border-bottom: 1px solid var(--line); }
.chip-btn {
  border: 1px solid var(--line-btn); background: var(--panel); color: var(--ink-2); border-radius: 999px;
  padding: 3px 10px; font-size: 12px; font-weight: 600; cursor: pointer; min-height: 28px;
}
.chip-btn:hover { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); }
.chip-screener { border-color: var(--brand); color: var(--brand-ink); }
.chip-screener kbd { font-size: 10px; margin-left: 2px; }
.script-body { padding: var(--s3) var(--s4) var(--s5); overflow-y: auto; font-size: 15px; line-height: 1.55; flex: 1; min-height: 0; }
.s-pinned { background: #f6f8ff; border-left: 3px solid var(--brand); border-radius: var(--r-sm); padding: 10px 12px; font-size: 16px; margin-bottom: var(--s2); }
.s-pinned h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.s-pinned p { margin: 4px 0; }
.s-sec { border-bottom: 1px solid var(--line); }
.s-sec > summary { font-weight: 700; cursor: pointer; padding: 10px 0; list-style: none; display: flex; align-items: center; gap: 8px; }
.s-sec > summary::-webkit-details-marker { display: none; }
.s-sec > summary::before { content: "▸"; color: var(--muted); font-size: 12px; transition: transform .15s; }
.s-sec[open] > summary::before { transform: rotate(90deg); }
.s-body { padding-bottom: 10px; }
.script-body p { margin: 6px 0; }
.script-body ul { margin: 6px 0; padding-left: 20px; }
.obj { border: 1px solid var(--line); border-radius: var(--r-sm); margin: 6px 0; }
.obj > summary { cursor: pointer; padding: 8px 10px; font-size: 14px; font-weight: 600; }
.obj-body { padding: 0 10px 8px; font-size: 14px; }
.script-body .fill { background: #fff3c4; border-radius: 4px; padding: 0 3px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(8px); max-width: min(640px, calc(100vw - 24px));
  background: var(--ink); color: #fff; padding: 8px 8px 8px 16px; border-radius: 10px; display: flex; align-items: center; gap: var(--s3);
  opacity: 0; transition: opacity .15s, transform .15s; pointer-events: none; z-index: 70; font-size: 14px;
  box-shadow: 0 8px 24px rgba(20,33,61,.25); min-height: 40px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast-undo { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.45); border-radius: 6px; padding: 4px 10px; font-weight: 600; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }

/* ---------- Dialogs ---------- */
dialog { border: 0; border-radius: var(--radius); padding: 0; max-width: 92vw; box-shadow: 0 20px 60px rgba(0,0,0,.25); color: var(--ink); }
dialog::backdrop { background: rgba(20,33,61,.45); }
.modal { padding: var(--s5); width: 560px; max-width: 100%; display: flex; flex-direction: column; gap: var(--s3); }
.modal.wide { width: 760px; }
.modal:has(> .modal-scroll) { max-height: calc(100vh - 48px); }
.modal-scroll { overflow-y: auto; min-height: 0; flex: 1; display: flex; flex-direction: column; gap: var(--s3); margin: 0 calc(-1 * var(--s5)); padding: 0 var(--s5) 4px; }
.modal h2 { font-size: 20px; }
.modal h3 { font-size: 15px; }
.modal-head { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; justify-content: space-between; }
.modal hr { border: 0; border-top: 1px solid var(--line); width: 100%; margin: 4px 0; }
.modal p { margin: 0; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.field input, .field select, .field textarea, .grid2 > input, .team-add input, .team-add select, .hours-row select {
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 8px 10px; font-weight: 400; font-size: 14px; background: var(--panel);
}
.field textarea { line-height: 1.5; resize: vertical; }
textarea.code, .field textarea.code { font-family: Consolas, monospace; font-size: 13px; }
.field-hint { font-size: 12px; font-weight: 400; color: var(--muted); }
.field-hint.warn { color: var(--amber-ink); font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.grid3 { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: var(--s3); align-items: end; }
.modal-actions { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.modal-actions.sticky { border-top: 1px solid var(--line); padding-top: var(--s3); }
.seg, .range { display: inline-flex; border: 1px solid var(--line-btn); border-radius: 10px; overflow: hidden; }
.seg button, .range button { border: 0; background: var(--panel); padding: 7px 12px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); }
.seg button.on, .range button.on { background: var(--brand-soft); color: var(--brand-ink); }
.seg button:focus-visible, .range button:focus-visible { outline-offset: -2px; }
.settings section { display: flex; flex-direction: column; gap: var(--s3); }
.settings section h3 { margin-top: var(--s3); }
.settings section h3:first-child { margin-top: 0; }
.hours-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.hours-row select { margin-left: 4px; padding: 6px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.danger-zone { margin-top: var(--s4); border: 1px solid #f3c0c0; background: #fff8f8; border-radius: 10px; padding: var(--s3) var(--s4); display: flex; flex-direction: column; gap: var(--s2); align-items: flex-start; }
.danger-zone h3 { color: var(--red-ink); margin: 0 !important; }
.discard-bar { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; background: var(--amber-soft); color: var(--amber-ink); border-radius: var(--r-sm); padding: 8px 12px; font-size: 14px; font-weight: 600; }
.discard-bar span { flex: 1; }
.pw-change summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--brand-ink); }
.pw-change .grid2 { margin: var(--s2) 0; }
.keys { border-collapse: collapse; font-size: 14px; }
.keys td { padding: 6px 8px; vertical-align: top; }
.keys td:nth-child(odd) { white-space: nowrap; }

/* Lead engine */
#engineBody h3 { font-size: 15px; margin: 18px 0 6px; }
#engineBody p { margin: 4px 0 8px; font-size: 13px; }
.test-banner { background: var(--amber-soft); color: var(--amber-ink); border: 1px solid #f0d9a6; border-radius: 10px; padding: 10px 14px; font-size: 14px; }
.engine-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.engine-stats div { background: var(--bg); border-radius: 10px; padding: 10px; }
.engine-stats b { display: block; font-size: 18px; }
.engine-stats span { font-size: 12px; color: var(--muted); }
.engine-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.engine-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.engine-table td { padding: 6px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.engine-table td:nth-child(2) { white-space: normal; }
.bar { display: inline-block; width: 60px; height: 6px; background: var(--bg); border-radius: 3px; margin-right: 6px; vertical-align: middle; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--brand); }
.signals { display: flex; flex-wrap: wrap; gap: 6px; }
.signal { background: var(--brand-soft); border-radius: 999px; padding: 4px 10px; font-size: 12px; }
.signal small { color: var(--muted); }
.runs { list-style: none; padding: 0; margin: 0; font-size: 13px; color: var(--muted); }
.runs li { padding: 4px 0; border-bottom: 1px dashed var(--line); }

/* Follow-ups */
.follow-calendar { display: flex; flex-direction: column; gap: var(--s2); }
.follow-calendar h3 { font-size: 14px; margin: 6px 0 0; }

/* Reports */
.modal.reports { width: 1000px; }
.reports-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 14px 0 6px; }
.tile { background: var(--bg); border-radius: 10px; padding: 12px; }
.tile b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.tile span { font-size: 12px; color: var(--muted); }
.charts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 8px; }
.chart h3, .report-table h3 { font-size: 14px; margin: 10px 0 2px; }
.chart p { font-size: 12px; color: var(--muted); margin: 0 0 6px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font-size: 10px; }
.chart .bar { fill: var(--brand); }
.chart .bar.meet { fill: var(--green); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart g.col:hover .bar { opacity: .75; }
.chart details { font-size: 12px; margin-top: 4px; }
.chart details table { width: 100%; border-collapse: collapse; margin-top: 4px; }
.chart details td, .chart details th { padding: 2px 4px; text-align: left; border-bottom: 1px solid var(--line); }
.report-tables { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.report-table table { width: 100%; border-collapse: collapse; font-size: 13px; }
.report-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.report-table td { padding: 6px 4px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.report-table .num { text-align: right; }
.inline-bar { display: inline-block; height: 6px; border-radius: 3px; background: var(--green); vertical-align: middle; margin-right: 6px; }
.chart-tip { position: fixed; z-index: 100; background: var(--ink); color: #fff; font-size: 12px; padding: 6px 10px; border-radius: 8px; pointer-events: none; white-space: nowrap; }

/* Sign-in and team */
body:not(.is-admin) .admin-only { display: none !important; }
body.signed-out > header, body.signed-out > main { display: none; }
.auth-screen { flex: 1; min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--ink); overflow: auto; }
.auth-card { background: var(--panel); border-radius: var(--radius); padding: 28px; width: 380px; max-width: 100%; display: flex; flex-direction: column; gap: var(--s3); }
.auth-card .brand { color: var(--ink); }
.auth-card h1 { font-size: 22px; }
.auth-card p { margin: 0; }
.auth-card .btn { min-height: 44px; }
.auth-card input { border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 10px; font-size: 14px; font-weight: 400; }
.auth-error { color: var(--red-ink); font-size: 13px; margin: 0; min-height: 1em; }
.team-add { display: grid; grid-template-columns: 1fr 1.4fr auto auto; gap: var(--s2); align-items: end; }
.team-add input, .team-add select { min-width: 0; }
.team-table td { padding: 8px 6px; }
.temp-pw { background: var(--green-soft); border-radius: 10px; padding: 10px 14px; font-size: 14px; }
.temp-pw code { font-size: 16px; font-weight: 700; user-select: all; }
.team-actions { display: flex; gap: 4px; justify-content: flex-end; }

@media (prefers-reduced-motion: reduce) {
  .live-dot, #rc-widget.rc-attn { animation: none; }
  .toast, .s-sec > summary::before { transition: none; }
}

/* ---------- Laptops ---------- */
@media (max-width: 1360px) {
  :root { --pad: 12px; }
  .layout { grid-template-columns: 300px minmax(0, 1fr) 320px; }
  .brand-name { display: none; }
  .focus-body { padding: 16px 20px; }
}
@media (max-width: 1180px) {
  .stats .stat { display: none; }
}

/* ---------- Tablets: script moves under the card, the phone panel sits at the end of the page ---------- */
@media (max-width: 1100px) {
  body { height: auto; overflow: visible; min-height: 100vh; }
  .layout { grid-template-columns: 300px minmax(0, 1fr); grid-template-rows: auto; }
  .queue { max-height: 80vh; }
  .script { grid-column: 1 / -1; }
  .script-body { max-height: none; }
  body.has-rc .queue { margin-bottom: 0; }
  body.has-rc #rc-widget { position: static !important; margin: 0 auto var(--pad) !important; }
  .reports .tiles { grid-template-columns: repeat(3, 1fr); }
  .charts, .report-tables { grid-template-columns: 1fr; }
}

/* ---------- Phones ---------- */
@media (max-width: 720px) {
  :root { --pad: 8px; }
  .topbar { gap: var(--s2); padding: 0 var(--s2); }
  .stats { margin-left: 0; }
  .goal { min-width: 84px; }
  .chip.practice { display: none; }
  .rc-status { font-size: 0; padding: 8px; }
  .rc-status::before { margin-right: 0 !important; }
  .call-chip { font-size: 12px; padding: 4px 8px; }
  .call-chip .chip-text { display: none; }
  .notes-head .hint { display: none; }
  .topbar .btn { padding: 6px 10px; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .dialer { order: 1; overflow: visible; }
  .script { order: 2; }
  .queue { order: 3; max-height: 420px; }
  .focus-body { padding: 14px 16px; }
  .state-band { padding: 6px 16px; }
  .contact-name { font-size: 24px; }
  .call-btn { width: 100%; min-width: 0; }
  .og { grid-template-columns: 1fr; gap: 4px; }
  .og-btns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2, .grid3, .team-add { grid-template-columns: 1fr; }
  .engine-stats { grid-template-columns: 1fr; }
  .engine-table { display: block; overflow-x: auto; }
  .modal { padding: var(--s4); }
  .modal-scroll { margin: 0 calc(-1 * var(--s4)); padding: 0 var(--s4) 4px; }
  .reports .tiles { grid-template-columns: repeat(2, 1fr); }
}
