:root {
  --page: #f3f3f7;
  --canvas: #ffffff;
  --surface: #ffffff;
  --surface-2: #fafafc;
  --line: #ececf2;
  --line-strong: #dedfe8;
  --text: #17171f;
  --text-2: #4f5263;
  --text-3: #8b8ea0;
  --accent: #6a5cf6;
  --accent-ink: #4f40e0;
  --accent-soft: #f1efff;
  --accent-line: #ddd8ff;
  --gradient: linear-gradient(135deg, #5b5bf0 0%, #8b5cf6 55%, #c06cf0 100%);
  --success: #138a5e;
  --success-soft: #e7f7ef;
  --warning: #a86200;
  --warning-soft: #fff4e2;
  --danger: #cc3340;
  --danger-soft: #fdeef0;
  --info: #2f6be0;
  --info-soft: #ebf2ff;
  --neutral-soft: #f1f1f5;
  --radius-xl: 18px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-canvas: 0 1px 2px rgba(23, 23, 31, 0.03), 0 8px 30px rgba(23, 23, 31, 0.04);
  --shadow-pop: 0 18px 50px rgba(23, 23, 31, 0.16);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Shell ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 244px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 12px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand-card {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  margin: 0 2px 22px; padding: 18px 12px 16px;
  background: var(--canvas); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 1px 2px rgba(23, 23, 31, 0.03), 0 10px 28px rgba(23, 23, 31, 0.07);
  color: var(--text); transition: box-shadow 0.15s, border-color 0.15s, transform 0.15s;
}
.brand-card:hover { text-decoration: none; border-color: var(--accent-line); box-shadow: 0 1px 2px rgba(23, 23, 31, 0.04), 0 14px 32px rgba(106, 92, 246, 0.12); }
.brand-card:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(106, 92, 246, 0.2); }
.org-logo { display: block; width: 84px; height: 84px; border-radius: 50%; }
.org-logo svg { display: block; width: 100%; height: 100%; stroke: none; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center; gap: 2px;
  width: 34px; height: 34px; border-radius: 10px; background: var(--gradient);
  box-shadow: 0 6px 16px rgba(106, 92, 246, 0.35);
}
.brand-mark i { width: 2.5px; border-radius: 2px; background: #fff; }
.brand-mark i:nth-child(1) { height: 7px; }
.brand-mark i:nth-child(2) { height: 13px; }
.brand-mark i:nth-child(3) { height: 17px; }
.brand-mark i:nth-child(4) { height: 11px; }
.brand-mark i:nth-child(5) { height: 6px; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -0.015em; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); padding: 16px 12px 6px; }
.nav a, .sidebar-foot a {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; position: relative;
  transition: background 0.15s, color 0.15s;
}
.nav a svg, .sidebar-foot a svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav a:hover, .sidebar-foot a:hover { background: rgba(23, 23, 31, 0.045); color: var(--text); text-decoration: none; }
.nav a.active, .sidebar-foot a.active { background: var(--canvas); color: var(--text); box-shadow: 0 1px 2px rgba(23, 23, 31, 0.06), inset 0 0 0 1px var(--line); }
.nav a.active svg, .sidebar-foot a.active svg { color: var(--accent); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.workspace {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--canvas); border: 1px solid var(--line);
  color: var(--text-3); font-size: 12.5px;
}
.workspace-dot { width: 8px; height: 8px; border-radius: 50%; background: #2ecf8f; box-shadow: 0 0 0 3px rgba(46, 207, 143, 0.15); }

.main {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  margin: 10px 10px 10px 0;
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-canvas);
  overflow: clip;
}

.topbar {
  display: none; align-items: center; gap: 10px;
  padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-weight: 600; }

.view { padding: 34px 40px 56px; max-width: 1220px; width: 100%; margin: 0 auto; outline: none; }
.scrim { position: fixed; inset: 0; background: rgba(23, 23, 31, 0.32); z-index: 30; }

/* ---------- Page header ---------- */

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 26px; }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.2; }
.page-head p { margin: 6px 0 0; color: var(--text-2); }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); font-weight: 500; margin-bottom: 12px; font-size: 13px; }
.back-link svg { width: 16px; height: 16px; }
.back-link:hover { color: var(--text); text-decoration: none; }

/* ---------- Hero (home) ---------- */

.hero {
  position: relative; overflow: hidden;
  border-radius: var(--radius-xl); border: 1px solid var(--line);
  padding: 40px 36px 34px; margin-bottom: 22px;
  background:
    radial-gradient(600px 220px at 12% 0%, rgba(139, 92, 246, 0.13), transparent 70%),
    radial-gradient(500px 240px at 92% 110%, rgba(91, 91, 240, 0.12), transparent 70%),
    var(--surface-2);
}
.hero h1 { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.15; }
.hero h1 .glow { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { margin: 10px 0 22px; color: var(--text-2); max-width: 560px; font-size: 15px; }
.hero-wave { position: absolute; right: 36px; top: 34px; display: flex; align-items: center; gap: 5px; height: 64px; opacity: 0.9; }
.hero-wave i { width: 5px; border-radius: 4px; background: var(--gradient); animation: wave 1.6s ease-in-out infinite; }
.hero-wave i:nth-child(odd) { animation-delay: -0.4s; }
.hero-wave i:nth-child(3n) { animation-delay: -0.8s; }
.hero-wave i:nth-child(4n) { animation-delay: -1.2s; }
.chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 15px; border-radius: 999px;
  background: var(--canvas); border: 1px solid var(--line-strong);
  color: var(--text); font-weight: 500; cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.chip svg { width: 17px; height: 17px; color: var(--accent); }
.chip:hover { border-color: var(--accent-line); box-shadow: 0 4px 14px rgba(106, 92, 246, 0.12); text-decoration: none; transform: translateY(-1px); }
.chip.primary { background: var(--gradient); color: #fff; border-color: transparent; box-shadow: 0 6px 18px rgba(106, 92, 246, 0.3); }
.chip.primary svg { color: #fff; }

/* ---------- Buttons ---------- */

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, opacity 0.15s, transform 0.15s;
}
.button svg { width: 16px; height: 16px; }
.button.primary { background: var(--gradient); color: #fff; box-shadow: 0 4px 14px rgba(106, 92, 246, 0.28); }
.button.primary:hover { box-shadow: 0 6px 20px rgba(106, 92, 246, 0.38); transform: translateY(-1px); text-decoration: none; }
.button.secondary { background: var(--canvas); border-color: var(--line-strong); color: var(--text); }
.button.secondary:hover { background: var(--surface-2); border-color: #cfd0dc; text-decoration: none; }
.button.ghost { background: transparent; color: var(--accent-ink); padding: 0 10px; }
.button.ghost:hover { background: var(--accent-soft); text-decoration: none; }
.button.small { min-height: 32px; padding: 0 12px; font-size: 13px; }
.button.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.button.danger:hover { background: var(--danger); color: #fff; text-decoration: none; }
.button[disabled] { opacity: 0.6; cursor: not-allowed; transform: none; }

.icon-button { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-sm); border: 0; background: transparent; cursor: pointer; color: var(--text-2); }
.icon-button svg { width: 20px; height: 20px; }
.icon-button:hover { background: var(--neutral-soft); color: var(--text); }

.spinner { width: 15px; height: 15px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; display: inline-block; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Sound wave (live signature) ---------- */

.wave { display: inline-flex; align-items: center; gap: 2px; height: 14px; }
.wave i { width: 2.5px; height: 100%; border-radius: 2px; background: currentColor; animation: wave 1.1s ease-in-out infinite; transform-origin: center; }
.wave i:nth-child(2) { animation-delay: -0.3s; }
.wave i:nth-child(3) { animation-delay: -0.6s; }
.wave i:nth-child(4) { animation-delay: -0.15s; }
@keyframes wave { 0%, 100% { transform: scaleY(0.3); } 50% { transform: scaleY(1); } }
.hero-wave i { height: 100%; }

/* ---------- Cards ---------- */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.card-head h2 { margin: 0; font-size: 14.5px; font-weight: 600; letter-spacing: -0.005em; display: flex; align-items: center; gap: 8px; }
.card-head .meta { color: var(--text-3); font-size: 12.5px; }
.card-body { padding: 18px 20px; }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: 18px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 22px; }
.grid.two { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 18px; }

.stat { padding: 18px 20px; }
.stat-label { color: var(--text-2); font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 9px; }
.stat-value { font-size: 32px; font-weight: 700; letter-spacing: -0.03em; margin-top: 8px; line-height: 1.1; display: flex; align-items: center; gap: 10px; }
.stat-value .wave { color: var(--success); height: 18px; }
.stat-note { color: var(--text-3); font-size: 12px; margin-top: 4px; }
.stat-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
.stat-icon svg { width: 16px; height: 16px; }

/* ---------- Agents ---------- */

.agent-card { display: flex; flex-direction: column; padding: 18px 18px 14px; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s; }
.agent-card:hover { border-color: var(--accent-line); box-shadow: 0 10px 28px rgba(106, 92, 246, 0.09); transform: translateY(-1px); }
.agent-top { display: flex; align-items: flex-start; gap: 12px; }
.avatar {
  flex-shrink: 0; display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, #efedff, #f6eaff); color: var(--accent-ink);
  font-weight: 700; font-size: 13.5px; border: 1px solid var(--accent-line);
}
.agent-name { font-weight: 600; font-size: 15px; line-height: 1.3; word-break: break-word; letter-spacing: -0.01em; }
.agent-name a { color: var(--text); }
.agent-meta { color: var(--text-3); font-size: 12.5px; margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.agent-actions { display: flex; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.agent-actions .button { flex: 1; }

.agent-list { list-style: none; margin: 0; padding: 6px 0; }
.agent-list li { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 20px; }
.agent-list li + li { border-top: 1px solid var(--line); }
.agent-list .avatar { width: 34px; height: 34px; border-radius: 10px; font-size: 12px; }

/* ---------- Badges ---------- */

.badge {
  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(--neutral-soft); color: var(--text-2);
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge .wave { height: 11px; }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent-ink); }
.badge.outline { background: var(--canvas); border: 1px solid var(--line-strong); color: var(--text-2); font-weight: 500; }
.badge.large { font-size: 14px; padding: 7px 15px; }
.badge.large .dot { width: 9px; height: 9px; }
.badge.large .wave { height: 14px; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11.5px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 11px 20px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2);
}
td { padding: 13px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th.actions, td.actions { width: 1%; text-align: right; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.chips.filter { margin-bottom: 16px; }
a.stat.link { color: inherit; text-decoration: none; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s; }
a.stat.link:hover { border-color: var(--accent-line); box-shadow: 0 4px 14px rgba(106, 92, 246, 0.12); transform: translateY(-1px); }
tr.clickable { cursor: pointer; transition: background 0.12s; }
tr.clickable:hover { background: #faf9ff; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-sub { color: var(--text-3); font-size: 12px; }
.phone-cell { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 18px; }
.field-label { font-weight: 600; font-size: 13px; }
.field-hint { color: var(--text-3); font-size: 12.5px; }
.field-error { color: var(--danger); font-size: 12.5px; }
.field-error:empty { display: none; }
input[type="text"], input[type="tel"], select, textarea {
  width: 100%; padding: 10px 13px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--canvas); transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder { color: #a9abb9; }
textarea { resize: vertical; min-height: 170px; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(106, 92, 246, 0.12); outline: none; }
.invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 4px rgba(204, 51, 64, 0.08) !important; }
.form-error { background: var(--danger-soft); color: var(--danger); border-radius: var(--radius-sm); padding: 10px 13px; font-size: 13px; margin-bottom: 16px; }

.call-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; max-width: 980px; }
.call-form { padding: 24px; }
.agent-preview { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px 15px; margin-bottom: 18px; font-size: 13px; }
.agent-preview .preview-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.agent-preview .preview-text { color: var(--text-2); white-space: pre-wrap; max-height: 150px; overflow: auto; margin-top: 8px; line-height: 1.55; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps li { position: relative; padding: 0 0 18px 38px; color: var(--text-2); font-size: 13px; }
.steps li:last-child { padding-bottom: 0; }
.steps li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: -2px; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
  background: var(--accent-soft); color: var(--accent-ink); border: 1px solid var(--accent-line);
}
.steps li strong { display: block; color: var(--text); font-weight: 600; margin-bottom: 1px; }

/* ---------- Key/value ---------- */

.kv { display: grid; grid-template-columns: minmax(120px, 150px) minmax(0, 1fr); gap: 11px 16px; margin: 0; }
.kv dt { color: var(--text-3); font-size: 13px; }
.kv dd { margin: 0; word-break: break-word; font-weight: 500; }
.mono { font-family: var(--mono); font-size: 12.5px; font-weight: 400; }
.uuid { display: inline-flex; align-items: center; gap: 4px; }
.copy { border: 0; background: none; cursor: pointer; color: var(--text-3); padding: 3px 5px; border-radius: 6px; }
.copy:hover { color: var(--accent-ink); background: var(--accent-soft); }
.copy svg { width: 14px; height: 14px; vertical-align: -2px; }

.prompt-text {
  white-space: pre-wrap; word-break: break-word; margin: 0;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 15px 17px; font-family: var(--font); font-size: 14px; line-height: 1.65; color: var(--text-2);
  max-height: 480px; overflow: auto;
}

/* ---------- Call hero + stepper ---------- */

.call-hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 20px 22px 6px; }
.call-hero .to { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.call-hero .sub { color: var(--text-2); font-size: 13px; margin-top: 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.call-hero-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.poll-note { color: var(--text-3); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.poll-note svg { width: 14px; height: 14px; }
.poll-note .wave { color: var(--success); height: 11px; }

.timeline { display: flex; padding: 18px 22px 20px; overflow-x: auto; }
.timeline-step { flex: 1; min-width: 92px; position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-3); text-align: center; }
.timeline-step::before { content: ""; position: absolute; top: 12px; left: -50%; right: 50%; height: 2px; background: var(--line-strong); }
.timeline-step:first-child::before { display: none; }
.timeline-step .step-dot {
  position: relative; z-index: 1;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--canvas); border: 2px solid var(--line-strong); color: #fff;
}
.timeline-step .step-dot svg { width: 14px; height: 14px; stroke-width: 2.6; }
.timeline-step.done { color: var(--text-2); }
.timeline-step.done::before { background: var(--accent); }
.timeline-step.done .step-dot { background: var(--gradient); border-color: transparent; }
.timeline-step.current { color: var(--text); font-weight: 600; }
.timeline-step.current::before { background: var(--accent); }
.timeline-step.current .step-dot { border-color: var(--accent); box-shadow: 0 0 0 5px rgba(106, 92, 246, 0.15); }
.timeline-step.current .step-dot::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.timeline-step.done.current .step-dot::after { display: none; }
.timeline-step.failed { color: var(--danger); }
.timeline-step.failed::before { background: var(--danger); }
.timeline-step.failed .step-dot { background: var(--danger); border-color: var(--danger); box-shadow: 0 0 0 5px rgba(204, 51, 64, 0.12); }

/* ---------- Transcript ---------- */

.transcript { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px; max-height: 580px; overflow-y: auto; }
.line { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; align-items: start; }
.line-who { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; padding-top: 4px; }
.role { font-size: 10.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; padding: 3px 8px; border-radius: 6px; background: var(--neutral-soft); color: var(--text-2); }
.line.assistant .role { background: var(--accent-soft); color: var(--accent-ink); }
.line-time { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.line-text { padding: 10px 14px; border-radius: 12px; white-space: pre-wrap; word-break: break-word; line-height: 1.55; background: var(--surface-2); border: 1px solid var(--line); }
.line.assistant .line-text { background: #f7f5ff; border-color: var(--accent-line); }
.line.interrupted .line-text { border-style: dashed; }
.line-flags { margin-top: 6px; }

/* ---------- Events ---------- */

details.section > summary { list-style: none; cursor: pointer; }
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary .chev { display: inline-grid; transition: transform 0.15s; }
details.section > summary .chev svg { width: 16px; height: 16px; }
details.section[open] > summary .chev { transform: rotate(90deg); }
.event-list { list-style: none; margin: 0; padding: 0; }
.event { display: grid; grid-template-columns: 84px 14px minmax(0, 1fr); gap: 10px; padding: 11px 20px; font-size: 13px; position: relative; }
.event + .event { border-top: 1px solid var(--line); }
.event-time { color: var(--text-3); font-variant-numeric: tabular-nums; font-size: 12px; padding-top: 1px; }
.event-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; background: var(--accent-line); border: 2px solid var(--accent); }
.event.tone-danger .event-dot { background: var(--danger-soft); border-color: var(--danger); }
.event-title { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.event-type { color: var(--text-3); font-family: var(--mono); font-size: 11.5px; font-weight: 400; }
.event-meta { margin: 7px 0 0; padding: 9px 11px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-word; color: var(--text-2); }
.event.tone-danger .event-title { color: var(--danger); }

/* ---------- States ---------- */

.state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 50px 20px; color: var(--text-2); gap: 6px; }
.state h3 { margin: 8px 0 0; color: var(--text); font-size: 16px; font-weight: 600; }
.state p { margin: 0 0 12px; max-width: 420px; }
.state .state-icon { display: grid; place-items: center; width: 50px; height: 50px; border-radius: 15px; background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-line); }
.state .state-icon svg { width: 23px; height: 23px; }
.state.error .state-icon { background: var(--danger-soft); color: var(--danger); border-color: #f7d4d8; }
.state.small { padding: 28px 16px; }
.loading-row { display: flex; align-items: center; gap: 10px; color: var(--text-2); padding: 22px 20px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 18px; }
.notice svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.notice.warning { background: var(--warning-soft); color: var(--warning); }
.notice.info { background: var(--info-soft); color: var(--info); }

/* ---------- Dialog ---------- */

.dialog { border: 1px solid var(--line); border-radius: 20px; padding: 0; width: min(640px, calc(100vw - 32px)); box-shadow: var(--shadow-pop); color: var(--text); }
.dialog::backdrop { background: rgba(23, 23, 31, 0.38); backdrop-filter: blur(3px); }
.dialog-body { padding: 24px 26px 22px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.dialog-head h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.dialog-head p { margin: 4px 0 0; color: var(--text-2); font-size: 13.5px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Toasts ---------- */

.toasts { position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 10px; z-index: 100; max-width: min(420px, calc(100vw - 40px)); }
.toast { display: flex; gap: 11px; align-items: flex-start; background: #17171f; color: #fff; padding: 12px 15px; border-radius: 12px; box-shadow: var(--shadow-pop); font-size: 13.5px; animation: toast-in 0.18s ease-out; }
.toast .toast-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; background: #8f95b8; }
.toast.success .toast-dot { background: #34d399; }
.toast.error .toast-dot { background: #f87171; }
.toast-detail { color: #b8bacb; font-size: 12.5px; margin-top: 2px; }
@keyframes toast-in { from { transform: translateY(6px); opacity: 0; } }

.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Responsive ---------- */

/* ---------- Knowledge bases ---------- */
.kb-avatar svg { width: 19px; height: 19px; }
.kb-description { margin: 8px 0 0; color: var(--text-2); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center;
  padding: 28px 20px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius);
  background: var(--surface-2); cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent-line); background: var(--accent-soft); outline: none; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone strong { font-size: 14.5px; color: var(--text); }
.dropzone .faint { font-size: 12.5px; }
.dropzone-icon { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 6px; border-radius: 12px; background: var(--canvas); border: 1px solid var(--accent-line); color: var(--accent-ink); }
.dropzone-icon svg { width: 20px; height: 20px; }

.upload-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.upload-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 13px; }
.upload-item > svg { width: 16px; height: 16px; color: var(--text-3); }
.upload-name { font-weight: 500; }
.upload-state { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.upload-state svg { width: 15px; height: 15px; flex-shrink: 0; stroke-width: 2; }
.upload-item.done .upload-state { color: var(--success); }
.upload-item.error { border-color: var(--danger-soft); background: var(--danger-soft); }
.upload-item.error .upload-state { color: var(--danger); }

.docs-table tr.expanded { background: #faf9ff; }
.doc-cell { display: flex; align-items: center; gap: 11px; min-width: 0; max-width: 420px; }
.doc-icon { display: grid; place-items: center; flex-shrink: 0; width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink); }
.doc-icon svg { width: 17px; height: 17px; }
.doc-name { font-weight: 600; color: var(--text); }
.doc-error { margin-top: 4px; max-width: 320px; color: var(--danger); font-size: 12px; }
.row-chev { display: inline-grid; place-items: center; color: var(--text-3); transition: transform 0.15s; }
.row-chev svg { width: 16px; height: 16px; stroke-width: 2; }
.row-chev.open { transform: rotate(90deg); color: var(--accent-ink); }

.detail-row > td { background: var(--surface-2); padding: 16px 20px 18px; }
.versions { display: flex; flex-direction: column; gap: 10px; }
.versions-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); }
.version-row { padding: 12px 14px; background: var(--canvas); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.version-main { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: 13px; }
.version-error { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); font-size: 12.5px; word-break: break-word; }
.version-error svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; stroke-width: 2; }
.version-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.version-actions:empty { display: none; }

.chunks { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.chunk { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); padding: 10px 12px; }
.chunk-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12.5px; margin-bottom: 8px; }
.chunk-section { font-weight: 600; color: var(--accent-ink); }
.chunk-text { margin: 0; max-height: 220px; overflow: auto; white-space: pre-wrap; word-break: break-word; font-family: var(--font); font-size: 13px; line-height: 1.55; color: var(--text-2); }

/* ---------- Transcript download ---------- */
.dialog.dialog-small { width: min(460px, calc(100vw - 32px)); }
.format-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.format-option {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; text-align: left;
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--canvas);
  font: inherit; color: var(--text); cursor: pointer; transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.format-option:hover, .format-option:focus-visible { border-color: var(--accent-line); background: var(--accent-soft); box-shadow: 0 6px 18px rgba(106, 92, 246, 0.1); outline: none; }
.format-badge { display: grid; place-items: center; flex-shrink: 0; width: 46px; height: 46px; border-radius: 12px; background: var(--info-soft); color: var(--info); font-weight: 700; font-size: 12.5px; letter-spacing: 0.04em; }
.format-badge.pdf { background: var(--danger-soft); color: var(--danger); }
.format-text { display: flex; flex-direction: column; gap: 2px; }
.format-text strong { font-size: 14.5px; }
.format-text span { color: var(--text-2); font-size: 13px; }

/* ---------- Call start progress ---------- */
.call-progress { list-style: none; margin: 0 0 18px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--accent-line); border-radius: var(--radius); background: var(--accent-soft); }
.progress-step { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--text-3); }
.progress-step.active { color: var(--accent-ink); font-weight: 600; }
.progress-step.done { color: var(--text-2); }
.progress-step.failed { color: var(--danger); font-weight: 600; }
.progress-mark { display: grid; place-items: center; flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line-strong); background: var(--canvas); }
.progress-step.active .progress-mark { border-color: var(--accent-line); }
.progress-step.done .progress-mark { border-color: transparent; background: var(--success); color: #fff; }
.progress-step.failed .progress-mark { border-color: transparent; background: var(--danger); color: #fff; }
.progress-mark svg { width: 13px; height: 13px; stroke-width: 2.4; }
.progress-mark .spinner { width: 13px; height: 13px; }
.link-button { padding: 0; border: 0; background: none; font: inherit; font-weight: 600; color: var(--accent-ink); cursor: pointer; }
.link-button:hover { text-decoration: underline; }

/* ---------- Dropdown ---------- */
.dd { position: relative; }
.dd-trigger {
  display: flex; align-items: center; gap: 11px; width: 100%; min-height: 48px; padding: 0 4px 0 14px;
  border: 1px solid #c9d3f2; border-radius: 14px; background: linear-gradient(180deg, #f8faff 0%, #eef2fc 100%);
  color: var(--text); font: inherit; font-size: 14.5px; text-align: left; cursor: pointer;
  box-shadow: 0 1px 2px rgba(23, 23, 31, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.dd-trigger:hover { border-color: #a9b8ea; }
.dd-trigger:focus-visible, .dd.open .dd-trigger { outline: none; border-color: #7d93e4; box-shadow: 0 0 0 3px rgba(91, 120, 230, 0.16); }
.dd-trigger.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(204, 51, 64, 0.1); }
.dd-trigger:disabled { cursor: not-allowed; background: var(--surface-2); border-color: var(--line); color: var(--text-3); box-shadow: none; }
.dd-icon { display: grid; place-items: center; flex-shrink: 0; width: 20px; height: 20px; color: var(--text-2); }
.dd-icon svg { width: 19px; height: 19px; }
.dd-trigger:disabled .dd-icon { color: var(--text-3); }
.dd-value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-value.placeholder { color: var(--text-3); }
.dd-sep { align-self: stretch; width: 1px; margin: 10px 0; background: #d5dcef; }
.dd-chevron { display: grid; place-items: center; width: 38px; color: var(--text-2); }
.dd-chevron svg { width: 17px; height: 17px; stroke-width: 2.1; transform: rotate(90deg); transition: transform 0.15s; }
.dd.open .dd-chevron svg { transform: rotate(-90deg); }
.dd-panel {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 6px; list-style: none;
  max-height: 320px; overflow-y: auto; outline: none;
  background: rgba(248, 250, 255, 0.97); backdrop-filter: blur(10px);
  border: 1px solid #c9d3f2; border-radius: 14px; box-shadow: 0 16px 40px rgba(30, 45, 100, 0.16);
}
.dd-option { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; font-size: 14.5px; color: var(--text); cursor: pointer; user-select: none; }
.dd-option.active { background: #eef1f8; }
.dd-option.selected { background: #e9e6e1; }
.dd-option.selected.active { background: #e2ded8; }
.dd-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-meta { color: var(--text-3); font-size: 12.5px; white-space: nowrap; }
.dd-check { display: grid; place-items: center; flex-shrink: 0; width: 20px; color: #3b6fe0; }
.dd-check svg { width: 18px; height: 18px; stroke-width: 2.2; }
.dd-divider { height: 1px; margin: 6px 4px; background: #dfe3ee; list-style: none; }
.dd-action, .dd-action .dd-icon { color: #3b6fe0; }
.dd-action .dd-icon svg { stroke-width: 2.1; }

/* ---------- Write prompt with AI ---------- */
.dialog.dialog-medium { width: min(580px, calc(100vw - 32px)); }
.field-label-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.button.ai-button {
  background: var(--accent-soft); color: var(--accent-ink); border: 1px solid var(--accent-line);
  font-weight: 600; box-shadow: none;
}
.button.ai-button:hover { background: #e8e4ff; border-color: #c8c0ff; text-decoration: none; }
.button.ai-button:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(106, 92, 246, 0.2); }
.button.ai-button svg { width: 15px; height: 15px; }
.ai-title { display: flex; align-items: center; gap: 10px; }
.ai-title-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--gradient); color: #fff; flex-shrink: 0; }
.ai-title-icon svg { width: 17px; height: 17px; }
#ai-prompt-form textarea { min-height: 150px; resize: vertical; }
#ai-prompt-form input[readonly], #ai-prompt-form textarea[readonly] { background: var(--surface-2); color: var(--text-2); }
#ai-prompt-form .notice { margin-bottom: 16px; }
.generated-note { display: flex; align-items: center; gap: 8px; padding: 8px 11px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-ink); font-size: 12.5px; font-weight: 500; }
.generated-note svg { width: 15px; height: 15px; flex-shrink: 0; }
textarea.just-generated { animation: generated-glow 1.6s ease-out; }
@keyframes generated-glow {
  0% { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(106, 92, 246, 0.22); background: var(--accent-soft); }
  100% { box-shadow: 0 0 0 0 rgba(106, 92, 246, 0); }
}
.shake { animation: field-shake 0.36s ease-in-out; }
@keyframes field-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.ai-summary-card { position: relative; overflow: hidden; }
.ai-summary-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--gradient); }
.ai-summary-card .card-head { flex-wrap: wrap; }
.ai-summary-title { display: inline-flex; align-items: center; gap: 10px; }
.ai-summary-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: var(--gradient); color: #fff; box-shadow: 0 4px 12px rgba(106, 92, 246, 0.3); }
.ai-summary-icon svg { width: 15px; height: 15px; }
.ai-summary-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.ai-wait { display: flex; align-items: center; gap: 16px; padding: 18px; border: 1px dashed var(--accent-line); border-radius: var(--radius); background: linear-gradient(135deg, #f7f5ff 0%, #fbf6ff 100%); }
.ai-wait-orb { display: grid; place-items: center; flex-shrink: 0; width: 46px; height: 46px; border-radius: 50%; background: var(--gradient); color: #fff; animation: ai-pulse 2.4s ease-in-out infinite; }
.ai-wait-orb svg { width: 22px; height: 22px; }
.ai-wait h3 { margin: 0 0 3px; font-size: 14.5px; font-weight: 600; }
.ai-wait p { margin: 0; color: var(--text-2); font-size: 13px; }
@keyframes ai-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(106, 92, 246, 0.35); }
  50% { box-shadow: 0 0 0 10px rgba(106, 92, 246, 0); }
}

.ai-loading { display: flex; flex-direction: column; gap: 16px; }
.ai-loading-head { display: flex; align-items: center; gap: 10px; color: var(--accent-ink); font-weight: 600; font-size: 13.5px; }
.ai-shimmer { display: flex; flex-direction: column; gap: 10px; }
.ai-shimmer i { display: block; height: 11px; border-radius: 6px; background: linear-gradient(90deg, #efedfb 0%, #dfdafb 45%, #efedfb 90%); background-size: 200% 100%; animation: ai-shimmer 1.4s linear infinite; }
@keyframes ai-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.ai-summary { display: flex; flex-direction: column; gap: 16px; }
.ai-outcome { display: flex; gap: 12px; padding: 14px 16px; border: 1px solid var(--accent-line); border-radius: var(--radius); background: linear-gradient(135deg, #f3f1ff 0%, #f9f3ff 100%); }
.ai-outcome-icon { display: grid; place-items: center; flex-shrink: 0; width: 34px; height: 34px; border-radius: 10px; background: var(--canvas); color: var(--accent-ink); box-shadow: 0 1px 3px rgba(23, 23, 31, 0.06); }
.ai-outcome-icon svg { width: 18px; height: 18px; }
.ai-label { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--accent-ink); }
.ai-outcome p { margin: 2px 0 0; font-size: 14.5px; font-weight: 600; line-height: 1.5; color: var(--text); }
.ai-overview { margin: 0; font-size: 14px; line-height: 1.7; color: var(--text); }
.ai-section h3 { margin: 0 0 9px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-3); }
.ai-points, .ai-actions { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.ai-points li { position: relative; padding-left: 18px; line-height: 1.55; }
.ai-points li::before { content: ""; position: absolute; left: 3px; top: 0.62em; width: 6px; height: 6px; border-radius: 50%; background: var(--gradient); }
.ai-actions li { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); line-height: 1.5; }
.ai-check { display: grid; place-items: center; flex-shrink: 0; width: 18px; height: 18px; margin-top: 2px; border: 1.5px solid var(--success); border-radius: 6px; background: var(--success-soft); color: var(--success); }
.ai-check svg { width: 12px; height: 12px; stroke-width: 2.6; }
.ai-foot { display: flex; align-items: center; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--text-3); font-size: 12px; }
.ai-foot svg { width: 13px; height: 13px; color: var(--accent); }

@media (max-width: 1080px) {
  .grid.two, .call-layout { grid-template-columns: minmax(0, 1fr); }
  .hero-wave { display: none; }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 40; background: var(--page);
    transform: translateX(-100%); transition: transform 0.2s ease;
    padding-top: calc(18px + env(safe-area-inset-top, 0px));
    box-shadow: var(--shadow-pop);
  }
  .sidebar.open { transform: none; }
  .main { margin: 0; border: 0; border-radius: 0; box-shadow: none; }
  .topbar { display: flex; }
  .view { padding: 22px 16px 40px; }
  .hero { padding: 28px 20px 24px; }
}

@media (max-width: 560px) {
  .upload-item { grid-template-columns: auto minmax(0, 1fr); }
  .upload-item > .faint, .upload-state { grid-column: 2; }
  .page-head h1, .hero h1 { font-size: 23px; }
  .page-actions { width: 100%; }
  .page-actions .button { flex: 1; }
  .chip { flex: 1; justify-content: center; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd { margin-bottom: 10px; }
  .line { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .line-who { flex-direction: row; align-items: center; gap: 8px; padding-top: 0; }
  .event { grid-template-columns: 14px minmax(0, 1fr); }
  .event-time { grid-column: 2; order: 2; }
  .call-hero .to { font-size: 20px; }
  .call-hero-side { align-items: flex-start; }
  .stat-value { font-size: 27px; }
  .timeline { padding: 16px 10px 18px; }
  .timeline-step { min-width: 0; font-size: 10.5px; line-height: 1.25; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
