/* ===================================================================
   CivicAI Platform Prototype — Design System
   Static demo only. Tokens + reusable components used by every screen.
=================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=DM+Sans:wght@400;500;600;700&display=swap');

/* ---------- Tokens ---------- */
:root {
  /* Color */
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-active: #1e40af;
  --color-primary-soft: #e8f0fe;
  --color-on-primary: #ffffff;

  --color-navy: #0f172a;
  --color-navy-soft: #1e293b;

  --color-accent: #f59e0b;
  --color-accent-soft: #fef3c7;

  --color-success: #16a34a;
  --color-success-soft: #dcfce7;
  --color-warning: #d97706;
  --color-warning-soft: #fef3c7;
  --color-danger: #dc2626;
  --color-danger-soft: #fee2e2;
  --color-info: #0369a1;
  --color-info-soft: #e0f2fe;

  --color-bg: #f6f8fb;
  --color-surface: #ffffff;
  --color-surface-alt: #f1f5f9;
  --color-foreground: #0f172a;
  --color-muted: #64748b;
  --color-muted-light: #94a3b8;
  --color-border: #e2e8f0;
  --color-border-strong: #cbd5e1;
  --color-ring: #2563eb;

  /* Type */
  --font-heading: 'Space Grotesk', 'DM Sans', sans-serif;
  --font-body: 'DM Sans', -apple-system, sans-serif;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;
  --text-4xl: 2.5rem;

  /* Spacing (4/8 rhythm) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 999px;

  /* Shadow */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12), 0 4px 8px rgba(15, 23, 42, 0.04);
  --shadow-focus: 0 0 0 4px rgba(37, 99, 235, 0.25);

  /* Motion */
  --dur-fast: 150ms;
  --dur-base: 220ms;
  --dur-slow: 360ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.7, 0, 0.84, 0);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Layout */
  --header-h: 64px;
  --bottom-nav-h: 68px;
  --sidebar-w: 264px;
  --max-mobile: 480px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--color-foreground);
  background: var(--color-bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 var(--space-2);
  letter-spacing: -0.01em;
}
p { margin: 0 0 var(--space-3); color: var(--color-foreground); }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; }
ul { margin: 0; padding: 0; list-style: none; }
input, select, textarea { font-family: inherit; font-size: var(--text-base); }

:focus-visible {
  outline: 3px solid var(--color-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---------- App shells ---------- */
.app-shell {
  max-width: var(--max-mobile);
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: var(--shadow-lg);
}

@media (min-width: 720px) {
  body.frame-desktop {
    background: linear-gradient(180deg, #eef2f9 0%, #e6ecf5 100%);
    padding: var(--space-8) 0;
  }
  body.frame-desktop .app-shell {
    border-radius: var(--radius-xl);
    overflow: hidden;
    min-height: 844px;
    height: 844px;
  }
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ---------- Top app bar ---------- */
.topbar {
  height: var(--header-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar__back {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full);
  background: transparent;
  border: none;
  color: var(--color-foreground);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}
.topbar__back:hover { background: var(--color-surface-alt); }
.topbar__title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: var(--text-lg);
  flex: 1;
}
.topbar__action {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full);
  background: transparent; border: none; color: var(--color-muted);
  cursor: pointer;
}

/* ---------- Bottom nav (mobile, citizen/provider) ---------- */
.bottom-nav {
  height: var(--bottom-nav-h);
  flex: 0 0 auto;
  display: flex;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  padding-bottom: env(safe-area-inset-bottom, 0);
  position: sticky;
  bottom: 0;
  z-index: 20;
}
.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--color-muted);
  font-size: var(--text-xs);
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  min-height: 44px;
  transition: color var(--dur-fast) var(--ease-out);
}
.bottom-nav__item svg { width: 22px; height: 22px; transition: transform var(--dur-fast) var(--ease-spring); }
.bottom-nav__item.is-active { color: var(--color-primary); }
.bottom-nav__item.is-active svg { transform: translateY(-1px); }
.bottom-nav__item:active svg { transform: scale(0.9); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: 0 var(--space-5);
  border-radius: var(--radius-md);
  border: none;
  font-weight: 600;
  font-size: var(--text-base);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), opacity var(--dur-fast);
  touch-action: manipulation;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn svg { width: 20px; height: 20px; flex-shrink: 0; }

.btn--primary { background: var(--color-primary); color: var(--color-on-primary); box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--color-primary-hover); }
.btn--secondary { background: var(--color-surface-alt); color: var(--color-foreground); }
.btn--secondary:hover { background: var(--color-border); }
.btn--outline { background: transparent; color: var(--color-primary); border: 1.5px solid var(--color-primary); }
.btn--outline:hover { background: var(--color-primary-soft); }
.btn--ghost { background: transparent; color: var(--color-muted); }
.btn--ghost:hover { background: var(--color-surface-alt); color: var(--color-foreground); }
.btn--danger { background: var(--color-danger); color: #fff; }
.btn--success { background: var(--color-success); color: #fff; }
.btn--block { width: 100%; }
.btn--sm { min-height: 38px; padding: 0 var(--space-4); font-size: var(--text-sm); border-radius: var(--radius-sm); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.icon-btn {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full);
  border: none; background: var(--color-surface-alt); color: var(--color-foreground);
  cursor: pointer; transition: background var(--dur-fast), transform var(--dur-fast);
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- Cards ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.card--interactive { cursor: pointer; transition: box-shadow var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out), border-color var(--dur-base); }
.card--interactive:hover { box-shadow: var(--shadow-md); border-color: var(--color-border-strong); transform: translateY(-2px); }
.card--interactive:active { transform: translateY(0) scale(0.99); }

/* ---------- Status pills ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}
.pill svg { width: 13px; height: 13px; }
.pill--reported { background: var(--color-info-soft); color: var(--color-info); }
.pill--assigned { background: #ede9fe; color: #6d28d9; }
.pill--progress { background: var(--color-warning-soft); color: var(--color-warning); }
.pill--resolved { background: var(--color-success-soft); color: var(--color-success); }
.pill--overdue { background: var(--color-danger-soft); color: var(--color-danger); }
.pill--neutral { background: var(--color-surface-alt); color: var(--color-muted); }

/* ---------- Chat ---------- */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: linear-gradient(180deg, #f8fafc 0%, #f3f6fb 100%);
}
.msg { display: flex; gap: var(--space-2); max-width: 88%; opacity: 0; animation: msgIn var(--dur-slow) var(--ease-out) forwards; }
@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.msg--bot { align-self: flex-start; }
.msg--user { align-self: flex-end; flex-direction: row-reverse; margin-left: auto; }
.msg__avatar {
  width: 30px; height: 30px; border-radius: var(--radius-full); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--color-primary); color: #fff;
}
.msg__avatar svg { width: 16px; height: 16px; }
.msg__bubble {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  line-height: 1.45;
  box-shadow: var(--shadow-sm);
}
.msg--bot .msg__bubble { background: var(--color-surface); border-bottom-left-radius: var(--radius-sm); color: var(--color-foreground); }
.msg--user .msg__bubble { background: var(--color-primary); color: #fff; border-bottom-right-radius: var(--radius-sm); }

.msg__card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: var(--radius-sm);
  padding: var(--space-3);
  box-shadow: var(--shadow-sm);
  width: 100%;
}

.typing { align-self: flex-start; display: flex; align-items: center; gap: var(--space-2); }
.typing__bubble {
  display: flex; gap: 4px; align-items: center;
  background: var(--color-surface); padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg); border-bottom-left-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.typing__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--color-muted-light); animation: typingBounce 1.1s ease-in-out infinite; }
.typing__dot:nth-child(2) { animation-delay: 0.15s; }
.typing__dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.chip-row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-self: flex-start; max-width: 100%; }
.chip {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  border: 1.5px solid var(--color-primary);
  background: var(--color-surface);
  color: var(--color-primary);
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out), color var(--dur-fast);
  min-height: 40px;
}
.chip:hover { background: var(--color-primary-soft); }
.chip:active { transform: scale(0.95); }
.chip:disabled { opacity: 0.4; cursor: not-allowed; }

.chat-inputbar {
  flex: 0 0 auto;
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0));
}
.chat-inputbar input {
  flex: 1;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 0 var(--space-4);
  min-height: 44px;
  background: var(--color-surface-alt);
  color: var(--color-foreground);
}
.chat-inputbar input:focus { border-color: var(--color-primary); background: var(--color-surface); }
.chat-inputbar button {
  width: 44px; height: 44px; border-radius: 50%; border: none;
  background: var(--color-primary); color: #fff; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform var(--dur-fast) var(--ease-spring), background var(--dur-fast);
  flex-shrink: 0;
}
.chat-inputbar button:active { transform: scale(0.9); }
.chat-inputbar button svg { width: 18px; height: 18px; }

/* ---------- Map placeholder ---------- */
.map-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 11;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #dbe7f5;
  border: 1px solid var(--color-border);
}
.map-frame svg.map-art { width: 100%; height: 100%; display: block; }
.map-pin {
  position: absolute;
  left: 50%; top: 42%;
  transform: translate(-50%, -100%);
  width: 36px; height: 44px;
  filter: drop-shadow(0 4px 6px rgba(15,23,42,0.25));
  animation: pinDrop 0.5s var(--ease-spring) both;
}
@keyframes pinDrop {
  0% { transform: translate(-50%, -180%) scale(0.6); opacity: 0; }
  100% { transform: translate(-50%, -100%) scale(1); opacity: 1; }
}
.map-address {
  position: absolute;
  left: var(--space-3); right: var(--space-3); bottom: var(--space-3);
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  display: flex; align-items: center; gap: var(--space-2);
  backdrop-filter: blur(4px);
}

/* ---------- Photo upload / dropzone ---------- */
.dropzone {
  border: 2px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  text-align: center;
  color: var(--color-muted);
  cursor: pointer;
  transition: border-color var(--dur-base), background var(--dur-base);
  background: var(--color-surface-alt);
}
.dropzone:hover { border-color: var(--color-primary); background: var(--color-primary-soft); }
.dropzone svg { width: 32px; height: 32px; margin: 0 auto var(--space-2); color: var(--color-muted-light); }
.photo-preview { position: relative; border-radius: var(--radius-md); overflow: hidden; }
.photo-preview img { width: 100%; height: 200px; object-fit: cover; }
.photo-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.photo-slot {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  border: 2px dashed var(--color-border-strong);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-1); color: var(--color-muted); font-size: var(--text-xs); font-weight: 600;
  cursor: pointer; overflow: hidden; position: relative; background: var(--color-surface-alt);
}
.photo-slot svg { width: 24px; height: 24px; }
.photo-slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-slot.is-filled { border-style: solid; border-color: var(--color-success); }

/* ---------- Analysis / assessment ---------- */
.spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.analysis-row { display: flex; align-items: center; gap: var(--space-3); color: var(--color-muted); font-size: var(--text-sm); }

.assessment {
  border-radius: var(--radius-md);
  background: var(--color-success-soft);
  border: 1px solid #bbf7d0;
  padding: var(--space-3);
  animation: popIn var(--dur-slow) var(--ease-spring) both;
}
@keyframes popIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
.assessment__head { display: flex; align-items: center; gap: var(--space-2); font-weight: 700; color: var(--color-success); margin-bottom: var(--space-1); }
.assessment__meta { display: flex; gap: var(--space-4); font-size: var(--text-sm); color: var(--color-foreground); flex-wrap: wrap; }
.assessment__meta b { font-weight: 700; }
.confidence-bar { height: 6px; border-radius: var(--radius-full); background: #bbf7d0; overflow: hidden; margin-top: var(--space-2); }
.confidence-bar__fill { height: 100%; background: var(--color-success); border-radius: var(--radius-full); width: 0%; transition: width 1s var(--ease-out); }

/* ---------- Timeline ---------- */
.timeline { display: flex; flex-direction: column; }
.timeline__step { display: flex; gap: var(--space-3); position: relative; padding-bottom: var(--space-6); }
.timeline__step:last-child { padding-bottom: 0; }
.timeline__rail { display: flex; flex-direction: column; align-items: center; }
.timeline__dot {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--color-surface-alt); color: var(--color-muted-light);
  border: 2px solid var(--color-border); flex-shrink: 0; z-index: 1;
}
.timeline__dot svg { width: 14px; height: 14px; }
.timeline__line { flex: 1; width: 2px; background: var(--color-border); margin: 2px 0; min-height: 24px; }
.timeline__step.is-done .timeline__dot { background: var(--color-success); border-color: var(--color-success); color: #fff; }
.timeline__step.is-done .timeline__line { background: var(--color-success); }
.timeline__step.is-current .timeline__dot { background: var(--color-primary); border-color: var(--color-primary); color: #fff; box-shadow: 0 0 0 4px var(--color-primary-soft); }
.timeline__body { padding-top: 2px; }
.timeline__title { font-weight: 700; margin-bottom: 2px; }
.timeline__meta { color: var(--color-muted); font-size: var(--text-sm); }

/* ---------- Lists / report cards ---------- */
.report-card { display: flex; gap: var(--space-3); align-items: center; }
.report-card__thumb { width: 56px; height: 56px; border-radius: var(--radius-md); overflow: hidden; flex-shrink: 0; background: var(--color-surface-alt); }
.report-card__thumb svg, .report-card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.report-card__body { flex: 1; min-width: 0; }
.report-card__title { font-weight: 700; font-size: var(--text-base); margin-bottom: 2px; }
.report-card__meta { color: var(--color-muted); font-size: var(--text-sm); display: flex; align-items: center; gap: var(--space-1); }
.report-card__chevron { color: var(--color-muted-light); flex-shrink: 0; }
.report-card__chevron svg { width: 18px; height: 18px; }

/* ---------- KPI tiles ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }
@media (min-width: 640px) { .kpi-grid { grid-template-columns: repeat(4, 1fr); } }
.kpi {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.kpi__label { font-size: var(--text-sm); color: var(--color-muted); font-weight: 600; margin-bottom: var(--space-2); display:flex; align-items:center; gap:var(--space-2); }
.kpi__label svg { width: 16px; height: 16px; }
.kpi__value { font-family: var(--font-heading); font-size: var(--text-3xl); font-weight: 700; line-height: 1; }
.kpi__delta { font-size: var(--text-xs); font-weight: 700; margin-top: var(--space-2); display: inline-flex; align-items: center; gap: 2px; }
.kpi__delta--up { color: var(--color-success); }
.kpi__delta--down { color: var(--color-danger); }

/* ---------- Admin shell (sidebar + responsive) ---------- */
.admin-shell { display: flex; min-height: 100dvh; background: var(--color-bg); }
.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--color-navy);
  color: #cbd5e1;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: var(--space-6) var(--space-4);
  gap: var(--space-1);
  position: sticky;
  top: 0;
  height: 100dvh;
  transition: transform var(--dur-base) var(--ease-out);
  z-index: 40;
}
.admin-brand { display: flex; align-items: center; gap: var(--space-2); color: #fff; font-family: var(--font-heading); font-weight: 700; font-size: var(--text-lg); margin-bottom: var(--space-6); padding: 0 var(--space-2); }
.admin-brand svg { width: 26px; height: 26px; color: var(--color-primary); }
.admin-nav__item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-sm);
  color: #cbd5e1; font-weight: 500; font-size: var(--text-sm);
  cursor: pointer; transition: background var(--dur-fast);
}
.admin-nav__item svg { width: 19px; height: 19px; flex-shrink: 0; }
.admin-nav__item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.admin-nav__item.is-active { background: var(--color-primary); color: #fff; }
.admin-nav__section { margin-top: var(--space-6); margin-bottom: var(--space-2); padding: 0 var(--space-2); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-muted-light); font-weight: 700; }
.admin-nav__spacer { flex: 1; }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-topbar {
  height: var(--header-h);
  display: flex; align-items: center; gap: var(--space-3);
  padding: 0 var(--space-6);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky; top: 0; z-index: 20;
}
.admin-menu-btn { display: none; }
.admin-content { padding: var(--space-6); flex: 1; }
.admin-page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-4); margin-bottom: var(--space-6); }
.admin-page-head h1 { font-size: var(--text-2xl); }
.sidebar-scrim { display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.5); z-index: 39; }

@media (max-width: 960px) {
  .admin-sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .admin-sidebar.is-open { transform: translateX(0); }
  .admin-menu-btn { display: flex; }
  .sidebar-scrim.is-open { display: block; }
  .admin-content { padding: var(--space-4); }
}

/* ---------- Table (desktop) / card list (mobile) ---------- */
.data-table-wrap { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--color-muted); font-weight: 700; padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border); background: var(--color-surface-alt);
  white-space: nowrap; cursor: pointer; user-select: none;
}
.data-table th .sort-icon { width: 12px; height: 12px; margin-left: 4px; opacity: 0.5; display: inline-block; vertical-align: middle; }
.data-table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border); font-size: var(--text-sm); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--dur-fast); cursor: pointer; }
.data-table tbody tr:hover { background: var(--color-surface-alt); }

@media (max-width: 720px) {
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr { border-bottom: 1px solid var(--color-border); padding: var(--space-3) var(--space-4); }
  .data-table td { border: none; padding: var(--space-1) 0; }
  .data-table td[data-label]::before { content: attr(data-label); display: block; font-size: var(--text-xs); color: var(--color-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 2px; }
}

/* ---------- Filters toolbar ---------- */
.toolbar { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-4); align-items: center; }
.select, .input {
  border: 1.5px solid var(--color-border); border-radius: var(--radius-sm);
  padding: 0 var(--space-3); min-height: 42px; background: var(--color-surface); color: var(--color-foreground);
  font-size: var(--text-sm);
}
.select:focus, .input:focus { border-color: var(--color-primary); }
.search-input { position: relative; flex: 1; min-width: 200px; }
.search-input svg { position: absolute; left: var(--space-3); top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--color-muted); }
.search-input input { width: 100%; padding-left: var(--space-8); }

/* ---------- Charts (hand-rolled SVG) ---------- */
.chart-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-4); box-shadow: var(--shadow-sm); }
.chart-card__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); }
.chart-card__head h3 { font-size: var(--text-base); margin: 0; }
.chart-legend { display: flex; gap: var(--space-4); font-size: var(--text-xs); color: var(--color-muted); flex-wrap: wrap; }
.chart-legend__item { display: flex; align-items: center; gap: 6px; }
.chart-legend__dot { width: 9px; height: 9px; border-radius: 50%; }
.bar { transform-origin: bottom; animation: barGrow var(--dur-slow) var(--ease-out) both; }
@keyframes barGrow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.line-path { stroke-dasharray: 600; stroke-dashoffset: 600; animation: drawLine 1.1s var(--ease-out) forwards; }
@keyframes drawLine { to { stroke-dashoffset: 0; } }
.chart-dot { opacity: 0; animation: popIn var(--dur-base) var(--ease-spring) forwards; }

/* ---------- Toast ---------- */
.toast-stack { position: fixed; left: 50%; bottom: calc(var(--bottom-nav-h) + var(--space-4)); transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: var(--space-2); width: calc(100% - var(--space-8)); max-width: 400px; pointer-events: none; }
.toast {
  background: var(--color-navy); color: #fff; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  font-size: var(--text-sm); font-weight: 500; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: var(--space-2);
  animation: toastIn var(--dur-base) var(--ease-spring) both;
}
.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
.toast--success { background: var(--color-success); }
.toast--info svg, .toast--success svg { color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.toast.is-leaving { animation: toastOut var(--dur-fast) var(--ease-in) forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }

/* ---------- Tooltip "demo only" ---------- */
.demo-tip {
  position: fixed; z-index: 200; background: var(--color-navy); color: #fff; font-size: var(--text-xs); font-weight: 600;
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); pointer-events: none;
  box-shadow: var(--shadow-md); opacity: 0; transform: translate(-50%, -4px); transition: opacity var(--dur-fast), transform var(--dur-fast);
  white-space: nowrap;
}
.demo-tip.is-visible { opacity: 1; transform: translate(-50%, -10px); }

/* ---------- Modal / sheet ---------- */
.sheet-scrim { position: fixed; inset: 0; background: rgba(15,23,42,0.5); z-index: 60; opacity: 0; pointer-events: none; transition: opacity var(--dur-base) var(--ease-out); }
.sheet-scrim.is-open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  background: var(--color-surface); border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-3) var(--space-5) var(--space-6);
  transform: translateY(100%); transition: transform var(--dur-slow) var(--ease-spring);
  max-width: var(--max-mobile); margin: 0 auto;
  max-height: 85dvh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.sheet.is-open { transform: translateY(0); }
.sheet__handle { width: 40px; height: 4px; background: var(--color-border-strong); border-radius: var(--radius-full); margin: 0 auto var(--space-4); }

/* ---------- Splash ---------- */
.splash {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: var(--space-8); text-align: center;
  background: radial-gradient(circle at 50% 0%, #eaf1ff 0%, var(--color-surface) 55%);
}
.splash__logo {
  width: 88px; height: 88px; border-radius: var(--radius-xl);
  background: var(--color-primary); display: flex; align-items: center; justify-content: center;
  margin-bottom: var(--space-6); box-shadow: var(--shadow-lg);
  animation: logoIn 0.7s var(--ease-spring) both;
}
@keyframes logoIn { from { opacity: 0; transform: scale(0.6) rotate(-8deg); } to { opacity: 1; transform: scale(1) rotate(0); } }
.splash__logo svg { width: 46px; height: 46px; color: #fff; }
.splash h1 { font-size: var(--text-2xl); animation: fadeUp 0.6s var(--ease-out) 0.15s both; }
.splash p { color: var(--color-muted); max-width: 320px; animation: fadeUp 0.6s var(--ease-out) 0.25s both; }
.splash__actions { width: 100%; max-width: 320px; margin-top: var(--space-8); animation: fadeUp 0.6s var(--ease-out) 0.35s both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.splash__tag { display: inline-flex; align-items: center; gap: var(--space-2); background: var(--color-primary-soft); color: var(--color-primary); font-weight: 700; font-size: var(--text-xs); padding: var(--space-1) var(--space-3); border-radius: var(--radius-full); margin-bottom: var(--space-4); animation: fadeUp 0.6s var(--ease-out) 0.05s both; }

/* ---------- Utility ---------- */
.hero-section { padding: var(--space-6) var(--space-4); }
.section-title { font-size: var(--text-xl); margin-bottom: var(--space-4); }
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.row { display: flex; align-items: center; gap: var(--space-3); }
.between { justify-content: space-between; }
.muted { color: var(--color-muted); }
.text-sm { font-size: var(--text-sm); }
.mt-0 { margin-top: 0; }
.empty-state { text-align: center; padding: var(--space-12) var(--space-4); color: var(--color-muted); }
.empty-state svg { width: 48px; height: 48px; margin: 0 auto var(--space-3); color: var(--color-border-strong); }
.badge-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.page-fade { animation: pageFade var(--dur-slow) var(--ease-out) both; }
@keyframes pageFade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.divider { height: 1px; background: var(--color-border); border: none; margin: var(--space-4) 0; }

.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--color-primary-soft); color: var(--color-primary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: var(--text-sm); flex-shrink: 0; }
