*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #101418;
  --surface: #171d22;
  --surface2: #202a31;
  --border: #2d3742;
  --text: #eef3f7;
  --muted: #a8b3bf;
  --accent: #8fb6ca;
  --accent-hover: #b8d4e2;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #10b981;
  --warn: #f59e0b;
  --radius: 8px;
  font-size: 15px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  min-height: 100vh;
}

/* ── Login ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-card .eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.login-card h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
}

.login-card p {
  color: var(--muted);
  font-size: 14px;
}

.admin-login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.admin-login-brand > img {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 11px;
}

.admin-login-note {
  display: grid;
  gap: 5px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
}

.admin-login-note span,
.provider-note,
.field-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.admin-google-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  overflow: hidden;
}

.admin-google-button > div,
.admin-google-button iframe {
  display: block !important;
  max-width: 100% !important;
}

/* ── Dashboard ── */
.dashboard { display: flex; flex-direction: column; min-height: 100vh; }

.admin-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.admin-bar-left { display: flex; align-items: center; gap: 12px; }

.admin-brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
}

.admin-identity {
  max-width: 280px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-bar-left .badge {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.admin-bar h1 { font-size: 16px; font-weight: 700; }

.tab-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent-hover); border-bottom-color: var(--accent); }

.tab-panel { display: none; padding: 28px 24px; max-width: 1220px; margin: 0 auto; width: 100%; }
.tab-panel.active { display: block; }

.page-title {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 18px;
  margin-bottom: 20px;
}

.page-title h2 {
  font-size: 24px;
  line-height: 1.1;
  margin: 3px 0 7px;
}

.eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── Forms & Inputs ── */
label { font-size: 13px; font-weight: 500; color: var(--muted); display: block; margin-bottom: 6px; }

input[type=text], input[type=password], input[type=email], input[type=search], textarea, select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  padding: 10px 12px;
  width: 100%;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
}

input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; }
textarea.mono { font-family: "SF Mono", "Fira Code", monospace; font-size: 12px; }

.field-help {
  margin-top: 6px;
}

.admin-access-card {
  display: grid;
  gap: 14px;
  margin-bottom: 26px;
}

.admin-access-card h2 {
  margin-bottom: 5px;
  font-size: 17px;
}

.admin-invite-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  padding: 9px 18px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #315f78; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #21485d; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-sm { padding: 5px 12px; font-size: 13px; }

/* ── Stat cards ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-grid-wide {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.stat-card .label { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 8px; }
.stat-card .value { font-size: 28px; font-weight: 700; color: var(--text); }
.stat-card .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Section headings ── */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  margin-top: 28px;
}

.section-head:first-child { margin-top: 0; }
.section-head h2 { font-size: 15px; font-weight: 700; }

.compact-head {
  margin-top: 0;
  margin-bottom: 10px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.ops-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
}

.range-row { display: flex; gap: 6px; }

.status-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 16px;
}

.analytics-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text);
  font-size: 13px;
}

.toggle-row input {
  width: auto;
  accent-color: var(--accent);
}

.muted-note {
  margin: -6px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.range-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.range-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.range-btn:hover:not(.active) { color: var(--text); }

/* ── Tables ── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { background: var(--surface2); }
thead th { text-align: left; padding: 10px 14px; font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: 0.05em; text-transform: uppercase; white-space: nowrap; }
tbody tr { border-top: 1px solid var(--border); }
tbody tr:hover { background: var(--surface2); }
tbody td { padding: 10px 14px; vertical-align: middle; }
.cell-muted { color: var(--muted); }
.cell-mono { font-family: "SF Mono", monospace; font-size: 12px; color: var(--muted); }

.tag-pill {
  display: inline-block;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  padding: 1px 7px;
  color: var(--muted);
  margin: 1px 2px 1px 0;
}

.tag-pill.good {
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.12);
  color: #86efac;
}

.tag-pill.danger {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
}

.tag-pill.warn {
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.12);
  color: #fcd34d;
}

.tag-pill.class-pill {
  border-color: rgba(99, 102, 241, 0.45);
  background: rgba(99, 102, 241, 0.14);
  color: #c7d2fe;
}

.tag-pill.featured-pill {
  border-color: rgba(143, 182, 202, 0.48);
  background: rgba(143, 182, 202, 0.14);
  color: #d5e8f2;
}

.tag-pill.past-pill {
  border-color: rgba(148, 163, 184, 0.4);
  background: rgba(148, 163, 184, 0.12);
  color: #cbd5e1;
}

.queue-list {
  display: grid;
  gap: 8px;
}

.queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text);
}

.queue-item strong {
  font-size: 18px;
}

.queue-item.good strong { color: var(--success); }
.queue-item.warn strong { color: var(--warn); }
.queue-item.danger strong { color: var(--danger); }

.admin-note {
  margin-top: 6px;
  padding: 7px 9px;
  border-left: 2px solid var(--accent);
  color: var(--muted);
  background: rgba(143, 182, 202, 0.08);
}

.event-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 5px;
}
.dot-load { background: var(--accent); }
.dot-start { background: var(--warn); }
.dot-complete { background: var(--success); }

/* ── Empty / loading state ── */
.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error ── */
.error-msg {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius);
  color: #fca5a5;
  font-size: 13px;
  padding: 10px 14px;
}

/* ── Search row ── */
.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
}

.search-row input,
.search-row select { max-width: 320px; }

/* ── Modal ── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open { display: flex; }

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-card h2 { font-size: 18px; font-weight: 700; }

.modal-actions { display: flex; gap: 10px; margin-top: 4px; }

.field { display: flex; flex-direction: column; gap: 6px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ── Confirm dialog ── */
#confirmBackdrop .modal-card { max-width: 420px; }
#confirmBackdrop p { color: var(--muted); font-size: 14px; line-height: 1.6; }

/* ── Misc ── */
.hidden { display: none !important; }
.flex-gap { display: flex; gap: 8px; align-items: center; }
.flex-gap.wrap { flex-wrap: wrap; }
.left-align { text-align: left; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warn { color: var(--warn); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
@media (max-width: 900px) {
  .dashboard-grid,
  .stat-grid-wide,
  .two-col {
    grid-template-columns: 1fr;
  }

  .page-title {
    display: grid;
  }
}

@media (max-width: 700px) {
  .form-grid { grid-template-columns: 1fr; }
  .admin-bar { padding: 0 14px; }
  .admin-identity { display: none; }
  .admin-invite-row { grid-template-columns: 1fr; }
  .tab-bar { padding: 0 14px; }
  .tab-btn { padding: 12px 10px; }
  .tab-panel { padding: 20px 14px; }
  .modal-actions { flex-direction: column; }
  .btn { width: 100%; }
  .flex-gap .btn { width: auto; }
}

.chart-card {
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.chart-card .section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.chart-legend {
  display: flex;
  gap: 14px;
  font-size: 0.8rem;
  color: var(--muted);
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.legend-swatch.human { background: var(--accent); }
.legend-swatch.bot { background: var(--border); }
.daily-chart { width: 100%; }
.daily-chart-svg { width: 100%; height: auto; display: block; }
.daily-chart-svg .bar-human { fill: var(--accent); }
.daily-chart-svg .bar-bot { fill: var(--border); }
.daily-chart-svg .bar-human:hover,
.daily-chart-svg .bar-bot:hover { fill: var(--accent-hover); }
.daily-chart-svg .chart-grid { stroke: var(--border); stroke-width: 1; opacity: 0.5; }
.daily-chart-svg .chart-axis-label { fill: var(--muted); font-size: 11px; }

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
  .stat-card { padding: 13px; }
  .stat-card .value { font-size: 22px; }
  .stat-card .label { margin-bottom: 6px; }
}
