/* ═══════════════════════════════════════════════════════════════════════════
   style.css — Sightline
   Premium Design System · Apple-inspired Liquid Glass
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Geist Font ─────────────────────────────────────────────────────────── */
@font-face {
  font-family: 'Geist';
  src: url('https://cdn.jsdelivr.net/fontsource/fonts/geist@1.0.0/latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Geist';
  src: url('https://cdn.jsdelivr.net/fontsource/fonts/geist@1.0.0/latin-500-normal.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Geist';
  src: url('https://cdn.jsdelivr.net/fontsource/fonts/geist@1.0.0/latin-600-normal.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Geist';
  src: url('https://cdn.jsdelivr.net/fontsource/fonts/geist@1.0.0/latin-700-normal.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ── Geist Mono ───────────────────────────────────────────────────────── */
@font-face {
  font-family: 'Geist Mono';
  src: url('https://cdn.jsdelivr.net/fontsource/fonts/geist-mono@1.0.0/latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Geist Mono';
  src: url('https://cdn.jsdelivr.net/fontsource/fonts/geist-mono@1.0.0/latin-500-normal.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* ── CSS Variables ──────────────────────────────────────────────────────── */
:root {
  /* Brand — Apple-inspired warm neutral system */
  --primary:          #E8364E;
  --primary-dark:     #CC2D43;
  --primary-light:    #FFF1F2;
  --primary-glow:     rgba(232,54,78,.10);

  /* Surface — Apple's warm whites and grays */
  --bg:               #F5F5F7;
  --surface:          #FFFFFF;
  --surface-raised:   rgba(255,255,255,.72);
  --surface-glass:    rgba(255,255,255,.45);
  --border:           rgba(0,0,0,.08);
  --border-light:     rgba(0,0,0,.04);
  --border-focus:     rgba(232,54,78,.35);
  --divider:          rgba(0,0,0,.06);

  /* Text — Apple SF color system */
  --text:             #1D1D1F;
  --text-secondary:   #6E6E73;
  --text-tertiary:    #AEAEB2;
  --text-muted:       #8E8E93;
  --text-inverse:     #FFFFFF;

  /* Accent */
  --navy:             #1D1D1F;
  --navy-light:       #48484A;
  --blue:             #007AFF;
  --blue-light:       #EBF5FF;

  /* Semantic — Apple system colors */
  --green:            #30D158;
  --green-light:      #E8FAE9;
  --red:              #FF3B30;
  --red-light:        #FFF1F1;
  --amber:            #FF9F0A;
  --amber-light:      #FFF6E5;
  --purple:           #AF52DE;
  --teal:             #5AC8FA;

  /* Apple Liquid Glass tokens */
  --glass-bg:         rgba(255,255,255,.55);
  --glass-border:     rgba(255,255,255,.25);
  --glass-shadow:     0 8px 32px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.04);
  --glass-blur:       40px;
  --glass-inner:      inset 0 1px 0 rgba(255,255,255,.5);

  /* Design tokens — Apple radius scale */
  --radius-xs:       6px;
  --radius-sm:       8px;
  --radius:          12px;
  --radius-lg:       16px;
  --radius-xl:       20px;
  --radius-2xl:      24px;
  --radius-full:     9999px;

  /* Apple shadow system — tinted for depth */
  --shadow-xs:        0 1px 2px rgba(0,0,0,.03);
  --shadow-sm:        0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.02);
  --shadow-md:        0 4px 16px rgba(0,0,0,.06), 0 1px 4px rgba(0,0,0,.04);
  --shadow-lg:        0 12px 40px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.03);
  --shadow-xl:        0 24px 64px rgba(0,0,0,.12), 0 4px 16px rgba(0,0,0,.04);
  --shadow-focus:     0 0 0 4px rgba(0,122,255,.18);
  --shadow-focus-red: 0 0 0 4px rgba(232,54,78,.15);
  --shadow-tinted:    0 4px 16px rgba(0,0,0,.05), 0 1px 3px rgba(232,54,78,.06);
  --shadow-glass:     0 8px 32px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.03), inset 0 1px 0 rgba(255,255,255,.5);
  --shadow-elevated:  0 8px 28px rgba(0,0,0,.08), 0 0 0 1px rgba(0,0,0,.04);

  /* Spacing scale — 4px grid */
  --space-1:          4px;
  --space-1-5:        6px;
  --space-2:          8px;
  --space-2-5:        10px;
  --space-3:          12px;
  --space-3-5:        14px;
  --space-4:          16px;
  --space-4-5:        18px;
  --space-5:          20px;
  --space-6:          24px;
  --space-7:          28px;
  --space-8:          32px;
  --space-10:         40px;
  --space-12:         48px;
  --space-16:         64px;

  /* Typography scale */
  --text-xs:          10px;
  --text-11:          11px;
  --text-sm:          12px;
  --text-13:          13px;
  --text-base:        14px;
  --text-md:          15px;
  --text-lg:          17px;
  --text-xl:          20px;
  --text-2xl:         24px;
  --text-3xl:         28px;
  --text-4xl:         34px;
  --text-5xl:         44px;

  /* Extended accent colors */
  --blue-hover:       #0066D6;
  --blue-dark:        #0055B3;
  --blue-glow:        rgba(0,122,255,.12);
  --green-dark:       #28B846;
  --red-dark:         #D63027;
  --amber-dark:       #CC7F08;
  --purple-light:     rgba(175,82,222,.1);
  --primary-soft:     rgba(232,54,78,.08);
  --navy-warm:        #2C2C2E;
  --log-green:        var(--green);
  --log-gold:         #FF9F0A;
  --log-red-light:    #FF6B6B;
  --log-blue:         #5AC8FA;
  --amber-text:       #CC7F08;

  /* Transitions — Apple ease curves */
  --transition:       .22s cubic-bezier(.25,.1,.25,1);
  --transition-spring:.35s cubic-bezier(.34,1.56,.64,1);
  --transition-fast:   .15s cubic-bezier(.25,.1,.25,1);

  /* Layout */
  --nav-h:           52px;
  --sidebar-w:       260px;


  /* SITREP compatibility aliases */
  --bg-app:          var(--bg);
  --bg-sidebar:      var(--bg);
  --bg-card:         #FFFFFF;
  --bg-console:      var(--navy);
  --accent:          var(--blue);
  --accent-hover:    var(--blue-hover);
  --success:         var(--green);
  --warning:        var(--amber);
  --danger:          var(--red);
  --text-primary:    var(--navy);
  --text-sidebar:   rgba(0,0,0,.45);
  --shadow-md-compat: 0 4px 24px rgba(0,0,0,.08);
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  line-height: 1.5;
  letter-spacing: -.01em;
  font-feature-settings: 'kern' 1, 'liga' 1;
}

/* ── Focus-visible ring ─────────────────────────────────────────────────── */
:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-radius: var(--radius-sm);
}
button:focus-visible,
.btn:focus-visible,
.sidebar-tab:focus-visible,
.chat-item:focus-visible,
.report-item:focus-visible,
.quick-prompt-btn:focus-visible,
.theme-pill:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.fi:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--blue-glow), var(--shadow-sm);
}

/* ── Text wrap ─────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6,
.welcome-greeting,
.welcome-title,
.auth-hero-title,
.report-hero-title,
.topbar-title,
.pipeline-title,
.bulletin-title,
.sitrep-topbar-title,
.bulletin-page-title,
.dash-topbar-title {
  text-wrap: balance;
  line-height: 1.15;
}
.msg-body p,
.narrative-body p,
.welcome-desc {
  text-wrap: pretty;
  line-height: 1.65;
}

/* ── Monospace standard ──────────────────────────────────────────────── */
code, pre, .chunk-box, .id-cell, .log-line, #log-console {
  font-family: 'Geist Mono', 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

/* ── Scrollbar — Apple thin overlay ─────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.25); }

/* ── Selection ─────────────────────────────────────────────────────────── */
::selection { background: var(--primary-glow); color: var(--text); }

/* ═══════════════════════════════════════════════════════════════════════════
   LEFT SIDEBAR NAVIGATION — Apple Finder-inspired Liquid Glass
   ═══════════════════════════════════════════════════════════════════════════ */
.sidebar-nav {
  background: rgba(245,245,247,.72);
  backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  border-right: 1px solid var(--border);
  color: var(--text);
  width: var(--sidebar-w);
  height: 100vh;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 1000;
  position: fixed;
  left: 0; top: 0;
  transition: width var(--transition), background var(--transition);
  overflow: hidden;
}
.sidebar-nav.collapsed { width: 72px; }
.sidebar-nav.collapsed .sidebar-brand,
.sidebar-nav.collapsed .sidebar-tab-label,
.sidebar-nav.collapsed .user-bar-info,
.sidebar-nav.collapsed .user-bar #user-logout { display: none; }
.sidebar-nav.collapsed .sidebar-tab { justify-content: center; padding: 10px; border-left: none; border-radius: var(--radius); }
.sidebar-nav.collapsed .sidebar-tab.active { border-left: none; padding-left: 10px; }
.sidebar-nav.collapsed .sidebar-nav-head { justify-content: center; padding: 16px 0 12px; }
.sidebar-nav.collapsed .sidebar-logo { margin: 0 auto; }
.sidebar-nav.collapsed .sidebar-nav-footer { padding: 12px 8px 16px; }
.sidebar-nav.collapsed .user-bar { justify-content: center; padding: 8px; gap: 0; width: auto; max-width: 48px; margin: 0 auto; }
.sidebar-nav.collapsed .user-bar img { width: 32px; height: 32px; }
.sidebar-nav.collapsed .sidebar-nav-footer { padding: 12px 8px 16px; overflow: hidden; }

.sidebar-nav-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  min-height: 56px;
}
.sidebar-logo {
  height: 32px; width: 32px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: margin var(--transition);
}
.sidebar-brand {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -.3px;
  white-space: nowrap;
  transition: opacity var(--transition);
  color: var(--text);
}
.sidebar-nav-tabs {
  flex: 1;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.sidebar-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  letter-spacing: -.01em;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition);
  white-space: nowrap;
  position: relative;
}
.sidebar-tab svg { flex-shrink: 0; }
.sidebar-tab-label { transition: opacity var(--transition), transform var(--transition-fast); }
.sidebar-tab:hover {
  color: var(--text);
  background: rgba(0,0,0,.05);
  transform: translateX(2px);
}
.sidebar-tab:active { transform: scale(.97) translateX(2px); background: rgba(0,0,0,.08); }
.sidebar-tab.active {
  color: var(--text);
  background: rgba(0,122,255,.08);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(0,122,255,.15);
}
.sidebar-tab.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 18px;
  background: var(--blue);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px rgba(0,122,255,.3);
}

.sidebar-nav-footer {
  padding: 12px 12px 16px;
  border-top: 1px solid var(--divider);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Main content offset for sidebar */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  overflow: hidden;
  display: flex;
  transition: margin-left var(--transition);
}
.sidebar-nav.collapsed ~ .main,
body.sidebar-collapsed .main {
  margin-left: 72px;
}

.busy-dot {
  width: 6px; height: 6px;
  background: var(--green);
  border-radius: 50%;
  display: none;
  animation: pulse 1.4s ease-in-out infinite;
  box-shadow: 0 0 6px rgba(48,209,88,.4);
}
.busy-dot.visible { display: block; }
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.4;transform:scale(.85)} }

/* ═══════════════════════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════════════════════ */
.panel { display: none; flex: 1; flex-direction: column; overflow: hidden; }
#panel-home { overflow-y: auto; overflow-x: hidden; }
.panel.active { display: flex; }

/* ═══════════════════════════════════════════════════════════════════════════
   TAB 1 — DATABASE — Apple-inspired
   ═══════════════════════════════════════════════════════════════════════════ */
.reports-wrap { flex: 1; display: flex; flex-direction: column; overflow: hidden; padding: 28px 32px; gap: 20px; }

/* Apple-style stat cards with glass effect */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  flex-shrink: 0;
}
.stat-card {
  background: var(--surface-raised);
  backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition);
  box-shadow: var(--shadow-glass);
}
.stat-card:hover { box-shadow: var(--shadow-elevated); transform: translateY(-2px); }
.stat-card:active { transform: translateY(0) scale(.98); }
.stat-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: 3px 0 0 3px;
}
.stat-card.stat-blue::before { background: var(--blue); }
.stat-card.stat-blue::after { content: ''; position: absolute; inset: 0; background: var(--blue); opacity: .03; border-radius: inherit; }
.stat-card.stat-red::before { background: var(--primary); }
.stat-card.stat-red::after { content: ''; position: absolute; inset: 0; background: var(--primary); opacity: .03; border-radius: inherit; }
.stat-card.stat-green::before { background: var(--green); }
.stat-card.stat-green::after { content: ''; position: absolute; inset: 0; background: var(--green); opacity: .03; border-radius: inherit; }
.stat-card.stat-amber::before { background: var(--amber); }
.stat-card.stat-amber::after { content: ''; position: absolute; inset: 0; background: var(--amber); opacity: .03; border-radius: inherit; }
.stat-card-label {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .8px;
  position: relative; z-index: 1;
}
.stat-card-value {
  font-size: 28px; font-weight: 700; color: var(--text);
  position: relative; z-index: 1;
  letter-spacing: -.5px;
  font-variant-numeric: tabular-nums;
}

/* Legacy stat-pill for backward compat */
.stat-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 5px 16px;
  font-size: 12px;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  letter-spacing: .1px;
}
.stat-pill strong { font-weight: 600; color: var(--text); }

.stats-actions {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}

.refresh-btn {
  margin-left: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 18px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition);
  font-family: inherit;
  letter-spacing: -.01em;
}
.refresh-btn:hover { background: var(--bg); color: var(--text); box-shadow: var(--shadow-xs); }

.filters {
  background: var(--surface-raised);
  backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-glass);
}

.fi {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition);
  letter-spacing: -.01em;
}
.fi:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,122,255,.15); }
.fi.wide { flex: 1; min-width: 180px; }
.fi-count { font-size: 12px; color: var(--text-muted); margin-left: auto; font-weight: 500; font-variant-numeric: tabular-nums; }

.table-wrap { flex: 1; overflow: auto; background: var(--surface-raised); backdrop-filter: blur(var(--glass-blur)) saturate(180%); -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%); border: 1px solid var(--glass-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-glass); }

.rtable { width: 100%; border-collapse: collapse; font-size: 13px; letter-spacing: -.01em; }
.rtable thead th {
  position: sticky; top: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  z-index: 2;
  transition: color var(--transition-fast);
}
.rtable thead th:hover { color: var(--text); }
.rtable thead th.sorted { color: var(--primary); }
.rtable tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--divider);
  vertical-align: middle;
  transition: background var(--transition-fast);
}
.rtable tbody tr { transition: background var(--transition-fast); }
.rtable tbody tr:hover td { background: var(--primary-light); }
.rtable tbody tr:hover { cursor: pointer; }
.rtable tbody tr:active td { background: rgba(232,54,78,.15); }

.id-cell { font-family: 'SF Mono','Consolas','Cascadia Code',monospace; font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.title-cell { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chunks-cell { text-align: center; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: .2px;
}
.b-green  { background: var(--green-light); color: var(--green-dark); }
.b-blue   { background: var(--blue-light); color: var(--blue-dark); }
.b-gray   { background: var(--bg); color: var(--text-muted); }
.b-yellow { background: var(--amber-light); color: var(--amber-dark); }
.b-red    { background: var(--red-light); color: var(--red-dark); }

.empty { text-align: center; padding: 80px 20px; color: var(--text-muted); font-size: 14px; font-weight: 400; }
.empty .icon { font-size: 32px; margin-bottom: 12px; opacity: .4; }

/* ── DB Report Modal — Liquid Glass ────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.3);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 200;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-2xl);
  width: min(660px, 94vw);
  max-height: 86vh; overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalIn .3s cubic-bezier(.34,1.56,.64,1);
}
@keyframes modalIn { from{transform:translateY(20px) scale(.96);opacity:0} to{transform:translateY(0) scale(1);opacity:1} }

.modal-hdr {
  padding: 24px 28px 20px;
  display: flex; align-items: flex-start; gap: 16px;
}
.modal-title { font-size: 17px; font-weight: 600; flex: 1; line-height: 1.4; letter-spacing: -.3px; }
.modal-close {
  background: var(--bg); border: 1px solid var(--border);
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; cursor: pointer; color: var(--text-muted);
  transition: background var(--transition), color var(--transition); line-height: 1; flex-shrink: 0;
}
.modal-close:hover { background: var(--red-light); color: var(--red); border-color: rgba(255,59,48,.3); }
.modal-close:active { transform: scale(.9); }

.modal-bdy { padding: 0 28px 24px; }
.dg { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.di label {
  display: block; font-size: 10px; text-transform: uppercase;
  letter-spacing: .8px; color: var(--text-muted); font-weight: 600; margin-bottom: 4px;
}
.di p { font-size: 14px; line-height: 1.5; color: var(--text); }
.di.full { grid-column: 1 / -1; }

.chunk-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  max-height: 220px; overflow-y: auto;
  color: var(--text-secondary);
  font-family: 'SF Mono','Geist Mono','Cascadia Code','Consolas',monospace;
  font-variant-numeric: tabular-nums;
}

.modal-ftr {
  padding: 16px 28px 20px;
  border-top: 1px solid var(--divider);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* ── Buttons — Apple-inspired ────────────────────────────────────────── */
.btn {
  padding: 9px 22px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  letter-spacing: -.01em;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 1px 3px rgba(232,54,78,.25);
}
.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(232,54,78,.3);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0) scale(.98); box-shadow: 0 1px 2px rgba(232,54,78,.2); }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg);
  border-color: rgba(0,0,0,.15);
}
.btn:disabled, .btn-secondary:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* ═══════════════════════════════════════════════════════════════════════════
   TAB 2 — AGENT CHAT — Apple Messages-inspired Liquid Glass
   ═══════════════════════════════════════════════════════════════════════════ */
#panel-agent { position: relative; overflow: hidden; }

/* ── Sidebar overlay — frosted glass ── */
.chat-sidebar-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 49;
  opacity: 0; pointer-events: none;
  transition: opacity .35s ease;
}
.chat-sidebar-overlay.open { opacity: 1; pointer-events: auto; }

/* ── Collapsible sidebar drawer — Liquid Glass ── */
.chat-sidebar {
  position: absolute; top: 0; left: 0; bottom: 0;
  width: 300px;
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  border-right: 1px solid rgba(255,255,255,.4);
  display: flex; flex-direction: column;
  z-index: 50;
  transform: translateX(-100%);
  transition: transform .35s cubic-bezier(.25,.1,.25,1), box-shadow .35s ease;
  box-shadow: none;
}
.chat-sidebar.open {
  transform: translateX(0);
  box-shadow: 20px 0 40px rgba(0,0,0,.08);
}

.chat-sidebar-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--divider);
}
.sidebar-close-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); display: flex; align-items: center;
  padding: 6px; border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition);
}
.sidebar-close-btn:hover { background: rgba(0,0,0,.05); color: var(--text); }
.sidebar-close-btn:active { transform: scale(.9); }
.sidebar-head-title {
  font-size: 14px; font-weight: 600; color: var(--text);
  letter-spacing: -.2px;
}

.chat-new-btn {
  margin: 14px 16px 10px;
  padding: 11px 0;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: -.01em;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition);
  box-shadow: 0 1px 6px rgba(232,54,78,.2);
}
.chat-new-btn:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 16px rgba(232,54,78,.28);
  transform: translateY(-1px);
}
.chat-new-btn:active { transform: translateY(0) scale(.98); }

.chat-list {
  flex: 1; overflow-y: auto;
  padding: 4px 8px 12px;
  display: flex; flex-direction: column; gap: 1px;
}
.chat-item {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition);
  position: relative;
  overflow: hidden;
}

/* ── Inline delete confirmation ── */
.delete-confirm {
  position: absolute; inset: 0;
  background: var(--red-light);
  border: 1.5px solid #fca5a5;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  z-index: 5;
  animation: dcSlideIn .2s ease;
}
@keyframes dcSlideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
.dc-label { font-size: 11.5px; font-weight: 600; color: #991b1b; letter-spacing: .1px; }
.dc-yes {
  background: var(--red); color: white;
  border: none; border-radius: var(--radius-xs);
  padding: 4px 14px; font-size: 11px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: background .15s, color .15s, border-color .15s;
  box-shadow: 0 1px 4px rgba(220,38,38,.3);
}
.dc-yes:hover { background: #b91c1c; box-shadow: 0 2px 8px rgba(220,38,38,.4); }
.dc-no {
  background: var(--surface); color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  padding: 4px 14px; font-size: 11px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: background .15s, color .15s, border-color .15s;
}
.dc-no:hover { background: var(--bg); color: var(--text); }

/* ── Inline rename ── */
.rename-confirm {
  position: absolute; inset: 0;
  background: var(--surface);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius);
  display: flex; align-items: center; gap: 6px;
  padding: 0 8px;
  z-index: 5;
  animation: dcSlideIn .2s ease;
}
.rc-input {
  flex: 1; min-width: 0;
  border: none; outline: none; background: transparent;
  font-size: 12px; font-family: inherit; font-weight: 600;
  color: var(--text); padding: 6px 0;
}
.rc-ok {
  background: var(--primary); color: white;
  border: none; border-radius: var(--radius-xs);
  padding: 3px 10px; font-size: 10.5px; font-weight: 700;
  cursor: pointer; font-family: inherit; transition: background .15s, color .15s, border-color .15s;
}
.rc-ok:hover { background: var(--primary-dark); }
.rc-cancel {
  background: none; border: none; color: var(--text-muted);
  font-size: 12px; font-weight: 700; cursor: pointer;
  padding: 3px 4px; transition: color .15s;
}
.rc-cancel:hover { color: var(--text); }

.chat-item:hover { background: rgba(0,0,0,.04); color: var(--text); }
.chat-item:active { transform: scale(.98); background: rgba(0,0,0,.06); }
.chat-item.active {
  background: var(--primary-light);
  color: var(--text);
  font-weight: 600;
  border-left: 3px solid var(--primary);
}
.chat-item-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item-actions { display: none; gap: 2px; flex-shrink: 0; }
.chat-item:hover .chat-item-actions { display: flex; }
.chat-item-btn {
  background: none; border: none; cursor: pointer;
  font-size: 11px; padding: 3px 6px; border-radius: var(--radius-xs);
  color: var(--text-muted); font-weight: 600; font-family: inherit;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition); letter-spacing: .5px;
}
.chat-item-btn:hover { background: rgba(0,0,0,.06); color: var(--text); }
.chat-item-btn:active { transform: scale(.9); }
.chat-item-btn.delete:hover { background: var(--red-light); color: var(--red); }

/* ── Chat Main — Apple clean ── */
.chat-main {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  position: relative;
}

/* Gemini-style animated background mesh */
.chat-main::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 600px 400px at 20% 40%, rgba(0,122,255,.06), transparent 70%),
    radial-gradient(ellipse 500px 350px at 80% 60%, rgba(175,82,222,.05), transparent 70%),
    radial-gradient(ellipse 400px 300px at 50% 80%, rgba(48,209,88,.04), transparent 70%);
  pointer-events: none;
  z-index: 0;
  animation: bgBreathe 12s ease-in-out infinite alternate;
}
@keyframes bgBreathe {
  0% { opacity: .6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.02); }
  100% { opacity: .7; transform: scale(1); }
}

/* Welcome mode — full background pulse */
.chat-main.welcome-mode::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle 500px at 50% 55%, rgba(0,122,255,.10), transparent 70%),
    radial-gradient(circle 700px at 30% 40%, rgba(0,122,255,.06), transparent 70%),
    radial-gradient(circle 600px at 70% 60%, rgba(90,160,255,.05), transparent 70%);
  pointer-events: none;
  z-index: 0;
  animation: bgPulse 4s ease-in-out infinite;
}
@keyframes bgPulse {
  0%, 100% { opacity: 0; transform: scale(.97); }
  50% { opacity: 1; transform: scale(1.02); }
}

/* ── Welcome mode — centered Gemini-style ── */
.chat-main.welcome-mode {
  flex-direction: column;
  justify-content: center;
}
.chat-main.welcome-mode .chat-topbar {
  display: none;
}
.chat-main.welcome-mode .chat-scroll {
  flex: 0 1 auto;
  overflow: visible;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.chat-main.welcome-mode .chat-center {
  max-width: 640px;
  text-align: center;
  padding-bottom: 16px;
}
.chat-main.welcome-mode .welcome-greeting {
  font-size: 28px;
  letter-spacing: -.5px;
  margin-bottom: 8px;
}
.chat-main.welcome-mode .welcome-desc {
  font-size: 15px;
  margin-bottom: 24px;
}
.chat-main.welcome-mode .welcome-section {
  text-align: left;
}
.chat-main.welcome-mode .quick-prompts {
  text-align: center;
  margin-bottom: 24px;
}
.chat-main.welcome-mode .quick-prompts-title {
  text-align: center;
}
.chat-main.welcome-mode .chat-footer {
  flex: 0 0 auto;
  padding: 0 20px 20px;
  background: transparent;
}
.chat-main.welcome-mode .chat-input-wrap {
  max-width: 640px;
  animation: breathe 4s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(0,122,255,0), 0 1px 3px rgba(0,0,0,.06);
    border-color: var(--border);
  }
  50% {
    box-shadow: 0 0 30px 6px rgba(0,122,255,.18), 0 0 60px 12px rgba(0,122,255,.06), 0 1px 3px rgba(0,0,0,.06);
    border-color: rgba(0,122,255,.45);
  }
}
@keyframes slideDownReturn {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(20px); }
}

/* ── Chat mode — messages flow normally ── */
.chat-main:not(.welcome-mode) .chat-scroll {
  flex: 1;
  overflow-y: auto;
  justify-content: flex-start;
}
.chat-main:not(.welcome-mode) .chat-footer {
  flex-shrink: 0;
}

/* Top bar — subtle glass */
.chat-topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 20px;
  background: rgba(255,255,255,.7);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  z-index: 10;
  position: relative;
}
.sidebar-toggle-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); display: flex; align-items: center;
  padding: 6px; border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition);
  animation: togglePulse 2.5s ease-in-out 3;
}
.sidebar-toggle-btn:hover { background: rgba(0,0,0,.06); color: var(--text); animation: none; }
@keyframes togglePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}
.topbar-title {
  font-size: 13.5px; font-weight: 600; color: var(--text);
  letter-spacing: -.1px;
}

/* Scrollable messages area */
.chat-scroll {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
}

/* Centered column for messages */
.chat-center {
  max-width: 780px;
  width: calc(100% - 48px);
  margin: 0 auto;
  padding: 28px 0 16px;
  display: flex; flex-direction: column; gap: 4px;
  flex-shrink: 0;
}

/* ── Messages — Apple Messages bubbles ── */
.msg {
  display: flex; flex-direction: column;
  padding: 3px 0;
  animation: msgFadeIn .3s ease;
}
@keyframes msgFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* User messages — Apple blue bubble */
.msg.user {
  align-items: flex-end;
}
.msg.user .msg-body {
  background: var(--blue);
  color: white;
  border-radius: 18px 18px 4px 18px;
  padding: 11px 18px;
  max-width: 72%;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  box-shadow: 0 1px 4px rgba(0,122,255,.18);
  letter-spacing: -.01em;
}

/* AI messages — clean card style */
.msg.assistant {
  align-items: flex-start;
}
.msg-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 6px;
  padding-left: 2px;
}
.msg.assistant .msg-body {
  background: transparent;
  border: none;
  padding: 0 2px 12px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text);
  max-width: 72ch;
  word-break: break-word;
  overflow-wrap: break-word;
  box-shadow: none;
}

/* Tool indicator — pill style */
.tool-ind {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  box-shadow: var(--shadow-xs);
  margin: 4px 0;
  width: fit-content;
}
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Welcome sections — Apple clean cards ── */
.welcome-greeting {
  font-size: 22px; font-weight: 700; color: var(--text);
  margin-bottom: 4px;
  letter-spacing: -.3px;
}
.welcome-desc {
  font-size: 14px; color: var(--text-secondary); line-height: 1.6;
  margin-bottom: 16px;
  letter-spacing: -.01em;
}
.welcome-section {
  margin-bottom: 8px; padding: 12px 16px;
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border-light);
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition);
}
.welcome-section:hover { border-color: var(--border); box-shadow: var(--shadow-xs); }
.welcome-section-title {
  font-size: 13px; font-weight: 600; color: var(--text);
  margin-bottom: 2px;
}
.welcome-section-desc {
  font-size: 12px; color: var(--text-muted); line-height: 1.55;
}

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

/* ── Quick prompt buttons — Apple pill chips ── */
.quick-prompts {
  margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--border-light);
}
.quick-prompts-title {
  font-size: 10px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px;
}
.welcome-history-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 1px solid var(--border-light);
  color: var(--text-muted); cursor: pointer;
  padding: 6px 14px; border-radius: 14px;
  font-size: 12px; font-weight: 500;
  margin-top: 16px;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}
.welcome-history-btn:hover {
  color: var(--text-secondary); background: var(--surface-raised); border-color: var(--border);
}
.quick-prompt-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; margin: 0 6px 8px 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; font-size: 12.5px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer;
  font-family: inherit; transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition);
  white-space: nowrap;
  letter-spacing: -.01em;
}
.quick-prompt-btn:hover {
  border-color: var(--blue); color: var(--blue);
  background: var(--blue-light); box-shadow: 0 2px 10px rgba(0,122,255,.12);
  transform: translateY(-1px);
}
.quick-prompt-btn:active { transform: translateY(0) scale(.97); }
.quick-prompt-btn:disabled { opacity: .4; pointer-events: none; cursor: not-allowed; }
/* Category-tinted prompt buttons — Apple colors */
.quick-prompt-btn.cat-search { border-color: rgba(0,122,255,.3); color: var(--blue); }
.quick-prompt-btn.cat-search:hover { border-color: var(--blue); background: rgba(0,122,255,.08); box-shadow: 0 2px 10px rgba(0,122,255,.15); }
.quick-prompt-btn.cat-kb { border-color: rgba(175,82,222,.3); color: var(--purple); }
.quick-prompt-btn.cat-kb:hover { border-color: var(--purple); background: rgba(175,82,222,.08); box-shadow: 0 2px 10px rgba(175,82,222,.15); }
.quick-prompt-btn.cat-ingest { border-color: rgba(48,209,88,.3); color: var(--green); }
.quick-prompt-btn.cat-ingest:hover { border-color: var(--green); background: rgba(48,209,88,.08); box-shadow: 0 2px 10px rgba(48,209,88,.15); }
.quick-prompt-btn.cat-analysis { border-color: rgba(255,159,10,.3); color: var(--amber); }
.quick-prompt-btn.cat-analysis:hover { border-color: var(--amber); background: rgba(255,159,10,.08); box-shadow: 0 2px 10px rgba(255,159,10,.15); }

/* ── Chat rate hint ── */
/* Rate limit hint removed — badge in user-bar is sufficient */

/* Rate limit message — Apple alert */
.rate-limit-msg {
  padding: 16px 20px;
  border-radius: var(--radius);
  background: var(--red-light);
  border: 1px solid rgba(255,59,48,.2);
  text-align: center;
  max-width: 420px;
  margin: 0 auto;
}
.rate-limit-msg-title {
  font-size: 15px; font-weight: 600; color: var(--red);
  margin-bottom: 8px;
}
.rate-limit-msg-body {
  font-size: 13px; color: var(--text-secondary);
  margin-bottom: 6px;
}
.rate-limit-msg-contact {
  font-size: 13px; color: var(--text-muted);
}
.rate-limit-msg-contact a {
  color: var(--blue); text-decoration: none;
  font-weight: 500;
}
.rate-limit-msg-contact a:hover {
  text-decoration: underline;
}

/* ═════════════════════════════════════════════════════════════════════
   AUTH / LOGIN STYLES
   ════════════════════════════════════════════════════════════════════ */

body.auth-locked .main,
body.auth-locked .nav {
  pointer-events: none;
  filter: blur(3px);
  opacity: 0.6;
}

body.auth-locked .auth-overlay { pointer-events: auto; }
body.auth-locked .auth-card   { pointer-events: auto; }

.auth-overlay {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: stretch;
  background: #FFFFFF;
  overflow: hidden;
}
.auth-overlay.hidden { display: none; }

/* Left hero panel — Premium white glass */
.auth-hero {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 48px; position: relative; overflow: hidden;
  background: #FFFFFF;
}
.auth-hero::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 30% 80%, rgba(232,54,78,.06) 0%, transparent 50%),
              radial-gradient(ellipse at 80% 20%, rgba(0,122,255,.04) 0%, transparent 40%);
  pointer-events: none;
}
.auth-hero-content { position: relative; z-index: 1; max-width: 480px; animation: heroFadeIn .7s ease-out; }
@keyframes heroFadeIn { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
.auth-hero-badge {
  display: inline-block; padding: 5px 14px; border-radius: var(--radius-full);
  background: rgba(232,54,78,.08); color: var(--primary);
  font-size: 11px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase;
  margin-bottom: 24px;
  border: 1px solid rgba(232,54,78,.15);
}
.auth-hero-title {
  font-size: 44px; font-weight: 700; color: var(--text); line-height: 1.1;
  letter-spacing: -.5px; margin: 0 0 18px;
}
.auth-hero-stats {
  display: flex; gap: 36px; margin-bottom: 40px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.auth-hero-stat { display: flex; flex-direction: column; gap: 4px; }
.auth-hero-stat-value {
  font-size: 32px; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.5px;
  animation: statPop .5s ease-out backwards;
}
.auth-hero-stat:nth-child(1) .auth-hero-stat-value { animation-delay: .3s; }
.auth-hero-stat:nth-child(2) .auth-hero-stat-value { animation-delay: .45s; }
.auth-hero-stat:nth-child(3) .auth-hero-stat-value { animation-delay: .6s; }
@keyframes statPop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: scale(1); } }
.auth-hero-stat-label {
  font-size: 11px; color: var(--text-tertiary); text-transform: uppercase;
  letter-spacing: .8px; font-weight: 500;
}
.auth-hero-features {
  display: flex; flex-direction: column; gap: 14px;
}
.auth-hero-feature {
  display: flex; align-items: center; gap: 12px;
  color: var(--text-secondary); font-size: 13.5px; font-weight: 400;
  letter-spacing: -.01em;
  animation: featureSlide .4s ease-out backwards;
}
.auth-hero-feature:nth-child(1) { animation-delay: .5s; }
.auth-hero-feature:nth-child(2) { animation-delay: .6s; }
.auth-hero-feature:nth-child(3) { animation-delay: .7s; }
.auth-hero-feature:nth-child(4) { animation-delay: .8s; }
@keyframes featureSlide { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: translateX(0); } }
.auth-hero-feature svg { flex-shrink: 0; color: var(--primary); opacity: .7; }

/* Data Sources — Apple pill style (white bg) */
.auth-hero-sources {
  margin-top: 32px; padding-top: 24px;
  border-top: 1px solid var(--border);
  animation: heroFadeIn .6s ease-out .9s backwards;
}
.auth-hero-sources-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .8px; color: var(--text-tertiary); margin-bottom: 12px;
}
.auth-hero-sources-list {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.auth-hero-source {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--radius-full);
  font-size: 12px; font-weight: 500;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  letter-spacing: -.01em;
}
.auth-hero-source.active {
  background: rgba(48,209,88,.06);
  border-color: rgba(48,209,88,.2);
  color: var(--text);
}
.auth-hero-source.active svg { color: var(--green); }
.source-badge {
  font-size: 9px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; padding: 2px 6px; border-radius: var(--radius-full);
}
.source-badge.active {
  background: rgba(48,209,88,.15); color: var(--green);
}
.source-badge.coming {
  background: rgba(255,255,255,.08); color: rgba(255,255,255,.4);
}
.source-badge.active {
  background: rgba(48,209,88,.15); color: var(--green);
}
.source-badge.coming {
  background: rgba(255,255,255,.06); color: rgba(255,255,255,.25);
}

/* Right login card — Liquid Glass */
.auth-card {
  width: 440px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 48px 36px;
  background: var(--bg);
  backdrop-filter: blur(60px) saturate(180%);
  -webkit-backdrop-filter: blur(60px) saturate(180%);
  border-left: 1px solid var(--border);
  box-shadow: -20px 0 60px rgba(0,0,0,.04), 0 0 0 1px rgba(0,0,0,.04);
  animation: authSlideIn .5s cubic-bezier(.34,1.56,.64,1);
}
@keyframes authSlideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }

.auth-card-inner { width: 100%; text-align: center; }
.auth-logo { width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 14px; box-shadow: 0 4px 16px rgba(232,54,78,.12); }
.auth-card h1 { font-size: 22px; font-weight: 700; color: var(--text); margin: 0 0 4px; letter-spacing: -.3px; }
.auth-subtitle { font-size: 14px; color: var(--text-secondary); margin: 0 0 28px; font-weight: 400; letter-spacing: -.01em; }

.auth-card-features {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 28px; text-align: left;
}
.auth-card-feature {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius);
  background: var(--bg); border: 1px solid var(--border);
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition);
}
.auth-card-feature:hover { border-color: rgba(0,0,0,.15); box-shadow: var(--shadow-sm); }
.auth-card-feature:active { transform: scale(.98); }
.auth-card-feature-icon {
  flex-shrink: 0; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
}
.auth-card-feature strong { font-size: 13px; font-weight: 600; color: var(--text); display: block; letter-spacing: -.2px; }
.auth-card-feature span { font-size: 12px; color: var(--text-secondary); line-height: 1.35; }

.auth-google-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 13px 20px; font-size: 14px; font-weight: 500; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer;
  box-shadow: var(--shadow-xs); transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition);
  margin-top: 4px; letter-spacing: -.01em;
  font-family: 'Geist', -apple-system, sans-serif;
}
.auth-google-btn:hover { background: var(--bg); box-shadow: var(--shadow-sm); transform: translateY(-1px); border-color: rgba(0,0,0,.15); }
.auth-google-btn:active { transform: translateY(0) scale(.98); }
.auth-google-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.auth-error { margin-top: 14px; min-height: 20px; font-size: 13px; color: var(--red); }

.auth-legal {
  margin-top: 20px; font-size: 12px; color: var(--text-secondary); line-height: 1.5;
  letter-spacing: -.01em;
}
.auth-legal a { color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border); font-weight: 500; }
.auth-legal a:hover { color: var(--blue); border-bottom-color: var(--blue); }

/* Legal Modal inside auth-overlay — must be above auth card */
.auth-overlay .modal-overlay {
  z-index: 10001;
}
.legal-modal {
  max-width: 560px;
  max-height: 80vh;
}
.legal-modal .modal-bdy {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
}
.legal-modal .modal-bdy h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 16px 0 6px;
}
.legal-modal .modal-bdy ul {
  padding-left: 20px;
  margin: 6px 0;
}
.legal-modal .modal-bdy li {
  margin-bottom: 4px;
}

.auth-copyright {
  position: absolute; bottom: 16px; left: 0; right: 0;
  font-size: 11px; color: var(--text-tertiary);
  letter-spacing: .3px; text-align: center;
}

/* user bar — Apple light style */
.user-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); background: rgba(0,0,0,.03); border-radius: var(--radius);
  border: 1px solid var(--border);
}
.user-bar.hidden { display: none; }
.user-bar img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.user-bar-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.user-bar-info #user-name { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; font-weight: 500; }
.user-bar-badges { display: flex; gap: 4px; align-items: center; }
.user-bar #user-logout {
  padding: 6px; color: var(--text-muted);
  background: transparent; border: none; border-radius: var(--radius-sm); cursor: pointer; transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition);
  display: flex; align-items: center;
}
.user-bar #user-logout:hover { background: rgba(0,0,0,.06); color: var(--text); }

.rate-badge {
  font-size: 11px; font-weight: 600; padding: 2px 7px;
  border-radius: var(--radius-full); white-space: nowrap;
  background: rgba(0,0,0,.04); color: var(--text-muted);
  border: 1px solid var(--border);
}
.rate-badge.rate-limit-low {
  background: var(--amber-light); color: #92400E;
  border-color: rgba(255,159,10,.3);
}
.rate-badge.rate-limit-exhausted {
  background: var(--red-light); color: var(--red-dark);
  border-color: rgba(255,59,48,.3);
}

/* ── Role badges — Apple style ─────────────────────────────────────────────── */
.role-badge {
  font-size: 10px; font-weight: 600; padding: 2px 8px;
  border-radius: var(--radius-full); white-space: nowrap; letter-spacing: .5px;
  text-transform: uppercase;
}
.role-badge.role-admin {
  background: rgba(255,59,48,.1); color: var(--red);
  border: 1px solid rgba(255,59,48,.2);
}
.role-badge.role-premium {
  background: rgba(175,82,222,.1); color: var(--purple);
  border: 1px solid rgba(175,82,222,.2);
}

/* ── Admin panel — Apple clean ─────────────────────────────────────────── */
.admin-panel-content {
  max-width: 800px; margin: 0 auto; padding: 24px;
}
.admin-panel-content h2 {
  color: var(--text-primary); margin-bottom: 8px;
}
.admin-hint {
  color: var(--text-muted); font-size: 13px; margin-bottom: 20px;
}
.admin-user-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.admin-user-table th {
  text-align: left; padding: 10px 12px; color: var(--text-muted);
  border-bottom: 1px solid var(--border); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .5px;
}
.admin-user-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
.admin-user-table tr:hover td { background: rgba(0,0,0,.02); }
.admin-loading { text-align: center; color: var(--text-muted); padding: 20px; }
.admin-role-badge {
  font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 10px; text-transform: uppercase; letter-spacing: .3px;
}
.admin-role-badge.role-admin {
  background: rgba(255,59,48,.1); color: var(--red);
}
.admin-role-badge.role-premium {
  background: rgba(175,82,222,.1); color: var(--purple);
}
.admin-role-badge.role-free {
  background: rgba(0,0,0,.04); color: var(--text-muted);
}
.admin-actions { white-space: nowrap; }
.btn-xs {
  padding: 3px 8px; font-size: 11px; margin-right: 4px;
  border-radius: var(--radius-sm); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  background: var(--surface); color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-xs:hover { background: var(--bg); color: var(--text-primary); }
.btn-xs.btn-premium { color: var(--purple); border-color: rgba(175,82,222,.3); }
.btn-xs.btn-premium:hover { background: rgba(175,82,222,.08); }
.btn-xs.btn-admin { color: var(--red); border-color: rgba(255,59,48,.3); }
.btn-xs.btn-admin:hover { background: rgba(255,59,48,.08); }

.typing-dots { display: flex; align-items: center; gap: 4px; height: 20px; }
.typing-dots span {
  display: inline-block; width: 5px; height: 5px;
  background: var(--text-muted); border-radius: 50%;
  animation: tdot 1.3s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes tdot { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-6px)} }

/* ── Chat footer — Apple iMessage-style input ── */
.chat-footer {
  padding: 10px 20px 20px;
  background: linear-gradient(to top, var(--bg) 80%, transparent);
  display: flex; flex-direction: column; align-items: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.chat-input-wrap {
  max-width: 780px; width: calc(100% - 48px);
  display: flex; align-items: flex-end; gap: 0;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 22px;
  padding: 6px 6px 6px 20px;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition);
}
.chat-input-wrap:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,122,255,.12), var(--shadow-md);
}
.chat-textarea {
  flex: 1;
  border: none;
  padding: 10px 0;
  font-size: 14px;
  resize: none;
  max-height: 150px;
  outline: none;
  font-family: inherit;
  line-height: 1.5;
  color: var(--text);
  background: transparent;
  letter-spacing: -.01em;
}
.chat-textarea::placeholder { color: var(--text-muted); }
.send-btn {
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition);
  box-shadow: 0 1px 4px rgba(0,122,255,.2);
}
.send-btn:hover {
  background: var(--blue-hover);
  box-shadow: 0 3px 10px rgba(0,122,255,.3);
  transform: scale(1.06);
}
.send-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; background: var(--text-muted); }
.send-btn svg { margin-left: 1px; }

/* Markdown in AI messages — Apple clean */
.msg-body h1,.msg-body h2,.msg-body h3 { font-size: 15px; margin: 14px 0 6px; font-weight: 700; letter-spacing: -.2px; }
.msg-body p     { margin: 6px 0; }
.msg-body ul,.msg-body ol { margin: 6px 0; padding-left: 22px; }
.msg-body li    { margin: 3px 0; }
.msg-body code  {
  background: var(--bg); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); padding: 2px 7px;
  font-size: 12px; font-family: 'SF Mono','Geist Mono','Cascadia Code','Consolas',monospace;
}
.msg.user .msg-body code { background: rgba(255,255,255,.18); border-color: transparent; }
.msg-body pre {
  background: var(--navy); color: var(--bg);
  padding: 16px 18px; border-radius: var(--radius);
  overflow-x: auto; margin: 10px 0; font-size: 12.5px;
  line-height: 1.6;
  border: 1px solid rgba(255,255,255,.08);
}
.msg-body pre code { background: none; color: inherit; padding: 0; border: none; }
.msg-body table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 13px; }
.msg-body th,.msg-body td { border: 1px solid var(--border); padding: 8px 14px; text-align: left; }
.msg-body th    { background: var(--surface); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); }
.msg-body a     { color: var(--blue); text-decoration: none; font-weight: 500; }
.msg-body a:hover { text-decoration: underline; }
.msg.user .msg-body a { color: rgba(255,255,255,.85); }
.msg-body hr    { border: none; border-top: 1px solid var(--border-light); margin: 12px 0; }
.msg-body blockquote { border-left: 3px solid var(--blue); padding-left: 16px; color: var(--text-secondary); margin: 10px 0; font-style: italic; }

/* ═══════════════════════════════════════════════════════════════════════════
   TAB 3 — SITREP
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── SITREP Page (topbar layout) ── */
.sitrep-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sitrep-topbar {
  padding: 20px 28px 0;
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.sitrep-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.brand-icon-sm {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, #007AFF 0%, #5856D6 100%);
  color: #fff;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
  letter-spacing: -.5px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,122,255,.25);
}
.sitrep-topbar-title {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.3px;
  margin: 0;
}
.sitrep-topbar-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 0 16px;
}
.sitrep-topbar-form .fi {
  max-width: 180px;
}
.sitrep-topbar-form .fi-date {
  max-width: 140px;
}
.sitrep-topbar-form .fi-date input {
  font-size: 12px;
}
.sitrep-skip-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 4px;
  white-space: nowrap;
}

.sitrep-reports-bar {
  padding: 0 28px;
  background: var(--bg);
  flex-shrink: 0;
}
.sitrep-reports-bar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0 6px;
}
.sitrep-reports-bar-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
  color: var(--text-muted);
}
.sitrep-reports-list {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 0 12px;
  scrollbar-width: thin;
}
.sitrep-reports-list .report-item {
  flex-shrink: 0;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast);
  white-space: nowrap;
}
.sitrep-reports-list .report-item:hover {
  background: rgba(0,122,255,.06);
  border-color: rgba(0,122,255,.3);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,122,255,.08);
}
.sitrep-reports-list .report-item:active { transform: scale(.96); }
.sitrep-reports-list .report-item.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,122,255,.25);
}

.sitrep-main-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 28px;
}


#btn-run {
  padding: 9px 18px;
  background: linear-gradient(135deg, #30D158 0%, #28B846 100%);
  color: white; border: none;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition);
  letter-spacing: -.01em;
  box-shadow: 0 1px 4px rgba(48,209,88,.2), 0 0 0 1px rgba(48,209,88,.1);
}
#btn-run:hover    { box-shadow: 0 4px 14px rgba(48,209,88,.3), 0 0 0 1px rgba(48,209,88,.2); transform: translateY(-1px); }
#btn-run:active   { transform: translateY(0) scale(.98); box-shadow: 0 1px 2px rgba(48,209,88,.2); }
#btn-run:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; transform: none; }

/* ── Theme pills — Apple chips ── */
.form-group-label {
  font-size: 10px; font-weight: 600; letter-spacing: .6px;
  text-transform: uppercase; color: var(--text-muted);
  margin-top: 2px;
}
.theme-pills {
  display: flex; flex-wrap: wrap; gap: 5px;
}
.theme-pills-loading, .theme-pills-empty {
  font-size: 11px; color: var(--text-muted); font-style: italic;
}
.theme-pill {
  padding: 4px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer; transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition);
  user-select: none;
}
.theme-pill:hover {
  background: var(--blue-light);
  color: var(--blue);
  border-color: rgba(0,122,255,.3);
}
.theme-pill:active { transform: scale(.95); }
.theme-pill.selected {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

/* ── Date range inputs ── */
.form-row-dates {
  display: flex; gap: 6px;
}
.form-date-field {
  flex: 1; display: flex; flex-direction: column; gap: 2px;
}
.form-date-field label {
  font-size: 9px; font-weight: 600; letter-spacing: .5px;
  text-transform: uppercase; color: var(--text-muted);
}
.form-date-field input[type="date"] {
  width: 100%; padding: 7px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text); font-size: 11px; outline: none;
  font-family: inherit;
  transition: border var(--transition);
}
.form-date-field input[type="date"]:focus {
  border-color: var(--blue);
}
.date-range-hint {
  font-size: 11px; color: var(--text-muted);
  margin: 2px 0 0; min-height: 14px;
  padding: 0 24px;
}

/* ── Chunk preview bar ── */
.chunk-preview {
  font-size: 11.5px; padding: 8px 10px; margin: 4px 24px 8px; border-radius: var(--radius-sm);
  margin: 6px 0 8px 0; line-height: 1.5;
}
.chunk-preview.hidden { display: none; }
.chunk-preview.ok  { background: rgba(48,209,88,.08); color: var(--green-dark); border: 1px solid rgba(48,209,88,.2); }
.chunk-preview.warn { background: rgba(255,159,10,.08); color: var(--amber-text); border: 1px solid rgba(255,159,10,.2); }
.chunk-preview.err  { background: rgba(255,59,48,.08); color: var(--red-dark); border: 1px solid rgba(255,59,48,.2); }
.chunk-preview .cp-count { font-weight: 700; }
.chunk-preview .cp-themes { font-size: 10.5px; opacity: .85; margin-top: 2px; }

/* ── Report view toggle — Apple segmented control ── */
.report-view-toggle {
  display: flex; gap: 0; margin-bottom: 20px;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 3px;
  border: 1px solid var(--border);
}
.report-view-btn {
  flex: 1;
  padding: 8px 16px;
  font-size: 12px; font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none; border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition);
  text-align: center;
  letter-spacing: .2px;
}
.report-view-btn:hover { color: var(--text-secondary); background: var(--surface); }
.report-view-btn:active { transform: scale(.97); }
.report-view-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}
.report-view-section.hidden { display: none; }

/* ── Narrative report body ─────────────────────────────────────────────────── */
.narrative-body {
  line-height: 1.85; font-size: 14.5px; color: var(--text);
  max-width: 100%;
}
.narrative-body h1,
.narrative-body h2,
.narrative-body h3 {
  font-weight: 700;
  color: var(--text);
  margin-top: 32px;
  margin-bottom: 14px;
  letter-spacing: -.3px;
  scroll-margin-top: 20px;
}
.narrative-body h1 {
  font-size: 22px;
  border-bottom: 3px solid var(--blue);
  padding-bottom: 10px;
  margin-left: -2px;
  padding-left: 2px;
}
.narrative-body h2 {
  font-size: 18px;
  border-bottom: 2px solid var(--blue);
  padding-bottom: 8px;
  position: relative;
}
.narrative-body h2::before {
  content: '';
  position: absolute;
  left: 0; bottom: -2px;
  width: 40px; height: 3px;
  background: var(--blue);
  border-radius: 2px;
}
.narrative-body h3 {
  font-size: 15px;
  border-left: 3px solid var(--blue);
  padding-left: 12px;
  border-bottom: none; padding-bottom: 0;
}
.narrative-body p {
  margin: 0 0 16px 0;
  text-align: left;
}
.narrative-body p:last-child { margin-bottom: 0; }
.narrative-body a { color: var(--blue); text-decoration: none; font-weight: 500; }
.narrative-body a:hover { text-decoration: underline; }
.narrative-body ul, .narrative-body ol {
  margin: 0 0 16px 20px;
  padding: 0;
}
.narrative-body li { margin-bottom: 6px; }
.narrative-body strong { font-weight: 700; color: var(--text); }
.narrative-body blockquote {
  border-left: 3px solid var(--blue);
  margin: 16px 0;
  padding: 12px 20px;
  background: var(--blue-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
  color: var(--text-secondary);
}

/* ── Narrative 2-column layout (TOC sidebar + content) ── */
.narrative-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 32px;
  align-items: start;
}
.narrative-toc {
  position: sticky;
  top: 0;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 16px 0;
}
.narrative-toc-title {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding-left: 12px;
}
.narrative-toc a {
  display: block;
  padding: 6px 12px;
  font-size: 12.5px; font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
  line-height: 1.45;
  letter-spacing: -.01em;
}
.narrative-toc a:hover {
  color: var(--blue);
  background: var(--blue-light);
  border-left-color: var(--blue);
}
.narrative-toc a:active { transform: scale(.98); }
.narrative-toc a.level-h2 { padding-left: 20px; font-size: 12px; }
.narrative-toc a.level-h3 { padding-left: 28px; font-size: 11.5px; }
.narrative-content {
  min-width: 0;
}

/* ── Report view sections wider ── */
.report-view-section {
  max-width: 100%;
}
#report-content {
  max-width: 100%;
}


.report-item {
  padding: 10px 12px; border-radius: var(--radius);
  cursor: pointer; transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition); margin-bottom: 2px;
}
.report-item:hover { background: rgba(0,0,0,.04); }
.report-item:active { transform: scale(.98); }
.report-item.active {
  background: var(--blue-light);
  border-left: 3px solid var(--blue);
}
.report-item-name { font-size: 12px; font-weight: 600; color: var(--text); line-height: 1.35; }
.report-item-meta { font-size: 10px; color: var(--text-muted); margin-top: 3px; }
.empty-state { color: var(--text-muted); font-size: 13px; padding: 24px 16px; text-align: center; }

/* SITREP view */
.sitrep-view { flex: 1; overflow-y: auto; padding: 28px 32px; max-width: 100%; }
.sitrep-view.hidden { display: none; }

#view-welcome {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 100%; text-align: center;
  color: var(--text-muted);
}
.welcome-icon {
  font-size: 11px; font-weight: 700; letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--text-muted); opacity: .4; margin-bottom: 16px;
}
.welcome-title { font-size: 24px; font-weight: 800; color: var(--text); margin-bottom: 8px; letter-spacing: -.5px; }
.welcome-sub   { font-size: 14px; max-width: 420px; line-height: 1.7; color: var(--text-secondary); }

/* Pipeline progress — Apple clean */
.pipeline-title {
  font-size: 15px; font-weight: 700; margin-bottom: 20px;
  display: flex; align-items: center; gap: 10px; letter-spacing: -.2px;
}
.steps-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 22px; }
@media (max-width: 900px) { .steps-grid { grid-template-columns: repeat(3, 1fr); } }

.step-card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
  transition: background .3s ease, border-color .3s ease, box-shadow .3s ease;
}
.step-card.waiting { opacity: .4; }
.step-card.active  { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,122,255,.1); }
.step-card.cached  { border-color: var(--amber); background: var(--amber-light); }
.step-card.done    { border-color: var(--green); background: var(--green-light); }
.step-card.error   { border-color: var(--red);   background: var(--red-light); }
.step-num  { font-size: 9px; font-weight: 700; color: var(--text-muted); letter-spacing: 1.5px; text-transform: uppercase; margin-bottom: 3px; }
.step-name { font-size: 11px; font-weight: 600; color: var(--text); }
.step-icon { font-size: 14px; float: right; margin-top: -18px; font-weight: 700; color: var(--text-muted); }

/* Log console — Apple dark */
.log-wrap {
  background: var(--navy);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255,255,255,.06);
}
.log-header {
  background: rgba(255,255,255,.04);
  padding: 10px 18px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.log-header-title {
  color: rgba(245,245,247,.4);
  font-size: 10px; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
}
.log-dot {
  width: 7px; height: 7px; border-radius: 50%;
  animation: pulse 1s infinite;
}
.log-dot.running { background: var(--green); box-shadow: 0 0 6px rgba(48,209,88,.5); }
.log-dot.done    { background: var(--blue);  animation: none; }
.log-dot.error   { background: var(--red);   animation: none; }

#log-console {
  height: 360px; overflow-y: auto;
  padding: 14px 18px;
  font-family: 'SF Mono','Geist Mono','Consolas','Courier New',monospace;
  font-size: 11.5px; line-height: 1.65;
}
#log-console::-webkit-scrollbar { width: 4px; }
#log-console::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: var(--radius-xs); }

.log-line          { padding: 1px 0; color: rgba(245,245,247,.4); }
.log-line.info     { color: var(--green); }
.log-line.warn     { color: var(--log-gold); }
.log-line.error    { color: var(--log-red-light); }
.log-line.debug    { color: rgba(245,245,247,.2); }
.log-line.cached   { color: #64D2FF; }
.log-line.step     { color: var(--log-blue); font-weight: 700; }
.log-line.done-line { color: var(--green); font-weight: 700; }
.log-line.gpu-warn { color: rgba(245,245,247,.15); font-size: 11px; font-style: italic; }

/* SITREP Report view */
/* ── Hero banner — Apple gradient with warm accent ──────────────────────────── */
.report-hero {
  position: relative;
  background: linear-gradient(145deg, #1D1D1F 0%, #2C2C2E 30%, #3A2A2A 70%, #2A1520 100%);
  border-radius: var(--radius-lg);
  padding: 32px 28px 24px;
  margin-bottom: 20px;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.report-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}
.report-hero-content { position: relative; z-index: 1; }
.report-hero-actions { position: relative; z-index: 1; flex-shrink: 0; margin-top: 4px; }
.report-hero-badge {
  display: inline-block;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.5px;
  color: rgba(255,255,255,.6);
  background: rgba(255,255,255,.08);
  padding: 3px 10px; border-radius: var(--radius-xs);
  margin-bottom: 10px;
}
.report-hero-title {
  font-size: var(--text-3xl); font-weight: 800; color: var(--text-inverse);
  line-height: 1.2; letter-spacing: -.5px; margin: 0 0 4px;
}
.report-hero-subtitle {
  font-size: 14px; color: rgba(255,255,255,.6);
  margin-bottom: 14px; letter-spacing: .2px;
}
.report-hero-meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
}
.report-hero-date {
  font-size: 12px; color: rgba(255,255,255,.5);
  background: rgba(255,255,255,.08);
  padding: 4px 10px; border-radius: var(--radius-xs);
}
.report-hero-theme {
  font-size: 11px; font-weight: 600;
  color: rgba(255,255,255,.7);
  background: rgba(0,122,255,.25);
  border: 1px solid rgba(0,122,255,.35);
  padding: 3px 10px; border-radius: 12px;
}

/* ── Key figures row ─────────────────────────────────────────────────────── */
.report-kf-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.report-kf-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: center;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition), transform var(--transition);
}
.report-kf-card:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.report-kf-card:active { transform: translateY(0) scale(.98); }
.report-kf-card.hdx-kf {
  border-color: rgba(0,122,255,.3);
  background: rgba(0,122,255,.04);
}
.report-kf-card.hdx-kf .report-kf-value {
  color: var(--blue);
}
.report-kf-card.hdx-kf .report-kf-label::after {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  vertical-align: middle;
  margin-left: 3px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23007AFF'%3E%3Cpath d='M8 1a7 7 0 100 14A7 7 0 008 1zm0 2a1 1 0 011 1v3.586l2.707 2.707a1 1 0 01-1.414 1.414l-3-3A1 1 0 017 7V4a1 1 0 011-1z'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}
.report-kf-value {
  font-size: 26px; font-weight: 700;
  color: var(--text); line-height: 1.2;
}
.report-kf-label {
  font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .5px;
  margin-top: 3px;
}

/* Legacy meta bar (kept for Q&A view fallback) */
.report-meta-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  margin: 0 0 20px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); font-size: 12px; color: var(--text-secondary);
}
.report-meta-label { font-weight: 700; color: var(--text-muted); margin-right: 2px; }
.report-meta-pill {
  display: inline-block; padding: 2px 10px; border-radius: 12px;
  background: var(--bg); border: 1px solid var(--border);
  font-size: 11px; font-weight: 500; color: var(--text);
}
.report-meta-sep { color: var(--border); margin: 0 4px; }
.report-actions { display: flex; gap: 8px; flex-shrink: 0; }
.btn-sm {
  padding: 7px 16px; border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-secondary); text-decoration: none;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition);
  display: inline-flex; align-items: center; gap: 5px;
  font-family: inherit; letter-spacing: .2px;
}
.btn-sm:hover { background: var(--bg); border-color: var(--text-muted); color: var(--text); }
.btn-sm:active { transform: scale(.97); }
.btn-sm:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn-discuss-agent {
  background: var(--blue) !important;
  color: var(--text-inverse) !important;
  border-color: var(--blue) !important;
  box-shadow: 0 2px 8px rgba(0,122,255,.2);
  white-space: nowrap;
}
.btn-discuss-agent:hover {
  background: var(--blue-hover) !important;
  border-color: var(--blue-hover) !important;
  box-shadow: 0 4px 12px rgba(0,122,255,.3);
  transform: translateY(-1px);
}
.btn-discuss-agent:active { transform: translateY(0) scale(.97); }

.sitrep-section-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px solid var(--border-light);
}
.sitrep-section-header {
  padding: 16px 20px;
  font-weight: 700; font-size: 13px;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; user-select: none;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
  letter-spacing: -.1px;
}
.sitrep-section-header:hover { background: var(--bg); }
.sitrep-section-header:active { background: rgba(0,0,0,.03); }
.sitrep-section-header .toggle-icon {
  margin-left: auto; color: var(--text-muted);
  font-size: 16px; transition: transform .25s ease;
}
.sitrep-section-header.collapsed .toggle-icon { transform: rotate(-90deg); }
.sitrep-section-body { padding: 18px 20px; }
.sitrep-section-body.hidden { display: none; }

.summary-text {
  font-size: 13.5px; line-height: 1.85; color: var(--text-secondary);
  background: var(--bg); padding: 18px 20px;
  border-radius: var(--radius); border-left: 3px solid var(--blue);
}
.cluster-badge {
  display: inline-block;
  background: var(--blue);
  color: white;
  font-size: 10px; font-weight: 700;
  padding: 2px 10px; border-radius: var(--radius-xl);
  letter-spacing: .5px;
}
.qa-item { padding: 16px 0; border-bottom: 1px solid var(--border-light); }
.qa-item:last-child { border-bottom: none; padding-bottom: 0; }
.qa-question { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 8px; line-height: 1.5; }
.qa-answer   { font-size: 13px; line-height: 1.85; color: var(--text-secondary); }
.no-answer   { font-style: italic; color: var(--text-muted); }

.citation {
  display: inline-block;
  background: var(--blue);
  color: white;
  font-size: 9px; font-weight: 700;
  padding: 1px 6px; border-radius: var(--radius-xs);
  cursor: pointer; transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition);
  vertical-align: middle; margin: 0 1px;
  letter-spacing: .3px;
}
.citation:hover { background: var(--blue-hover); transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.citation:active { transform: translateY(0) scale(.95); }

.sources-section {
  border-top: 2px solid var(--border);
  margin-top: 32px;
  padding-top: 20px;
}
.sources-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--text-muted); margin-bottom: 14px;
}
.source-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius);
  text-decoration: none; color: var(--text);
  font-size: 12px; line-height: 1.45;
  transition: background var(--transition), box-shadow var(--transition);
  margin-bottom: 2px;
  border: 1px solid transparent;
}
.source-item:hover {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
}
.source-item:active { transform: scale(.99); }
.source-item-num {
  flex-shrink: 0;
  background: var(--blue); color: white;
  font-size: 9px; font-weight: 700;
  padding: 2px 7px; border-radius: var(--radius-xs); margin-top: 1px;
}
.source-item-body  { flex: 1; min-width: 0; }
.source-item-title { font-weight: 600; color: var(--text); margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-item-domain { font-size: 10px; color: var(--text-muted); }
.source-item-icon  { flex-shrink: 0; color: var(--text-muted); font-size: 13px; margin-top: 1px; }

/* ── Source cards grid (narrative view) ────────────────────────────────────── */
.sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
.source-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition);
}
.source-card:hover {
  border-color: var(--blue);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.source-card:active { transform: translateY(0) scale(.99); }
.source-card-icon {
  flex-shrink: 0;
  font-size: 18px;
  line-height: 1;
  margin-top: 2px;
}
.source-card-body {
  flex: 1;
  min-width: 0;
}
.source-card-title {
  font-weight: 600;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.source-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.source-card-domain {
  font-size: 10px;
  color: var(--blue);
  font-weight: 500;
}
.source-card-date {
  font-size: 10px;
  color: var(--text-muted);
}
.source-card-num {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  color: var(--blue);
  background: var(--blue-light);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  margin-top: 2px;
}

/* SITREP Citation Modal — Liquid Glass */
.sitrep-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.25);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.sitrep-modal-overlay.hidden { display: none; }
.sitrep-modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 560px; max-width: 92vw; max-height: 80vh; overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: fadeUp .2s ease-out;
}
@keyframes fadeUp { from{transform:translateY(16px);opacity:0} to{transform:translateY(0);opacity:1} }

.sitrep-modal-head {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: white; padding: 18px 22px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex; align-items: center; justify-content: space-between;
}
.sitrep-modal-head h3 { font-size: 13px; font-weight: 700; letter-spacing: .3px; }
.sitrep-modal-close {
  background: none; border: none; color: rgba(255,255,255,.6);
  font-size: 18px; cursor: pointer;
  transition: color var(--transition); line-height: 1;
}
.sitrep-modal-close:hover { color: white; }
.sitrep-modal-body { padding: 22px; }
.modal-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--text-muted); margin-bottom: 8px;
}
.sitrep-modal-context {
  background: var(--bg); border-radius: var(--radius);
  padding: 14px 16px; font-size: 13px; line-height: 1.75;
  color: var(--text-secondary);
  border-left: 3px solid var(--blue);
  max-height: 200px; overflow-y: auto;
}
.modal-source-link { margin-bottom: 18px; }
.modal-source-link a {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  background: var(--blue);
  color: white; border-radius: var(--radius);
  text-decoration: none;
  font-size: 13px; font-weight: 600; line-height: 1.4;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition); word-break: break-word;
  box-shadow: 0 2px 8px rgba(0,122,255,.2);
}
.modal-source-link a:hover { background: var(--blue-hover); transform: translateY(-1px); }
.modal-source-link a[data-no-url] { background: var(--text-muted); pointer-events: none; box-shadow: none; }
.modal-link-icon { font-size: 16px; flex-shrink: 0; margin-left: auto; }

/* Utilities */
.hidden { display: none !important; }
.tag-wrap { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.tag { background: var(--blue-light); color: var(--blue-dark); font-size: 10px; padding: 3px 10px; border-radius: var(--radius-xl); font-weight: 600; letter-spacing: .2px; }

/* ═══════════════════════════════════════════════════════════════════════════
   PDF UPLOAD MODAL (admin-only)
   ═══════════════════════════════════════════════════════════════════════════ */

/* Upload form grid */
.up-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.up-full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .8px; color: var(--text-muted);
}
.up-submit-row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.up-file { padding: 6px 8px; }

/* Tag chips */
.tag-box {
  display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; min-height: 0;
}
.tag-chip {
  display: flex; align-items: center; gap: 4px;
  background: var(--blue-light); color: var(--blue-dark);
  font-size: 11px; font-weight: 600;
  padding: 4px 10px; border-radius: var(--radius-xl);
}
.tag-chip button {
  background: none; border: none; cursor: pointer;
  color: var(--blue); font-size: 13px; line-height: 1; padding: 0;
  transition: color var(--transition);
}
.tag-chip button:hover { color: var(--red); }
.tag-input-row { display: flex; gap: 6px; align-items: center; }
.tag-input-row .fi { flex: 1; }

/* Spinner (reuse) */
.spinner {
  display: inline-block; width: 14px; height: 14px; margin-right: 8px;
  border: 2px solid var(--border); border-top-color: var(--blue);
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Tablet & Mobile
   ═══════════════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════════════
   HOME DASHBOARD — Immersive map view
   ═══════════════════════════════════════════════════════════════════════════ */

/* Hide sidebar on Home tab for immersive full-width map */
.sidebar-nav.hidden { display: none; }
.sidebar-nav.hidden ~ .main .hamburger-btn { display: flex; }
.sidebar-nav:not(.hidden) ~ .main .hamburger-btn { display: none; }

.dashboard {
  max-width: 100%;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* ── Top bar — minimal floating ── */
.dash-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px 0;
  flex-shrink: 0;
}
.dash-topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.dash-topbar-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.5px;
  margin: 0;
}
.dash-topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.dash-topbar-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: var(--radius-sm);
}
.dash-topbar-brand-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.3px;
}
.dash-quick-links {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-left: 4px;
}
.dash-quick-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -.01em;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
  white-space: nowrap;
}
.dash-quick-link:hover {
  background: var(--surface-raised);
  color: var(--blue);
  border-color: var(--blue);
  box-shadow: var(--shadow-glass);
}
.dash-quick-link:active {
  transform: scale(.97);
}
.dash-quick-link svg {
  flex-shrink: 0;
  opacity: .7;
}
.dash-quick-link:hover svg {
  opacity: 1;
}

/* ── Data Sources pills (overlay on map) ── */
.dash-map-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1000;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  pointer-events: none;
}
.dash-map-overlay .dash-source {
  pointer-events: auto;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(255,255,255,.75);
  border-color: rgba(0,0,0,.08);
}
.dash-source {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: -.01em;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.dash-source.active {
  background: rgba(0,122,255,.08);
  border: 1px solid rgba(0,122,255,.2);
  color: var(--blue);
}
.dash-source.coming {
  background: rgba(0,0,0,.03);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
}
.dash-source svg {
  flex-shrink: 0;
}
.dash-source-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
}
.dash-source-badge.live {
  background: rgba(48,209,88,.15);
  color: var(--green);
}
.dash-source-badge.coming {
  background: rgba(0,0,0,.04);
  color: var(--text-muted);
}

/* ── View Full Bulletin Button ── */
.dash-view-bulletin-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 20px;
  padding: 10px 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -.01em;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition), transform var(--transition-fast);
  font-family: inherit;
}
.dash-view-bulletin-btn:hover {
  background: var(--surface-raised);
  border-color: var(--blue);
  box-shadow: var(--shadow-glass);
  transform: translateY(-1px);
}
.dash-view-bulletin-btn:active {
  transform: translateY(0) scale(.98);
}

/* ── World Map — Leaflet (hero) ── */
.dash-map-wrap {
  position: relative;
  margin: 12px 24px 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  min-height: 420px;
  height: 70vh;
  max-height: 800px;
  flex-shrink: 0;
  display: flex;
}
.dash-world-map {
  flex: 1;
  width: 100%;
  height: 100%;
  transition: margin-right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.dash-world-map.panel-open {
  margin-right: 320px;
}

/* ── Crisis Detail Panel ── */
.dash-crisis-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 320px;
  height: 100%;
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(40px) saturate(1.8);
  -webkit-backdrop-filter: blur(40px) saturate(1.8);
  border-left: 1px solid rgba(255,255,255,0.6);
  box-shadow: -8px 0 32px rgba(0,0,0,0.08);
  z-index: 800;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.dash-crisis-panel.open {
  transform: translateX(0);
}
.dash-crisis-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.dash-crisis-panel-country {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.2;
}
.dash-crisis-panel-close {
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(0,0,0,0.06);
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}
.dash-crisis-panel-close:hover {
  background: rgba(0,0,0,0.12);
}
.dash-crisis-panel-body {
  padding: 16px 20px 20px;
  overflow-y: auto;
  flex: 1;
}
.dash-crisis-panel-body .crisis-severity-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.dash-crisis-panel-body .crisis-headline {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 10px;
}
.dash-crisis-panel-body .crisis-summary {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.dash-crisis-panel-body .crisis-meta {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.dash-crisis-panel-body .crisis-meta-item {
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 4px;
}
.dash-crisis-panel-body .crisis-meta-item strong {
  color: var(--text-primary);
  font-weight: 600;
}
.dash-crisis-panel-body .crisis-themes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}
.dash-crisis-panel-body .crisis-theme-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(0,122,255,0.08);
  color: #007AFF;
  font-weight: 500;
}
.dash-crisis-panel-body .crisis-hdx-section {
  margin-bottom: 16px;
}
.dash-crisis-panel-body .crisis-hdx-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}
.dash-crisis-panel-body .crisis-hdx-figure {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  font-size: 13px;
}
.dash-crisis-panel-body .crisis-hdx-figure:last-child {
  border-bottom: none;
}
.dash-crisis-panel-body .crisis-hdx-label {
  color: var(--text-secondary);
}
.dash-crisis-panel-body .crisis-hdx-value {
  font-weight: 700;
  color: var(--text-primary);
}
.dash-crisis-panel-body .crisis-sitrep-btn {
  display: block;
  width: 100%;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-md);
  background: #007AFF;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background 0.2s;
  margin-top: 8px;
}
.dash-crisis-panel-body .crisis-sitrep-btn:hover {
  background: #0062cc;
}

/* Leaflet overrides */
.dash-map-wrap .leaflet-container {
  background: #f0f0f2;
  font-family: inherit;
  border-radius: var(--radius-lg);
}
.dash-map-wrap .leaflet-control-zoom {
  border: none !important;
  box-shadow: var(--shadow-sm) !important;
  border-radius: var(--radius-sm) !important;
  overflow: hidden;
}
.dash-map-wrap .leaflet-control-zoom a {
  width: 36px !important;
  height: 36px !important;
  line-height: 36px !important;
  font-size: 18px !important;
  color: var(--text-secondary) !important;
  background: rgba(255,255,255,.92) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-color: var(--border) !important;
  transition: background var(--transition), color var(--transition);
}
.dash-map-wrap .leaflet-control-zoom a:hover {
  background: var(--surface) !important;
  color: var(--text) !important;
}
.dash-map-wrap .leaflet-control-attribution {
  font-size: 10px !important;
  background: rgba(255,255,255,.7) !important;
  backdrop-filter: blur(6px);
  padding: 2px 8px !important;
}
.dash-map-wrap .leaflet-control-attribution a {
  color: var(--blue) !important;
}

/* Crisis marker styles */
.crisis-marker {
  background: none !important;
  border: none !important;
}
.crisis-marker-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--blue);
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 3px rgba(0,122,255,.25), 0 2px 6px rgba(0,0,0,.15);
  transition: transform .15s ease, box-shadow .15s ease;
  cursor: pointer;
  position: relative;
}
.crisis-marker-dot:hover {
  transform: scale(1.4);
  box-shadow: 0 0 0 6px rgba(0,122,255,.3), 0 2px 8px rgba(0,0,0,.2);
}
.crisis-marker-dot.severity-high {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239,68,68,.25), 0 2px 6px rgba(0,0,0,.15);
  animation: pulse-red 2s ease-in-out infinite;
}
.crisis-marker-dot.severity-high:hover {
  box-shadow: 0 0 0 6px rgba(239,68,68,.35), 0 2px 8px rgba(0,0,0,.2);
  animation: none;
}
.crisis-marker-dot.severity-medium {
  background: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245,158,11,.25), 0 2px 6px rgba(0,0,0,.15);
  animation: pulse-amber 2.5s ease-in-out infinite;
}
.crisis-marker-dot.severity-medium:hover {
  box-shadow: 0 0 0 6px rgba(245,158,11,.35), 0 2px 8px rgba(0,0,0,.2);
  animation: none;
}
.crisis-marker-dot.severity-low {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34,197,94,.25), 0 2px 6px rgba(0,0,0,.15);
}
.crisis-marker-dot.severity-low:hover {
  box-shadow: 0 0 0 6px rgba(34,197,94,.35), 0 2px 8px rgba(0,0,0,.2);
}
@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 3px rgba(239,68,68,.25), 0 2px 6px rgba(0,0,0,.15); }
  50% { box-shadow: 0 0 0 8px rgba(239,68,68,.15), 0 2px 8px rgba(0,0,0,.2); }
}
@keyframes pulse-amber {
  0%, 100% { box-shadow: 0 0 0 3px rgba(245,158,11,.25), 0 2px 6px rgba(0,0,0,.15); }
  50% { box-shadow: 0 0 0 7px rgba(245,158,11,.15), 0 2px 8px rgba(0,0,0,.2); }
}

/* ── Dashboard Sections ── */
.dash-section {
  padding: 24px 32px 0;
}
.dash-section-head {
  margin-bottom: 16px;
}

/* ── Hamburger button ── */
.hamburger-btn {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1100;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition-fast);
  box-shadow: var(--shadow-sm);
}
.hamburger-btn:hover {
  background: var(--surface);
  box-shadow: var(--shadow-md);
  color: var(--text);
}
.hamburger-btn:active { transform: scale(.92); }
.sidebar-nav:not(.hidden) ~ .main .hamburger-btn { display: none; }

/* ── Weekly Overview ── */
.dash-weekly-section {
  padding: 32px 32px 32px;
}
.dash-section-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 18px;
}
.dash-section-title {
  font-size: var(--text-xl); font-weight: 800;
  color: var(--text); letter-spacing: -.3px; margin: 0;
}
.dash-section-date {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.dash-overview-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.dash-kf-card {
  background: var(--surface-raised);
  backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: center;
  box-shadow: var(--shadow-glass);
  transition: box-shadow var(--transition), transform var(--transition-fast);
  overflow: hidden;
  min-width: 0;
}
.dash-kf-card:hover { box-shadow: var(--shadow-elevated); transform: translateY(-1px); }
.dash-kf-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.5px;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-kf-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: .3px;
  margin-top: 2px;
}

.dash-weekly-text {
  background: var(--surface-raised);
  backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-glass);
  line-height: 1.7;
  color: var(--text-secondary);
  font-size: 14px;
}
.dash-weekly-text p {
  margin: 0 0 12px 0;
}
.dash-weekly-text p:last-child {
  margin-bottom: 0;
}
.dash-weekly-text strong {
  color: var(--text);
  font-weight: 700;
}
.dash-weekly-loading {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 16px;
}

/* ── Bulletin Tab — horizontal tabs layout ── */
.bulletin-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.bulletin-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px 12px;
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.bulletin-page-title {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.3px;
  margin: 0;
}
.bulletin-gen-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  background: rgba(0,122,255,.06);
  border: 1px solid rgba(0,122,255,.2);
  border-radius: var(--radius-full);
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition);
  white-space: nowrap;
}
.bulletin-gen-btn:hover {
  background: rgba(0,122,255,.12);
  border-color: var(--blue);
  box-shadow: 0 1px 4px rgba(0,122,255,.1);
}
.bulletin-gen-btn:active { transform: scale(.96); }
.bulletin-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 28px 12px;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: thin;
  background: var(--surface);
}
.bulletin-tab-pill {
  flex-shrink: 0;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast);
  white-space: nowrap;
  font-family: inherit;
  letter-spacing: -.01em;
}
.bulletin-tab-pill:hover {
  background: rgba(0,122,255,.06);
  border-color: rgba(0,122,255,.3);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,122,255,.08);
}
.bulletin-tab-pill:active { transform: scale(.96); }
.bulletin-tab-pill.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,122,255,.25);
}
.bulletin-tab-loading,
.bulletin-tab-empty {
  font-size: 13px;
  color: var(--text-muted);
  padding: 8px 0;
}
.bulletin-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
}
.bulletin-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  color: var(--text-muted);
  text-align: center;
  gap: 12px;
}
.bulletin-empty-state p {
  font-size: 14px;
  margin: 0;
}

/* ── Mobile Bottom Tab Bar (hidden on desktop) ── */
.mobile-tab-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(40px) saturate(1.8);
  -webkit-backdrop-filter: blur(40px) saturate(1.8);
  border-top: 1px solid var(--border);
  padding: 6px 0 env(safe-area-inset-bottom, 8px);
  justify-content: space-around;
  align-items: center;
  height: auto;
}
body.auth-locked .mobile-tab-bar { display: none !important; }

.mobile-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 500;
  padding: 4px 0;
  cursor: pointer;
  transition: color var(--transition-fast);
  min-width: 56px;
}
.mobile-tab svg { transition: transform var(--transition-fast); }
.mobile-tab.active {
  color: var(--primary);
}
.mobile-tab.active svg {
  transform: scale(1.1);
}
.mobile-tab span {
  line-height: 1.2;
}

/* Tablet (768px and below) */
@media (max-width: 768px) {
  :root { --nav-h: 0px; }

  /* Hide sidebar, show bottom tab bar */
  .sidebar-nav { display: none; }
  .hamburger-btn { display: none !important; }
  .mobile-tab-bar { display: flex; }
  .main { margin-left: 0 !important; }

  /* Add bottom padding for tab bar */
  .panel { padding-bottom: 70px; }

  /* Auth responsive */
  .auth-overlay { flex-direction: column; }
  .auth-hero { padding: 32px 24px; min-height: auto; }
  .auth-hero-title { font-size: 28px; }
  .auth-hero-stats { gap: 20px; margin-bottom: 20px; }
  .auth-hero-stat-value { font-size: 22px; }
  .auth-hero-features { gap: 8px; }
  .auth-hero-sources { margin-top: 20px; padding-top: 14px; }
  .auth-hero-sources-list { gap: 6px; }
  .auth-card { width: 100%; padding: 32px 24px; box-shadow: 0 -4px 20px rgba(0,0,0,.1); }

  /* Chat responsive */
  .chat-sidebar { width: 85vw; }
  .chat-center { width: calc(100% - 24px); padding: 16px 0; }
  .chat-input-wrap { width: calc(100% - 24px); }
  .msg.user .msg-body { max-width: 90%; }
  .chat-footer { padding: 8px 12px 14px; }

  /* SITREP responsive */
  .sitrep-page { min-height: 100%; }
  .sitrep-topbar { padding: 12px 16px 0; }
  .sitrep-topbar-form { flex-wrap: wrap; }
  .sitrep-reports-bar { padding: 0 16px; }
  .sitrep-main-content { padding: 0 16px; }
  .narrative-layout { grid-template-columns: 1fr; }
  .narrative-toc { display: none; }

  /* DB responsive */
  .filters { overflow-x: auto; flex-wrap: nowrap; padding: 8px 12px; }
  .fi.wide { min-width: 140px; }
  .reports-wrap { padding: 16px 12px; gap: 12px; }
  .table-wrap { border-radius: var(--radius); }

  /* Ingest responsive */
  .ingest-wrap { padding: 16px 12px; }
  .mq-form { grid-template-columns: 1fr 1fr; }
  .up-grid { grid-template-columns: 1fr; }

  /* Dashboard responsive */
  .dashboard { padding: 0; }
  .dash-topbar { padding: 12px 16px 0; }
  .dash-topbar-left { flex-wrap: wrap; gap: 8px; }
  .dash-quick-links { flex-wrap: wrap; }
  .dash-map-wrap { height: 45vh; margin: 8px 16px 0; border-radius: var(--radius); }
  .dash-world-map { min-height: 240px; }
  .dash-world-map.panel-open { margin-right: 0; }
  .dash-crisis-panel { width: 100%; height: 65vh; transform: translateY(100%); border-radius: var(--radius-xl) var(--radius-xl) 0 0; border-left: none; border-top: 1px solid var(--glass-border); }
  .dash-crisis-panel.open { transform: translateY(0); }
  .dash-crisis-panel-header { padding: 14px 16px 10px; }
  .dash-crisis-panel-close { width: 32px; height: 32px; font-size: 18px; }
  .dash-section { padding: 20px 16px 0; }
  .dash-weekly-section { padding: 0 16px 24px; }
  .dash-overview-stats { grid-template-columns: repeat(2, 1fr); }
  .dash-map-overlay { top: 8px; left: 8px; gap: 4px; }
  .dash-source { padding: 3px 8px; font-size: 10px; }
  .bulletin-tabs { padding: 4px 16px 10px; }
  .bulletin-content { padding: 16px; }

  /* Bulletin responsive */
  .bulletin-crises-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .severity-filter { flex-wrap: wrap; }
  .crisis-grid { grid-template-columns: 1fr; }
  .bulletin-kf-row { flex-wrap: wrap; }
  .bulletin-kf-card { min-width: calc(50% - 8px); }
  .bulletin-page-head { padding: 16px; }

  /* Admin */
  .admin-panel-content { padding: 16px 12px; }
  .admin-user-table { font-size: 12px; }
}

/* Mobile (480px and below) */
@media (max-width: 480px) {
  :root { --nav-h: 0px; }

  .mobile-tab-bar { padding: 4px 0 env(safe-area-inset-bottom, 6px); }
  .mobile-tab { font-size: 9px; min-width: 48px; }
  .mobile-tab svg { width: 20px; height: 20px; }

  /* Auth */
  .auth-overlay { flex-direction: column; }
  .auth-hero { padding: 20px 16px; }
  .auth-hero-title { font-size: 22px; }
  .auth-hero-stats { gap: 16px; margin-bottom: 16px; }
  .auth-hero-stat-value { font-size: 18px; }
  .auth-hero-features { display: none; }
  .auth-hero-sources { display: none; }
  .auth-card { width: 100%; padding: 24px 16px; }
  .auth-card h1 { font-size: 20px; }
  .auth-logo { width: 48px; height: 48px; }
  .auth-card-feature { padding: 8px 10px; }
  .auth-card-feature-icon { width: 28px; height: 28px; }
  .auth-card-feature strong { font-size: 11.5px; }
  .auth-card-feature span { font-size: 10px; }
  .auth-copyright { font-size: 10px; }

  /* Chat */
  .chat-input-wrap { border-radius: 20px; padding: 4px 4px 4px 16px; }
  .send-btn { width: 36px; height: 36px; }
  .chat-textarea { font-size: 13px; }
  .welcome-greeting { font-size: 22px; }
  .quick-prompt-btn { padding: 6px 12px; font-size: 11px; }

  /* SITREP */
  .sitrep-view { padding: 16px 12px; }
  .steps-grid { grid-template-columns: repeat(2, 1fr); }
  .pipeline-title { font-size: 14px; }
  .sitrep-topbar-form { gap: 8px; }
  .sitrep-topbar-form .fi { font-size: 13px; padding: 8px 10px; }
  .fi-date label { font-size: 10px; }

  /* DB */
  .stats-row { padding: 8px 10px; }
  .stat-pill { font-size: 11px; padding: 4px 10px; }
  .rtable { font-size: 11px; }
  .stat-card { padding: 10px 12px; }
  .stat-card-value { font-size: 18px; }

  /* Dashboard */
  .dash-topbar { padding: 10px 12px 0; }
  .dash-topbar-title { font-size: var(--text-lg); }
  .dash-topbar-left { flex-wrap: wrap; gap: 6px; }
  .dash-quick-links { gap: 4px; flex-wrap: wrap; }
  .dash-quick-link { padding: 5px 10px; font-size: 11px; }
  .dash-map-wrap { height: 38vh; margin: 6px 12px 0; }
  .dash-world-map { min-height: 200px; }
  .dash-world-map.panel-open { margin-right: 0; }
  .dash-crisis-panel { width: 100%; height: 70vh; transform: translateY(100%); border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
  .dash-crisis-panel.open { transform: translateY(0); }
  .dash-map-overlay { top: 6px; left: 6px; gap: 3px; }
  .dash-source { padding: 2px 6px; font-size: 9px; }
  .dash-section { padding: 16px 12px 0; }
  .dash-weekly-section { padding: 0 12px 16px; }
  .dash-overview-stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .dash-kf-value { font-size: 18px; }
  .dash-kf-card { padding: 10px 12px; }

  /* Bulletin */
  .bulletin-title { font-size: 18px; }
  .bulletin-kf-card { min-width: calc(50% - 6px); padding: 10px 12px; }
  .bulletin-kf-value { font-size: 18px; }
  .crisis-grid { gap: 10px; }
  .crisis-card { padding: 12px 14px; }
  .crisis-card-country { font-size: 15px; }
  .crisis-card-headline { font-size: 12px; }
  .crisis-card-summary { font-size: 11px; }

  /* Login */
  .auth-google-btn { padding: 11px 14px; font-size: 14px; }

  /* Toast */
  .toast-container { top: 12px; right: 12px; left: 12px; }
  .toast { max-width: 100%; font-size: 12px; }
}

/* ── Skeleton loaders ── */
.skeleton {
  background: linear-gradient(90deg, var(--border-light) 25%, var(--bg) 50%, var(--border-light) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

.skeleton-row { height: 36px; margin-bottom: 1px; }
.skeleton-row.short { width: 60%; }
.skeleton-row.medium { width: 80%; }
.skeleton-card {
  height: 80px; border-radius: var(--radius); margin-bottom: 8px;
}

/* ── Toast notifications ── */
.toast-container {
  position: fixed; top: 70px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 13px; font-weight: 500; color: var(--text);
  animation: toastIn .3s ease-out;
  max-width: 380px; word-break: break-word;
}
.toast.success { border-left: 4px solid var(--green); background: var(--green-light); }
.toast.error   { border-left: 4px solid var(--red);   background: var(--red-light); }
.toast.warning { border-left: 4px solid var(--amber);  background: var(--amber-light); }
.toast.info    { border-left: 4px solid var(--blue);   background: var(--blue-light); }
.toast-icon { flex-shrink: 0; font-size: 16px; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(20px); } }

/* ═══════════════════════════════════════════════════════════════════════════
   WEEKLY BULLETIN
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Sidebar bulletin items — Apple light ──────────────────────────────── */
.bulletin-item {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  margin-bottom: 4px;
}
.bulletin-item:hover {
  background: rgba(0,0,0,.04);
}
.bulletin-item:active { transform: scale(.98); }
.bulletin-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.bulletin-item-meta {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Bulletin generate button (sidebar) ─────────────────────────────────── */
.bulletin-gen-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: var(--blue);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition);
}
.bulletin-gen-btn:hover {
  background: var(--blue-hover);
}
.bulletin-gen-btn:active { transform: scale(.97); }
.bulletin-gen-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Bulletin loading/error ──────────────────────────────────────────────── */
.bulletin-loading, .bulletin-error {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 15px;
}
.bulletin-error {
  color: var(--red);
}

/* ── Bulletin header ─────────────────────────────────────────────────────── */
.bulletin-header {
  margin-bottom: 24px;
}
.bulletin-title-row {
  margin-bottom: 16px;
}
.bulletin-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin: 0;
  letter-spacing: -.5px;
}
.bulletin-fallback-notice {
  background: var(--amber-light);
  color: var(--amber-dark);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin: 8px 0;
  border: 1px solid rgba(255,159,10,.4);
}

/* ── Key figures row ─────────────────────────────────────────────────────── */
.bulletin-kf-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.bulletin-kf-card {
  background: var(--surface-raised);
  backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow-glass);
}
.bulletin-kf-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.bulletin-kf-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: .3px;
  margin-top: 4px;
}

/* ── Global overview ──────────────────────────────────────────────────────── */
.bulletin-overview {
  background: var(--surface-raised);
  backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-glass);
}
.bulletin-overview h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 10px 0;
  letter-spacing: .3px;
}
.bulletin-overview p {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin: 0;
}

/* ── Crisis cards grid ───────────────────────────────────────────────────── */
.bulletin-crises {
  margin-bottom: 24px;
}
.bulletin-crises h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 16px 0;
  letter-spacing: .3px;
}
.bulletin-crises-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.bulletin-crises-head h3 {
  margin: 0;
}
.severity-filter {
  display: flex;
  gap: 6px;
}
.severity-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.severity-pill:hover {
  border-color: var(--text-tertiary);
  color: var(--text);
}
.severity-pill.active {
  background: var(--navy);
  color: var(--text-inverse);
  border-color: var(--navy);
}
.crisis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}
.crisis-card {
  background: var(--surface-raised);
  backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-glass);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  border-left: 4px solid var(--text-muted);
  border-top: 1px solid var(--glass-border);
  border-right: 1px solid var(--glass-border);
  border-bottom: 1px solid var(--glass-border);
}
.crisis-card:hover {
  box-shadow: var(--shadow-elevated);
  transform: translateY(-2px);
}
.crisis-card:active { transform: translateY(0) scale(.99); }
.crisis-card.crisis-high {
  border-left-color: var(--red);
}
.crisis-card.crisis-medium {
  border-left-color: var(--amber);
}
.crisis-card.crisis-low {
  border-left-color: var(--green);
}
.crisis-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.crisis-card-country {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.crisis-card-headline {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 4px;
}
.crisis-card-summary {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.severity-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.hdx-kf-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.hdx-kf-mini {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 10px;
  background: rgba(0,122,255,.08);
  border: 1px solid rgba(0,122,255,.2);
  border-radius: var(--radius-xs);
  min-width: 70px;
}
.hdx-kf-mini .hdx-kf-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--blue);
}
.hdx-kf-mini .hdx-kf-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.crisis-sitrep-btn {
  display: inline-block;
  margin-top: 12px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  background: var(--blue-light);
  border: 1px solid rgba(0,122,255,.2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition-fast), border-color var(--transition);
}
.crisis-sitrep-btn:hover {
  background: var(--blue);
  color: var(--text-inverse);
}
.crisis-sitrep-btn:active { transform: scale(.97); }
