:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #16202c;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --danger: #b91c1c;
  --ok: #15803d;
  --warn: #b45309;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, "Noto Naskh Arabic", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.7;
}

h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
hr { border: none; border-top: 1px solid var(--line); margin: 20px 0; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--brand); color: #fff; padding: 12px 20px;
}
.brand { font-size: 20px; font-weight: 700; }
.brand .sub { font-size: 12px; font-weight: 400; opacity: .8; margin-inline-start: 10px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.pill {
  background: rgba(255,255,255,.16); padding: 4px 12px; border-radius: 999px; font-size: 12px;
}
.pill.ok { background: #15803d; }
.pill.bad { background: #b91c1c; }

/* ---------- tabs ---------- */
.tabs {
  display: flex; gap: 4px; padding: 0 20px; background: #fff;
  border-bottom: 1px solid var(--line); overflow-x: auto;
}
.tab {
  background: none; border: none; border-bottom: 3px solid transparent;
  padding: 12px 18px; font-size: 15px; font-family: inherit; cursor: pointer; color: var(--muted);
  white-space: nowrap;
}
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

main { padding: 20px; max-width: 1200px; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px;
}

.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 10px; }
.row > div { min-width: 130px; }
.grow { flex: 1; }
.checkbox label { display: flex; align-items: center; gap: 6px; font-weight: 400; }

label { display: block; font-size: 13px; font-weight: 600; margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-family: inherit; font-size: 14px; background: #fff; color: var(--ink);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); border-color: transparent; }

.btn {
  background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 9px 18px;
  font-family: inherit; font-size: 14px; cursor: pointer; margin-top: 12px; color: var(--ink);
}
.btn:hover:not(:disabled) { background: #f1f5f9; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.4); color: #fff; margin: 0; }
.btn.small { padding: 4px 10px; font-size: 12px; margin: 0; }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- dropzone ---------- */
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 24px;
  text-align: center; display: flex; flex-direction: column; gap: 6px; align-items: center;
  margin-top: 12px; transition: .15s;
}
.dropzone.drag { border-color: var(--brand); background: #ecfdf5; }
.file-list { margin-top: 10px; }
.file-list div { font-size: 13px; padding: 4px 0; border-bottom: 1px dashed var(--line); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
th, td { text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; background: #f8fafc; }

.badge { padding: 2px 9px; border-radius: 999px; font-size: 11px; display: inline-block; }
.badge.indexed { background: #dcfce7; color: var(--ok); }
.badge.failed { background: #fee2e2; color: var(--danger); }
.badge.queued, .badge.extracting, .badge.embedding { background: #fef3c7; color: var(--warn); }

.progress { background: var(--line); border-radius: 999px; height: 6px; overflow: hidden; margin-top: 4px; }
.progress span { display: block; height: 100%; background: var(--brand); }

.note {
  background: #f0fdfa; border: 1px solid #ccfbf1; border-radius: 8px;
  padding: 10px 12px; font-size: 13px; margin-top: 12px;
}
.alert { padding: 10px 12px; border-radius: 8px; font-size: 13px; margin: 10px 0; }
.alert.error { background: #fee2e2; color: var(--danger); }

.answer-body { white-space: pre-wrap; background: #f8fafc; padding: 14px; border-radius: 8px; }
.source {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-top: 8px;
  font-size: 13px;
}
.source .excerpt { color: var(--muted); margin-top: 4px; }

pre {
  background: #0f172a; color: #e2e8f0; padding: 14px; border-radius: 8px;
  overflow-x: auto; direction: ltr; text-align: left; font-size: 12.5px;
}

/* ---------- login ---------- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 32px; width: 340px; text-align: center;
}
.login-card .logo { font-size: 26px; font-weight: 700; color: var(--brand); }
.login-card label { text-align: right; }
.login-card .btn { width: 100%; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 20px; inset-inline-start: 20px; background: #0f172a; color: #fff;
  padding: 12px 18px; border-radius: 8px; font-size: 14px; max-width: 420px; z-index: 50;
}
.toast.error { background: var(--danger); }
