:root {
  --bg: #0b1220;
  --panel: #121a2b;
  --border: #243049;
  --text: #e8eef8;
  --muted: #93a0b8;
  --accent: #3ee0b8;
  --warn: #f0b429;
  --danger: #f07178;
  --font: "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 10% -10%, #16324a 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-size: .9em; background: #0a101c; padding: .1rem .35rem; border-radius: 4px; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 220px;
  background: rgba(10, 16, 28, .92); border-right: 1px solid var(--border);
  padding: 1.25rem 1rem; display: flex; flex-direction: column; gap: 1.5rem;
}
.brand strong { display: block; font-size: 1.05rem; }
.brand span { color: var(--muted); font-size: .8rem; }
.sidebar nav { display: flex; flex-direction: column; gap: .35rem; }
.sidebar nav a {
  color: var(--muted); padding: .45rem .65rem; border-radius: 8px;
}
.sidebar nav a.active, .sidebar nav a:hover {
  background: #1a2438; color: var(--text); text-decoration: none;
}
.content { margin-left: 220px; padding: 1.5rem 1.75rem 3rem; }
.top h1 { margin: 0 0 1.25rem; font-size: 1.5rem; font-weight: 650; }
.grid.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .85rem; margin-bottom: 1.25rem;
}
.stat, .panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 1rem 1.1rem;
}
.stat-label { display: block; color: var(--muted); font-size: .75rem; margin-bottom: .35rem; }
.stat-value { font-size: 1.35rem; }
.panel { margin-bottom: 1.25rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.panel h2 { margin: 0 0 .75rem; font-size: 1.05rem; }
.panel-head h2 { margin: 0; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { text-align: left; padding: .55rem .4rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.actions { white-space: nowrap; }
.actions a { margin-right: .65rem; }
.muted { color: var(--muted); }
.badge { display: inline-block; font-size: .7rem; padding: .1rem .4rem; border-radius: 999px; margin-left: .35rem; }
.badge-warn { background: rgba(240,180,41,.15); color: var(--warn); }
.badge-ok { background: rgba(62,224,184,.15); color: var(--accent); }
.badge-status { margin-left: 0; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }

.calls-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1.05fr) minmax(300px, 1fr);
  gap: 1rem;
  align-items: start;
}
.calls-list-panel,
.calls-detail-panel { margin-bottom: 0; min-height: 420px; }
.calls-table-wrap {
  max-height: min(70vh, 720px);
  overflow: auto;
  margin: 0 -.35rem;
  padding: 0 .35rem;
}
.calls-table thead th {
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 1;
}
.calls-row { cursor: pointer; transition: background .12s ease; }
.calls-row:hover { background: rgba(62,224,184,.06); }
.calls-row.is-selected { background: rgba(62,224,184,.12); box-shadow: inset 3px 0 0 var(--accent); }
.calls-row-link {
  color: inherit;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.calls-row-link:hover { text-decoration: underline; }
.calls-when-main { white-space: nowrap; font-variant-numeric: tabular-nums; }
.calls-visitor-name { display: block; font-weight: 600; }
.calls-visitor-email { display: block; font-size: .8rem; word-break: break-all; }
.calls-cost { font-variant-numeric: tabular-nums; white-space: nowrap; }
.calls-cost-main { display: block; font-weight: 650; }
.calls-cost-tag { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; }
.calls-empty { padding: .35rem 0; }
.calls-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .65rem;
  margin-bottom: 1rem;
}
.calls-summary-item {
  background: #0a101c;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .65rem .75rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  align-items: flex-start;
}
.calls-summary-value {
  font-size: 1.15rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.calls-meta { display: flex; flex-direction: column; gap: .55rem; margin-bottom: 1rem; }
.calls-meta-row { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: center; }
.calls-cost-notes { margin: .15rem 0 0; font-size: .8rem; }
.calls-conv-title {
  margin: 0 0 .65rem;
  font-size: .95rem;
  font-weight: 650;
}
@media (max-width: 1100px) {
  .calls-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.chat-line.chat-user { border-color: #2a3a55; }
.chat-line.chat-assistant { border-color: rgba(62,224,184,.35); }
.chat-line.chat-system .who { color: var(--muted); }

@media (max-width: 980px) {
  .calls-layout { grid-template-columns: 1fr; }
}
.btn, button.btn {
  display: inline-block; background: var(--accent); color: #042218; border: 0;
  border-radius: 999px; padding: .55rem 1.1rem; font-weight: 650; cursor: pointer; font: inherit;
}
.btn-sm { padding: .35rem .8rem; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
label { display: block; font-size: .8rem; color: var(--muted); margin: .75rem 0 .3rem; }
input, select, textarea {
  width: 100%; max-width: 520px; background: #0a101c; border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: .55rem .7rem; font: inherit;
}
textarea { min-height: 90px; max-width: 100%; }
.check { display: flex; align-items: center; gap: .5rem; margin: .5rem 0; color: var(--text); }
.check input { width: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .85rem; max-width: 720px; }
.alert { padding: .7rem .9rem; border-radius: 8px; margin: .75rem 0; }
.alert-error { background: rgba(240,113,120,.12); color: #ffb4b8; }
.alert-ok { background: rgba(62,224,184,.12); color: var(--accent); }
.alert-warn { background: rgba(240,180,41,.12); color: var(--warn); }
.login-page { display: grid; place-items: center; padding: 2rem; }
.login-card {
  width: min(420px, 100%); background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 1.75rem;
}
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; font-weight: 700; margin: 0 0 .5rem; }
.login-card h1 { margin: 0 0 .35rem; font-size: 1.4rem; }
.chat { display: flex; flex-direction: column; gap: .65rem; }
.chat-line { padding: .65rem .8rem; border-radius: 10px; background: #0a101c; border: 1px solid var(--border); }
.chat-line .who { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); font-weight: 700; }
.link-list { margin: 0; padding-left: 1.1rem; line-height: 1.8; }
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; margin-bottom: 1rem; }
.filters label { margin-top: 0; }
.filters select, .filters input { max-width: 220px; }
@media (max-width: 800px) {
  .sidebar { position: static; width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .content { margin-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
}
.clip-layout { display: grid; grid-template-columns: minmax(280px, .9fr) minmax(320px, 1.1fr); gap: 1rem; align-items: start; }
.clip-list { max-height: min(70vh, 720px); overflow: auto; }
.clip-item { display: block; padding: .7rem .75rem; border-radius: 10px; border: 1px solid transparent; color: inherit; text-decoration: none; }
.clip-item:hover { background: rgba(62,224,184,.06); text-decoration: none; }
.clip-item.is-selected { background: rgba(62,224,184,.12); border-color: rgba(62,224,184,.35); }
.clip-item strong { display: block; }
.clip-item span { display: block; color: var(--muted); font-size: .8rem; margin-top: .2rem; }
.record-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .75rem 0; }
.record-row audio { height: 36px; max-width: 260px; }
@media (max-width: 980px) { .clip-layout { grid-template-columns: 1fr; } }
