:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --soft: #eef0f3;
  --text: #16181d;
  --muted: #646b78;
  --faint: #9aa1ad;
  --accent: #2f6fed;
  --accent-soft: #e6eefe;
  --green: #16a34a;
  --green-soft: #e3f6ea;
  --red: #e5383b;
  --amber: #b7791f;
  --amber-soft: #fbf1df;
  --phone: #12151b;
  --phone-2: #1d222b;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 20px rgba(16, 24, 40, .06);
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #171a21; --soft: #20242d; --text: #e9ebef; --muted: #a1a8b5; --faint: #6f7684;
    --accent: #6d9bff; --accent-soft: #1d2a45; --green: #22c55e; --green-soft: #15301f; --red: #f05252;
    --amber: #e0a43c; --amber-soft: #33270f; --phone: #0a0c10; --phone-2: #161a21;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #171a21; --soft: #20242d; --text: #e9ebef; --muted: #a1a8b5; --faint: #6f7684;
  --accent: #6d9bff; --accent-soft: #1d2a45; --green: #22c55e; --green-soft: #15301f; --red: #f05252;
  --amber: #e0a43c; --amber-soft: #33270f; --phone: #0a0c10; --phone-2: #161a21;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- шапка ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  max-width: 1280px; margin: 0 auto; padding: 18px 24px 8px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 36px; height: 36px; border-radius: 11px; background: var(--green);
  -webkit-mask: none; position: relative;
}
.logo::after {
  content: ""; position: absolute; inset: 8px;
  background: #fff;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6.6 10.8c1.4 2.8 3.8 5.1 6.6 6.6l2.2-2.2c.3-.3.7-.4 1-.2 1.1.4 2.3.6 3.6.6.6 0 1 .4 1 1V20c0 .6-.4 1-1 1C10.6 21 3 13.4 3 4c0-.6.4-1 1-1h3.5c.6 0 1 .4 1 1 0 1.3.2 2.5.6 3.6.1.3 0 .7-.2 1z'/%3E%3C/svg%3E") center/contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6.6 10.8c1.4 2.8 3.8 5.1 6.6 6.6l2.2-2.2c.3-.3.7-.4 1-.2 1.1.4 2.3.6 3.6.6.6 0 1 .4 1 1V20c0 .6-.4 1-1 1C10.6 21 3 13.4 3 4c0-.6.4-1 1-1h3.5c.6 0 1 .4 1 1 0 1.3.2 2.5.6 3.6.1.3 0 .7-.2 1z'/%3E%3C/svg%3E") center/contain no-repeat;
}
.brand-name { font-weight: 700; font-size: 16px; line-height: 1.1; white-space: nowrap; }
.brand-sub { color: var(--muted); font-size: 13px; }
.tabs { display: flex; gap: 4px; background: var(--soft); padding: 4px; border-radius: 12px; }
.tab { border: 0; background: transparent; padding: 7px 16px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 500; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

main { max-width: 1280px; margin: 0 auto; padding: 8px 24px 48px; }

/* ---------- выбор роли ---------- */
.intro { max-width: 760px; margin: 28px 0 24px; }
h1 { font-size: 30px; line-height: 1.15; margin: 0 0 10px; letter-spacing: -.01em; }
.lead { color: var(--muted); font-size: 17px; margin: 0 0 18px; }
.steps { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0; }
.steps li { display: flex; align-items: center; gap: 8px; background: var(--surface); padding: 6px 14px 6px 6px; border-radius: 999px; box-shadow: var(--shadow); font-weight: 500; }
.steps b { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--green-soft); color: var(--green); font-size: 13px; }

.scenarios { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.scenario { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.scenario h2 { margin: 0 0 4px; font-size: 18px; }
.scenario .sub { color: var(--muted); margin: 0 0 14px; font-size: 14px; }
.personas { display: grid; gap: 10px; }
.persona {
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px;
  width: 100%; text-align: left; border: 0; cursor: pointer;
  background: var(--soft); border-radius: 12px; padding: 12px 14px; transition: background .15s, transform .15s;
}
.persona:hover { background: var(--accent-soft); }
.persona:active { transform: scale(.99); }
.persona .ava { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; }
.persona .nm { font-weight: 600; }
.persona .ln { color: var(--muted); font-size: 13px; }
.persona .go {
  display: flex; align-items: center; gap: 6px; background: var(--green); color: #fff; font-weight: 600; font-size: 13px;
  padding: 7px 12px; border-radius: 999px; white-space: nowrap;
}
.persona .go svg { width: 14px; height: 14px; fill: currentColor; }
.fine { color: var(--faint); font-size: 13px; margin-top: 18px; }

/* ---------- звонок ---------- */
.call { display: grid; grid-template-columns: 340px minmax(0, 1fr) minmax(0, 1.25fr); gap: 20px; align-items: start; margin-top: 16px; }
.phone-col { display: grid; gap: 14px; position: sticky; top: 12px; }
.phone {
  background: linear-gradient(180deg, var(--phone-2), var(--phone)); color: #f3f4f6;
  border-radius: 28px; padding: 26px 22px 22px; text-align: center; box-shadow: 0 18px 40px rgba(10, 12, 16, .25);
}
.phone-status { font-size: 13px; color: #9aa3b2; letter-spacing: .02em; }
.avatar { width: 92px; height: 92px; margin: 18px auto 12px; border-radius: 50%; background: #2a313d; display: grid; place-items: center; position: relative; }
.avatar span { font-size: 34px; font-weight: 700; color: #fff; }
.avatar::before, .avatar::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(34, 197, 94, .5); opacity: 0; }
.phone.ringing .avatar::before { animation: pulse 1.6s infinite; }
.phone.ringing .avatar::after { animation: pulse 1.6s .5s infinite; }
.phone.talking .avatar { box-shadow: 0 0 0 calc(var(--lvl, 0) * 14px) rgba(34, 197, 94, .25); transition: box-shadow .08s; }
@keyframes pulse { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(1.6); opacity: 0; } }
.caller { font-size: 20px; font-weight: 600; }
.caller-sub { color: #9aa3b2; font-size: 14px; }
.timer { font-variant-numeric: tabular-nums; font-size: 15px; margin-top: 8px; color: #d1d5db; min-height: 22px; }
.state { min-height: 22px; font-size: 13px; color: #9aa3b2; margin-top: 2px; }
.state .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; background: #9aa3b2; }
.state.speaking .dot { background: #60a5fa; }
.state.listening .dot { background: #22c55e; }
.state.thinking .dot { background: #f59e0b; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }

.ring-actions, .live-actions { display: flex; justify-content: center; gap: 44px; margin-top: 26px; }
.round { border: 0; background: none; cursor: pointer; display: grid; justify-items: center; gap: 8px; color: #d1d5db; font-size: 13px; }
.round svg { width: 64px; height: 64px; padding: 18px; border-radius: 50%; fill: #fff; }
.round.accept svg { background: var(--green); }
.round.accept { animation: nudge 1.4s infinite; }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 10% { transform: translateY(-4px) rotate(-8deg); } 20% { transform: translateY(0) rotate(6deg); } 30% { transform: rotate(0); } }
.round.decline svg { background: var(--red); }
.round.small svg { background: #2a313d; }
.round.small.off svg { background: #f3f4f6; fill: #111; }
.round:focus-visible svg { outline: 3px solid #93c5fd; outline-offset: 3px; }

.ended-actions { display: grid; gap: 8px; margin-top: 22px; }
.btn { border: 0; border-radius: 12px; padding: 11px 16px; cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--green); color: #fff; }
.btn.ghost { background: rgba(255, 255, 255, .08); color: inherit; }
.settings .btn.ghost { background: var(--soft); }
.btn.tiny { padding: 6px 10px; font-size: 13px; font-weight: 500; border-radius: 9px; }

.type-reply { display: flex; gap: 6px; margin-top: 20px; }
.type-reply input { flex: 1; min-width: 0; border: 0; border-radius: 12px; padding: 10px 12px; background: #252b36; color: #f3f4f6; }
.type-reply input::placeholder { color: #8a93a3; }
.type-reply button { border: 0; border-radius: 12px; width: 42px; background: #2a313d; color: #fff; cursor: pointer; }

.role-card { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); font-size: 14px; }
.role-card .who { font-weight: 600; margin-bottom: 4px; }
.role-card .hint { color: var(--muted); }
.role-card .tag { display: inline-block; font-size: 12px; font-weight: 600; color: var(--amber); background: var(--amber-soft); padding: 2px 8px; border-radius: 999px; margin-bottom: 8px; }

.settings { background: var(--surface); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow); font-size: 14px; }
.settings summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.settings .row { display: grid; gap: 6px; margin: 12px 0 8px; }
.voice-pick { display: flex; gap: 6px; }
.voice-pick select { flex: 1; min-width: 0; border: 0; background: var(--soft); border-radius: 9px; padding: 6px 8px; }
.check { display: flex; gap: 8px; align-items: center; margin: 6px 0; cursor: pointer; }

.panel { background: var(--surface); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.side-col { display: grid; gap: 20px; }
.panel h2 { font-size: 16px; margin: 0 0 12px; }
.panel h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); margin: 18px 0 8px; font-weight: 600; }

.stages { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
.stages li { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 9px; color: var(--faint); }
.stages li .mk { width: 16px; height: 16px; border-radius: 50%; background: var(--soft); }
.stages li.done { color: var(--text); }
.stages li.done .mk { background: var(--green); box-shadow: inset 0 0 0 4px var(--green-soft); }
.stages li.now { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.stages li.now .mk { background: var(--accent); box-shadow: inset 0 0 0 4px var(--accent-soft); }
.stages li .t { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--faint); font-weight: 400; }

.facts { margin: 0; display: grid; gap: 6px; }
.facts .empty { color: var(--faint); font-size: 14px; }
.facts .f { background: var(--soft); border-radius: 10px; padding: 7px 10px; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; }
.facts .f.fresh { animation: flash 1.2s; }
@keyframes flash { 0% { background: var(--green-soft); } 100% { background: var(--soft); } }
.facts .f.key { background: var(--green-soft); }

.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; max-height: calc(100vh - 150px); overflow: auto; }
.timeline .empty { color: var(--faint); font-size: 14px; }
.ev { display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: start; }
.ev .t { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--faint); padding-top: 7px; }
.ev .b { border-radius: 12px; padding: 7px 11px; }
.ev.manager .b { background: var(--accent-soft); }
.ev.client .b { background: var(--soft); }
.ev .who { font-size: 12px; font-weight: 600; color: var(--muted); }
.ev.manager .who { color: var(--accent); }
.ev.sys .b, .ev.stage .b, .ev.fact .b, .ev.warn .b { padding: 3px 0; font-size: 13px; color: var(--muted); }
.ev.stage .b::before { content: "→ "; color: var(--accent); font-weight: 700; }
.ev.stage .b b { color: var(--text); }
.ev.fact .b::before { content: "✓ "; color: var(--green); font-weight: 700; }
.ev.warn .b { color: var(--amber); }
.ev .typing { color: var(--faint); font-style: italic; }
.ev .cut { color: var(--faint); }

/* итог */
.summary h2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.badge { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--soft); color: var(--muted); }
.badge.booked { background: var(--green-soft); color: var(--green); }
.badge.callback, .badge.thinking, .badge.dropped { background: var(--amber-soft); color: var(--amber); }
.badge.refused { background: #fde8e8; color: var(--red); }
.summary .outcome { font-size: 16px; font-weight: 600; margin: 0 0 10px; }
.summary .agree { background: var(--green-soft); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.summary .agree small { display: block; color: var(--muted); font-size: 12px; }
.summary ul { margin: 0; padding-left: 18px; }
.summary li { margin: 3px 0; }
.summary .meter { display: inline-flex; gap: 3px; vertical-align: middle; margin-left: 6px; }
.summary .meter i { width: 14px; height: 6px; border-radius: 3px; background: var(--soft); }
.summary .meter i.on { background: var(--green); }
.summary .kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; font-size: 14px; }
.summary .kv span:nth-child(odd) { color: var(--muted); }
.loading { color: var(--muted); display: flex; align-items: center; gap: 10px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--soft); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- автосалон ---------- */
.dealer-head { margin: 28px 0 20px; max-width: 820px; }
.dealer-head .note { display: inline-block; background: var(--amber-soft); color: var(--amber); font-weight: 600; font-size: 13px; padding: 4px 10px; border-radius: 999px; margin-bottom: 10px; }
.dealer-head p { color: var(--muted); margin: 6px 0; }
.dgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.card { background: var(--surface); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 8px; font-size: 15px; }
.card p { margin: 4px 0; color: var(--muted); font-size: 14px; }
.card .big { color: var(--text); font-weight: 600; font-size: 16px; }
.section-title { font-size: 18px; margin: 28px 0 12px; }
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 12px 14px; background: var(--soft); white-space: nowrap; }
td { padding: 10px 14px; vertical-align: top; }
tr:nth-child(even) td { background: color-mix(in srgb, var(--soft) 45%, transparent); }
td .m { font-weight: 600; }
td .s { color: var(--muted); font-size: 13px; }
td.price { white-space: nowrap; font-weight: 600; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; font-size: 12px; background: var(--green-soft); color: var(--green); padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.list { display: grid; gap: 10px; }

/* ---------- адаптив ---------- */
@media (max-width: 1100px) {
  .call { grid-template-columns: 320px minmax(0, 1fr); }
  .timeline-col { grid-column: 1 / -1; }
  .timeline { max-height: none; }
}
@media (max-width: 760px) {
  .top { padding: 14px 16px 6px; }
  main { padding: 6px 16px 40px; }
  h1 { font-size: 24px; }
  .lead { font-size: 15px; }
  .scenarios, .dgrid { grid-template-columns: 1fr; }
  .call { grid-template-columns: 1fr; }
  .phone-col { position: static; }
  .brand-sub { display: none; }
  .persona { grid-template-columns: 40px 1fr; }
  .persona .go { grid-column: 1 / -1; justify-content: center; }
}
