:root {
  color-scheme: dark;
  --bg: #0a1019;
  --panel: #111a27;
  --panel-2: #151f2f;
  --border: #253247;
  --text: #f2f6fb;
  --muted: #9fb0c6;
  --accent: #4ce3a2;
  --accent-strong: #21c884;
  --danger: #ff6b7a;
  --warning: #f4c45e;
  --shadow: 0 24px 80px rgb(0 0 0 / 0.25);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 15% 0%, #14253a 0, transparent 34%), var(--bg); color: var(--text); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
code { color: #b9f8da; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px clamp(20px, 4vw, 64px);
  border-bottom: 1px solid rgb(255 255 255 / 0.07);
  background: rgb(10 16 25 / 0.88);
  backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px; background: var(--accent); color: #07150f; font-size: 24px; font-weight: 900; }
.brand strong, .brand span { display: block; }
.brand span { color: var(--muted); font-size: 12px; margin-top: 2px; }
.top-actions { display: flex; align-items: center; gap: 10px; }

.page { width: min(1320px, calc(100% - 32px)); margin: 34px auto 80px; }
.panel { border: 1px solid var(--border); background: linear-gradient(145deg, rgb(20 30 45 / 0.97), rgb(13 21 33 / 0.97)); border-radius: 22px; box-shadow: var(--shadow); }
.login-panel { padding: clamp(24px, 4vw, 46px); display: flex; justify-content: space-between; gap: 32px; align-items: end; }
.login-panel h1, .call-panel h1 { margin: 4px 0 8px; font-size: clamp(28px, 4vw, 46px); letter-spacing: -0.04em; }
.inline-form { display: flex; gap: 12px; align-items: end; min-width: min(440px, 100%); }
.inline-form label { flex: 1; }

.hero-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.75fr); gap: 18px; }
.call-panel, .status-panel, .detail-panel, .history-panel { padding: clamp(20px, 3vw, 34px); }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.section-heading.compact { align-items: center; margin-bottom: 18px; }
h2 { margin: 3px 0 0; letter-spacing: -0.025em; }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: 0.16em; margin: 0; }

label > span { display: block; color: #dce6f3; font-size: 13px; font-weight: 650; margin: 0 0 8px; }
input, textarea { width: 100%; border: 1px solid #31425b; border-radius: 12px; background: #0b1320; color: var(--text); padding: 13px 14px; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(76 227 162 / 0.12); }
textarea { resize: vertical; min-height: 106px; }
.call-form { display: grid; gap: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check-line { display: flex; align-items: flex-start; gap: 10px; border: 1px solid #2a394f; background: rgb(8 15 25 / 0.55); padding: 13px; border-radius: 12px; }
.check-line input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--accent); }
.check-line span { margin: 0; color: var(--muted); line-height: 1.45; font-weight: 500; }
.form-actions { display: flex; gap: 12px; margin-top: 4px; }

.button { border: 1px solid transparent; border-radius: 11px; padding: 11px 16px; font-weight: 750; color: var(--text); background: #223047; transition: transform .12s, opacity .12s, background .12s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .42; cursor: not-allowed; }
.button.primary { background: var(--accent); color: #06150e; }
.button.primary:hover:not(:disabled) { background: var(--accent-strong); }
.button.danger { background: rgb(255 107 122 / .12); border-color: rgb(255 107 122 / .45); color: #ff9ca6; }
.button.ghost { border-color: #33425a; background: transparent; color: #cad7e8; }
.button.large { min-height: 48px; padding-inline: 22px; }
.button.small { padding: 8px 12px; font-size: 12px; }
.icon-button { width: 36px; height: 36px; border: 0; border-radius: 10px; background: #243147; color: white; font-size: 24px; }

.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 7px 11px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.badge.neutral { background: #202b3d; color: #b8c5d6; }
.badge.success { background: rgb(76 227 162 / .14); color: var(--accent); }
.badge.warning { background: rgb(244 196 94 / .13); color: var(--warning); }
.badge.danger { background: rgb(255 107 122 / .13); color: #ff9ca6; }

.status-panel h2 { margin-bottom: 24px; }
.status-list { display: grid; gap: 18px; }
.status-row { display: flex; align-items: center; gap: 12px; }
.status-row strong, .status-row small { display: block; }
.status-row small { color: var(--muted); margin-top: 3px; }
.status-dot { width: 12px; height: 12px; border-radius: 50%; background: #526177; box-shadow: 0 0 0 5px rgb(82 97 119 / .12); }
.status-dot.ok { background: var(--accent); box-shadow: 0 0 0 5px rgb(76 227 162 / .12); }
.status-dot.bad { background: var(--danger); box-shadow: 0 0 0 5px rgb(255 107 122 / .12); }
.current-state { margin-top: 28px; padding: 18px; border-radius: 16px; background: #0b1320; border: 1px solid #28364c; }
.current-state span, .current-state strong, .current-state small { display: block; }
.current-state span { color: var(--muted); font-size: 12px; }
.current-state strong { margin: 8px 0; font-size: 18px; }
.current-state small { color: var(--accent); font-variant-numeric: tabular-nums; }
.fine-print { color: #8191a8; line-height: 1.55; font-size: 12px; margin: 20px 0 0; }

.alert { padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; font-size: 13px; line-height: 1.45; }
.alert.error { border: 1px solid rgb(255 107 122 / .45); background: rgb(255 107 122 / .1); color: #ffb0b8; }
.alert.success { border: 1px solid rgb(76 227 162 / .4); background: rgb(76 227 162 / .09); color: #a9f5d2; }

.details-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; margin-top: 18px; }
.detail-panel { min-height: 390px; }
.recording-panel { margin-bottom: 18px; padding: 14px; border: 1px solid #2f4058; border-radius: 14px; background: #0b1320; }
.recording-heading { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 10px; }
.recording-heading small { color: var(--muted); text-align: right; }
.recording-panel audio { width: 100%; display: block; }
.empty-state { color: #7f8ea3; display: grid; place-items: center; text-align: center; min-height: 250px; border: 1px dashed #2f3e54; border-radius: 14px; padding: 24px; }
.transcript { display: flex; flex-direction: column; align-items: stretch; gap: 12px; max-height: 520px; overflow: auto; }
.transcript-turn { max-width: 88%; padding: 12px 14px; border-radius: 15px; line-height: 1.48; }
.transcript-turn small { display: block; opacity: .65; margin-bottom: 5px; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.transcript-turn.assistant { align-self: flex-start; background: #202e43; }
.transcript-turn.prospect { align-self: flex-end; background: rgb(76 227 162 / .13); border: 1px solid rgb(76 227 162 / .2); }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-content: start; }
.result-item { background: #0b1320; border: 1px solid #29374c; border-radius: 13px; padding: 14px; }
.result-item.wide { grid-column: 1 / -1; }
.result-item span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 6px; }
.result-item strong { line-height: 1.4; word-break: break-word; }

.history-panel { margin-top: 18px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 12px; text-align: left; border-bottom: 1px solid #243248; font-size: 13px; }
th { color: #8fa0b6; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: rgb(255 255 255 / .025); }

#diagnosticsDialog { width: min(850px, calc(100% - 28px)); border: 1px solid var(--border); border-radius: 18px; color: var(--text); background: #0e1724; padding: 24px; box-shadow: var(--shadow); }
#diagnosticsDialog::backdrop { background: rgb(0 0 0 / .7); backdrop-filter: blur(5px); }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
#diagnosticsOutput { max-height: 62vh; overflow: auto; white-space: pre-wrap; background: #080e17; border: 1px solid #29364b; border-radius: 12px; padding: 16px; color: #bcd0e7; font-size: 12px; line-height: 1.5; }

@media (max-width: 900px) {
  .hero-grid, .details-grid { grid-template-columns: 1fr; }
  .login-panel { align-items: stretch; flex-direction: column; }
  .inline-form { min-width: 0; }
}
@media (max-width: 620px) {
  .page { width: min(100% - 20px, 1320px); margin-top: 18px; }
  .topbar { padding-inline: 12px; }
  .brand span { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .form-actions, .inline-form { flex-direction: column; align-items: stretch; }
  .result-grid { grid-template-columns: 1fr; }
  .result-item.wide { grid-column: auto; }
}
