:root {
    color-scheme: dark;
    --bg: #0b1020;
    --panel: #121a2d;
    --panel-soft: #172139;
    --line: #263451;
    --text: #eef3ff;
    --muted: #97a6c3;
    --accent: #6c7cff;
    --accent-strong: #8794ff;
    --green: #38d39f;
    --red: #ff6b7a;
    --yellow: #f7c85b;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: radial-gradient(circle at 25% -10%, #202d59 0, transparent 35%), var(--bg); color: var(--text); }
a { color: var(--accent-strong); text-decoration: none; }
.topbar { height: 72px; padding: 0 max(24px, calc((100vw - 1200px) / 2)); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,.08); background: rgba(9,14,28,.82); backdrop-filter: blur(16px); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--text); font-weight: 750; letter-spacing: -.02em; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; background: linear-gradient(135deg, #6475ff, #8f63ff); box-shadow: 0 10px 30px rgba(108,124,255,.28); }
.nav { display: flex; align-items: center; gap: 22px; }
.nav > a:not(.button) { color: var(--muted); }
.nav form { margin: 0; }
.nav-logout { border: 0; padding: 0; background: none; color: var(--muted); cursor: pointer; font: inherit; }
.page { width: min(1200px, calc(100% - 40px)); margin: 0 auto; padding: 44px 0 72px; }
.page-heading { margin-bottom: 28px; }
.page-heading h1 { margin: 5px 0 8px; font-size: clamp(30px, 4vw, 46px); line-height: 1.08; letter-spacing: -.04em; }
.page-heading p, .panel-heading p { margin: 0; color: var(--muted); }
.heading-actions { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.eyebrow { color: #9eabff; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .13em; }
.button { appearance: none; border: 0; border-radius: 12px; padding: 12px 18px; background: linear-gradient(135deg, var(--accent), #875fff); color: white; font-weight: 750; font-size: 14px; cursor: pointer; box-shadow: 0 9px 25px rgba(108,124,255,.22); }
.button-small { padding: 9px 14px; }
.button-wide { width: 100%; margin-top: 8px; }
.button-secondary { background: var(--panel-soft); color: var(--text); border: 1px solid var(--line); box-shadow: none; }
.button-danger { background: rgba(255,107,122,.12); color: #ff9aa5; border: 1px solid rgba(255,107,122,.36); box-shadow: none; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button-group { display: flex; align-items: center; gap: 10px; }
.button-group form { margin: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card, .panel, .form-card, .login-card { border: 1px solid rgba(255,255,255,.08); background: linear-gradient(145deg, rgba(23,33,57,.96), rgba(15,23,42,.96)); border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.18); }
.stat-card { padding: 22px; }
.stat-card span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.stat-card strong { font-size: 34px; letter-spacing: -.04em; }
.panel { overflow: hidden; margin-bottom: 20px; }
.panel-heading { padding: 20px 22px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.panel h2 { margin: 0 0 4px; font-size: 18px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 16px 20px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.06); vertical-align: middle; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
tr:last-child td { border-bottom: 0; }
.table-subtitle { color: var(--muted); font-size: 12px; margin-top: 4px; max-width: 520px; }
.row-link { white-space: nowrap; font-weight: 650; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
.status { display: inline-flex; align-items: center; border-radius: 99px; padding: 6px 10px; background: rgba(151,166,195,.12); color: #b8c3d8; font-size: 12px; white-space: nowrap; }
.status-completed { background: rgba(56,211,159,.13); color: #6de4bc; }
.status-failed, .status-canceled { background: rgba(255,107,122,.13); color: #ff8b97; }
.status-in_progress, .status-answered, .status-dialing, .status-queued, .status-dispatching { background: rgba(108,124,255,.16); color: #aeb7ff; }
.status-no_answer, .status-busy { background: rgba(247,200,91,.13); color: #f8d77f; }
.filter-bar { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; color: var(--muted); }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 11px; background: #0d1528; color: var(--text); padding: 12px 13px; font: inherit; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(108,124,255,.13); }
textarea { resize: vertical; min-height: 84px; }
.filter-bar select { width: 230px; padding: 9px 11px; }
.filter-bar { flex-wrap: wrap; }
.form-card { padding: 26px; }
.form-grid { display: grid; gap: 18px; }
.two-columns { grid-template-columns: 1fr 1fr; }
.field { margin-bottom: 20px; }
.field label { display: block; font-weight: 700; margin-bottom: 8px; }
.field label span { color: var(--red); }
.field small { display: block; color: var(--muted); margin-top: 7px; }
.errorlist { margin: 7px 0 0; padding: 0; list-style: none; color: #ff929d; font-size: 13px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }
.messages { margin-bottom: 18px; }
.message { padding: 13px 15px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-soft); }
.message + .message { margin-top: 8px; }
.message-success { border-color: rgba(56,211,159,.4); color: #87e9c8; }
.message-error { border-color: rgba(255,107,122,.4); color: #ffabb3; }
.login-shell { min-height: calc(100vh - 190px); display: grid; place-items: center; }
.login-card { width: min(440px, 100%); padding: 34px; }
.login-card h1 { margin: 8px 0 10px; letter-spacing: -.035em; }
.stack-form { display: grid; gap: 9px; margin-top: 24px; }
.muted { color: var(--muted); }
.back-link { display: inline-block; margin-bottom: 14px; color: var(--muted); }
.detail-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 20px; }
.detail-card { padding: 22px; }
.definition-list { display: grid; grid-template-columns: 160px 1fr; gap: 15px 20px; margin: 20px 0 0; }
.definition-list dt { color: var(--muted); }
.definition-list dd { margin: 0; overflow-wrap: anywhere; }
.definition-list.compact { grid-template-columns: 115px 1fr; }
.audio-panel { padding-bottom: 20px; }
.audio-panel audio { display: block; width: calc(100% - 44px); margin: 20px 22px 0; }
.transcript { padding: 22px; display: grid; gap: 14px; }
.bubble { width: min(78%, 720px); padding: 14px 16px; border: 1px solid var(--line); border-radius: 15px 15px 15px 4px; background: #111a2f; line-height: 1.5; }
.bubble-agent { justify-self: end; border-radius: 15px 15px 4px 15px; background: rgba(108,124,255,.12); border-color: rgba(108,124,255,.3); }
.bubble-role { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 5px; }
.empty-state, .empty-cell { color: var(--muted); padding: 22px; }
.bulk-actions { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin: 0 0 12px; }
.selection-cell { width: 46px; padding-right: 4px; text-align: center; }
.selection-cell input { width: 17px; height: 17px; accent-color: var(--accent); }
.selection-disabled { color: #4c5871; }
.table-batch { display: inline-flex; margin-top: 7px; padding: 3px 7px; border-radius: 99px; background: rgba(108,124,255,.1); color: #aeb7ff; font-size: 11px; }
.form-section { margin: 8px -26px -26px; padding: 24px 26px 26px; border-top: 1px solid var(--line); background: rgba(5,10,21,.16); }
.recipients-grid { align-items: stretch; }
.upload-field { padding: 18px; border: 1px dashed #3b4b70; border-radius: 14px; background: rgba(13,21,40,.72); }
.upload-field input[type="file"] { padding: 10px; }
.format-example { margin-top: 18px; padding: 14px; border-radius: 10px; background: #09101f; color: #b8c3d8; line-height: 1.7; overflow-wrap: anywhere; }
.variable-help { margin-top: 9px; }
.variable-help-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.variable-menu-button { border: 1px solid #334467; border-radius: 8px; padding: 7px 10px; background: rgba(108,124,255,.1); color: #c4cbff; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.variable-menu-button:hover { border-color: var(--accent); background: rgba(108,124,255,.18); }
.variable-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.variable-chip { border: 1px solid #334467; border-radius: 8px; padding: 6px 9px; background: #0c1427; color: #aeb7ff; font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; cursor: pointer; }
.variable-chip:hover { border-color: var(--accent); background: rgba(108,124,255,.12); }
.editor-context-menu { position: fixed; z-index: 1000; width: 235px; padding: 6px; border: 1px solid #3b4b70; border-radius: 11px; background: #111a2f; box-shadow: 0 18px 55px rgba(0,0,0,.48); }
.editor-context-menu[hidden] { display: none; }
.context-item { width: 100%; min-height: 36px; display: flex; justify-content: space-between; align-items: center; gap: 10px; border: 0; border-radius: 7px; padding: 8px 10px; background: transparent; color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.context-item:hover { background: rgba(108,124,255,.16); }
.context-item small { color: var(--muted); font-size: 10px; text-align: right; }
.context-item-arrow span { color: var(--muted); font-size: 18px; }
.context-separator { height: 1px; margin: 5px 3px; background: var(--line); }
.context-submenu-wrap { position: relative; }
.context-submenu { display: none; position: absolute; left: calc(100% - 3px); top: -6px; width: 330px; max-height: 320px; overflow-y: auto; padding: 6px; border: 1px solid #3b4b70; border-radius: 11px; background: #111a2f; box-shadow: 0 18px 55px rgba(0,0,0,.48); }
.context-submenu-wrap:hover .context-submenu, .context-submenu-wrap:focus-within .context-submenu { display: block; }
.template-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.template-card { padding: 22px; margin: 0; }
.template-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.template-card-heading h2 { margin: 0 0 5px; }
.template-card-heading p { margin: 0; color: var(--muted); }
.template-card-heading form { margin: 0; }
.template-goal { margin-top: 20px; color: #dbe4f7; line-height: 1.55; }
.template-meta { margin-top: 20px; color: var(--muted); font-size: 12px; }
.template-application-status { margin-top: 10px; padding: 11px 13px; border: 1px solid rgba(56,211,159,.34); border-radius: 10px; background: rgba(56,211,159,.08); color: #b6f2dc; }
.template-application-status strong, .template-application-status span { display: block; }
.template-application-status span { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.45; white-space: pre-line; }
.template-field-applied { animation: template-field-applied .75s ease; }
@keyframes template-field-applied {
    0% { border-color: var(--green); box-shadow: 0 0 0 4px rgba(56,211,159,.16); }
    100% { border-color: var(--line); box-shadow: none; }
}

.configuration-hero { display: grid; grid-template-columns: 1.05fr 1fr 1fr; gap: 1px; margin-bottom: 20px; overflow: hidden; border: 1px solid rgba(108,124,255,.26); border-radius: 18px; background: var(--line); box-shadow: 0 20px 70px rgba(22,36,85,.2); }
.configuration-hero > div { min-height: 114px; padding: 24px; background: linear-gradient(145deg, rgba(27,41,76,.98), rgba(13,22,43,.98)); }
.configuration-hero p, .configuration-route span { display: block; margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.configuration-route strong { display: block; margin-top: 9px; line-height: 1.35; }
.live-dot { display: inline-block; width: 9px; height: 9px; margin-right: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 6px rgba(56,211,159,.11); }
.configuration-publish .form-card { border: 0; border-radius: 0; box-shadow: none; background: transparent; }
.publication-warning { margin: 4px 0 18px; padding: 13px 15px; border: 1px solid rgba(247,200,91,.3); border-radius: 11px; background: rgba(247,200,91,.07); color: #e9d79b; }
.section-heading { display: flex; justify-content: space-between; align-items: end; margin: 34px 0 16px; }
.section-heading h2 { margin: 0 0 5px; }
.section-heading p { margin: 0; color: var(--muted); }
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 34px; }
.profile-card { margin: 0; padding: 22px; }
.profile-card-head { display: flex; justify-content: space-between; gap: 16px; align-items: start; }
.profile-card-head h2 { margin: 0 0 5px; }
.profile-card-head p, .profile-description { margin: 0; color: var(--muted); }
.pipeline-mini, .pipeline-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 20px 0; }
.pipeline-mini > div, .pipeline-strip > div { min-width: 0; padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: rgba(8,14,29,.55); }
.pipeline-mini span, .pipeline-strip span { display: block; color: #9eabff; font-size: 10px; font-weight: 800; letter-spacing: .09em; }
.pipeline-mini strong, .pipeline-strip strong { display: block; margin-top: 7px; overflow-wrap: anywhere; font-size: 13px; }
.pipeline-mini small, .pipeline-strip small { display: block; margin-top: 5px; color: var(--muted); overflow-wrap: anywhere; }
.profile-actions { margin-top: 20px; flex-wrap: wrap; }
.profile-actions .button { padding: 9px 12px; }
.settings-section .panel-heading > div { position: relative; padding-left: 55px; }
.settings-section .panel-heading h2 { margin-bottom: 5px; }
.step-number { position: absolute; left: 0; top: 0; display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid rgba(108,124,255,.35); border-radius: 12px; background: rgba(108,124,255,.12); color: #b5bdff; font: 800 11px ui-monospace, monospace; }
.settings-section h3 { margin: 24px 0 16px; padding-top: 22px; border-top: 1px solid var(--line); }
.settings-section input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }
.field label { display: flex; align-items: center; gap: 7px; }
.field label .field-help-icon { display: inline-grid; width: 17px; height: 17px; place-items: center; flex: 0 0 17px; border: 1px solid rgba(158,171,255,.42); border-radius: 50%; color: #b7c1ff; font: 800 11px/1 ui-sans-serif, sans-serif; cursor: help; }
.catalog-status { padding: 7px 10px; border-radius: 99px; background: rgba(108,124,255,.11); color: #b6beff; font-size: 12px; white-space: nowrap; }
.catalog-diagnostics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.catalog-diagnostics[hidden] { display: none; }
.catalog-source { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; background: rgba(8,14,29,.5); }
.catalog-source strong { font-size: 13px; }
.catalog-source span { color: var(--green); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.catalog-source small { grid-column: 1 / -1; color: var(--muted); line-height: 1.45; overflow-wrap: anywhere; }
.catalog-source-warning { border-color: rgba(247,200,91,.34); }
.catalog-source-warning span { color: var(--yellow); }
.catalog-source-error { border-color: rgba(255,101,125,.32); }
.catalog-source-error span { color: #ff899d; }
.voice-preview { display: flex; align-items: center; gap: 16px; margin-top: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #0b1326; }
.voice-preview audio { width: min(480px, 70%); }
.voice-preview span { color: var(--muted); font-size: 13px; }
.voice-id-guide { display: grid; gap: 5px; margin-top: 2px; padding: 13px 15px; border: 1px solid rgba(108,124,255,.24); border-radius: 11px; background: rgba(108,124,255,.07); }
.voice-id-guide strong { color: #c9d0ff; font-size: 13px; }
.voice-id-guide span { color: var(--muted); font-size: 12px; line-height: 1.5; }
.sticky-save { position: sticky; bottom: 14px; z-index: 10; display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 20px; padding: 16px 18px; border: 1px solid rgba(108,124,255,.34); border-radius: 15px; background: rgba(12,19,38,.94); box-shadow: 0 18px 60px rgba(0,0,0,.42); backdrop-filter: blur(16px); }
.sticky-save strong, .sticky-save span { display: block; }
.sticky-save span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.pipeline-strip { grid-template-columns: repeat(4, 1fr); margin: 0; padding: 20px 22px; }
.cost-total { text-align: right; }
.cost-total strong, .cost-total span { display: block; }
.cost-total strong { font-size: 22px; }
.cost-total span { margin-top: 3px; color: var(--muted); }
.unresolved-rate { margin-top: 4px; color: var(--yellow); font-size: 11px; }
.filter-panel { padding: 18px; }
.cost-filters { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)) auto; gap: 12px; align-items: end; }
.cost-filters .field { margin: 0; }
.cost-stat-grid small, .stat-card small { display: block; margin-top: 9px; color: var(--muted); }
.analytics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.metric-list { padding: 8px 22px 18px; }
.metric-list > div { display: flex; justify-content: space-between; gap: 18px; padding: 14px 0; border-bottom: 1px solid rgba(255,255,255,.06); }
.metric-list > div:last-child { border-bottom: 0; }
.metric-list span { color: var(--muted); }
.daily-bars { display: grid; gap: 12px; padding: 22px; }
.daily-bars > div { display: grid; grid-template-columns: 95px 1fr 150px; align-items: center; gap: 16px; }
.daily-bar { height: 8px; overflow: hidden; border-radius: 99px; background: #0a1224; }
.daily-bar i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), #8d61ff); }

@media (max-width: 800px) {
    .topbar { padding: 0 18px; }
    .nav > a:not(.button) { display: none; }
    .page { width: min(100% - 24px, 1200px); padding-top: 28px; }
    .heading-actions { align-items: flex-start; flex-direction: column; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .two-columns, .detail-grid { grid-template-columns: 1fr; }
    .definition-list, .definition-list.compact { grid-template-columns: 1fr; gap: 6px; }
    .definition-list dd { margin-bottom: 10px; }
    .button-group { width: 100%; }
    .button-group { flex-wrap: wrap; }
    .bubble { width: 92%; }
    .template-grid { grid-template-columns: 1fr; }
    .catalog-diagnostics { grid-template-columns: 1fr; }
    .bulk-actions { align-items: flex-start; flex-direction: column; }
    .context-submenu { left: 14px; top: 36px; width: min(300px, calc(100vw - 40px)); }
    .configuration-hero, .profile-grid, .analytics-grid { grid-template-columns: 1fr; }
    .pipeline-strip { grid-template-columns: 1fr 1fr; }
    .cost-filters { grid-template-columns: 1fr 1fr; }
    .sticky-save { position: static; align-items: flex-start; flex-direction: column; }
    .daily-bars > div { grid-template-columns: 80px 1fr; }
    .daily-bars strong { grid-column: 2; }
}
