: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-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; }
.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; }

@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%; }
    .bubble { width: 92%; }
}
