:root {
  --bg: #0b1220;
  --panel: #121a2b;
  --panel2: #182338;
  --border: #243049;
  --text: #e8eefc;
  --muted: #93a0b8;
  --primary: #3b82f6;
  --primary-press: #2563eb;
  --danger: #ef4444;
  --warn: #f59e0b;
  --ok: #22c55e;
  --chip: #1e293b;
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font); min-height: 100%; }
button, input, textarea { font: inherit; }
button { cursor: pointer; border: 1px solid var(--border); background: var(--panel2); color: var(--text); border-radius: 10px; padding: 0.55rem 0.9rem; }
button.primary { background: var(--primary); border-color: transparent; font-weight: 600; }
button.primary:hover { background: var(--primary-press); }
button.danger { background: #7f1d1d; border-color: #991b1b; }
button.ghost { background: transparent; }
button.link { background: none; border: none; color: var(--primary); padding: 0; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
input, textarea { width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 10px; padding: 0.6rem 0.75rem; }
label { display: grid; gap: 0.35rem; font-size: 0.9rem; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 0.75rem; }
.error { color: #fca5a5; }
.row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; }
.stack-gap { display: grid; gap: 0.5rem; margin: 0.5rem 0; }
.check { display: flex; align-items: center; gap: 0.5rem; }

.view { min-height: 100vh; }
#view-login { display: grid; place-items: center; padding: 1.5rem; }
.login-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 1.5rem; display: grid; gap: 0.85rem; }
.brand { display: flex; gap: 0.75rem; align-items: center; }
.brand h1 { margin: 0; font-size: 1.35rem; }
.brand p { margin: 0.15rem 0 0; }
.logo { width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, #3b82f6, #8b5cf6); display: grid; place-items: center; font-weight: 800; }
.logo.sm { width: 28px; height: 28px; font-size: 0.7rem; border-radius: 8px; }

.topbar { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; justify-content: space-between; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); background: rgba(18,26,43,0.9); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(8px); }
.brand.mini { display: flex; gap: 0.5rem; align-items: center; }
.day-strip { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.stat { background: var(--panel2); border: 1px solid var(--border); border-radius: 999px; padding: 0.25rem 0.65rem; font-size: 0.75rem; }
.stat strong { color: #fff; }
.badge { font-size: 0.65rem; padding: 0.15rem 0.45rem; border-radius: 999px; background: var(--chip); border: 1px solid var(--border); }
.badge.warn { background: #78350f; border-color: #b45309; }
.badge.danger { background: #7f1d1d; border-color: #b91c1c; }
.pill { display: inline-block; padding: 0.2rem 0.55rem; border-radius: 999px; background: #1d4ed8; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; }

.tabs { display: flex; gap: 0.25rem; padding: 0.5rem 1rem; border-bottom: 1px solid var(--border); }
.tab { background: transparent; border: none; color: var(--muted); border-radius: 8px; }
.tab.active { background: var(--panel2); color: var(--text); }
.tab-panel { padding: 1rem; }
.toolbar { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.75rem; flex-wrap: wrap; }

.lanes { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.75rem; }
.lane { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); min-height: 180px; display: flex; flex-direction: column; }
.lane-h { padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 0.85rem; display: flex; justify-content: space-between; }
.lane-body { padding: 0.5rem; display: grid; gap: 0.5rem; overflow: auto; max-height: 70vh; }
.lead-card { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 0.6rem 0.7rem; cursor: pointer; }
.lead-card.selected { outline: 2px solid var(--primary); }
.lead-card h4 { margin: 0 0 0.2rem; font-size: 0.92rem; }
.lead-card p { margin: 0.1rem 0; font-size: 0.78rem; color: var(--muted); }
.lead-card .meta { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-top: 0.35rem; }

.live-panel { display: grid; gap: 0.75rem; }
.live-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: flex-start; }
.live-head h2 { margin: 0; font-size: 1.2rem; }
.live-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 0.75rem; }
@media (max-width: 900px) {
  .live-grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
}
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem; }
.card-h { font-weight: 600; margin-bottom: 0.5rem; display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.transcript { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; min-height: 280px; max-height: 55vh; overflow: auto; padding: 0.75rem; display: grid; gap: 0.55rem; }
.bubble { max-width: 92%; padding: 0.5rem 0.7rem; border-radius: 12px; font-size: 0.9rem; line-height: 1.35; }
.bubble.user { background: #1e293b; justify-self: start; }
.bubble.assistant { background: #1e3a5f; justify-self: end; }
.btn-col { display: grid; gap: 0.45rem; margin-bottom: 0.75rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.5rem; }
.chip { background: var(--chip); border: 1px solid var(--border); border-radius: 999px; padding: 0.35rem 0.65rem; font-size: 0.78rem; }
.chip.active { background: #1d4ed8; border-color: #3b82f6; }
.timer-bar { position: relative; height: 28px; background: #0f172a; border-radius: 8px; overflow: hidden; margin: 0.5rem 0; border: 1px solid var(--border); }
.timer-fill { position: absolute; inset: 0 auto 0 0; width: 100%; background: linear-gradient(90deg, #22c55e, #eab308, #ef4444); opacity: 0.35; transition: width 0.2s linear; }
#timer-label { position: relative; z-index: 1; display: grid; place-items: center; height: 100%; font-size: 0.8rem; }
.empty { padding: 3rem 1rem; text-align: center; color: var(--muted); }
.list { list-style: none; padding: 0; margin: 0.5rem 0 0; display: grid; gap: 0.35rem; }
.list li { background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 0.45rem 0.6rem; font-size: 0.85rem; }
.list.compact li { font-size: 0.8rem; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0.75rem; }
.health { background: var(--bg); border-radius: 8px; padding: 0.6rem; font-size: 0.75rem; overflow: auto; color: var(--muted); }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: grid; place-items: center; z-index: 50; padding: 1rem; }
.modal-card { width: min(520px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 1.1rem; display: grid; gap: 0.75rem; }
.modal-card h3 { margin: 0; }
