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

:root {
  --bg:       #f5f6f8;
  --surface:  #ffffff;
  --border:   #e2e5ea;
  --text:     #1e293b;
  --text-dim: #64748b;
  --primary:  #047857;
  --primary-hover: #065f46;
  --primary-light: #ecfdf5;
  --accent:   #0d9488;
  --danger:   #dc2626;
  --radius:   10px;
  --radius-sm: 6px;
  --shadow:   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,.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12);
  --transition: .2s ease;
  --nav-h: 56px;
}

html { font-size: 15px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Custom scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── Nav ───────────────────────────────────────────────────────── */
.nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.5rem;
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  background: rgba(255,255,255,.92);
}
.nav-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: -.02em;
  flex-shrink: 0;
}
.nav-links { display: flex; gap: .25rem; }
.nav-link {
  padding: .45rem .9rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-dim);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { background: var(--primary-light); color: var(--primary); }
.nav-user { margin-left: auto; display: flex; align-items: center; gap: .6rem; flex-shrink: 0; }
.nav-username { font-size: .85rem; font-weight: 500; color: var(--text-dim); }

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: background var(--transition);
  flex-shrink: 0;
}
.nav-toggle:hover { background: var(--bg); }
.nav-toggle svg { width: 20px; height: 20px; }

/* ── Layout ────────────────────────────────────────────────────── */
.main { max-width: 860px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
.section-title { font-size: 1.4rem; font-weight: 700; margin-bottom: .25rem; letter-spacing: -.01em; }
.section-desc { color: var(--text-dim); margin-bottom: 1.5rem; font-size: .9rem; }
.section-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.subsection-title { font-size: 1.1rem; font-weight: 600; margin: 1.5rem 0 .25rem; }

/* ── Forms ─────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.15rem; }
.form-label {
  font-size: .85rem; font-weight: 500; color: var(--text-dim);
  display: inline-flex; align-items: center; gap: .4rem;
  margin-bottom: .35rem;
}
.form-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: .75rem; }
.form-actions { display: flex; gap: .5rem; align-items: center; margin-top: 1.25rem; flex-wrap: wrap; }

.input-area, .input-text {
  width: 100%;
  padding: .7rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .95rem;
  font-family: inherit;
  resize: vertical;
  transition: border-color var(--transition), box-shadow var(--transition);
  background: var(--surface);
  color: var(--text);
  min-height: 44px; /* touch-friendly */
}
.input-area:focus, .input-text:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(4,120,87,.1);
}
.input-area::placeholder, .input-text::placeholder { color: #94a3b8; }
.input-small {
  width: 4rem; padding: .35rem .5rem;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: .85rem; text-align: center;
  min-height: 36px;
}

/* Custom checkbox */
input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1.15rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition), transform .1s ease;
  min-height: 40px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:hover { background: var(--bg); }
.btn:active { transform: scale(.98); }
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; min-height: 34px; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-title { font-size: 1rem; font-weight: 600; margin-bottom: .75rem; color: var(--primary); }

/* ── Answer ────────────────────────────────────────────────────── */
.answer-text { line-height: 1.7; font-size: .93rem; }

/* ── Markdown body ────────────────────────────────────────────── */
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  margin-top: 1rem; margin-bottom: .4rem; line-height: 1.3;
}
.markdown-body h1 { font-size: 1.3rem; }
.markdown-body h2 { font-size: 1.15rem; }
.markdown-body h3 { font-size: 1.05rem; }
.markdown-body h4 { font-size: .95rem; }
.markdown-body > *:first-child { margin-top: 0; }
.markdown-body p { margin: .4rem 0; }
.markdown-body ul, .markdown-body ol { margin: .4rem 0; padding-left: 1.4rem; }
.markdown-body li { margin-bottom: .2rem; }
.markdown-body strong { font-weight: 600; }
.markdown-body em { font-style: italic; }
.markdown-body blockquote {
  margin: .5rem 0; padding: .5rem .9rem;
  border-left: 3px solid var(--primary); background: var(--primary-light);
  color: var(--text-dim); font-size: .9rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.markdown-body code {
  background: var(--bg); padding: .1rem .35rem; border-radius: 3px;
  font-size: .85rem; font-family: 'Consolas', 'Monaco', monospace;
}
.markdown-body pre { background: var(--bg); padding: .75rem; border-radius: var(--radius); overflow-x: auto; margin: .5rem 0; }
.markdown-body pre code { background: none; padding: 0; }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: .75rem 0; }
.markdown-body table { border-collapse: collapse; width: 100%; margin: .5rem 0; font-size: .9rem; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border); padding: .4rem .6rem; text-align: left; }
.markdown-body th { background: var(--bg); font-weight: 600; }

/* ── Chunks ────────────────────────────────────────────────────── */
.chunks-grid { display: flex; flex-direction: column; gap: .6rem; margin-top: .75rem; }

.chunk-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}
.chunk-card:hover { box-shadow: var(--shadow-md); }
.chunk-card.mini { padding: .75rem; }
.chunk-text { font-size: .9rem; margin: .5rem 0 .35rem; line-height: 1.55; }
.chunk-ref { color: var(--text-dim); font-size: .8rem; }
.chunk-meta { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .4rem; }

/* ── Badges ────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .55rem;
  border-radius: 5px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}
.badge-ayet      { background: #dbeafe; color: #1e40af; }
.badge-hadis     { background: #fef3c7; color: #92400e; }
.badge-tefsir    { background: #e0e7ff; color: #3730a3; }
.badge-gorus     { background: #f3e8ff; color: #6b21a8; }
.badge-arguman   { background: #ecfdf5; color: #065f46; }
.badge-temsil    { background: #fce7f3; color: #9d174d; }
.badge-scan-butunluk  { background: #fee2e2; color: #991b1b; }
.badge-scan-icerik    { background: #fef3c7; color: #92400e; }
.badge-scan-referans  { background: #dbeafe; color: #1e40af; }
.badge-confidence     { background: var(--bg); color: var(--text-dim); }
.badge-flag           { background: #fef3c7; color: #78350f; }
.badge-sihhat-sahih    { background: #d1fae5; color: #065f46; }
.badge-sihhat-hasen    { background: #dbeafe; color: #1e40af; }
.badge-sihhat-zayif    { background: #fef3c7; color: #92400e; }
.badge-sihhat-mevzu    { background: #fee2e2; color: #991b1b; }
.badge-sihhat-belirsiz { background: var(--bg); color: var(--text-dim); }
.badge-verified  { background: #d1fae5; color: #065f46; }
.badge-contested { background: #fef3c7; color: #78350f; }
.badge-kaynak    { background: #1e293b; color: #fff; }

/* ── Findings ──────────────────────────────────────────────────── */
.findings-list { display: flex; flex-direction: column; gap: .5rem; margin-top: .75rem; }
.finding-card {
  display: flex;
  gap: .75rem;
  padding: .85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: box-shadow var(--transition);
}
.finding-card:hover { box-shadow: var(--shadow-md); }
.finding-check { flex-shrink: 0; display: flex; align-items: flex-start; gap: .4rem; padding-top: .1rem; cursor: pointer; }
.finding-index { font-size: .8rem; font-weight: 600; color: var(--text-dim); }
.finding-body { flex: 1; min-width: 0; }
.finding-meta { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .4rem; }
.finding-reason { font-size: .9rem; margin-bottom: .3rem; }
.finding-suggestion { font-size: .85rem; color: var(--accent); font-style: italic; }
.finding-chunk { color: var(--text-dim); font-size: .78rem; }

/* ── Details ───────────────────────────────────────────────────── */
.details-block { margin: 1rem 0; }
.details-block summary {
  cursor: pointer;
  font-weight: 600;
  font-size: .95rem;
  padding: .4rem 0;
  color: var(--text);
  transition: color var(--transition);
}
.details-block summary:hover { color: var(--primary); }
.details-block ul { padding-left: 1.25rem; margin-top: .4rem; }
.details-block li { font-size: .9rem; margin-bottom: .25rem; color: var(--text-dim); }

/* ── Table ─────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; padding: .6rem .75rem; border-bottom: 2px solid var(--border); color: var(--text-dim); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.table td { padding: .6rem .75rem; border-bottom: 1px solid var(--border); }
.table tr { transition: background var(--transition); }
.table tr:hover td { background: var(--primary-light); }

/* Mobile card view for tables */
.report-cards { display: none; }
.report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: .75rem;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}
.report-card:hover { box-shadow: var(--shadow-md); }
.report-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .75rem;
  margin-bottom: .5rem;
}
.report-card-title { font-weight: 600; font-size: .95rem; color: var(--text); word-break: break-word; }
.report-card-meta {
  display: flex;
  gap: .75rem;
  align-items: center;
  font-size: .82rem;
  color: var(--text-dim);
  margin-bottom: .75rem;
}
.report-card-stat {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
}

/* ── Status / loading ──────────────────────────────────────────── */
.status {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin: 1rem 0;
  font-size: .9rem;
  animation: fadeIn .3s ease;
}
.status.loading { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.status.success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.status.error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.hidden { display: none !important; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── File drop ─────────────────────────────────────────────────── */
.file-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  text-align: center;
  margin-bottom: .75rem;
  color: var(--text-dim);
  font-size: .9rem;
  transition: border-color var(--transition), background var(--transition);
  cursor: pointer;
}
.file-drop:hover { border-color: #94a3b8; }
.file-drop.dragover { border-color: var(--primary); background: var(--primary-light); }
.file-drop-icon { font-size: 1.75rem; margin-bottom: .4rem; display: block; opacity: .5; }
.file-label { color: var(--primary); font-weight: 500; cursor: pointer; text-decoration: underline; }

/* ── Empty state ───────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-dim);
  font-size: .95rem;
}
.empty-state-icon {
  display: block;
  font-size: 2.5rem;
  margin-bottom: .75rem;
  opacity: .4;
}

/* ── Spinner ───────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
  margin-right: .4rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Typing dots ─────────────────────────────────────────────── */
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}
.typing-dots span {
  width: 7px;
  height: 7px;
  background: var(--text-dim);
  border-radius: 50%;
  animation: typing 1.4s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes typing {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* ── Chat Layout (sidebar + main) ─────────────────────────────── */
.main-wide { max-width: 1200px; padding: 0; }

.chat-layout {
  display: flex;
  height: calc(100vh - var(--nav-h));
  height: calc(100dvh - var(--nav-h));
}

/* Sidebar */
.chat-sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition);
}
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  min-height: 52px;
}
.sidebar-title { font-size: .9rem; font-weight: 700; color: var(--text); }
.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: .4rem 0;
}
.sidebar-empty {
  text-align: center;
  padding: 2rem .75rem;
  color: var(--text-dim);
  font-size: .85rem;
}
.sidebar-item {
  display: block;
  padding: .65rem 1rem;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: .85rem;
  color: var(--text);
  line-height: 1.4;
  transition: background .12s;
  border-left: 3px solid transparent;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-item:hover { background: var(--bg); }
.sidebar-item.active { background: var(--primary-light); border-left-color: var(--primary); }
.sidebar-item-preview {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
.sidebar-item-meta {
  display: block;
  font-size: .75rem;
  color: var(--text-dim);
  margin-top: .15rem;
}
.sidebar-toggle { display: none; }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--nav-h);
  background: rgba(0,0,0,.3);
  z-index: 89;
  opacity: 0;
  transition: opacity .2s ease;
}
.sidebar-overlay.visible {
  display: block;
  opacity: 1;
}

/* ── Chat UI ──────────────────────────────────────────────────── */
.chat-section {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--nav-h));
  height: calc(100dvh - var(--nav-h));
  flex: 1;
  min-width: 0;
  padding: 1rem 1.5rem 1rem;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-shrink: 0;
}
.chat-header .section-desc { margin-bottom: 0; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  scroll-behavior: smooth;
}

.chat-msg {
  display: flex;
  max-width: 80%;
  animation: msgIn .3s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-msg-user { align-self: flex-end; }
.chat-msg-assistant { align-self: flex-start; }
.chat-msg-error { align-self: center; }

.chat-bubble {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: .93rem;
  line-height: 1.6;
  box-shadow: var(--shadow);
}
.chat-bubble-user {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 3px;
}
.chat-bubble-assistant {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px;
}
.chat-bubble-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  font-size: .85rem;
}
.chat-loading {
  color: var(--text-dim);
}

.chat-rewrite {
  margin-top: .6rem;
  padding-top: .5rem;
  border-top: 1px solid var(--border);
  font-size: .82rem;
  color: var(--text-dim);
}

.chat-details { margin: .5rem 0 0; }
.chat-details summary { font-size: .85rem; }

.chat-chunks { display: flex; flex-direction: column; gap: .4rem; margin-top: .5rem; }

/* Chat empty state */
.chat-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  color: var(--text-dim);
  padding: 2rem;
  gap: .5rem;
}
.chat-empty-icon { font-size: 3rem; opacity: .3; }
.chat-empty-title { font-size: 1.1rem; font-weight: 600; color: var(--text); }
.chat-empty-desc { font-size: .9rem; max-width: 360px; }

/* Chat input bar */
.chat-input-bar {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
}
.chat-input-row {
  display: flex;
  gap: .5rem;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  padding: .65rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .95rem;
  font-family: inherit;
  resize: none;
  overflow-y: auto;
  max-height: 150px;
  line-height: 1.5;
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 44px;
}
.chat-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(4,120,87,.1);
}
.chat-input::placeholder { color: #94a3b8; }
.chat-send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  transition: background var(--transition), transform .1s ease;
  flex-shrink: 0;
}
.chat-send-btn:hover { background: var(--primary-hover); }
.chat-send-btn:active { transform: scale(.95); }
.chat-send-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.chat-send-btn svg { width: 20px; height: 20px; }

.chat-input-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
  justify-content: flex-end;
}
.form-label-inline { font-size: .8rem; display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; }

/* ── Responsive ────────────────────────────────────────────────── */

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

  /* Nav mobile menu */
  .nav { padding: 0 1rem; gap: .75rem; }
  .nav-toggle { display: inline-flex; }
  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    flex-direction: column;
    padding: .5rem;
    z-index: 99;
  }
  .nav-links.open { display: flex; }
  .nav-link { padding: .65rem 1rem; border-radius: var(--radius-sm); font-size: .9rem; }
  .nav-username { display: none; }

  /* Chat sidebar overlay */
  .chat-sidebar {
    position: fixed;
    left: -300px;
    top: var(--nav-h);
    bottom: 0;
    z-index: 90;
    width: 280px;
    box-shadow: var(--shadow-lg);
    transition: left .25s ease;
  }
  .chat-sidebar.open { left: 0; }
  .sidebar-toggle { display: inline-flex; }
  .chat-section { padding: .75rem 1rem .75rem; }

  /* General */
  .main { padding: 1.25rem 1rem 3rem; }
  .section-title { font-size: 1.25rem; }
  .chat-msg { max-width: 90%; }
}

/* Mobile */
@media (max-width: 640px) {
  html { font-size: 14.5px; }

  .nav { padding: 0 .75rem; gap: .5rem; }
  .main { padding: 1rem .75rem 2.5rem; }
  .main-wide { padding: 0; }
  .section-title { font-size: 1.15rem; }
  .section-desc { font-size: .85rem; margin-bottom: 1rem; }

  .form-row { flex-direction: column; align-items: stretch; }
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; }

  .chat-msg { max-width: 95%; }
  .chat-section { padding: .5rem .75rem .5rem; }
  .chat-input-actions { flex-wrap: wrap; gap: .5rem; }
  .chat-header .section-title { font-size: 1.05rem; }
  .chat-header .section-desc { display: none; }

  /* Table → card view for reports */
  .table-wrap { display: none; }
  .report-cards { display: block; }

  /* Ingest page adjustments */
  .file-drop { padding: 1.25rem .75rem; }

  /* Finding cards */
  .finding-card { flex-direction: column; gap: .5rem; }
  .finding-check { flex-direction: row; }
}

/* Small mobile */
@media (max-width: 380px) {
  html { font-size: 14px; }
  .nav-brand { font-size: 1.1rem; }
  .btn { padding: .5rem .85rem; font-size: .82rem; }
  .chat-bubble { padding: .6rem .8rem; font-size: .88rem; }
}

/* ── Login page ───────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f0fdf4 0%, #f5f6f8 50%, #ecfdf5 100%);
  padding: 1rem;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  animation: fadeIn .4s ease;
}
.login-header { text-align: center; margin-bottom: 2rem; }
.login-brand { font-size: 1.75rem; font-weight: 700; color: var(--primary); letter-spacing: -.02em; }
.login-desc { color: var(--text-dim); font-size: .9rem; margin-top: .35rem; }
.login-form .form-group { margin-bottom: 1.15rem; }
.login-form .form-label { display: block; margin-bottom: .35rem; }
.login-btn {
  width: 100%;
  justify-content: center;
  padding: .7rem;
  font-size: .95rem;
  margin-top: .75rem;
  min-height: 46px;
}

@media (max-width: 480px) {
  .login-card { padding: 2rem 1.5rem; border-radius: var(--radius); }
  .login-brand { font-size: 1.5rem; }
}

/* ── Safe area (notch devices) ───────────────────────────────── */
@supports (padding: env(safe-area-inset-bottom)) {
  .chat-input-bar { padding-bottom: env(safe-area-inset-bottom); }
  .nav { padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); }
}

/* ── Focus visible (keyboard navigation) ─────────────────────── */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.btn:focus-visible, .chat-input:focus-visible, .input-text:focus-visible, .input-area:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(4,120,87,.15);
}

/* ── Print ────────────────────────────────────────────────────── */
@media print {
  .nav, .chat-sidebar, .chat-input-bar, .sidebar-toggle, .form-actions { display: none; }
  .chat-section { height: auto; }
  .chat-messages { overflow: visible; }
}
