:root {
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --border: #2e2e2b; --border-strong: #3d3d39;
  --text: #f4f4f1; --text-2: #c3c2b7; --muted: #8b8a82;
  --accent: #3987e5; --accent-soft: rgba(57, 135, 229, 0.18);
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 10px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; }
a { color: inherit; }
button { font: inherit; color: var(--text); background: var(--accent); border: 0; border-radius: 8px; padding: 8px 14px; cursor: pointer; }
button.ghost { background: transparent; border: 1px solid var(--border-strong); color: var(--text-2); padding: 6px 10px; }
button.ghost:hover { border-color: var(--accent); color: var(--text); }
button.danger { background: var(--critical); }
button:disabled { opacity: 0.5; cursor: default; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }
.error { color: var(--serious); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card h2 { margin: 0 0 12px; font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-2); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { margin: 0; font-size: 22px; }

.topbar { display: flex; align-items: center; gap: 24px; padding: 12px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); z-index: 5; }
.brand { font-weight: 700; font-size: 16px; }
#nav { display: flex; gap: 4px; flex: 1; }
#nav a { text-decoration: none; padding: 6px 12px; border-radius: 8px; color: var(--text-2); }
#nav a.active { background: var(--surface-2); color: var(--text); }
.topbar .right { display: flex; align-items: center; gap: 10px; }
main { padding: 20px; max-width: 1400px; margin: 0 auto; display: grid; gap: 16px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .sub { font-size: 12px; color: var(--text-2); }
.bar { height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.bar > i.warn { background: var(--warning); } .bar > i.crit { background: var(--critical); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; padding: 6px 8px; border-bottom: 1px solid var(--border); }
td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr.row { cursor: pointer; } tr.row:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.pill.booked { background: rgba(12,163,12,0.18); color: #6fd66f; }
.pill.failed, .pill.cancelled { background: rgba(208,59,59,0.18); color: #f08c8c; }
.pill.contacting, .pill.confirming, .pill.searching, .pill.queued, .pill.running, .pill.dialing { background: var(--accent-soft); color: #86b6ef; }
.pill.waiting_user { background: rgba(250,178,25,0.18); color: #f6c65a; }
.pill.error { background: rgba(208,59,59,0.18); color: #f08c8c; } .pill.warn { background: rgba(250,178,25,0.18); color: #f6c65a; } .pill.info { color: var(--muted); }

.attention { display: flex; flex-direction: column; gap: 8px; }
.attention .item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border-left: 3px solid var(--warning); }
.attention .item.error { border-left-color: var(--critical); }
.attention .item .actions { margin-left: auto; display: flex; gap: 6px; }
.attention .empty { color: var(--good); }
.icon { flex: none; width: 18px; text-align: center; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.toolbar label { min-width: 140px; }

.chart { position: relative; height: 180px; display: flex; align-items: flex-end; gap: 2px; padding-top: 18px; }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; position: relative; }
.chart .col i { display: block; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.chart .col:hover i { background: #5598e7; }
.chart .col .tip { display: none; position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--border-strong); padding: 6px 8px; border-radius: 6px; white-space: nowrap; font-size: 12px; z-index: 3; }
.chart .col:hover .tip { display: block; }
.chart-x { display: flex; gap: 2px; margin-top: 6px; }
.chart-x span { flex: 1; text-align: center; font-size: 10px; color: var(--muted); overflow: hidden; }

.drawer { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 10; display: flex; justify-content: flex-end; }
.drawer-panel { width: min(760px, 100%); height: 100%; background: var(--surface); border-left: 1px solid var(--border); overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.drawer-head #drawer-title { font-weight: 700; font-size: 16px; }
.section h3 { margin: 16px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
pre.transcript { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; white-space: pre-wrap; font-size: 12px; max-height: 320px; overflow: auto; }
details summary { cursor: pointer; color: var(--text-2); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: grid; grid-template-columns: 56px 1fr; gap: 10px; padding: 4px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.msg { padding: 8px 10px; border-radius: 8px; margin: 4px 0; max-width: 85%; font-size: 13px; }
.msg.agent { background: var(--surface-2); } .msg.user { background: var(--accent-soft); margin-left: auto; } .msg.system { color: var(--muted); font-size: 12px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--border-strong); padding: 10px 16px; border-radius: 8px; z-index: 20; }
@media (max-width: 720px) { .topbar { flex-wrap: wrap; gap: 10px; } #nav { order: 3; width: 100%; overflow-x: auto; } main { padding: 12px; } .kv { grid-template-columns: 1fr; } }
