/* ═══════════════════════════════════════════════════════
   ComplianceOS — Design System
   Dark sidebar · Light content · Traffic-light status
   ═══════════════════════════════════════════════════════ */

:root {
  /* Sidebar */
  --sb-bg:           #0F1629;
  --sb-border:       rgba(255,255,255,0.06);
  --sb-text:         rgba(255,255,255,0.45);
  --sb-text-hover:   rgba(255,255,255,0.80);
  --sb-text-active:  #FFFFFF;
  --sb-link-hover:   rgba(255,255,255,0.06);
  --sb-link-active:  rgba(59,130,246,0.18);
  --sb-accent:       #3B82F6;
  --sb-w:            240px;

  /* Brand / Primary */
  --primary:         #2563EB;
  --primary-dark:    #1D4ED8;
  --primary-light:   #DBEAFE;
  --primary-ring:    rgba(37,99,235,0.18);

  /* Page chrome */
  --bg:              #F0F4FA;
  --surface:         #FFFFFF;
  --surface-2:       #F8FAFC;
  --border:          #E2E8F0;
  --border-strong:   #CBD5E1;

  /* Typography */
  --text-1:          #0F172A;
  --text-2:          #475569;
  --text-3:          #94A3B8;

  /* Traffic-light status */
  --green:           #16A34A;
  --green-bg:        #DCFCE7;
  --green-border:    #86EFAC;
  --red:             #DC2626;
  --red-bg:          #FEE2E2;
  --red-border:      #FECACA;
  --amber:           #B45309;
  --amber-bg:        #FEF3C7;
  --amber-border:    #FDE68A;
  --sky:             #0369A1;
  --sky-bg:          #E0F2FE;
  --sky-border:      #7DD3FC;

  /* Elevation */
  --e1: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --e2: 0 4px 6px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
  --e3: 0 10px 20px rgba(0,0,0,0.08), 0 4px 8px rgba(0,0,0,0.04);
  --e4: 0 20px 40px rgba(0,0,0,0.10), 0 8px 16px rgba(0,0,0,0.05);

  /* Radii */
  --r-xs:   6px;
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   20px;
  --r-full: 9999px;

  /* Motion */
  --ease:   cubic-bezier(0.4, 0, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  color: var(--text-1);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ══════════════════════════════════════════════════════
   AUTH PAGES (Login / Register)
   ══════════════════════════════════════════════════════ */

.auth-body {
  background: var(--sb-bg);
  min-height: 100vh;
  display: flex;
}

.auth-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Left dark panel */
.auth-brand-panel {
  width: 420px;
  flex-shrink: 0;
  background: var(--sb-bg);
  padding: 3rem 3.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.auth-brand-panel::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(37,99,235,0.12) 0%, transparent 70%);
  top: -200px;
  left: -200px;
  pointer-events: none;
}

.auth-brand-panel::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59,130,246,0.08) 0%, transparent 70%);
  bottom: -100px;
  right: -100px;
  pointer-events: none;
}

.auth-brand-inner { position: relative; z-index: 1; }

.auth-logo {
  width: 48px;
  height: 48px;
  border-radius: var(--r-md);
  background: var(--sb-link-active);
  border: 1px solid rgba(59,130,246,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sb-accent);
  margin-bottom: 1.75rem;
}

.auth-brand-sub {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sb-accent);
  margin-bottom: 0.5rem;
}

.auth-brand-name {
  font-size: 1.75rem;
  font-weight: 800;
  color: #FFFFFF;
  letter-spacing: -0.03em;
  margin-bottom: 0.75rem;
}

.auth-tagline {
  font-size: 1rem;
  color: rgba(255,255,255,0.5);
  margin-bottom: 2rem;
  line-height: 1.5;
}

.auth-features {
  list-style: none;
  display: grid;
  gap: 0.75rem;
}

.auth-features li {
  font-size: 0.875rem;
  color: rgba(255,255,255,0.55);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.auth-features li::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sb-accent);
  flex-shrink: 0;
  opacity: 0.8;
}

/* Right form panel */
.auth-form-panel {
  flex: 1;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem;
}

.auth-form-inner {
  width: min(400px, 100%);
  animation: fadeSlideUp 480ms var(--ease) both;
}

.auth-heading h2 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-1);
  margin-bottom: 0.35rem;
}

.auth-heading p {
  font-size: 0.9rem;
  color: var(--text-2);
  margin-bottom: 1.75rem;
}

.auth-form {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.field-label {
  display: grid;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-1);
}

.field-hint {
  font-weight: 400;
  color: var(--text-3);
  font-size: 0.8rem;
}

.auth-form input {
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-1);
  padding: 0.65rem 0.85rem;
  font-size: 1rem;
  font-family: inherit;
  width: 100%;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}

.auth-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.form-error {
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  border-radius: var(--r-sm);
  padding: 0.65rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--red);
  margin-bottom: 0.5rem;
}

.flash-msg {
  background: var(--green-bg);
  border: 1px solid var(--green-border);
  border-radius: var(--r-sm);
  padding: 0.65rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--green);
  margin-bottom: 0.5rem;
}

.auth-switch {
  font-size: 0.875rem;
  color: var(--text-2);
  text-align: center;
  margin-top: 1rem;
}

/* ══════════════════════════════════════════════════════
   APP LAYOUT (authenticated pages)
   ══════════════════════════════════════════════════════ */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: var(--sb-w);
  background: var(--sb-bg);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform 280ms var(--ease);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 190;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.visible { display: block; }

/* Brand area */
.sidebar-top {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--r-xs);
  background: var(--sb-link-active);
  border: 1px solid rgba(59,130,246,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sb-accent);
  flex-shrink: 0;
}

.brand-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sb-accent);
  line-height: 1;
  margin-bottom: 0.2rem;
}

.brand-name {
  font-size: 0.95rem;
  font-weight: 800;
  color: #FFFFFF;
  letter-spacing: -0.01em;
  line-height: 1;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 1.25rem 0.75rem;
  display: grid;
  align-content: start;
  gap: 0.15rem;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sb-text);
  padding: 0.75rem 0.5rem 0.35rem;
  margin-top: 0.25rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--r-sm);
  color: var(--sb-text);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 150ms var(--ease), color 150ms var(--ease);
  position: relative;
}

.sidebar-link:hover {
  background: var(--sb-link-hover);
  color: var(--sb-text-hover);
  text-decoration: none;
}

.sidebar-link.active {
  background: var(--sb-link-active);
  color: var(--sb-text-active);
  font-weight: 600;
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--sb-accent);
  border-radius: 0 2px 2px 0;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--sb-border);
  flex-shrink: 0;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--sb-link-active);
  border: 1px solid rgba(59,130,246,0.25);
  color: var(--sb-accent);
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(255,255,255,0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.72rem;
  color: var(--sb-text);
  text-transform: capitalize;
}

.logout-form { margin: 0; }

.logout-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--r-xs);
  border: 1px solid rgba(255,255,255,0.08);
  background: transparent;
  color: var(--sb-text);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 140ms var(--ease), color 140ms var(--ease);
}

.logout-btn:hover {
  background: rgba(239,68,68,0.1);
  color: #FCA5A5;
  border-color: rgba(239,68,68,0.2);
}

/* ── Main area ───────────────────────────────────────── */
.main-area {
  margin-left: var(--sb-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

.mobile-topbar {
  display: none;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1rem;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--e1);
}

/* Hamburger */
.hamburger {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0;
  transition: background 140ms var(--ease);
}

.hamburger:hover { background: var(--surface-2); }

.hamburger span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: var(--text-2);
  border-radius: 1px;
  transition: transform 260ms var(--ease), opacity 200ms var(--ease);
}

.hamburger.open span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-1);
}

.mobile-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.main-content {
  flex: 1;
  padding: 2rem 2.25rem;
  max-width: 1120px;
  width: 100%;
  display: grid;
  gap: 1.5rem;
  align-content: start;
}

.flash-notice {
  background: var(--primary-light);
  border: 1px solid rgba(37,99,235,0.22);
  border-radius: var(--r-sm);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary-dark);
  animation: fadeIn 280ms var(--ease);
}

.main-footer {
  padding: 1rem 2.25rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.main-footer p {
  font-size: 0.78rem;
  color: var(--text-3);
}

/* ══════════════════════════════════════════════════════
   PAGE HEADER
   ══════════════════════════════════════════════════════ */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  animation: fadeSlideUp 420ms var(--ease) both;
}

.page-eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-1);
}

.page-date {
  font-size: 0.83rem;
  color: var(--text-3);
  font-weight: 500;
  padding-top: 0.2rem;
}

.header-stats {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ══════════════════════════════════════════════════════
   STAT CHIPS
   ══════════════════════════════════════════════════════ */

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  animation: fadeSlideUp 420ms var(--ease) 60ms both;
}

.stat-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  box-shadow: var(--e1);
  transition: transform 220ms var(--ease), box-shadow 220ms var(--ease);
}

.stat-chip:hover { transform: translateY(-2px); box-shadow: var(--e2); }

.stat-icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-active  .stat-icon-wrap { background: var(--green-bg);   color: var(--green); }
.stat-inactive .stat-icon-wrap { background: var(--surface-2);  color: var(--text-3); }
.stat-neutral  .stat-icon-wrap { background: var(--primary-light); color: var(--primary); }

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
}

.stat-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-1);
}

.stat-active  .stat-value { color: var(--green); }
.stat-inactive .stat-value { color: var(--text-3); }

/* ══════════════════════════════════════════════════════
   CONTROL CARDS (Weekly / Monthly / On-Demand)
   ══════════════════════════════════════════════════════ */

.controls-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.control-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.4rem;
  display: grid;
  gap: 1rem;
  box-shadow: var(--e1);
  transition: transform 240ms var(--ease), box-shadow 240ms var(--ease);
  position: relative;
  overflow: hidden;
}

.control-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #60A5FA);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 260ms var(--ease);
}

.control-card:hover { transform: translateY(-3px); box-shadow: var(--e3); }
.control-card:hover::after { transform: scaleX(1); }

.control-card:nth-child(1) { animation: fadeSlideUp 480ms var(--ease) 100ms both; }
.control-card:nth-child(2) { animation: fadeSlideUp 480ms var(--ease) 180ms both; }
.control-card:nth-child(3) { animation: fadeSlideUp 480ms var(--ease) 260ms both; }

.control-head {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
}

.control-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--r-sm);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.control-meta { flex: 1; min-width: 0; }

.control-meta h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 0.15rem;
}

.control-meta p {
  font-size: 0.78rem;
  color: var(--text-3);
  font-weight: 500;
}

.control-desc {
  font-size: 0.855rem;
  color: var(--text-2);
  line-height: 1.6;
}

/* ── Toggle ──────────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  min-height: 44px;
  padding: 0.1rem 0;
}

.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }

.toggle-track {
  width: 44px;
  height: 26px;
  border-radius: var(--r-full);
  background: var(--border-strong);
  position: relative;
  flex-shrink: 0;
  transition: background 200ms var(--ease);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}

.toggle-track::after {
  content: '';
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 4px;
  left: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: transform 320ms var(--spring);
}

.toggle-row input:checked + .toggle-track { background: var(--primary); }
.toggle-row input:checked + .toggle-track::after { transform: translateX(18px); }

/* ── Status pill (in control card header) ───────────── */
.status-pill {
  border-radius: var(--r-full);
  padding: 0.22rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
  flex-shrink: 0;
}

.status-pill.ok  { background: var(--green-bg);  color: var(--green); border: 1px solid var(--green-border); }
.status-pill.off { background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border); }

/* ══════════════════════════════════════════════════════
   BADGES
   ══════════════════════════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: var(--r-full);
  padding: 0.22rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge-green  { background: var(--green-bg);  color: var(--green);  border-color: var(--green-border); }
.badge-red    { background: var(--red-bg);    color: var(--red);    border-color: var(--red-border); }
.badge-amber  { background: var(--amber-bg);  color: var(--amber);  border-color: var(--amber-border); }
.badge-sky    { background: var(--sky-bg);    color: var(--sky);    border-color: var(--sky-border); }
.badge-gray   { background: var(--surface-2); color: var(--text-3); border-color: var(--border); }

/* ══════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════ */

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  border-radius: var(--r-sm);
  background: var(--primary);
  color: #fff;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 0.65rem 1.1rem;
  min-height: 40px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background 160ms var(--ease), transform 130ms var(--ease), box-shadow 160ms var(--ease);
  letter-spacing: 0.01em;
  text-decoration: none;
}

.btn-primary:hover:enabled {
  background: var(--primary-dark);
  box-shadow: var(--e2);
  transform: translateY(-1px);
  text-decoration: none;
}

.btn-primary:active:enabled { transform: translateY(0); box-shadow: none; }

.btn-primary:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  background: var(--text-3);
}

.btn-primary.full-width { width: 100%; }

.btn-sm {
  font-size: 0.8rem;
  padding: 0.4rem 0.75rem;
  min-height: 32px;
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
}

.btn-ghost:hover:enabled {
  background: var(--border);
  color: var(--text-1);
  box-shadow: none;
}

/* Ripple */
.ripple-wave {
  position: absolute;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.4);
  transform: scale(0);
  animation: ripple 600ms linear forwards;
  pointer-events: none;
  margin-left: -20px;
  margin-top: -20px;
}

/* Spinner */
.btn-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════
   TABLE CARDS
   ══════════════════════════════════════════════════════ */

.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--e1);
  overflow: hidden;
  animation: fadeSlideUp 480ms var(--ease) 320ms both;
}

.table-card + .table-card { animation-delay: 400ms; }
.table-card + .table-card + .table-card { animation-delay: 480ms; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.section-header h2 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.01em;
}

.section-sub {
  font-size: 0.78rem;
  color: var(--text-3);
  font-weight: 400;
  margin-top: 0.1rem;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--green);
  background: var(--green-bg);
  border: 1px solid var(--green-border);
  border-radius: var(--r-full);
  padding: 0.22rem 0.65rem;
  animation: pulse-ring 2.5s ease infinite;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
}

th {
  text-align: left;
  padding: 0.6rem 1rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--text-1);
  border-bottom: 1px solid var(--border);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 130ms var(--ease); }
tbody tr:hover { background: var(--surface-2); }

.empty-row {
  color: var(--text-3);
  font-size: 0.875rem;
  padding: 2rem 1rem !important;
  text-align: center;
}

.text-muted { color: var(--text-3); }

/* Run type dot */
.run-type-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  margin-right: 0.5rem;
  vertical-align: middle;
  opacity: 0.7;
}

/* User cell in admin table */
.user-cell {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.cell-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cell-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-1);
}

.cell-email {
  font-size: 0.78rem;
  color: var(--text-3);
}

.row-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.row-actions form { margin: 0; }

/* ══════════════════════════════════════════════════════
   KEYFRAMES
   ══════════════════════════════════════════════════════ */

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes ripple {
  from { transform: scale(0); opacity: 0.5; }
  to   { transform: scale(4); opacity: 0; }
}

@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(22,163,74,0.4); }
  70%  { box-shadow: 0 0 0 6px rgba(22,163,74,0); }
  100% { box-shadow: 0 0 0 0 rgba(22,163,74,0); }
}

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

@keyframes rowSlideIn {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Row enter classes driven by JS */
tbody tr.row-enter   { opacity: 0; transform: translateX(-12px); }
tbody tr.row-visible { animation: rowSlideIn 320ms var(--ease) forwards; }

/* ══════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════ */

/* ─ 960px ──────────────────────────────────────────────── */
@media (max-width: 960px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .controls-grid { grid-template-columns: 1fr; }

  .control-card:nth-child(1),
  .control-card:nth-child(2),
  .control-card:nth-child(3) { animation-delay: 100ms; }

  .main-content { padding: 1.5rem; gap: 1.25rem; }
}

/* ─ 768px : sidebar collapses ───────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.45);
  }

  .main-area { margin-left: 0; }

  .mobile-topbar { display: flex; }

  /* Auth */
  .auth-brand-panel { width: 200px; padding: 2rem; }
  .auth-brand-name  { font-size: 1.25rem; }
  .auth-tagline     { display: none; }
  .auth-features    { display: none; }
  .auth-form-panel  { padding: 2rem 1.5rem; }
}

/* ─ 600px ───────────────────────────────────────────── */
@media (max-width: 600px) {
  .stat-row { grid-template-columns: 1fr 1fr; gap: 0.75rem; }

  .main-content { padding: 1rem; gap: 1rem; }

  .page-title { font-size: 1.3rem; }

  .stat-chip { padding: 0.85rem 1rem; gap: 0.7rem; }
  .stat-icon-wrap { width: 34px; height: 34px; }
  .stat-value { font-size: 0.95rem; }

  .control-card { padding: 1.1rem; }

  .section-header { padding: 0.9rem 1rem; }
  th { padding: 0.5rem 0.75rem; }
  td { padding: 0.6rem 0.75rem; }

  .row-actions { flex-direction: column; }
  .row-actions .btn-primary { width: 100%; }

  .main-content { padding: 0.875rem; gap: 0.875rem; }

  /* Auth: hide brand panel on small phones */
  .auth-brand-panel { display: none; }
  .auth-form-panel { padding: 2rem 1.25rem; background: var(--bg); }
  .auth-form-inner { width: 100%; }

  .main-footer { padding: 0.875rem 1rem; }
}

/* ─ 400px ───────────────────────────────────────────── */
@media (max-width: 400px) {
  .stat-row { grid-template-columns: 1fr; }
  .main-content { padding: 0.75rem; gap: 0.75rem; }
  .page-title { font-size: 1.15rem; }
}

/* ══════════════════════════════════════════════════════
   FORM CARDS (groups / settings)
   ══════════════════════════════════════════════════════ */

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--e1);
  padding: 1.75rem 2rem;
  animation: fadeSlideUp 480ms var(--ease) 160ms both;
}

.card-heading {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-1);
  margin: 0 0 0.4rem;
}

.card-desc {
  font-size: 0.875rem;
  color: var(--text-2);
  margin: 0 0 1.25rem;
  line-height: 1.55;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1.5rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.notice-warn {
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  color: var(--amber);
  border-radius: var(--r-sm);
  padding: 0.6rem 0.875rem;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 1rem;
}

.status-facts {
  margin: 1rem 0;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.fact-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0.875rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border);
}

.fact-row:last-child { border-bottom: none; }
.fact-row span:first-child { color: var(--text-2); }
.fact-row span:last-child  { font-weight: 500; }

/* ══════════════════════════════════════════════════════
   UPLOAD ZONE
   ══════════════════════════════════════════════════════ */

.upload-zone {
  position: relative;
  border: 2px dashed var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 200ms, background 200ms;
  margin-bottom: 0.5rem;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}

.upload-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.upload-icon {
  color: var(--text-3);
  margin-bottom: 0.75rem;
  display: flex;
  justify-content: center;
}

.upload-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-1);
  margin: 0 0 0.25rem;
}

.upload-sub {
  font-size: 0.875rem;
  color: var(--text-2);
  margin: 0 0 0.5rem;
}

.upload-link { color: var(--primary); text-decoration: underline; }

.upload-hint {
  font-size: 0.78rem;
  color: var(--text-3);
  margin: 0.25rem 0 0;
  line-height: 1.5;
}

.upload-hint code {
  background: var(--border);
  border-radius: 3px;
  padding: 0 4px;
  font-size: 0.75rem;
}

.upload-filename {
  font-size: 0.83rem;
  color: var(--primary);
  font-weight: 500;
  margin: 0.4rem 0 0;
  min-height: 1.2em;
}

/* ══════════════════════════════════════════════════════
   SCREENING RESULT ROWS
   ══════════════════════════════════════════════════════ */

.result-excluded td { background: var(--red-bg); }
.result-excluded td:first-child { border-left: 3px solid var(--red); }

.result-review td { background: var(--amber-bg); }
.result-review td:first-child { border-left: 3px solid var(--amber); }

.result-excl { color: var(--red); font-weight: 600; }
.result-rev  { color: var(--amber); font-weight: 600; }

/* ══════════════════════════════════════════════════════
   PROGRESS BAR
   ══════════════════════════════════════════════════════ */

.progress-wrap {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.5rem 0;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 600ms ease;
}

.progress-label {
  font-size: 0.83rem;
  color: var(--text-2);
  margin: 0 0 1rem;
}

/* ══════════════════════════════════════════════════════
   MISC PAGE HELPERS
   ══════════════════════════════════════════════════════ */

.flash-error {
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  color: var(--red);
  border-radius: var(--r-sm);
  padding: 0.7rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 1rem;
}

.meta-row {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.page-sub {
  font-size: 0.875rem;
  color: var(--text-2);
  margin: 0.2rem 0 0;
}

.small-text { font-size: 0.8rem; }

.stat-danger { border-color: var(--red-border); background: var(--red-bg); }
.stat-warn   { border-color: var(--amber-border); background: var(--amber-bg); }

/* ─ responsive: settings / form-card ─────────────────── */
@media (max-width: 960px) {
  .settings-grid  { grid-template-columns: 1fr; }
  .form-grid-2    { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .form-card { padding: 1.1rem 1rem; }
  .upload-zone { padding: 1.5rem 1rem; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .meta-row { gap: 0.6rem; }
}

/* ══════════════════════════════════════════════════════
   SIDEBAR SEARCH BUTTON
   ══════════════════════════════════════════════════════ */

.sidebar-search-btn {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: calc(100% - 1.5rem);
  margin: 0.5rem 0.75rem 0.25rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--r-sm);
  color: var(--sb-text-hover);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms, color 150ms;
  font-family: inherit;
}

.sidebar-search-btn:hover {
  background: rgba(255,255,255,0.1);
  color: var(--sb-text-active);
}

.sidebar-search-btn kbd {
  margin-left: auto;
  font-size: 0.7rem;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: inherit;
  color: var(--sb-text);
  pointer-events: none;
}

/* ══════════════════════════════════════════════════════
   SEARCH MODAL
   ══════════════════════════════════════════════════════ */

.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(15, 22, 41, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: clamp(3rem, 10vh, 8rem);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.search-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.search-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: 0 24px 64px rgba(0,0,0,0.24), 0 4px 16px rgba(0,0,0,0.1);
  width: min(600px, calc(100vw - 2rem));
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
  transform: translateY(-12px) scale(0.98);
  transition: transform 220ms var(--ease), opacity 220ms ease;
  opacity: 0;
}

.search-overlay.open .search-modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.search-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.search-modal-title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--primary);
}

.search-modal-title-row h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-1);
  margin: 0;
}

.modal-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: background 150ms, color 150ms, border-color 150ms;
}

.modal-close-btn:hover {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-1);
}

/* Search form */
.search-form {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  border-bottom: 1px solid var(--border);
}

.search-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.875rem;
}

.search-submit-btn {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Search results area */
.search-results {
  padding: 0 1.5rem 1.5rem;
  min-height: 2rem;
}

.search-loading {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.5rem 0;
  color: var(--text-2);
  font-size: 0.875rem;
}

.search-verdict {
  padding: 1.25rem 0 0.75rem;
}

.verdict-row {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-bottom: 0.75rem;
}

.verdict-badge {
  font-size: 1rem;
  font-weight: 700;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.verdict-badge.excluded {
  background: var(--red-bg);
  color: var(--red);
  border: 1.5px solid var(--red-border);
}

.verdict-badge.review {
  background: var(--amber-bg);
  color: var(--amber);
  border: 1.5px solid var(--amber-border);
}

.verdict-badge.clear {
  background: var(--green-bg);
  color: var(--green);
  border: 1.5px solid var(--green-border);
}

.verdict-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-1);
}

.verdict-sub {
  font-size: 0.8rem;
  color: var(--text-2);
}

/* Source sections (OIG / SAM) */
.search-source-section {
  margin-top: 1rem;
}

.source-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.source-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
}

.source-status {
  font-size: 0.72rem;
}

.match-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0.65rem 0.875rem;
  margin-bottom: 0.4rem;
  font-size: 0.8rem;
}

.match-card-name {
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 0.2rem;
}

.match-card-meta {
  color: var(--text-2);
  line-height: 1.5;
}

.match-score {
  float: right;
  font-size: 0.72rem;
  color: var(--text-3);
  font-weight: 500;
}

.no-matches-note {
  font-size: 0.8rem;
  color: var(--text-3);
  padding: 0.5rem 0;
}

.search-error-msg {
  color: var(--red);
  font-size: 0.875rem;
  padding: 1rem 0;
}

/* ─ responsive: modal ────────────────────────────────── */
@media (max-width: 600px) {
  .search-overlay { padding-top: 1rem; align-items: flex-end; }
  .search-modal {
    width: 100%;
    max-height: 92vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }
  .search-form-row { grid-template-columns: 1fr; }
}
