:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --panel: #131a23;
  --panel-2: #182230;
  --line: #24303f;
  --text: #e6edf5;
  --muted: #8ba0b8;
  --accent: #4da3ff;
  --accent-ink: #05121f;
  --good: #3ddc97;
  --warn: #ffc857;
  --bad: #ff6b6b;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--accent); }

header.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.brand { font-weight: 650; letter-spacing: -0.01em; }
.brand span { color: var(--muted); font-weight: 400; }
nav { display: flex; gap: 6px; }
nav button {
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 6px 12px; border-radius: 8px; cursor: pointer; font: inherit;
}
nav button.active, nav button:hover { color: var(--text); border-color: var(--line); background: var(--panel-2); }

main { max-width: 1080px; margin: 0 auto; padding: 24px; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.02em; }
h2 { font-size: 17px; margin: 0 0 12px; letter-spacing: -0.01em; }
h3 { font-size: 14px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
p.lede { color: var(--muted); margin: 0 0 20px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px;
  background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
textarea { min-height: 96px; resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

button.primary, button.danger, button.ghost, a.button {
  font: inherit; font-weight: 550; padding: 9px 16px; border-radius: 8px; cursor: pointer; border: 1px solid transparent;
}
button.primary, a.button.primary { background: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.08); }
button.danger { background: var(--bad); color: #2a0808; }
button.ghost { background: transparent; color: var(--text); border-color: var(--line); }
button.ghost:hover { background: var(--panel-2); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.stat strong { display: block; font-size: 24px; letter-spacing: -0.02em; }
.stat span { font-size: 12px; color: var(--muted); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; border: 1px solid var(--line); color: var(--muted); }
.pill.good { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.pill.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }

.list { display: flex; flex-direction: column; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.list-item { background: var(--panel); padding: 11px 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.list-item:hover { background: var(--panel-2); }
.list-item strong { display: block; font-weight: 600; }
.list-item span { color: var(--muted); font-size: 13px; }
.list-item.clickable { cursor: pointer; }
.empty { background: var(--panel); padding: 16px; color: var(--muted); text-align: center; font-size: 14px; }

.notice { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; border: 1px solid; }
.notice.success { background: color-mix(in srgb, var(--good) 10%, transparent); border-color: color-mix(in srgb, var(--good) 35%, transparent); color: var(--good); }
.notice.error { background: color-mix(in srgb, var(--bad) 10%, transparent); border-color: color-mix(in srgb, var(--bad) 35%, transparent); color: var(--bad); }
.notice:empty { display: none; }

.callout { border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); background: color-mix(in srgb, var(--warn) 8%, transparent); border-radius: 8px; padding: 12px 14px; margin-bottom: 14px; font-size: 13.5px; color: var(--text); }
.callout strong { color: var(--warn); }
.check { display: flex; align-items: flex-start; gap: 9px; font-size: 13.5px; color: var(--text); margin-bottom: 12px; }
.check input { width: auto; margin: 3px 0 0; flex: none; }

pre.prompt { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 14px; overflow: auto; max-height: 320px; font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; color: var(--muted); }
.transcript { font-size: 12.5px; color: var(--muted); white-space: pre-wrap; max-height: 200px; overflow: auto; margin-top: 8px; padding: 10px; background: var(--bg); border-radius: 6px; border: 1px solid var(--line); }

.login { max-width: 340px; margin: 14vh auto; }
.muted { color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }
.back { background: none; border: none; color: var(--muted); cursor: pointer; font: inherit; padding: 0 0 10px; }
.back:hover { color: var(--text); }

audio.recording {
  display: block;
  width: 100%;
  max-width: 420px;
  height: 32px;
  margin-top: 10px;
  border-radius: 6px;
}
/* Must grow, not just shrink. Without flex:1 this column sized to whatever was
   left beside the badge, and the detail values inside it collapsed to a few
   pixels wide — every field rendered as a vertical ribbon of single characters.
   min-width:0 is what still allows it to shrink below its content. */
.list-item .main { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 0; }

.stat.linked { cursor: pointer; transition: border-color 120ms, background 120ms; }
.stat.linked:hover { border-color: var(--accent); background: var(--panel); }
button.ghost.small { padding: 4px 10px; font-size: 12.5px; font-weight: 500; margin-top: 8px; align-self: flex-start; }
.detail-panel {
  margin-top: 10px; padding: 12px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px;
  display: flex; flex-direction: column; gap: 7px;
}
/* Flex rather than a fixed grid, so the value drops onto its own full-width
   line when the panel is too narrow to hold a label column beside it. */
.detail-row { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; align-items: baseline; }
.detail-label { flex: 0 0 116px; }
.detail-value { flex: 1 1 220px; min-width: 0; }
.detail-label { color: var(--muted); flex: 0 0 116px; }
.detail-value { color: var(--text); overflow-wrap: anywhere; flex: 1 1 220px; min-width: 0; }

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.recycle { margin-top: 14px; }
.recycle > summary {
  cursor: pointer; color: var(--muted); font-size: 13px; padding: 8px 0;
  list-style: none; display: flex; align-items: center; gap: 8px;
}
.recycle > summary::-webkit-details-marker { display: none; }
.recycle > summary:hover { color: var(--text); }
.recycle .list { margin-top: 8px; }
.recycle .list-item { opacity: 0.72; }
button.danger.small { padding: 4px 10px; font-size: 12.5px; font-weight: 500; }

.hours-grid { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.hours-row { display: grid; grid-template-columns: 108px 1fr 12px 1fr; gap: 10px; align-items: center; }
.hours-row label.day { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--text); font-size: 13.5px; }
.hours-row label.day input { width: auto; margin: 0; flex: none; }
.hours-row input[type=time] { margin: 0; padding: 6px 9px; }
.hours-row .dash { color: var(--muted); text-align: center; }
.hours-row.closed input[type=time] { opacity: 0.35; }
#editCard h3 { margin-bottom: 6px; }

/* A call the agent could not finish. Loud on purpose: this is the one the
   owner has to listen to and ring back themselves. */
.list-item.review { border-left: 3px solid var(--bad); background: color-mix(in srgb, var(--bad) 7%, var(--panel)); }
.list-item.review:hover { background: color-mix(in srgb, var(--bad) 11%, var(--panel)); }
.review-reason { color: var(--bad); font-size: 13px; }

/* The page a client opens on their phone. Deliberately plain: no navigation,
   no console chrome, one decision to make. */
main.connect { max-width: 460px; margin: 12vh auto; padding: 0 24px; text-align: center; }
main.connect h1 { font-size: 24px; margin-bottom: 10px; }
main.connect .lede { margin-bottom: 26px; }
.providers { display: flex; flex-direction: column; gap: 10px; margin-bottom: 26px; }
a.provider {
  display: block; padding: 14px 18px; border-radius: 10px; text-decoration: none;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 16px;
}
a.provider:hover { filter: brightness(1.08); }
.muted.small { font-size: 12.5px; line-height: 1.6; }

/* Public pages: home, privacy, terms. Readable prose width, no console chrome. */
main.page { max-width: 680px; margin: 0 auto; padding: 40px 24px 64px; }
main.page h1 { font-size: 26px; margin-bottom: 8px; }
main.page h2 { font-size: 17px; margin: 28px 0 8px; }
main.page p, main.page li { color: var(--text); line-height: 1.65; }
main.page ul { padding-left: 20px; margin: 8px 0; }
main.page li { margin-bottom: 6px; }
main.page .muted a { color: var(--accent); }

/* --- AI call handling ---------------------------------------------------
   The badge has to be readable at a glance from across a room: an owner
   checking whether the assistant is still covering the desk should not have to
   read a sentence. */
.ai-handling { margin-top: 16px; }
.ai-handling-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ai-handling-head h2 { margin: 0 0 4px; }
.ai-handling-head p { margin: 0; max-width: 52ch; font-size: 14px; }

.mode-badge {
  flex: none; align-self: center;
  font-weight: 600; font-size: 14px; line-height: 1;
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line, #2a3442); color: var(--muted, #8296ad);
}
.mode-badge.is-override { border-color: #3ddc97; color: #3ddc97; }
.mode-badge.is-hours { border-color: #4da3ff; color: #4da3ff; }

.mode-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin: 18px 0; }
.mode-choice {
  text-align: left; padding: 12px 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line, #2a3442); background: transparent; color: inherit;
  display: flex; flex-direction: column; gap: 4px; font: inherit;
}
.mode-choice:hover { border-color: #4da3ff; }
.mode-choice.selected { border-color: #4da3ff; box-shadow: inset 0 0 0 1px #4da3ff; }
.mode-choice span { font-size: 13px; }

.cover-now { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding-top: 16px; border-top: 1px solid var(--line, #2a3442); }
.cover-now p { margin: 2px 0 0; font-size: 13px; }
.timer-row { display: flex; flex-wrap: wrap; gap: 8px; }
.timer-row .timer { padding: 8px 12px; font-size: 14px; }

.cover-active { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding-top: 16px; border-top: 1px solid var(--line, #2a3442); }
.cover-active p { margin: 0; }
/* Tabular figures stop the countdown jittering as the digits change. */
#coverActiveLeft { font-variant-numeric: tabular-nums; }

.mode-history { margin-top: 16px; font-size: 13px; }
.mode-history summary { cursor: pointer; color: var(--muted, #8296ad); }
.mode-history ul { margin: 10px 0 0; padding-left: 18px; color: var(--muted, #8296ad); }
.mode-history li { margin-bottom: 4px; }

@media (max-width: 620px) {
  .ai-handling-head { flex-direction: column; }
  .mode-badge { align-self: flex-start; }
  .cover-now, .cover-active { flex-direction: column; align-items: stretch; }
  .timer-row .timer { flex: 1 1 auto; }
}

/* --- Demo line ---------------------------------------------------------
   One shared number moves between prospects, so which business it currently
   answers as has to be readable without opening anything. */
.demo-line { margin-top: 16px; }
.demo-line-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.demo-line-head h2 { margin: 0 0 4px; }
.demo-line-head p { margin: 0; font-size: 14px; max-width: 60ch; }
#pointDemoLine:disabled { opacity: 0.5; cursor: default; }

@media (max-width: 620px) {
  .demo-line-head { flex-direction: column; align-items: stretch; }
}

.reprospect { border-left: 3px solid var(--accent); }
.reprospect > p.muted { max-width: 70ch; margin: 0 0 14px; }
.reprospect textarea { min-height: 90px; }

.voice-pick { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 10px; }
.voice-pick label { flex: 1 1 320px; margin: 0; }

.check { display: flex; align-items: center; gap: 9px; margin: 10px 0 4px; cursor: pointer; }
.check input { width: auto; margin: 0; }

.tuning { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin: 12px 0; }
.tuning label { margin: 0; font-size: 13px; }
.tuning input[type=range] { width: 100%; margin: 6px 0 4px; padding: 0; }
.tuning .muted { font-size: 12px; display: block; line-height: 1.4; }

/* --- Client portal -------------------------------------------------------
   Built for a phone. The first thing on screen is whether anything needs the
   owner at all — one big number, green when it is zero — and everything else
   sits under it. Phone numbers are links, so calling back is one tap. */
body.portal { padding: 0; }
.portal #portalView { max-width: 720px; margin: 0 auto; padding: 14px 14px 80px; }
.portal .card { padding: 16px; margin-bottom: 14px; }
.portal h2 { font-size: 17px; margin: 0 0 6px; }
.login-card { max-width: 420px; margin: 10vh auto; }
.wide { width: 100%; padding: 14px; font-size: 16px; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
          gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.topbar .brand { font-size: 16px; }

.hero { display: grid; grid-template-columns: 1fr; gap: 14px; margin: 4px 0 16px; }
.hero-main { border-radius: 14px; padding: 22px 20px; text-align: center; border: 1px solid var(--line); }
.hero.calm .hero-main { background: color-mix(in srgb, var(--good) 12%, transparent); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.hero.busy .hero-main { background: color-mix(in srgb, var(--bad) 12%, transparent); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.hero-count { font-size: 56px; font-weight: 800; line-height: 1; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.hero.calm .hero-count { color: var(--good); }
.hero.busy .hero-count { color: var(--bad); }
.hero-label { margin-top: 6px; font-size: 16px; font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 6px; text-align: center; }
.stat-n { display: block; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-l { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; }

.attention { border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.alert-card { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 8%, transparent); }

.day { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 18px 0 8px; }
.call-row { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.call-row.flagged { border-left: 4px solid var(--bad); }
.call-row.big { padding: 16px; }
.call-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.call-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.call-who strong { font-size: 16px; }
.phone { color: var(--accent); text-decoration: none; font-variant-numeric: tabular-nums; }
.phone.small { font-size: 13px; }
.small { font-size: 12.5px; }
.review-reason { color: var(--bad); font-weight: 600; margin: 8px 0 4px; line-height: 1.4; }
.outcome-line { margin: 6px 0 2px; }
.call-row .recording { width: 100%; margin-top: 10px; height: 36px; }
.call-row details summary { cursor: pointer; font-size: 13px; color: var(--accent); margin-top: 8px; }
.transcript { white-space: pre-wrap; font-size: 12.5px; line-height: 1.5; margin: 8px 0 0; max-height: 320px; overflow-y: auto;
              background: color-mix(in srgb, var(--panel) 60%, transparent); padding: 10px; border-radius: 8px; border: 1px solid var(--line); }
.call-row .actions { margin-top: 12px; }
.call-row .actions .button, .call-row .actions button { min-height: 44px; padding: 0 16px; display: inline-flex; align-items: center; text-decoration: none; }
.appt-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.appt-row:last-child { border-bottom: 0; }
#portalToast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 10; max-width: 90vw; }

@media (max-width: 480px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .hero-count { font-size: 48px; }
  .call-head { flex-direction: column; align-items: flex-start; }
}

.subscribed { border: 1px solid var(--good); background: color-mix(in srgb, var(--good) 10%, transparent);
              border-radius: 10px; padding: 12px 14px; margin-bottom: 18px; }
.subscribed p { margin: 6px 0 0; font-size: 13.5px; color: var(--muted); }

.call-row .actions button.subtle { color: var(--muted); border-color: transparent; margin-left: auto; }
.call-row .actions button.subtle:hover { color: var(--bad); }
button.link { background: none; border: 0; padding: 0; color: inherit; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }
#deletedCard summary { cursor: pointer; font-weight: 600; }

.setup-fee { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
