:root {
  --bg: #0b0f14;
  --bg-raised: #12181f;
  --bg-card: #161d26;
  --bg-inset: #0e141b;
  --bg-hover: #1c2530;
  --line: #2a3542;
  --line-strong: #3a4756;
  --text: #e6edf3;
  --text-dim: #9aa8b6;
  --text-mute: #6e7c8a;
  --accent: #3b82c4;
  --accent-hover: #4f94d4;
  --accent-soft: rgba(59, 130, 196, 0.14);
  --warn: #c9a227;
  --warn-soft: rgba(201, 162, 39, 0.14);
  --danger: #c45b5b;
  --danger-soft: rgba(196, 91, 91, 0.14);
  --ok: #3d9a6e;
  --ok-soft: rgba(61, 154, 110, 0.14);
  --radius: 8px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "IBM Plex Sans", "Segoe UI", Helvetica, Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 14px; line-height: 1.45; min-height: 100%;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
.muted { color: var(--text-dim); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }

.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(ellipse at top, #15202b, var(--bg));
}
.login-card {
  width: min(400px, 100%); background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 12px; padding: 28px; box-shadow: var(--shadow);
}
.mark {
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; margin-bottom: 14px;
}
.mark.sm { width: 32px; height: 32px; font-size: 12px; margin: 0; }
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card .sub { margin: 0 0 20px; color: var(--text-dim); }
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; color: var(--text-dim); font-size: 12px; font-weight: 500; }
.field input {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg-inset); color: var(--text);
}
.field input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg-raised); color: var(--text); cursor: pointer; font-weight: 500;
}
.btn:hover { background: var(--bg-hover); }
.btn-primary {
  width: 100%; background: var(--accent); border-color: transparent; color: #fff; margin-top: 4px;
}
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }
.login-foot { margin-top: 18px; color: var(--text-mute); font-size: 12px; text-align: center; }
.alert { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.alert-danger { background: var(--danger-soft); color: #f0b4b4; border: 1px solid rgba(196,91,91,.35); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--bg-raised);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand strong { display: block; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 20px; }

.kpi-strip {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px;
}
.kpi {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px;
}
.kpi-label { color: var(--text-dim); font-size: 12px; margin-bottom: 6px; }
.kpi-value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; }

.panels {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px;
}
.card {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px;
}
.card h2 { margin: 0 0 4px; font-size: 15px; }
.stat-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 10px 0; }
.stat-num { font-size: 22px; font-weight: 600; }
.flag-list { list-style: none; margin: 0; padding: 0; max-height: 180px; overflow: auto; }
.flag-list li {
  padding: 8px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--text-dim);
}
.flag-list li strong { color: var(--text); font-weight: 500; }

.sentiment-bars { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.sent-row { display: grid; grid-template-columns: 90px 1fr 40px; gap: 8px; align-items: center; font-size: 12px; }
.sent-bar { height: 8px; background: var(--bg-inset); border-radius: 99px; overflow: hidden; }
.sent-fill { height: 100%; background: var(--accent); border-radius: 99px; }
.sent-fill.Positive { background: var(--ok); }
.sent-fill.Negative { background: var(--danger); }
.sent-fill.Neutral { background: var(--text-mute); }
.sent-fill.Unknown { background: var(--line-strong); }

.table-card { padding: 0; overflow: hidden; }
.table-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 4px; background: var(--bg-inset); padding: 3px; border-radius: 8px; }
.tab {
  border: 0; background: transparent; color: var(--text-dim); padding: 7px 14px;
  border-radius: 6px; cursor: pointer; font-weight: 500;
}
.tab.active { background: var(--bg-card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.table-scroll { overflow: auto; max-height: 62vh; }
.calls-table { width: 100%; border-collapse: collapse; }
.calls-table th, .calls-table td {
  text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top;
}
.calls-table th {
  position: sticky; top: 0; background: var(--bg-raised); color: var(--text-dim);
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
}
.calls-table tr:hover td { background: var(--bg-hover); }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600;
}
.badge-ok { background: var(--ok-soft); color: #7dcea6; }
.badge-warn { background: var(--warn-soft); color: #e6c86a; }
.badge-danger { background: var(--danger-soft); color: #f0b4b4; }
.badge-mute { background: var(--bg-inset); color: var(--text-mute); }
.summary-cell { max-width: 420px; color: var(--text-dim); font-size: 13px; }
.summary-cell .pending { color: var(--warn); font-size: 11px; }
.expand-btn { font-size: 12px; }

.modal {
  border: 1px solid var(--line); border-radius: 12px; padding: 0;
  background: var(--bg-card); color: var(--text); width: min(720px, 94vw);
  box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(0,0,0,.55); }
.modal-inner { margin: 0; }
.modal-inner header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.modal-inner h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 16px; max-height: 70vh; overflow: auto; white-space: pre-wrap; font-family: var(--mono); font-size: 12px; line-height: 1.55; }

@media (max-width: 960px) {
  .kpi-strip, .panels { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .kpi-strip, .panels { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 8px; }
}

.alert-ok { background: var(--ok-soft); color: #7dcea6; border: 1px solid rgba(61,154,110,.35); }
.login-links { margin: 14px 0 0; text-align: center; font-size: 13px; }
.wrap.narrow { max-width: 520px; }
.form-stack .btn-primary { margin-top: 8px; }
.form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; margin-top: 12px;
}
.form-grid .field:first-child { grid-column: 1 / -1; }
.form-grid .check-field { grid-column: 1 / -1; }
.form-grid select {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg-inset); color: var(--text);
}
.check-field label { color: var(--text-dim); font-size: 13px; display: flex; gap: 8px; align-items: center; }
.actions { white-space: nowrap; }
.actions form { margin: 0 4px 4px 0; }
.site-foot {
  text-align: center; color: var(--text-mute); font-size: 12px;
  padding: 24px 16px 32px; border-top: 1px solid var(--line); margin-top: 8px;
}
@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
}
