/* ═══════════════════════════════════════════════════════════════════════════
   style.css — ReliefAgent Data Platform
   Premium Design System
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── CSS Variables ──────────────────────────────────────────────────────── */
:root {
  /* Brand */
  --primary:        #C8102E;
  --primary-dark:   #A00D24;
  --primary-light:  #fdf2f2;
  --primary-glow:   rgba(200,16,46,.12);

  /* Surface */
  --bg:             #f4f5f7;
  --surface:        #ffffff;
  --surface-raised: #ffffff;
  --border:         #e2e4e8;
  --border-light:   #eff1f3;

  /* Text */
  --text:           #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --text-inverse:   #ffffff;

  /* Accent */
  --navy:           #0f1d36;
  --navy-light:     #1a2d4d;
  --blue:           #2563eb;
  --blue-light:     #dbeafe;

  /* Semantic */
  --green:          #059669;
  --green-light:    #ecfdf5;
  --red:            #dc2626;
  --red-light:      #fef2f2;
  --amber:          #d97706;
  --amber-light:    #fffbeb;

  /* Design tokens */
  --radius-sm:      6px;
  --radius:         10px;
  --radius-lg:      14px;
  --radius-xl:      20px;
  --shadow-xs:      0 1px 2px rgba(0,0,0,.04);
  --shadow-sm:      0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:      0 4px 12px rgba(0,0,0,.07), 0 1px 3px rgba(0,0,0,.04);
  --shadow-lg:      0 10px 30px rgba(0,0,0,.1), 0 2px 6px rgba(0,0,0,.04);
  --shadow-xl:      0 20px 50px rgba(0,0,0,.15);
  --transition:     .2s cubic-bezier(.4,0,.2,1);

  /* Layout */
  --nav-h:          56px;
  --sidebar-w:      260px;
  --sitrep-sidebar-w: 270px;

  /* SITREP compatibility aliases */
  --bg-app:         #f4f5f7;
  --bg-sidebar:     #0f1d36;
  --bg-card:        #ffffff;
  --bg-console:     #0a0f1a;
  --accent:         #1a2d4d;
  --accent-hover:   #0f1d36;
  --success:        #059669;
  --warning:        #d97706;
  --danger:         #dc2626;
  --text-primary:   #0f172a;
  --text-sidebar:   rgba(255,255,255,.4);
  --shadow-md-compat: 0 4px 24px rgba(0,0,0,0.15);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ═══════════════════════════════════════════════════════════════════════════
   NAVIGATION
   ═══════════════════════════════════════════════════════════════════════════ */
.nav {
  background: var(--navy);
  color: var(--text-inverse);
  padding: 0 24px;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
  z-index: 100;
  position: sticky;
  top: 0;
}
.nav::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary) 30%, transparent 100%);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}
.nav-logo-img {
  height: 32px;
  width: auto;
  object-fit: contain;
  border-radius: 4px;
}
.nav-brand {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .5px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
  flex-shrink: 0;
}
.tab-group {
  background: rgba(255,255,255,.06);
  padding: 3px;
  border-radius: 8px;
  flex-shrink: 0;
}
.tab-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.6);
  padding: 7px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: .2px;
  transition: all var(--transition);
  white-space: nowrap;
  font-family: inherit;
}
.tab-btn.active {
  background: var(--primary);
  color: white;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(200,16,46,.35);
}
.tab-btn:hover:not(.active) {
  color: rgba(255,255,255,.9);
  background: rgba(255,255,255,.08);
}

.nav-reset {
  background: none;
  border: 1px solid rgba(255,255,255,.2);
  color: rgba(255,255,255,.6);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .3px;
  transition: all var(--transition);
  white-space: nowrap;
  font-family: inherit;
}
.nav-reset:hover {
  background: rgba(255,255,255,.08);
  color: white;
  border-color: rgba(255,255,255,.35);
}

.busy-dot {
  width: 7px; height: 7px;
  background: #fbbf24;
  border-radius: 50%;
  display: none;
  animation: pulse 1.4s ease-in-out infinite;
  box-shadow: 0 0 8px rgba(251,191,36,.5);
}
.busy-dot.visible { display: block; }
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.4;transform:scale(.85)} }

/* ═══════════════════════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════════════════════ */
.main { flex: 1; overflow: hidden; display: flex; }
.panel { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.panel.active { display: flex; }

/* ═══════════════════════════════════════════════════════════════════════════
   TAB 1 — DATABASE
   ═══════════════════════════════════════════════════════════════════════════ */
.reports-wrap { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.stats-row {
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.stat-pill {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 5px 16px;
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  letter-spacing: .1px;
}
.stat-pill strong { font-weight: 700; color: var(--text); }

.refresh-btn {
  margin-left: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 16px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--transition);
  font-family: inherit;
}
.refresh-btn:hover { background: var(--border-light); color: var(--text); border-color: var(--text-muted); }

.filters {
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  flex-shrink: 0;
}

.fi {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 12.5px;
  outline: none;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: all var(--transition);
}
.fi:focus      { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.fi.wide       { flex: 1; min-width: 180px; }
.fi-count      { font-size: 11px; color: var(--text-muted); margin-left: auto; font-weight: 500; }

.table-wrap { flex: 1; overflow: auto; }

.rtable { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.rtable thead th {
  position: sticky; top: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  z-index: 2;
}
.rtable thead th:hover  { color: var(--text); }
.rtable thead th.sorted { color: var(--primary); }
.rtable tbody td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
.rtable tbody tr { transition: background var(--transition); }
.rtable tbody tr:hover td { background: var(--primary-light); }
.rtable tbody tr:hover { cursor: pointer; }

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

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: .2px;
}
.b-green  { background: var(--green-light); color: #065f46; }
.b-blue   { background: var(--blue-light); color: #1e40af; }
.b-gray   { background: var(--bg); color: var(--text-muted); }
.b-yellow { background: var(--amber-light); color: #92400e; }
.b-red    { background: var(--red-light); color: #991b1b; }

.empty { text-align: center; padding: 60px 20px; color: var(--text-muted); font-size: 13px; font-weight: 400; }
.empty .icon { font-size: 28px; margin-bottom: 8px; opacity: .5; }

/* ── DB Report Modal ────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(8px);
  z-index: 200;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: min(660px, 94vw);
  max-height: 86vh; overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalIn .25s ease;
}
@keyframes modalIn { from{transform:translateY(12px) scale(.98);opacity:0} to{transform:translateY(0) scale(1);opacity:1} }

.modal-hdr {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: flex-start; gap: 14px;
}
.modal-title { font-size: 15px; font-weight: 700; flex: 1; line-height: 1.45; letter-spacing: -.2px; }
.modal-close {
  background: var(--bg); border: 1px solid var(--border);
  width: 28px; height: 28px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; cursor: pointer; color: var(--text-muted);
  transition: all var(--transition); line-height: 1;
}
.modal-close:hover { background: var(--red-light); color: var(--red); border-color: #fca5a5; }

.modal-bdy { padding: 20px 24px; }
.dg { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.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: 13.5px; line-height: 1.45; color: var(--text); }
.di.full { grid-column: 1 / -1; }

.chunk-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  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','Cascadia Code','Consolas',monospace;
}

.modal-ftr {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  display: flex; gap: 8px; justify-content: flex-end;
}

/* ── Buttons ────────────────────────────────────────── */
.btn {
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: .2px;
  transition: all var(--transition);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 1px 3px rgba(200,16,46,.3);
}
.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 3px 10px rgba(200,16,46,.35);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--border-light);
  border-color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════════════════
   TAB 2 — AGENT CHAT (Gemini-style)
   ═══════════════════════════════════════════════════════════════════════════ */
#panel-agent { position: relative; overflow: hidden; }

/* ── Sidebar overlay ── */
.chat-sidebar-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 49;
  opacity: 0; pointer-events: none;
  transition: opacity .3s ease;
}
.chat-sidebar-overlay.open { opacity: 1; pointer-events: auto; }

/* ── Collapsible sidebar drawer ── */
.chat-sidebar {
  position: absolute; top: 0; left: 0; bottom: 0;
  width: 300px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 50;
  transform: translateX(-100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  box-shadow: none;
}
.chat-sidebar.open {
  transform: translateX(0);
  box-shadow: 4px 0 24px rgba(0,0,0,.12);
}

.chat-sidebar-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
}
.sidebar-close-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); display: flex; align-items: center;
  padding: 4px; border-radius: 6px;
  transition: all var(--transition);
}
.sidebar-close-btn:hover { background: var(--bg); color: var(--text); }
.sidebar-head-title {
  font-size: 13px; font-weight: 700; color: var(--text);
  letter-spacing: .2px;
}

.chat-new-btn {
  margin: 12px 14px;
  padding: 10px 0;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: .2px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 2px 6px rgba(200,16,46,.25);
}
.chat-new-btn:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(200,16,46,.35);
  transform: translateY(-1px);
}

.chat-list {
  flex: 1; overflow-y: auto;
  padding: 0 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: all 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: 5px;
  padding: 4px 14px; font-size: 11px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: all .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: 5px;
  padding: 4px 14px; font-size: 11px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: all .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: 4px;
  padding: 3px 10px; font-size: 10.5px; font-weight: 700;
  cursor: pointer; font-family: inherit; transition: all .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: var(--bg); color: var(--text); }
.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: 4px;
  color: var(--text-muted); font-weight: 600; font-family: inherit;
  transition: all var(--transition); letter-spacing: .5px;
}
.chat-item-btn:hover { background: var(--border-light); color: var(--text); }
.chat-item-btn.delete:hover { background: var(--red-light); color: var(--red); }

/* ── Chat Main (Gemini-style centered) ── */
.chat-main {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; background: var(--bg);
}

/* Top bar with sidebar toggle */
.chat-topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}
.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: all var(--transition);
}
.sidebar-toggle-btn:hover { background: var(--bg); color: var(--text); }
.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;
}

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

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

/* User messages — right-aligned rounded chip */
.msg.user {
  align-items: flex-end;
}
.msg.user .msg-body {
  background: var(--primary);
  color: white;
  border-radius: 20px 20px 4px 20px;
  padding: 12px 20px;
  max-width: 75%;
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
  box-shadow: 0 2px 8px rgba(200,16,46,.15);
}

/* AI messages — full width clean text */
.msg.assistant {
  align-items: flex-start;
}
.msg-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  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: 100%;
  word-break: break-word;
  overflow-wrap: break-word;
  box-shadow: none;
}

/* Tool indicator */
.tool-ind {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  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(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Quick prompt buttons ── */
.quick-prompts {
  margin-top: 16px; padding-top: 16px;
  border-top: 1px solid var(--border-light);
}
.quick-prompts-title {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .8px; margin-bottom: 10px;
}
.quick-prompt-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; 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: all var(--transition);
  white-space: nowrap;
}
.quick-prompt-btn:hover {
  border-color: var(--primary); color: var(--primary);
  background: var(--primary-light); box-shadow: 0 2px 8px var(--primary-glow);
  transform: translateY(-1px);
}

/* ── Chat rate hint ── */
.chat-rate-hint {
  text-align: center; font-size: 11px; color: var(--text-muted);
  padding: 4px 0 0; letter-spacing: .1px; max-width: 780px; width: 100%;
  margin: 0 auto; min-height: 18px;
}
.chat-rate-hint.low { color: var(--amber); font-weight: 600; }
.chat-rate-hint.exhausted { color: var(--red); font-weight: 600; }
.rate-upgrade { color: var(--primary); font-weight: 500; }
.rate-upgrade a { color: var(--primary); text-decoration: underline; }
.rate-upgrade a:hover { color: var(--primary-dark, #2563eb); }

/* Rate limit message in chat (shown when limit reached) */
.rate-limit-msg {
  padding: 16px 20px;
  border-radius: var(--radius);
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.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(--primary); text-decoration: underline;
}
.rate-limit-msg-contact a:hover {
  color: var(--primary-dark, #2563eb);
}

/* ═════════════════════════════════════════════════════════════════════
   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-box   { pointer-events: auto; }

.auth-overlay {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f1d36 0%, #1a2d4d 40%, #2a1a1a 100%);
  backdrop-filter: blur(8px);
}
.auth-overlay.hidden { display: none; }

.auth-box {
  width: 440px; max-width: 92vw; text-align: center;
  padding: 44px 36px 32px;
  background: rgba(255,255,255,.97);
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 60px rgba(0,0,0,.3);
  animation: authFadeIn .5s ease-out;
}
@keyframes authFadeIn { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

.auth-brand { margin-bottom: 28px; }
.auth-logo { width: 72px; height: 72px; margin-bottom: 14px; border-radius: 16px; box-shadow: 0 4px 16px rgba(59,130,246,.2); }
.auth-brand h1 { font-size: 28px; font-weight: 800; color: var(--primary); margin: 0 0 4px; letter-spacing: -.5px; }
.auth-brand p  { font-size: 14px; color: var(--text-muted); margin: 0; }
.auth-subtitle { font-weight: 400 !important; letter-spacing: .3px; }

.auth-features {
  display: flex; flex-direction: column; gap: 10px;
  margin: 24px 0 28px; text-align: left;
}
.auth-feature {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius);
  background: var(--bg); border: 1px solid var(--border-light);
  transition: all var(--transition);
}
.auth-feature:hover { border-color: var(--primary); box-shadow: 0 2px 8px var(--primary-glow); }
.auth-feature-icon {
  flex-shrink: 0; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-light); color: var(--primary);
  border-radius: var(--radius-sm);
}
.auth-feature-text { display: flex; flex-direction: column; gap: 2px; }
.auth-feature-text strong { font-size: 13px; font-weight: 600; color: var(--text); }
.auth-feature-text span  { font-size: 11.5px; color: var(--text-muted); line-height: 1.4; }

.auth-google-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 13px 18px; font-size: 15px; font-weight: 600; color: #3c4043;
  background: #fff; border: 1px solid #dadce0; border-radius: 8px; cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,.08); transition: all .2s ease;
}
.auth-google-btn:hover { background: #f8f9fa; box-shadow: 0 4px 12px rgba(0,0,0,.12); transform: translateY(-1px); }
.auth-google-btn:active { transform: translateY(0); }
.auth-google-btn:disabled { opacity: 0.6; 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: 11.5px; color: var(--text-muted); line-height: 1.5;
}
.auth-legal a { color: var(--text-secondary); text-decoration: underline; text-decoration-color: var(--border); }
.auth-legal a:hover { color: var(--primary); }

.auth-copyright {
  margin-top: 24px; font-size: 11px; color: rgba(255,255,255,.35);
  letter-spacing: .3px; text-align: center;
}

/* user bar */
.user-bar {
  position: relative;
  top: auto; right: auto;
  z-index: 60;
  display: flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 10px; font-size: 13px; font-weight: 500;
  color: rgba(255,255,255,.85); background: rgba(255,255,255,.08); border-radius: 8px;
  border: 1px solid rgba(255,255,255,.12);
}
.user-bar.hidden { display: none; }
.user-bar img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.user-bar #user-name { color: rgba(255,255,255,.9); white-space: nowrap; }
.user-bar button {
  margin-left: 6px; padding: 3px 8px; font-size: 11px; color: rgba(255,255,255,.65);
  background: transparent; border: 1px solid rgba(255,255,255,.2); border-radius: 6px; cursor: pointer; transition: all .15s;
}
.user-bar button:hover { background: rgba(255,255,255,.1); color: white; border-color: rgba(255,255,255,.4); }

.rate-badge {
  font-size: 11px; font-weight: 600; padding: 2px 7px;
  border-radius: 10px; white-space: nowrap;
  background: rgba(255,255,255,.1); color: rgba(255,255,255,.7);
  border: 1px solid rgba(255,255,255,.15);
}
.rate-badge.rate-limit-low {
  background: rgba(234,179,8,.15); color: #eab308;
  border-color: rgba(234,179,8,.3);
}
.rate-badge.rate-limit-exhausted {
  background: rgba(220,38,38,.15); color: #ef4444;
  border-color: rgba(220,38,38,.3);
}

.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 (Gemini-style centered input) ── */
.chat-footer {
  padding: 12px 20px 20px;
  background: var(--bg);
  display: flex; justify-content: center;
  flex-shrink: 0;
}
.chat-input-wrap {
  max-width: 780px; width: 100%;
  display: flex; align-items: flex-end; gap: 0;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 24px;
  padding: 6px 6px 6px 20px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}
.chat-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow), 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;
}
.chat-textarea::placeholder { color: var(--text-muted); }
.send-btn {
  background: var(--primary);
  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: all var(--transition);
  box-shadow: 0 2px 6px rgba(200,16,46,.25);
}
.send-btn:hover {
  background: var(--primary-dark);
  box-shadow: 0 3px 10px rgba(200,16,46,.35);
  transform: scale(1.06);
}
.send-btn:disabled { opacity: .35; cursor: not-allowed; transform: none; box-shadow: none; }
.send-btn svg { margin-left: 1px; }

/* Markdown in AI messages */
.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: 5px; padding: 2px 7px;
  font-size: 12px; font-family: 'SF Mono','Cascadia Code','Consolas',monospace;
}
.msg.user .msg-body code { background: rgba(255,255,255,.15); border-color: transparent; }
.msg-body pre {
  background: #1e293b; color: #e2e8f0;
  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,.06);
}
.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(--bg); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); }
.msg-body a     { color: var(--primary); 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(--primary); padding-left: 16px; color: var(--text-secondary); margin: 10px 0; font-style: italic; }

/* ═══════════════════════════════════════════════════════════════════════════
   TAB 3 — SITREP
   ═══════════════════════════════════════════════════════════════════════════ */
.sitrep-layout { flex: 1; display: flex; overflow: hidden; }

/* Sidebar */
.sitrep-sidebar {
  width: var(--sitrep-sidebar-w);
  min-width: var(--sitrep-sidebar-w);
  background: var(--navy);
  display: flex; flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}
.sitrep-sidebar::-webkit-scrollbar { width: 4px; }
.sitrep-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }

.sitrep-brand {
  padding: 20px 18px 16px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand-icon {
  font-size: 13px;
  font-weight: 800;
  background: var(--primary);
  color: white;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  letter-spacing: 1px;
}
.sitrep-brand h1 {
  font-size: 14px; font-weight: 700; color: #fff;
  letter-spacing: 2.5px; text-transform: uppercase;
}
.sitrep-brand span { font-size: 10px; color: rgba(255,255,255,.4); margin-top: 2px; display: block; letter-spacing: .3px; }

.sidebar-run { padding: 14px 12px; border-bottom: 1px solid rgba(255,255,255,.06); }
#btn-toggle-form {
  width: 100%; padding: 10px 14px;
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.8);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius);
  font-size: 12px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: all var(--transition);
  font-family: inherit; letter-spacing: .3px;
}
#btn-toggle-form:hover { background: rgba(255,255,255,.12); color: white; border-color: rgba(255,255,255,.2); }

.run-form { margin-top: 10px; display: flex; flex-direction: column; gap: 7px; }
.run-form.hidden { display: none; }
.run-form input, .run-form textarea {
  width: 100%; padding: 9px 12px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius-sm);
  color: #fff; font-size: 12px; outline: none;
  font-family: inherit;
  transition: border var(--transition);
}
.run-form input::placeholder { color: rgba(255,255,255,.25); }
.run-form input:focus { border-color: var(--primary); }
.run-form label { display: flex; align-items: center; gap: 7px; color: rgba(255,255,255,.4); font-size: 11px; cursor: pointer; }
.run-form label input[type=checkbox] { accent-color: var(--primary); cursor: pointer; }
#btn-run {
  padding: 10px;
  background: var(--green);
  color: white; border: none;
  border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: opacity var(--transition);
  letter-spacing: .2px;
}
#btn-run:hover    { opacity: .88; }
#btn-run:disabled { opacity: .4; cursor: not-allowed; }

/* ── Theme pills ── */
.form-group-label {
  font-size: 10px; font-weight: 600; letter-spacing: .6px;
  text-transform: uppercase; color: rgba(255,255,255,.35);
  margin-top: 2px;
}
.theme-pills {
  display: flex; flex-wrap: wrap; gap: 5px;
}
.theme-pills-loading, .theme-pills-empty {
  font-size: 11px; color: rgba(255,255,255,.25); font-style: italic;
}
.theme-pill {
  padding: 4px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 500;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.5);
  cursor: pointer; transition: all var(--transition);
  user-select: none;
}
.theme-pill:hover {
  background: rgba(255,255,255,.1);
  color: rgba(255,255,255,.7);
}
.theme-pill.selected {
  background: var(--primary);
  border-color: var(--primary);
  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: rgba(255,255,255,.3);
}
.form-date-field input[type="date"] {
  width: 100%; padding: 7px 8px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius-sm);
  color: #fff; font-size: 11px; outline: none;
  font-family: inherit;
  transition: border var(--transition);
  color-scheme: dark;
}
.form-date-field input[type="date"]:focus {
  border-color: var(--primary);
}
.date-range-hint {
  font-size: 11px; color: var(--text-muted, #888);
  margin: 4px 0 2px 0; min-height: 16px;
}

/* ── Chunk preview bar ── */
.chunk-preview {
  font-size: 11.5px; padding: 8px 10px; border-radius: 6px;
  margin: 6px 0 8px 0; line-height: 1.5;
}
.chunk-preview.hidden { display: none; }
.chunk-preview.ok  { background: rgba(76,175,80,.12); color: #4caf50; border: 1px solid rgba(76,175,80,.25); }
.chunk-preview.warn { background: rgba(255,152,0,.12); color: #ff9800; border: 1px solid rgba(255,152,0,.25); }
.chunk-preview.err  { background: rgba(244,67,54,.12); color: #f44336; border: 1px solid rgba(244,67,54,.25); }
.chunk-preview .cp-count { font-weight: 700; }
.chunk-preview .cp-themes { font-size: 10.5px; opacity: .85; margin-top: 2px; }

/* ── Report view toggle ── */
.report-view-toggle {
  display: flex; gap: 0; margin-bottom: 20px;
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; width: fit-content;
}
.report-view-btn {
  padding: 8px 20px; border: none;
  font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  background: var(--surface); color: var(--text-muted);
  transition: all var(--transition);
  letter-spacing: .2px;
}
.report-view-btn:hover { color: var(--text); }
.report-view-btn.active {
  background: var(--primary); color: #fff;
}
.report-view-section.hidden { display: none; }

/* ── Narrative report body ── */
.narrative-body {
  line-height: 1.8; font-size: 14px; color: var(--text);
  text-align: justify;
}
.narrative-body h1,
.narrative-body h2,
.narrative-body h3 {
  font-size: 16px; font-weight: 700;
  margin: 24px 0 10px; letter-spacing: -.3px;
  color: var(--text); border-bottom: 1px solid var(--border-light);
  padding-bottom: 6px;
}
.narrative-body h3 { font-size: 15px; border-bottom: none; padding-bottom: 0; margin: 18px 0 8px; }
.narrative-body p { margin: 8px 0; }
.narrative-body a { color: var(--primary); text-decoration: none; font-weight: 500; }
.narrative-body a:hover { text-decoration: underline; }

.sidebar-section-title {
  padding: 14px 18px 6px;
  font-size: 9px; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase;
  color: rgba(255,255,255,.3);
}
#sitrep-reports-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
#sitrep-reports-list::-webkit-scrollbar { width: 4px; }
#sitrep-reports-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 4px; }

.report-item {
  padding: 10px 12px; border-radius: var(--radius);
  cursor: pointer; transition: all var(--transition); margin-bottom: 2px;
}
.report-item:hover { background: rgba(255,255,255,.05); }
.report-item.active {
  background: rgba(200,16,46,.2);
  border-left: 3px solid var(--primary);
}
.report-item-name { font-size: 12px; font-weight: 600; color: rgba(255,255,255,.85); line-height: 1.35; }
.report-item-meta { font-size: 10px; color: rgba(255,255,255,.35); margin-top: 3px; }
.sidebar-empty { color: rgba(255,255,255,.3); font-size: 12px; padding: 12px 10px; }

/* SITREP main area */
.sitrep-main { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.sitrep-view { flex: 1; overflow-y: auto; padding: 28px 32px; }
.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: 20px; font-weight: 800; letter-spacing: 4px;
  color: var(--text-muted); opacity: .3; margin-bottom: 16px;
}
.welcome-title { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 8px; letter-spacing: -.3px; }
.welcome-sub   { font-size: 13px; max-width: 400px; line-height: 1.7; }

/* Pipeline progress */
.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: all .3s ease;
}
.step-card.waiting { opacity: .4; }
.step-card.active  { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.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 */
.log-wrap {
  background: #0a0f1a;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255,255,255,.04);
}
.log-header {
  background: rgba(255,255,255,.03);
  padding: 10px 18px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.log-header-title {
  color: rgba(255,255,255,.35);
  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(5,150,105,.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','Consolas','Courier New',monospace;
  font-size: 11.5px; line-height: 1.65;
}
#log-console::-webkit-scrollbar { width: 4px; }
#log-console::-webkit-scrollbar-thumb { background: #374151; border-radius: 4px; }

.log-line          { padding: 1px 0; color: rgba(255,255,255,.35); }
.log-line.info     { color: #6ee7b7; }
.log-line.warn     { color: #fcd34d; }
.log-line.error    { color: #fca5a5; }
.log-line.debug    { color: rgba(255,255,255,.2); }
.log-line.cached   { color: #7dd3fc; }
.log-line.step     { color: #93c5fd; font-weight: 700; }
.log-line.done-line { color: #34d399; font-weight: 700; }
.log-line.gpu-warn { color: rgba(255,255,255,.15); font-size: 11px; font-style: italic; }

/* SITREP Report view */
.report-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.report-title   { font-size: 22px; font-weight: 800; line-height: 1.3; letter-spacing: -.4px; }
.report-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 4px; letter-spacing: .2px; }
.report-meta-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  margin: -12px 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: all 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-discuss-agent {
  background: var(--primary) !important;
  color: white !important;
  border-color: var(--primary) !important;
  box-shadow: 0 2px 6px rgba(200,16,46,.25);
}
.btn-discuss-agent:hover {
  background: var(--primary-dark) !important;
  border-color: var(--primary-dark) !important;
  box-shadow: 0 3px 10px rgba(200,16,46,.35);
  transform: translateY(-1px);
}

.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 .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(--primary);
}
.cluster-badge {
  display: inline-block;
  background: var(--primary);
  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(--navy-light);
  color: white;
  font-size: 9px; font-weight: 700;
  padding: 1px 6px; border-radius: 4px;
  cursor: pointer; transition: all var(--transition);
  vertical-align: middle; margin: 0 1px;
  letter-spacing: .3px;
}
.citation:hover { background: var(--navy); transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,.15); }

.sources-section  { border-top: 1px solid var(--border-light); margin-top: 8px; padding-top: 14px; }
.sources-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--text-muted); margin-bottom: 10px;
}
.source-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius);
  text-decoration: none; color: var(--text);
  font-size: 12px; line-height: 1.45;
  transition: background var(--transition); margin-bottom: 1px;
}
.source-item:hover { background: var(--bg); }
.source-item-num {
  flex-shrink: 0;
  background: var(--navy-light); color: white;
  font-size: 9px; font-weight: 700;
  padding: 2px 7px; border-radius: 4px; 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; }

/* SITREP Citation Modal */
.sitrep-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  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: var(--navy);
  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(--primary);
  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(--primary);
  color: white; border-radius: var(--radius);
  text-decoration: none;
  font-size: 13px; font-weight: 600; line-height: 1.4;
  transition: all var(--transition); word-break: break-word;
  box-shadow: 0 2px 8px rgba(200,16,46,.25);
}
.modal-source-link a:hover { background: var(--primary-dark); 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: #1e40af; font-size: 10px; padding: 3px 10px; border-radius: var(--radius-xl); font-weight: 600; letter-spacing: .2px; }

/* ═══════════════════════════════════════════════════════════════════════════
   TAB 4 — INGEST
   ═══════════════════════════════════════════════════════════════════════════ */
.ingest-wrap {
  flex: 1; overflow-y: auto; padding: 28px 32px;
  display: flex; flex-direction: column; gap: 24px;
}
.ingest-section {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  box-shadow: var(--shadow-sm);
}
.ingest-section-hdr {
  display: flex; align-items: center; gap: 10px; margin-bottom: 18px;
  padding-bottom: 14px; border-bottom: 1px solid var(--border-light);
}
.ingest-section-hdr span { font-size: 22px; }
.ingest-section-hdr h3 {
  font-size: 14px; font-weight: 700; color: var(--text);
  margin: 0; letter-spacing: -.2px;
}
.ingest-hint { font-size: 12.5px; color: var(--text-muted); margin-bottom: 16px; line-height: 1.6; }

/* Query form grid */
.mq-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.mq-actions {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; margin-bottom: 14px;
}
.mq-sel-all-label {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--text-muted); cursor: pointer; user-select: none;
}

/* Ingest status bar */
.ingest-status {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 12.5px; font-weight: 500;
  margin-bottom: 12px;
  border: 1px solid transparent;
}
.ingest-status.info    { background: var(--blue-light); color: #1e40af; border-color: #93c5fd; }
.ingest-status.success { background: var(--green-light); color: #065f46; border-color: #86efac; }
.ingest-status.warning { background: var(--amber-light); color: #92400e; border-color: #fcd34d; }
.ingest-status.error   { background: var(--red-light);   color: #991b1b; border-color: #fca5a5; }

/* Ingested badge */
.badge-ingested {
  display: inline-block;
  background: var(--green-light); color: #065f46;
  padding: 2px 8px; border-radius: 4px;
  font-size: 10px; font-weight: 600; white-space: nowrap;
  letter-spacing: .2px;
}
.badge-new {
  display: inline-block;
  background: var(--blue-light); color: #1e40af;
  padding: 2px 8px; border-radius: 4px;
  font-size: 10px; font-weight: 600; white-space: nowrap;
  letter-spacing: .2px;
}

/* Upload form */
.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: #1e40af;
  font-size: 11px; font-weight: 600;
  padding: 4px 10px; border-radius: var(--radius-xl);
}
.tag-chip button {
  background: none; border: none; cursor: pointer;
  color: #3b82f6; 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; }

/* td-title max width in ingest table */
#panel-ingest .td-title { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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

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

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

  .nav {
    flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px;
  }
  .nav-logo .sub { display: none; }
  .nav-brand { font-size: 12px; }
  .tab-group {
    order: 3; width: 100%; margin-top: 4px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  .tab-btn { padding: 6px 12px; font-size: 12px; white-space: nowrap; }
  .nav-reset { padding: 5px 10px; font-size: 10px; }

  /* Auth responsive */
  .auth-box { padding: 32px 20px 24px; }
  .auth-brand h1 { font-size: 24px; }
  .auth-features { gap: 8px; }
  .auth-feature { padding: 10px 12px; }

  /* Chat responsive */
  .chat-sidebar { width: 85vw; }
  .chat-center { padding: 16px 12px; }
  .msg.user .msg-body { max-width: 90%; }
  .chat-footer { padding: 8px 12px 14px; }

  /* SITREP responsive */
  .sitrep-layout { flex-direction: column; }
  .sitrep-sidebar {
    width: 100%; min-width: 100%; max-height: 40vh;
    border-right: none; border-bottom: 1px solid rgba(255,255,255,.1);
  }
  .sitrep-main { min-height: 50vh; }

  /* DB responsive */
  .filters { overflow-x: auto; flex-wrap: nowrap; padding: 8px 12px; }
  .fi.wide { min-width: 140px; }

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

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

  .nav { padding: 6px 8px; gap: 6px; }
  .nav-logo-img { height: 24px; }
  .nav-brand { font-size: 14px; }
  .tab-btn { padding: 5px 10px; font-size: 11px; }
  .user-bar #user-name { display: none; }
  .busy-dot { display: none !important; }

  /* Auth */
  .auth-box { padding: 28px 16px 20px; width: 95vw; }
  .auth-brand h1 { font-size: 22px; }
  .auth-logo { width: 56px; height: 56px; }
  .auth-feature { padding: 8px 10px; }
  .auth-feature-icon { width: 30px; height: 30px; }
  .auth-feature-text strong { font-size: 12px; }
  .auth-feature-text span { font-size: 10.5px; }
  .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; }

  /* SITREP */
  .sitrep-view { padding: 16px 12px; }
  .steps-grid { grid-template-columns: repeat(2, 1fr); }
  .pipeline-title { font-size: 14px; }

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

  /* Ingest */
  .mq-form { grid-template-columns: 1fr; }
  .mq-actions { flex-wrap: wrap; gap: 6px; }

  /* Quick prompts */
  .quick-prompt-btn { padding: 6px 12px; font-size: 11px; }

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

/* ── 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); } }
