:root {
  --bg: #0b0f17;
  --surface: #131a26;
  --surface-2: #1b2434;
  --border: #283548;
  --text: #eef2f8;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --ok: #10b981;
  --warn: #f59e0b;
  --err: #ef4444;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.brand-mark { font-weight: 700; font-size: 15px; letter-spacing: 0.2px; color: #fff; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 390px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
}
.login-card h1 { margin: 10px 0 6px; font-size: 20px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.banner {
  padding: 10px 20px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.banner.warn { background: rgba(245, 158, 11, 0.14); color: #fcd34d; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 8px 20px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-weight: 500;
}
.tab.active { color: #fff; border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.container { max-width: 1380px; margin: 0 auto; padding: 20px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.card h3 { margin: 0 0 12px; font-size: 15px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-val { font-size: 24px; font-weight: 700; margin-top: 4px; }

.filter-bar, .section-head, .inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.section-head { justify-content: space-between; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
input, select, textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.span-2 { grid-column: span 2; }

.btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
  display: inline-block;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.ghost { background: transparent; }
.btn.full { width: 100%; margin-top: 10px; }

.pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.pill.ok { background: rgba(16, 185, 129, 0.16); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.35); }
.pill.warn { background: rgba(245, 158, 11, 0.16); color: #fcd34d; border-color: rgba(245, 158, 11, 0.35); }
.pill.err { background: rgba(239, 68, 68, 0.16); color: #fca5a5; border-color: rgba(239, 68, 68, 0.35); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tr.clickable:hover { background: var(--surface-2); cursor: pointer; }

.events-list { max-height: 360px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.event-row { padding: 8px 10px; background: var(--surface-2); border-radius: 6px; font-size: 12px; }

.transcript {
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--bg);
  border-radius: 8px;
  margin: 10px 0;
}
.msg-bubble { max-width: 82%; padding: 8px 12px; border-radius: 10px; font-size: 13px; }
.msg-bubble.user { align-self: flex-start; background: var(--surface-2); }
.msg-bubble.assistant { align-self: flex-end; background: #1d4ed8; color: #fff; }
.msg-meta { font-size: 11px; opacity: 0.7; margin-top: 2px; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-card {
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}
.error-msg { color: #fca5a5; font-size: 12px; margin-top: 6px; }
.ok-msg { color: #6ee7b7; font-size: 13px; }

@media (max-width: 900px) {
  .grid-2, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
}
