:root {
  --bg: #fffdfa; --surface: #ffffff; --surface-2: #fff6ee; --text: #0d1b36; --muted: #6a6f86; --line: #e5e7f0;
  --accent: #F57C2A; --accent-2: #0B2250; --accent-soft: #fff0e4; --accent-ink: #ffffff;
  --good: #15803d; --good-soft: #e7f6ec; --warn: #b45309; --warn-soft: #fdf2e1; --bad: #c2261d; --bad-soft: #fdeceb;
  --agent: #fff0e4; --lead: #f1f2f8;
  --hot: #c2261d; --warm: #b45309; --cold: #5b6178;
  --radius: 14px; --shadow: 0 1px 2px rgba(20, 24, 50, .04), 0 6px 20px rgba(20, 24, 50, .05);
  --danger: var(--bad);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f17; --surface: #151824; --surface-2: #1c2030; --text: #e9ebf3; --muted: #9a9fb6; --line: #262a3b;
    --accent: #FF8F45; --accent-2: #8fa6d9; --accent-soft: #3a2414; --accent-ink: #1a0d03;
    --good: #4ade80; --good-soft: #13291c; --warn: #fbbf24; --warn-soft: #2b2312; --bad: #f87171; --bad-soft: #2d1616;
    --agent: #23214a; --lead: #1c2030; --hot: #f87171; --warm: #fbbf24; --cold: #9a9fb6;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
h1 { font-size: 22px; line-height: 1.25; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; letter-spacing: -.005em; }
h3 { font-size: 14px; margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); margin: 0; }

/* ---------- Controls ---------- */
label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin: 14px 0 6px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; display: block; line-height: 1.55; }
button {
  font: inherit; font-weight: 600; border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); transition: filter .15s, transform .05s, background .15s;
}
button:hover { filter: brightness(1.07); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
button.secondary:hover { background: var(--surface-2); filter: none; }
button.ghost { background: transparent; color: var(--muted); }
button.ghost:hover { background: var(--surface-2); color: var(--text); filter: none; }
button.danger { background: var(--bad); color: #fff; }
button.link { background: none; color: var(--accent); padding: 0; font-weight: 500; }
button.small, .small { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.full { width: 100%; margin-top: 18px; }
.note { color: var(--muted); font-size: 13px; margin: 8px 0 0; min-height: 20px; }
.note.error { color: var(--bad); }
.check { display: flex; gap: 10px; align-items: flex-start; color: var(--text); font-weight: 400; font-size: 14px; margin-top: 16px; }
.check input { width: 18px; height: 18px; margin-top: 2px; flex: none; accent-color: var(--accent); }
.phone-row { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 8px; }
.voice-row { grid-template-columns: minmax(0, 1fr) auto; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 14px; }
.form-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 18px; }

/* ---------- Cards, tags ---------- */
.panel, .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.tag { text-transform: capitalize; }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag.hot { background: var(--bad-soft); color: var(--hot); }
.tag.warm { background: var(--warn-soft); color: var(--warm); }
.tag.cold, .tag.not_interested { color: var(--cold); }
.tag.good, .tag.active-tag { background: var(--good-soft); color: var(--good); }
.tag.live { background: var(--accent-soft); color: var(--accent); }
.tag.live::before { animation: pulse 1.2s infinite; }
.hot { color: var(--hot); } .warm { color: var(--warm); } .cold, .not_interested { color: var(--cold); }
@keyframes pulse { 50% { opacity: .25; } }
.banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--warn-soft); color: var(--text); border-radius: 12px; padding: 12px 16px; margin: 0 0 18px; font-size: 14px; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 4px 8px 18px; }
.logo { width: 32px; height: 32px; border-radius: 10px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center; color: #fff; }
.logo svg { width: 18px; height: 18px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; background: none; color: var(--muted); font-weight: 500; text-align: left; padding: 10px 12px; border-radius: 10px; }
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: var(--surface-2); color: var(--text); filter: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .count { margin-left: auto; background: var(--accent); color: var(--accent-ink); font-size: 11px; border-radius: 999px; padding: 0 7px; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; }
.who { display: flex; align-items: center; gap: 10px; padding: 6px 8px 10px; min-width: 0; }
.who b, .who small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who small { color: var(--muted); font-size: 12px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: 13px; font-weight: 700; background: var(--accent-soft); color: var(--accent); }
.content { padding: 28px 32px 56px; max-width: 1180px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* ---------- Home ---------- */
.hero { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-radius: 18px; padding: 26px 28px; display: flex; justify-content: space-between; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 18px; }
.hero h1 { font-size: 24px; }
.hero p { margin: 6px 0 0; opacity: .88; }
.hero button { background: #fff; color: #2a2370; }
.setup-progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 4px 0 14px; }
.setup-progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: inherit; transition: width .4s; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.step { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.step.done { background: var(--surface-2); border-color: transparent; }
.step.done .step-title { color: var(--muted); text-decoration: line-through; }
.step.next { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.step-icon { width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 13px; font-weight: 700; border: 2px solid var(--line); color: var(--muted); }
.step.done .step-icon { background: var(--good); border-color: var(--good); color: #fff; }
.step-body { flex: 1; min-width: 0; }
.step-title { font-weight: 600; }
.step-body small { display: block; color: var(--muted); font-size: 13px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 18px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 28px; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: 13px; }
.stat i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--accent); }

/* ---------- Lists, tables ---------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: var(--surface-2); color: var(--muted); font-weight: 500; padding: 6px 12px; border-radius: 999px; font-size: 13px; }
.chip:hover { color: var(--text); filter: none; }
.chip.active { background: var(--text); color: var(--surface); }
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr[data-id] { cursor: pointer; transition: background .1s; }
tbody tr[data-id]:hover { background: var(--surface-2); }
td.empty { color: var(--muted); text-align: center; padding: 40px 10px; }
td small { display: block; color: var(--muted); font-size: 12px; }
td.clip { max-width: 360px; color: var(--muted); }
.person { display: flex; align-items: center; gap: 12px; }
.empty-state { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty-state b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }
.empty-state button { margin-top: 14px; }

/* ---------- Assistant ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.template-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.choice { text-align: left; background: var(--surface); color: var(--text); border: 1px solid var(--line); padding: 12px 14px; border-radius: 12px; font-weight: 500; }
.choice small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; margin-top: 2px; }
.choice:hover { border-color: var(--accent); filter: none; }
.choice.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.choice .emoji { font-size: 20px; display: block; margin-bottom: 6px; }
.hint-box { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; font-size: 13px; color: var(--muted); }
.hint-box code { background: var(--surface); padding: 1px 6px; border-radius: 6px; font-size: 12px; }

/* ---------- Dialogs, wizard ---------- */
dialog { border: 0; border-radius: 18px; background: var(--surface); color: var(--text); padding: 24px; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: 0 24px 64px rgba(10, 12, 30, .25); }
dialog::backdrop { background: rgba(14, 16, 32, .5); backdrop-filter: blur(3px); }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 6px; }
.dialog-head h2 { font-size: 18px; margin: 0; }
dialog.wizard { width: min(720px, calc(100vw - 24px)); padding: 0; overflow: hidden; }
.wizard-top { padding: 22px 28px 0; }
dialog:focus, .wizard-body:focus { outline: none; }
.wizard-body { padding: 4px 28px 8px; max-height: calc(100vh - 230px); overflow-y: auto; }
.wizard-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 28px 22px; border-top: 1px solid var(--line); margin-top: 12px; }
.stepper { display: flex; gap: 6px; margin: 0 0 18px; }
.stepper span { flex: 1; height: 4px; border-radius: 999px; background: var(--surface-2); }
.stepper span.on { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.eyebrow { color: var(--accent); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.wizard h2 { font-size: 22px; margin: 4px 0 4px; }
.wizard .lead-text { color: var(--muted); margin: 0 0 8px; }
.big-choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.done-mark { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; margin: 8px auto 12px; background: var(--good-soft); color: var(--good); font-size: 30px; }
dl.facts { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; margin: 16px 0; font-size: 14px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }
.summary { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; margin: 14px 0; }
.transcript { display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 85%; padding: 9px 13px; border-radius: 14px; white-space: pre-wrap; font-size: 14px; }
.msg.agent { background: var(--agent); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.lead { background: var(--lead); align-self: flex-end; border-bottom-right-radius: 4px; }
.msg small { display: block; color: var(--muted); font-size: 11px; }

/* ---------- Login and practice pages ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 24px 20px 48px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.topbar nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.grid { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 18px; align-items: start; }
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 500px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg); }
.auth { width: min(400px, 100%); }
.auth .brand { justify-content: center; padding-bottom: 10px; font-size: 18px; }
.auth h1 { text-align: center; margin-bottom: 4px; }
.auth .sub { text-align: center; color: var(--muted); margin: 0 0 20px; }
#log { height: 380px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
#log .empty { color: var(--muted); margin: auto; text-align: center; }
.callbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.status { color: var(--muted); font-size: 14px; flex: 1; min-width: 160px; }
#talk { width: 100%; margin-top: 12px; padding: 18px; font-size: 16px; user-select: none; touch-action: none; }
#talk.rec { background: var(--bad); color: #fff; }
.hint { color: var(--muted); font-size: 12px; text-align: center; margin-top: 6px; }

/* ---------- Small screens ---------- */
@media (max-width: 960px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: sticky; top: 0; z-index: 5; height: auto; flex-direction: row; align-items: center; padding: 8px 10px; gap: 2px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0 8px 0 2px; }
  .brand span { display: none; }
  .nav-item { width: auto; padding: 8px 10px; white-space: nowrap; }
  .nav-item .label { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; border: 0; padding: 0; display: flex; }
  .sidebar-foot .who { display: none; }
  .content { padding: 20px 16px 48px; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .hero { padding: 20px; }
  dl.facts { grid-template-columns: 110px 1fr; }
  .wizard-top, .wizard-body, .wizard-foot { padding-left: 18px; padding-right: 18px; }
}

/* Plain questions that write the call script */
.questions label { color: var(--text); font-size: 14px; }
.questions .optional { margin-left: 6px; color: var(--muted); font-size: 12px; font-weight: 400; }
input.missing { border-color: var(--bad); }
details.advanced { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
details.advanced summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 500; }
details.advanced summary:hover { color: var(--text); }
#wizardNote { position: sticky; bottom: 0; margin: 0; padding: 6px 0; background: var(--surface); }
.banner[hidden] { display: none; }

/* Lead sources */
.copy-row { display: flex; gap: 8px; margin-top: 10px; }
.copy-row input { flex: 1; min-width: 0; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
ol.how { margin: 12px 0 0; padding-left: 20px; color: var(--text); font-size: 14px; line-height: 1.6; }
ol.how li + li { margin-top: 4px; }
ol.how code, .card code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 12px; }
#snippet { margin-top: 12px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
