/* ============================================================
   RAG App — Design system (Linear/Vercel inspired, minimalist)
   Slate + Indigo palette · Inter · 8px grid
   ============================================================ */

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --primary-border: #c7d2fe;

  --sky: #0ea5e9;
  --sky-soft: #e0f2fe;

  --emerald: #059669;
  --emerald-soft: #d1fae5;

  --amber: #b45309;
  --amber-soft: #fef3c7;

  --red: #dc2626;
  --red-soft: #fee2e2;

  --text: #0f172a;
  --text-body: #475569;
  --text-muted: #94a3b8;
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;

  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.05);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text-body);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { color: var(--text); font-weight: 600; letter-spacing: -0.02em; }

a { color: var(--sky); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre { font-family: var(--font-mono); }
pre { white-space: pre-wrap; word-break: break-word; }

.d-none { display: none !important; }

/* ---------- Layout scaffolding ---------- */

.page { width: 100%; max-width: 1120px; margin: 0 auto; padding: 32px 40px; flex: 1; }
.page-narrow { max-width: 760px; }

/* ---------- Top navigation ---------- */

.topnav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topnav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
  text-decoration: none !important;
}

.logo-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.topnav-links { display: flex; gap: 4px; flex: 1; }

.nav-link {
  padding: 7px 12px;
  border-radius: var(--radius);
  color: var(--text-body);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none !important;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.nav-link:hover { background: var(--slate-100); color: var(--text); }

.nav-link.active {
  color: var(--text);
  font-weight: 600;
  background: var(--slate-100);
}

.topnav-right { display: flex; align-items: center; gap: 16px; }

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

.user-email { font-size: 13px; color: var(--text-body); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none !important;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

/* SweetAlert2 button classes (buttonsStyling: false) */
.btn-success { background: #059669; color: #fff; }
.btn-success:hover:not(:disabled) { background: #047857; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-ghost {
  background: var(--surface);
  color: var(--text-body);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--slate-50); color: var(--text); }

.btn-danger-ghost {
  background: var(--surface);
  color: var(--red);
  border-color: #fecaca;
}
.btn-danger-ghost:hover:not(:disabled) { background: var(--red-soft); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 11px 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon { padding: 9px; }

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-pad { padding: 24px; }

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

.card-head h3 { margin: 0; font-size: 16px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

.stat-card { padding: 20px; }

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.stat-label { font-size: 13px; color: var(--text-muted); }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); letter-spacing: -0.03em; }
.stat-trend { font-size: 12px; color: var(--emerald); }

/* ---------- Page header ---------- */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.page-title { margin: 0 0 4px; font-size: 24px; }
.page-sub { margin: 0; font-size: 14px; color: var(--text-muted); }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data thead th {
  background: var(--slate-50);
  text-align: left;
  padding: 10px 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.data tbody td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--text-body);
  vertical-align: middle;
}

table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--slate-50); }

.doc-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none !important;
}
.doc-name:hover { color: var(--primary); }

.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.semibold { font-weight: 600; }

/* ---------- Badges & pills ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-emerald { background: var(--emerald-soft); color: var(--emerald); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-sky { background: var(--sky-soft); color: var(--sky); }
.badge-indigo { background: var(--primary-soft); color: var(--primary); }
.badge-slate { background: var(--slate-100); color: var(--text-body); }

/* ---------- File chips ---------- */

.file-chip {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.file-chip.md { background: var(--sky-soft); color: var(--sky); }
.file-chip.pdf { background: var(--red-soft); color: var(--red); }
.file-chip.txt { background: var(--amber-soft); color: var(--amber); }
.file-chip.cs, .file-chip.json, .file-chip.csv { background: var(--primary-soft); color: var(--primary); }
.file-chip.fallback { background: var(--slate-100); color: var(--text-body); }

/* ---------- Forms ---------- */

.field { margin-bottom: 18px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-body);
  margin-bottom: 6px;
}

.field label .label-hint { color: var(--text-muted); font-weight: 400; }

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="url"],
.field select,
.field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.field textarea { resize: vertical; min-height: 120px; }

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

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

.field .validation { margin-top: 6px; font-size: 12px; color: var(--red); }

.form-errors {
  background: var(--red-soft);
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--red);
  margin-bottom: 20px;
}
.form-errors div { margin: 2px 0; }

/* ---------- Alerts ---------- */

.alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 20px;
}

.alert-success { background: var(--emerald-soft); color: var(--emerald); }
.alert-error { background: var(--red-soft); color: var(--red); }

.alert .alert-dismiss {
  background: none;
  border: none;
  color: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.alert .alert-dismiss:hover { background: rgba(0, 0, 0, 0.06); }

/* ---------- Status chip (connection) ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 500;
}

.chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.chip.success { background: var(--emerald-soft); color: var(--emerald); }
.chip.warning { background: var(--amber-soft); color: var(--amber); }
.chip.danger { background: var(--red-soft); color: var(--red); }
.chip.neutral { background: var(--slate-100); color: var(--text-body); }

/* ---------- Breadcrumb ---------- */

.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 0 0 16px; }
.breadcrumb a { color: var(--sky); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: var(--text-muted); }
.breadcrumb .current { color: var(--text-body); }

/* ---------- Auth screens ---------- */

.auth-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 28px;
  text-decoration: none !important;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 32px;
}

.auth-card h1 { margin: 0 0 6px; font-size: 22px; }
.auth-card .auth-sub { margin: 0 0 24px; font-size: 14px; color: var(--text-muted); }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 12px;
}
.auth-divider::before,
.auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.auth-footer { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-body); }

/* ---------- Chat ---------- */

.chat-page { max-width: 860px; margin: 0 auto; width: 100%; }

.chat-head { padding: 8px 4px 16px; }

.chat-title { margin: 0 0 4px; font-size: 20px; }
.chat-sub { margin: 0 0 12px; font-size: 13px; color: var(--text-muted); }

.chat-shell {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 220px);
  min-height: 420px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 4px;
}

.msg-row { display: flex; margin-bottom: 16px; }
.msg-row.user { justify-content: flex-end; }
.msg-row.assistant { justify-content: flex-start; }

.chat-bubble-user {
  max-width: 70%;
  background: var(--primary-soft);
  color: var(--text);
  border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
  padding: 12px 16px;
  animation: fadeInUp 0.2s ease-out;
}

.chat-bubble-assistant {
  max-width: 70%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
  padding: 12px 16px;
  box-shadow: var(--shadow-sm);
  animation: fadeInUp 0.2s ease-out;
}

.chat-bubble-assistant .answer-text { white-space: pre-wrap; }

/* Sanitized markdown rendered inside assistant answers */
.markdown-body { white-space: normal; line-height: 1.6; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body p { margin: 0 0 10px; }
.markdown-body ul, .markdown-body ol { margin: 0 0 10px; padding-left: 22px; }
.markdown-body li { margin-bottom: 4px; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
  margin: 16px 0 8px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.markdown-body h1 { font-size: 18px; }
.markdown-body h2 { font-size: 16px; }
.markdown-body h3 { font-size: 15px; }
.markdown-body h4 { font-size: 14px; }
.markdown-body code {
  background: var(--slate-100);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12.5px;
  color: var(--text);
}
.markdown-body pre {
  background: var(--slate-100);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 0 0 10px;
}
.markdown-body pre code { background: none; padding: 0; }
.markdown-body blockquote {
  margin: 0 0 10px;
  padding: 2px 14px;
  border-left: 3px solid var(--primary-border);
  color: var(--text-body);
}
.markdown-body a { color: var(--sky); }
.markdown-body table { border-collapse: collapse; margin: 0 0 10px; font-size: 13px; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border); padding: 6px 10px; }
.markdown-body th { background: var(--slate-50); }

.msg-time { display: block; margin-top: 6px; font-size: 11px; color: var(--text-muted); text-align: right; }

.source-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
}

.source-header {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--slate-100);
  color: var(--text-body);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  border: none;
  font-family: inherit;
}
.source-header:hover { background: var(--slate-50); }

.source-list { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.source-list .source-chip { background: var(--slate-100); color: var(--text-body); }

.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 16px;
  color: var(--text-muted);
  font-size: 13px;
  box-shadow: var(--shadow-sm);
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(2) { animation-delay: -0.32s; }
.typing-dot:nth-child(3) { animation-delay: -0.16s; }

.chat-input-wrap { flex-shrink: 0; padding: 16px 4px 8px; }

.chat-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px 8px 8px 16px;
  box-shadow: var(--shadow-sm);
}

.chat-input-row:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.chat-input-row input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
}

.btn-attach {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
  flex-shrink: 0;
}
.btn-attach:hover:not(:disabled) { background: var(--slate-100); color: var(--text); }
.btn-attach:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-attach.uploading { color: var(--primary); animation: spin 1s linear infinite; }

.btn-send {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: none;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.12s ease;
  flex-shrink: 0;
}
.btn-send:hover:not(:disabled) { background: var(--primary-hover); }
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }

.chat-hint { text-align: center; font-size: 11px; color: var(--text-muted); margin: 10px 0 0; }

/* Empty state */

.empty-state { text-align: center; padding: 64px 24px; }

.empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.empty-state h3 { margin: 0 0 6px; font-size: 16px; }
.empty-state p { margin: 0 0 16px; font-size: 13px; color: var(--text-muted); }

/* ---------- Dropzone ---------- */

.dropzone {
  display: block;
  text-align: center;
  background: var(--surface);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 48px 32px;
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.dropzone:hover { border-color: var(--primary); background: var(--slate-50); }

.dropzone h3 { margin: 14px 0 4px; font-size: 16px; }
.dropzone .drop-sub { margin: 0 0 16px; font-size: 13px; color: var(--text-muted); }
.dropzone .drop-help { margin: 14px 0 0; font-size: 12px; color: var(--text-muted); }

.divider-text {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0;
  color: var(--text-muted);
  font-size: 12px;
}
.divider-text::before,
.divider-text::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- Info box ---------- */

.info-box {
  display: flex;
  gap: 12px;
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  border-radius: 10px;
  padding: 16px;
  font-size: 13px;
  color: var(--text-body);
  margin-top: 24px;
}

.info-box svg { flex-shrink: 0; color: var(--primary); margin-top: 1px; }

/* ---------- Provider cards (Settings) ---------- */

.provider-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.provider-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.provider-card:hover { border-color: var(--border-strong); }

.provider-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.provider-card:has(input:checked) {
  border-color: var(--primary);
  border-width: 2px;
  padding: 15px;
  background: var(--primary-soft);
}

.provider-card .provider-icon { color: var(--primary); margin-bottom: 4px; }
.provider-card .provider-name { font-weight: 600; font-size: 14px; color: var(--text); }
.provider-card .provider-caption { font-size: 12px; color: var(--text-muted); }

/* ---------- Detail rows ---------- */

.meta-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }

.meta-card { padding: 16px 20px; }
.meta-card .meta-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.meta-card .meta-value { font-size: 15px; font-weight: 600; color: var(--text); }

.info-rows { padding: 8px 0; }
.info-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.info-row:last-child { border-bottom: none; }
.info-row .info-label { color: var(--text-muted); }
.info-row .info-value { color: var(--text); font-weight: 500; text-align: right; }

.raw-preview {
  background: var(--slate-50);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 12px;
  color: var(--text-body);
  max-height: 260px;
  overflow-y: auto;
}

/* ---------- Chunk list ---------- */

.chunk-item { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.chunk-item:last-child { border-bottom: none; }

.chunk-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }

.chunk-index {
  background: var(--slate-100);
  color: var(--text-body);
  border-radius: 6px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 600;
}

.chunk-tokens { margin-left: auto; font-size: 12px; color: var(--text-muted); }
.chunk-content { font-size: 13px; color: var(--text-body); margin: 0; }

details.chunk-expand { margin-top: 8px; }
details.chunk-expand summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--sky);
  list-style: none;
}
details.chunk-expand summary:hover { text-decoration: underline; }
details.chunk-expand summary::-webkit-details-marker { display: none; }

/* ---------- Quick actions ---------- */

.action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--text-body);
  text-decoration: none !important;
  font-size: 13px;
  font-weight: 500;
  border-bottom: 1px solid var(--border);
}
.action-row:last-child { border-bottom: none; }
.action-row:hover { background: var(--slate-50); color: var(--text); }

.action-row .action-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.action-row .chevron { margin-left: auto; color: var(--text-muted); }

/* ---------- System status ---------- */

.status-row { display: flex; align-items: center; gap: 10px; padding: 14px 20px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--emerald); flex-shrink: 0; }
.status-dot-error { background: var(--red); }
.status-dot-checking { background: var(--text-muted); }
.status-row .status-title { font-size: 13px; font-weight: 500; color: var(--text); }
.status-row .status-sub { font-size: 12px; color: var(--text-muted); }

/* ---------- Search toolbar ---------- */

.toolbar { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); }

.search-box { position: relative; flex: 1; max-width: 320px; }
.search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search-box input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
}
.search-box input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.toolbar select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  color: var(--text-body);
  background: var(--surface);
}

.table-foot { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; font-size: 12px; color: var(--text-muted); }

.pagination { display: flex; gap: 4px; }
.page-btn {
  min-width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-body);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}
.page-btn:hover { border-color: var(--border-strong); }
.page-btn.current { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Error page ---------- */

.error-page { text-align: center; padding: 80px 24px; }
.error-page .error-code { font-size: 64px; font-weight: 700; color: var(--primary); letter-spacing: -0.04em; margin: 0; }
.error-page h1 { font-size: 22px; margin: 8px 0; }
.error-page p { color: var(--text-muted); max-width: 480px; margin: 0 auto 24px; }

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 18px 24px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* ---------- Animations ---------- */

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .meta-grid { grid-template-columns: repeat(2, 1fr); }
  .provider-grid { grid-template-columns: 1fr; }
  .page { padding: 24px 20px; }
  .topnav-inner { gap: 16px; padding: 0 16px; }
  .user-email { display: none; }
  .nav-link { padding: 7px 8px; font-size: 13px; }
}

@media (max-width: 640px) {
  .stat-grid { grid-template-columns: 1fr; }
  .meta-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; }
  .topnav-links { gap: 0; }
  .brand span.brand-text { display: none; }
  .chat-bubble-user, .chat-bubble-assistant { max-width: 85%; }
}
