:root {
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active-bg: rgba(37, 99, 235, 0.15);
  --sidebar-active-border: #2563eb;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --main-bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --user-bubble: #2563eb;
  --user-bubble-text: #ffffff;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--main-bg);
}

.hidden { display: none !important; }

/* ── App shell ────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.logo {
  display: block;
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 3px;
}

.logo-sub {
  display: block;
  font-size: 10px;
  color: var(--sidebar-text);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-top: 2px;
  opacity: 0.65;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background 0.12s, color 0.12s;
  cursor: pointer;
}

.nav-item svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: 0.75;
}

.nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: #e2e8f0;
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  border-left-color: var(--sidebar-active-border);
  color: #ffffff;
}

.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,0.07);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.user-name { font-size: 13px; font-weight: 600; color: #f1f5f9; }
.user-role { font-size: 11px; color: var(--sidebar-text); opacity: 0.6; margin-top: 1px; }

.sign-out {
  width: 100%;
  padding: 7px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 7px;
  color: var(--sidebar-text);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.sign-out:hover { background: rgba(255,255,255,0.07); color: #e2e8f0; }

/* ── Main ─────────────────────────────────────────────── */
.main-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--main-bg);
}

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: white;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.main-header h1 { font-size: 19px; font-weight: 600; }

/* ── Health badge ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 500;
}

.badge-active { background: #dcfce7; color: #15803d; }
.badge-error  { background: #fee2e2; color: #b91c1c; }
.badge-checking { background: #fef9c3; color: #854d0e; }

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

/* ── Page content ─────────────────────────────────────── */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ── Loading / spinner ────────────────────────────────── */
.loading {
  text-align: center;
  color: var(--text-muted);
  padding: 48px 24px;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid #e2e8f0;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 12px;
}

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

/* ── Dashboard ────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
}

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.stat-value {
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ── Dashboard rows ───────────────────────────────────── */
.dashboard-row { margin-bottom: 20px; }
.dashboard-row:last-child { margin-bottom: 0; }

.dashboard-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 900px) {
  .dashboard-grid-2 { grid-template-columns: 1fr; }
}

/* health + chart card share the stat-card surface look */
.health-card,
.chart-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.card-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.health-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid #f1f5f9;
}

.health-row:last-child { border-bottom: none; }

.health-label {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

.health-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 5px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  word-break: break-all;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.status-pill::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status-pill.ok      { background: #dcfce7; color: #15803d; }
.status-pill.bad     { background: #fee2e2; color: #b91c1c; }
.status-pill.pending { background: #fef9c3; color: #854d0e; }

.usage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 0;
  border-bottom: 1px solid #f1f5f9;
}

.usage-row:last-child { border-bottom: none; }
.usage-label { font-size: 13px; color: var(--text-muted); }
.usage-value { font-size: 14px; font-weight: 600; color: var(--text); }
.usage-value.mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; }

.chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

.chart-card { display: flex; flex-direction: column; }
.chart-canvas-wrap { position: relative; height: 220px; }

/* ── Documents ────────────────────────────────────────── */
.docs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.docs-title { font-size: 15px; font-weight: 600; }

.search-input {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  width: 250px;
  outline: none;
  background: white;
  font-family: inherit;
}

.search-input:focus { border-color: var(--accent); }

.docs-table {
  width: 100%;
  background: white;
  border-radius: 12px;
  border: 1px solid var(--border);
  border-collapse: collapse;
  overflow: hidden;
}

.docs-table th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.docs-table td {
  padding: 11px 16px;
  font-size: 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.docs-table tr:last-child td { border-bottom: none; }
.docs-table tr:hover td { background: #f8fafc; }

.folder-badge {
  display: inline-block;
  padding: 2px 8px;
  background: #eff6ff;
  color: #2563eb;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.tag-chip {
  display: inline-block;
  padding: 2px 7px;
  background: #f1f5f9;
  color: var(--text-muted);
  border-radius: 4px;
  font-size: 11px;
  margin: 1px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
}

.page-btn {
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}

.page-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Documents (enterprise upgrade) ───────────────────── */
.docs-actionbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.docs-actionbar .search-input {
  width: 100%;
  max-width: 520px;
}

.docs-filter-group { display: flex; gap: 8px; }

.docs-filter {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  cursor: pointer;
}

.docs-filter:focus { border-color: var(--accent); }

.docs-sync-btn {
  padding: 8px 14px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.docs-sync-btn:hover { background: var(--accent-hover); }
.docs-sync-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.docs-bulkbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.docs-bulk-count {
  font-size: 13px;
  color: var(--text-muted);
  margin-right: auto;
}

.docs-banner {
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid transparent;
}

.docs-banner[data-kind="success"] {
  background: #dcfce7;
  color: #15803d;
  border-color: #86efac;
}

.docs-banner[data-kind="warn"] {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}

.docs-banner[data-kind="error"] {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

.docs-banner[data-kind="info"] {
  background: #e0f2fe;
  color: #075985;
  border-color: #7dd3fc;
}

.docs-check-cell {
  width: 32px;
  text-align: center;
  padding-left: 4px !important;
  padding-right: 4px !important;
}

.docs-check-cell input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
  margin: 0;
}

.docs-summary {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.metric-card {
  flex: 1;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.metric-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 4px;
}

.metric-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.metric-value.small { font-size: 14px; font-weight: 600; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.status-pill.indexed { background: #dcfce7; color: #15803d; }
.status-pill.pending { background: #fef3c7; color: #b45309; }
.status-pill.failed { background: #fee2e2; color: #b91c1c; }
.status-pill.unknown { background: #e2e8f0; color: #475569; }

.docs-table tr[data-path] { cursor: pointer; }
.docs-table td.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--text);
}

/* ── Document inspection drawer ──────────────────────── */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 50;
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.doc-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  max-width: 92vw;
  background: white;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.08);
  transform: translateX(100%);
  transition: transform 0.2s ease;
  z-index: 51;
  display: flex;
  flex-direction: column;
}

.doc-drawer.open { transform: translateX(0); }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.drawer-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-close {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 20px;
  color: var(--text-muted);
  padding: 4px 8px;
  line-height: 1;
}

.drawer-close:hover { color: var(--text); }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.drawer-section { margin-bottom: 22px; }

.drawer-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.drawer-meta-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid #f1f5f9;
}

.drawer-meta-row:last-child { border-bottom: none; }
.drawer-meta-label { color: var(--text-muted); }
.drawer-meta-value { color: var(--text); font-weight: 500; }

.drawer-raw {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: var(--text-muted);
  white-space: pre-wrap;
  max-height: 180px;
  overflow-y: auto;
}

.chunks-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.chunks-table th, .chunks-table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid #f1f5f9;
}

.chunks-table th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.chunks-table td.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.drawer-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
}

.btn-danger {
  width: 100%;
  padding: 9px 14px;
  background: #dc2626;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-danger:hover { background: #b91c1c; }

/* ── Chat ─────────────────────────────────────────────── */
.chat-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
}

/* override page-content padding for chat */
.page-content.chat-mode { padding: 0 24px; }

.chat-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-subtitle { font-size: 13px; color: var(--text-muted); }

.toolbar-actions { display: flex; gap: 8px; }

.btn {
  padding: 7px 13px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: white;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s;
}

.btn:hover { background: #f1f5f9; }

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-primary:hover { background: var(--accent-hover); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  gap: 10px;
  padding: 40px;
  user-select: none;
}

.chat-empty-icon { font-size: 38px; opacity: 0.35; }
.chat-empty-title { font-size: 17px; font-weight: 600; color: var(--text); }
.chat-empty-sub { font-size: 14px; }

.message {
  display: flex;
  flex-direction: column;
  max-width: 76%;
}

.message.user  { align-self: flex-end;  align-items: flex-end; }
.message.assistant { align-self: flex-start; align-items: flex-start; }

.bubble {
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user .bubble {
  background: var(--user-bubble);
  color: var(--user-bubble-text);
  border-bottom-right-radius: 4px;
}

.message.assistant .bubble {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.sources-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
  padding-left: 2px;
}

.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px 3px 4px;
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background 0.12s, transform 0.08s, box-shadow 0.12s;
}

.source-chip:hover {
  background: #dbeafe;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.18);
}

.source-chip .src-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  padding: 0 5px;
  background: #2563eb;
  color: white;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
}

.source-chip .src-icon { font-size: 11px; }

.source-chip .src-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Thinking panel ─────────────────────────────────── */
.thinking-panel {
  margin: 4px 0 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
  font-size: 12.5px;
  overflow: hidden;
}

.thinking-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  color: var(--text-muted);
}

.thinking-summary::-webkit-details-marker { display: none; }

.thinking-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid #cbd5e1;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.thinking-check { color: #16a34a; font-weight: 700; }

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

.thinking-steps {
  padding: 6px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 1px solid var(--border);
}

.thinking-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  color: var(--text-muted);
  font-size: 12.5px;
}

.thinking-step.done { color: var(--text); }
.thinking-step.done .step-state::before { content: '✓'; color: #16a34a; font-weight: 700; }
.thinking-step .step-state { margin-left: auto; }

/* ── Document inspection modal ──────────────────────── */
.doc-inspect-modal {
  width: 720px;
  max-width: 95vw;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
}

.doc-inspect-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.meta-pill {
  padding: 3px 9px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.doc-inspect-body {
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
  padding-right: 4px;
}

.doc-inspect-chunk {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fafbfc;
}

.chunk-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--border);
}

.chunk-heading {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.chunk-score {
  font-size: 11px;
  padding: 2px 8px;
  background: #eff6ff;
  color: #2563eb;
  border-radius: 999px;
  font-weight: 600;
}

.chunk-body {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
}

/* ── Utility bar ────────────────────────────────────── */
.utility-bar {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  padding-left: 2px;
}

.util-btn {
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  transition: background 0.12s, transform 0.08s;
}

.util-btn:hover { background: #f1f5f9; transform: scale(1.08); }
.util-btn.active { background: #e0f2fe; color: #0369a1; }

/* ── Follow-up chips ────────────────────────────────── */
.followup-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding-left: 2px;
}

.followup-chip {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  border-radius: 999px;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  max-width: 100%;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}

.followup-chip:hover {
  background: #f8fafc;
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.typing-indicator {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 8px 4px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  animation: bounce 1.2s infinite;
}

.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-5px); }
}

.chat-input-area {
  border-top: 1px solid var(--border);
  padding: 14px 0 12px;
  flex-shrink: 0;
}

.chat-input-row { display: flex; gap: 9px; align-items: flex-end; }

.chat-textarea {
  flex: 1;
  min-height: 46px;
  max-height: 150px;
  padding: 11px 15px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 14.5px;
  font-family: inherit;
  resize: none;
  outline: none;
  background: white;
  transition: border-color 0.12s;
  line-height: 1.5;
}

.chat-textarea:focus { border-color: var(--accent); }

.send-btn {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--accent);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s;
}

.send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.send-btn:disabled { background: #94a3b8; cursor: not-allowed; }

.input-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; text-align: center; }

/* ── Conversations ────────────────────────────────────── */
.section-header {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
}

.conv-list { display: flex; flex-direction: column; gap: 8px; }

.conv-item {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.conv-item:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(37,99,235,0.07);
}

.conv-title { font-size: 14px; font-weight: 500; color: var(--text); }
.conv-meta  { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.conv-count { font-size: 12px; color: var(--text-muted); white-space: nowrap; margin-left: 12px; }

.conv-detail-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.back-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
}

.back-btn:hover { text-decoration: underline; }

/* ── Logs ─────────────────────────────────────────────── */
.log-list {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 12px;
}

.log-entry {
  display: flex;
  gap: 14px;
  padding: 9px 16px;
  border-bottom: 1px solid #f1f5f9;
  line-height: 1.4;
}

.log-entry:last-child { border-bottom: none; }
.log-time  { color: var(--text-muted); flex-shrink: 0; min-width: 145px; }
.log-level { font-weight: 700; flex-shrink: 0; width: 40px; }
.log-level.info  { color: #2563eb; }
.log-level.error { color: #dc2626; }
.log-level.warn  { color: #d97706; }
.log-msg   { color: var(--text); word-break: break-word; }

/* ── Login ────────────────────────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.login-card {
  background: #1e293b;
  border-radius: 16px;
  padding: 40px 36px;
  width: 340px;
  border: 1px solid rgba(255,255,255,0.09);
}

.login-logo {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 4px;
  text-align: center;
  margin-bottom: 4px;
}

.login-subtitle {
  text-align: center;
  color: #94a3b8;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 30px;
}

#login-form { display: flex; flex-direction: column; gap: 11px; }

#password-input {
  padding: 11px 15px;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  color: white;
  font-size: 15px;
  font-family: inherit;
  outline: none;
}

#password-input:focus { border-color: var(--accent); }
#password-input::placeholder { color: #64748b; }

#login-form button {
  padding: 11px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s;
}

#login-form button:hover { background: var(--accent-hover); }

.error { color: #f87171; font-size: 13px; text-align: center; }

/* ── Modal ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.modal {
  background: white;
  border-radius: 14px;
  padding: 28px;
  width: 530px;
  max-width: 92vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
}

.modal h3 { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.modal > p { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }

.code-block {
  background: #0f172a;
  border-radius: 8px;
  padding: 16px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 13px;
  color: #e2e8f0;
  white-space: pre;
  overflow-x: auto;
  margin-bottom: 16px;
}

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ── Documents upload panel ───────────────────────────────────────── */
.docs-upload {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 14px;
}
.docs-upload-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
}
.docs-upload-caret { transition: transform .15s ease; }
.docs-upload-body { display: none; padding: 0 16px 16px; }
.docs-upload[data-open="true"] .docs-upload-body { display: block; }
.docs-upload[data-open="true"] .docs-upload-caret { transform: rotate(180deg); }
.docs-dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 96px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 18px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.docs-dropzone.is-dragover {
  background: rgba(37, 99, 235, .06);
  border-color: var(--accent);
  color: var(--accent);
}
.docs-upload-staged {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  font-size: 13px;
}
.docs-upload-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-subtle, #f9fafb);
  transition: background .15s, border-color .15s, color .15s;
}
.docs-upload-row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.docs-upload-row-size { color: var(--text-muted); margin-left: 6px; font-weight: 400; }
.docs-upload-row-status { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.docs-upload-row-remove { font-size: 12px; color: var(--text-muted); text-decoration: none; }
.docs-upload-row-remove:hover { color: #b91c1c; text-decoration: underline; }
.docs-upload-row[data-state="running"] { border-color: var(--accent); }
.docs-upload-row[data-state="running"] .docs-upload-row-status { color: var(--accent); }
.docs-upload-row[data-state="created"] { border-color: #10b981; background: rgba(16, 185, 129, .06); }
.docs-upload-row[data-state="created"] .docs-upload-row-status { color: #047857; }
.docs-upload-row[data-state="updated"] { border-color: #2563eb; background: rgba(37, 99, 235, .06); }
.docs-upload-row[data-state="updated"] .docs-upload-row-status { color: #1d4ed8; }
.docs-upload-row[data-state="skipped"] { border-color: var(--border); background: transparent; opacity: .7; }
.docs-upload-row[data-state="skipped"] .docs-upload-row-status { color: var(--text-muted); }
.docs-upload-row[data-state="error"] { border-color: #ef4444; background: rgba(239, 68, 68, .06); }
.docs-upload-row[data-state="error"] .docs-upload-row-status { color: #b91c1c; }
.docs-upload-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}
.docs-upload-submit {
  padding: 8px 14px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}
.docs-upload-submit:hover:not(:disabled) { background: var(--accent-hover); }
.docs-upload-submit:disabled { opacity: .55; cursor: not-allowed; }
.docs-upload-status {
  margin-top: 10px;
  font-size: 13px;
  min-height: 18px;
  color: var(--text-muted);
}
.docs-upload-status.is-error { color: #b91c1c; }
.docs-upload-status.is-success { color: #047857; }
