/* ─────────────────────────────────────────────────────────────────────────────
   ALIGN — Academic Learning & Intelligence for Guided CBET Normalization
   International University of East Africa
   Dark theme: near-black backgrounds, IUEA maroon accents, gold highlights
   ───────────────────────────────────────────────────────────────────────────── */

:root {
  /* Brand */
  --maroon:        #B91C2E;
  --maroon-dark:   #7E1421;
  --maroon-bright: #D9384C;
  --maroon-glow:   rgba(217,56,76,0.35);
  --gold:          #D4AF37;
  --gold-light:    #E8C45A;
  --gold-pale:     rgba(212,175,55,0.12);

  /* Dark surfaces — cool charcoal with subtle warmth */
  --bg:            #0E1014;
  --bg-nav:        #ffffff;
  --bg-surface:    #161A21;
  --bg-card:       #1A1E26;
  --bg-card-2:     #1F2430;
  --bg-hover:      #232936;
  --bg-input:      #11141A;
  --bg-overlay:    rgba(8,10,14,0.78);

  /* Borders */
  --border:        #2A303C;
  --border-light:  #222732;
  --border-strong: #353B4A;
  --border-accent: rgba(217,56,76,0.45);

  /* Text */
  --text:          #F1F3F8;
  --text-dim:      #B8BFCC;
  --text-muted:    #7C8597;
  --text-faint:    #4A5160;

  /* Semantic */
  --danger:        #F87171;
  --danger-bg:     rgba(248,113,113,0.12);
  --success:       #4ADE80;
  --success-bg:    rgba(74,222,128,0.12);
  --warning:       #FBBF24;
  --warning-bg:    rgba(251,191,36,0.12);
  --info:          #60A5FA;
  --info-bg:       rgba(96,165,250,0.12);
  --pending-fg:    #C084FC;
  --pending-bg:    rgba(192,132,252,0.12);

  /* UI */
  --font:          -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono:     "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --radius:        8px;
  --radius-lg:     12px;
  --shadow:        0 2px 12px rgba(0,0,0,0.5), 0 1px 3px rgba(0,0,0,0.4);
  --shadow-lg:     0 12px 40px rgba(0,0,0,0.6), 0 4px 12px rgba(0,0,0,0.4);
  --transition:    .18s ease;
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 1200px 600px at 20% -10%, rgba(217,56,76,0.08), transparent 60%),
    radial-gradient(ellipse 900px 500px at 100% 100%, rgba(96,165,250,0.04), transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--maroon-bright); text-decoration: none; }
a:hover { color: #E0394F; text-decoration: underline; }
::selection { background: var(--maroon); color: #fff; }

/* ── Layout ─────────────────────────────────────────────────────────────────── */
.page-wrap { max-width: 1280px; margin: 0 auto; padding: 0 28px; }

/* ── Navbar ─────────────────────────────────────────────────────────────────── */
.navbar {
  background: #ffffff;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 1px 8px rgba(0,0,0,0.08);
}
.navbar__brand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: #111;
  font-weight: 700;
  text-decoration: none;
}
.navbar__brand:hover { color: #111; text-decoration: none; opacity: .85; }
.navbar__logo {
  height: 34px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}
.navbar__wordmark {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.navbar__align {
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: .16em;
  color: #111;
  text-transform: uppercase;
}
.navbar__align .a-accent { color: var(--maroon-bright); }
.navbar__sub { display: none; }
.navbar__nav { display: flex; gap: 2px; align-items: center; }
.navbar__nav a {
  color: #555;
  font-size: .85rem;
  font-weight: 500;
  padding: 7px 13px;
  border-radius: var(--radius);
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.navbar__nav a:hover { color: #111; background: #f3f4f6; text-decoration: none; }
.navbar__nav a.active { color: #fff; background: var(--maroon); }
.navbar__divider { width: 1px; height: 22px; background: #e5e7eb; margin: 0 4px; }
.navbar__user { font-size: .8rem; color: #888; padding: 0 8px; }

/* ── Main content ─────────────────────────────────────────────────────────────── */
.main { padding: 36px 0 60px; }

/* ── Page header ──────────────────────────────────────────────────────────────── */
.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.page-subtitle {
  font-size: .92rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* ── LOGIN PAGE ──────────────────────────────────────────────────────────────── */
body.login-body {
  min-height: 100vh;
  overflow: hidden;
  background: #000;
}
.login-bg {
  position: fixed;
  inset: 0;
  background: #050203;
  z-index: 0;
}
.login-bg::after { display: none; }
.login-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 62% 38%;
}

/* Left branding panel — content is the bg image, panel is transparent */
.login-brand {
  background: url('/images/login_bg.png') left center / cover no-repeat, #050203;
  position: relative;
}
.login-brand::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, transparent 75%, rgba(5,2,3,0.85) 90%, rgba(5,2,3,1) 100%);
  pointer-events: none;
}
.login-brand__iuea {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 56px;
}
.login-brand__logo {
  height: 68px;
  width: auto;
  object-fit: contain;
}
.login-brand__iuea-text .institution {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.35;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.login-brand__iuea-text .institution span { color: var(--maroon-bright); }
.login-brand__iuea-text .motto {
  font-size: .84rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 3px;
}
.login-brand__align-wordmark {
  font-size: 5.5rem;
  font-weight: 900;
  letter-spacing: .14em;
  line-height: 1;
  text-transform: uppercase;
  background: linear-gradient(175deg, #ffffff 0%, #d8cccf 45%, #9a8a8e 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 18px;
}
.login-brand__align-wordmark .a-accent {
  background: linear-gradient(175deg, #F07080 0%, #C02438 100%);
  -webkit-background-clip: text;
  background-clip: text;
}
.login-brand__tagline {
  font-size: 1.1rem;
  color: var(--text-dim);
  line-height: 1.55;
  margin-bottom: 6px;
}
.login-brand__tagline strong { color: #fff; font-weight: 600; }
.login-brand__tagline .cbet { color: var(--maroon-bright); font-weight: 700; }
.login-brand__divider {
  width: 56px;
  height: 2px;
  background: linear-gradient(90deg, var(--maroon-bright), transparent);
  margin: 24px 0;
}
.login-brand__ai {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 44px;
}
.login-brand__ai-icon { font-size: 1.7rem; line-height: 1; }
.login-brand__ai-text .ai-label { font-size: .88rem; color: #fff; font-weight: 600; }
.login-brand__ai-text .ai-label span { color: var(--maroon-bright); }
.login-brand__ai-text .ai-sub { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }
.login-brand__features {
  display: flex;
  gap: 0;
  align-items: center;
}
.login-brand__feature {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: .73rem;
  text-align: center;
  padding: 0 18px;
}
.login-brand__feature:first-child { padding-left: 0; }
.login-brand__feature + .login-brand__feature {
  border-left: 1px solid var(--border);
}
.login-brand__feature-icon {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border-accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  background: rgba(155,25,41,0.1);
}

/* Right form panel */
.login-form-panel {
  background: rgba(10,4,5,0.95);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px 48px;
  backdrop-filter: blur(12px);
}
.login-form-panel h2 { font-size: 1.45rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.login-form-panel .subtitle { color: var(--text-muted); font-size: .88rem; margin-bottom: 36px; }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 7px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.form-control {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .93rem;
  font-family: var(--font);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  outline: none;
}
.form-control:focus {
  border-color: var(--maroon-bright);
  box-shadow: 0 0 0 3px rgba(217,56,76,0.18);
}
.form-control::placeholder { color: var(--text-faint); }
select.form-control {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%237A6068' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
textarea.form-control { resize: vertical; min-height: 90px; }
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: 5px; }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 22px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, var(--maroon-bright) 0%, var(--maroon) 100%);
  color: #fff;
  border-color: var(--maroon-dark);
  box-shadow: 0 2px 8px rgba(217,56,76,0.35), inset 0 1px 0 rgba(255,255,255,0.12);
}
.btn-primary:hover {
  background: linear-gradient(180deg, #E84A5E 0%, var(--maroon-bright) 100%);
  box-shadow: 0 4px 16px rgba(217,56,76,0.5), inset 0 1px 0 rgba(255,255,255,0.15);
}
.btn-gold { background: var(--gold); color: #0A0405; font-weight: 700; border-color: var(--gold); }
.btn-gold:hover { background: var(--gold-light); }
.btn-danger { background: rgba(224,85,85,0.12); color: var(--danger); border-color: rgba(224,85,85,0.3); }
.btn-danger:hover { background: rgba(224,85,85,0.22); }
.btn-secondary { background: var(--bg-hover); color: var(--text-dim); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-card); border-color: var(--border-accent); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; padding: 8px 12px; }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-sm { padding: 6px 14px; font-size: .82rem; }
.btn-lg { padding: 13px 28px; font-size: 1rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: .35; cursor: not-allowed; pointer-events: none; }

/* ── Progress bar ────────────────────────────────────────────────────────────── */
.progress-wrap { margin-top: 14px; }
.progress-bar-outer { height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, var(--maroon), var(--maroon-bright));
  border-radius: 3px;
  transition: width .4s ease;
}
.progress-label { font-size: .78rem; color: var(--text-muted); margin-top: 6px; }

/* ── Card ───────────────────────────────────────────────────────────────────── */
.card {
  background: linear-gradient(180deg, var(--bg-card-2) 0%, var(--bg-card) 100%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-light);
}
.card-title { font-size: 1rem; font-weight: 700; color: var(--text); }

/* ── Stat cards ──────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: linear-gradient(180deg, var(--bg-card-2) 0%, var(--bg-card) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform var(--transition), border-color var(--transition);
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--maroon), var(--maroon-bright));
}
.stat-value { font-size: 2.4rem; font-weight: 800; color: #fff; line-height: 1; letter-spacing: -0.02em; }
.stat-label { font-size: .75rem; color: var(--text-muted); margin-top: 8px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }

/* ── Table ──────────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow);
}
.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.data-table thead { background: var(--bg-surface); }
.data-table th {
  color: var(--text-muted);
  padding: 14px 18px;
  text-align: left;
  font-weight: 600;
  font-size: .72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  color: var(--text);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover td { background: rgba(35,41,54,0.5); }
.data-table .col-actions { text-align: right; white-space: nowrap; }

/* ── Badges ──────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 99px;
  font-size: .73rem; font-weight: 700; letter-spacing: .04em;
  white-space: nowrap; border: 1px solid transparent;
}
.badge::before { content: ''; display: block; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.badge-indexed   { background: var(--success-bg); color: var(--success); border-color: rgba(61,184,122,0.2); }
.badge-indexed::before { background: var(--success); }
.badge-uploaded  { background: var(--info-bg); color: var(--info); border-color: rgba(74,158,224,0.2); }
.badge-uploaded::before { background: var(--info); }
.badge-extracting,.badge-chunking,.badge-embedding { background: var(--warning-bg); color: var(--warning); border-color: rgba(212,160,23,0.2); }
.badge-extracting::before,.badge-chunking::before,.badge-embedding::before { background: var(--warning); animation: pulse .9s ease-in-out infinite alternate; }
.badge-failed    { background: var(--danger-bg); color: var(--danger); border-color: rgba(224,85,85,0.2); }
.badge-failed::before { background: var(--danger); }
.badge-pending   { background: var(--pending-bg); color: var(--pending-fg); border-color: rgba(154,111,216,0.2); }
.badge-pending::before { background: var(--pending-fg); }
.badge-running   { background: var(--warning-bg); color: var(--warning); border-color: rgba(212,160,23,0.2); }
.badge-running::before { background: var(--warning); animation: pulse .9s ease-in-out infinite alternate; }
.badge-completed { background: var(--success-bg); color: var(--success); border-color: rgba(61,184,122,0.2); }
.badge-completed::before { background: var(--success); }
.badge-ai { background: rgba(99,102,241,0.15); color: #a5b4fc; border-color: rgba(99,102,241,0.3); font-size:.7rem; padding:1px 6px; vertical-align: middle; }
.badge-ai::before { display:none; }
.badge-admin { background: rgba(155,25,41,0.15); color: #F08090; border-color: rgba(155,25,41,0.3); }
.badge-admin::before { background: var(--maroon-bright); }
.badge-curriculum_reviewer { background: var(--gold-pale); color: var(--gold); border-color: rgba(201,162,39,0.25); }
.badge-curriculum_reviewer::before { background: var(--gold); }
.badge-viewer { background: rgba(255,255,255,.04); color: var(--text-muted); border-color: var(--border); }
.badge-viewer::before { background: var(--text-faint); }
@keyframes pulse { from { opacity: .4; } to { opacity: 1; } }

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay { display: none; position: fixed; inset: 0; background: var(--bg-overlay); z-index: 300; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(3px); }
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px; width: 100%; max-width: 540px;
  max-height: 92vh; overflow-y: auto; position: relative;
  animation: modal-in .2s ease;
}
.modal-wide { max-width: 780px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(-14px) scale(.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal h2 { font-size: 1.15rem; font-weight: 700; color: var(--text); margin-bottom: 22px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border-light); }
.modal-close { position: absolute; top: 14px; right: 14px; background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--text-muted); line-height: 1; padding: 4px 8px; border-radius: var(--radius); }
.modal-close:hover { background: var(--bg-hover); color: var(--text); }

/* ── Toast ──────────────────────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { padding: 13px 18px; border-radius: var(--radius); font-size: .88rem; font-weight: 500; box-shadow: var(--shadow-lg); opacity: 0; transform: translateX(14px); animation: toast-in .22s ease forwards; max-width: 360px; pointer-events: auto; border: 1px solid transparent; }
.toast-success { background: rgba(61,184,122,0.14); color: var(--success); border-color: rgba(61,184,122,0.25); }
.toast-error   { background: rgba(224,85,85,0.14); color: var(--danger); border-color: rgba(224,85,85,0.25); }
.toast-info    { background: rgba(74,158,224,0.14); color: var(--info); border-color: rgba(74,158,224,0.25); }
.toast-warning { background: rgba(212,160,23,0.14); color: var(--warning); border-color: rgba(212,160,23,0.25); }
@keyframes toast-in { to { opacity: 1; transform: translateX(0); } }

/* ── Chunk browser ────────────────────────────────────────────────────────────── */
.chunk-browser { display: grid; grid-template-columns: 280px 1fr; gap: 20px; min-height: 480px; }
.chunk-tree { overflow-y: auto; max-height: 600px; border-right: 1px solid var(--border-light); padding-right: 12px; }
.chunk-tree-item { padding: 8px 12px; border-radius: var(--radius); cursor: pointer; font-size: .83rem; border-left: 3px solid transparent; transition: background var(--transition); line-height: 1.4; color: var(--text-muted); margin-bottom: 2px; }
.chunk-tree-item:hover { background: var(--bg-hover); color: var(--text-dim); }
.chunk-tree-item.active { background: rgba(155,25,41,0.12); border-left-color: var(--maroon-bright); color: var(--text); }
.chunk-detail { font-size: .88rem; line-height: 1.85; color: var(--text-dim); white-space: pre-wrap; }
.chunk-meta { font-size: .76rem; color: var(--text-muted); margin-bottom: 12px; display: flex; gap: 14px; flex-wrap: wrap; }

/* ── Search results ─────────────────────────────────────────────────────────── */
.search-result { padding: 14px 16px; border: 1px solid var(--border-light); border-radius: var(--radius); margin-bottom: 10px; background: var(--bg-surface); transition: border-color var(--transition); }
.search-result:hover { border-color: var(--border-accent); }
.search-result-score { float: right; font-size: .73rem; background: var(--gold-pale); color: var(--gold); padding: 2px 8px; border-radius: 99px; font-weight: 700; border: 1px solid rgba(201,162,39,0.2); }
.search-result-path { font-size: .76rem; color: var(--maroon-bright); margin-bottom: 5px; }
.search-result-text { font-size: .86rem; line-height: 1.65; color: var(--text-dim); }

/* ── Conversion output ────────────────────────────────────────────────────────── */
.output-section { border: 1px solid var(--border-light); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
.output-section-header { background: var(--bg-surface); padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; user-select: none; transition: background var(--transition); }
.output-section-header:hover { background: var(--bg-hover); }
.output-section-title { font-weight: 600; font-size: .9rem; color: var(--text); }
.output-section-meta { font-size: .76rem; color: var(--text-muted); }
.output-section-body { padding: 16px; font-size: .88rem; line-height: 1.85; white-space: pre-wrap; color: var(--text-dim); border-top: 1px solid var(--border-light); background: var(--bg-card); }
.output-stats { display: flex; gap: 22px; padding: 12px 16px; background: var(--bg-surface); border-radius: var(--radius); margin-bottom: 18px; font-size: .83rem; color: var(--text-muted); flex-wrap: wrap; border: 1px solid var(--border-light); }
.output-stats strong { color: var(--text); }

/* ── Gap resolution ──────────────────────────────────────────────────────────── */
.gap-item { border: 1px solid var(--border-light); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; background: var(--bg-surface); }
.gap-item--blocker { border-left: 3px solid var(--danger); }
.gap-item--warning { border-left: 3px solid #d97706; }
.gap-item--suggestion { border-left: 3px solid var(--info); }
.gap-item--resolved { opacity: .65; }
.gap-item--skipped  { opacity: .5; }
.gap-item__header { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.gap-suggestion { background: var(--bg-hover); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 10px; display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: .83rem; flex-wrap: wrap; }
.badge-blocker    { background: rgba(224,85,85,0.15); color: var(--danger); }
.qa-issues-table { width: 100%; table-layout: fixed; }
.qa-issues-table th:nth-child(1) { width: 90px; }
.qa-issues-table th:nth-child(2) { width: 140px; }
.qa-issues-table th:nth-child(3), .qa-issues-table th:nth-child(4) { width: auto; }
.qa-issue-row td { vertical-align: top; padding: 8px 10px; }
.qa-issue-row--blocker td:first-child { border-left: 3px solid var(--danger); }
.qa-issue-row--warning td:first-child { border-left: 3px solid #d97706; }
.qa-issue-row--suggestion td:first-child { border-left: 3px solid var(--info); }
.qa-input-row td { padding: 0 10px 10px 10px; border-top: none; }
.qa-input-wrap { background: var(--bg-hover); border: 1px solid var(--border-light); border-radius: var(--radius); padding: 8px 10px; }
.qa-input-label { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; display: block; margin-bottom: 5px; }
.qa-note-textarea { font-size: .85rem; resize: vertical; min-height: 54px; }
.qa-saved-indicator { font-size: .75rem; color: var(--success); white-space: nowrap; padding-top: 4px; }
.badge-warning    { background: rgba(217,119,6,0.15);  color: #d97706; }
.badge-suggestion { background: rgba(74,158,224,0.15); color: var(--info); }
.badge-open       { background: rgba(61,184,122,0.1);  color: var(--success); }
.badge-resolved   { background: rgba(61,184,122,0.2);  color: var(--success); }
.badge-skipped    { background: rgba(180,180,180,0.15); color: var(--text-muted); }
.btn-warning { background: rgba(217,119,6,0.12); color: #d97706; border-color: rgba(217,119,6,0.3); }
.btn-warning:hover { background: rgba(217,119,6,0.22); }
.btn-success { background: rgba(61,184,122,0.15); color: var(--success); border-color: rgba(61,184,122,0.3); }
.btn-success:hover { background: rgba(61,184,122,0.25); }

/* ── Settings ───────────────────────────────────────────────────────────────── */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; }
.setting-item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--border-light); border-radius: var(--radius); background: var(--bg-surface); }
.setting-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.setting-dot.set   { background: var(--success); box-shadow: 0 0 6px rgba(61,184,122,0.4); }
.setting-dot.unset { background: var(--text-faint); }
.setting-info { flex: 1; min-width: 0; }
.setting-label { font-size: .84rem; font-weight: 600; color: var(--text-dim); }
.setting-value { font-size: .78rem; color: var(--text-muted); font-family: var(--font-mono); word-break: break-all; }

/* ── Spec editor ─────────────────────────────────────────────────────────────── */
.spec-editor { font-family: var(--font-mono); font-size: .83rem; min-height: 360px; background: #050203; color: #E8D8DC; border: 1.5px solid var(--border); border-radius: var(--radius); padding: 14px; resize: vertical; width: 100%; }
.spec-editor:focus { outline: none; border-color: var(--maroon); box-shadow: 0 0 0 3px rgba(155,25,41,0.15); }

/* ── Tabs ────────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab { padding: 10px 20px; font-size: .88rem; font-weight: 600; color: var(--text-muted); border: none; background: none; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; font-family: var(--font); transition: color var(--transition); }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--maroon-bright); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Alerts ──────────────────────────────────────────────────────────────────── */
.alert { padding: 13px 16px; border-radius: var(--radius); font-size: .88rem; margin-bottom: 16px; border: 1px solid transparent; }
.alert-info    { background: var(--info-bg);    color: var(--info);    border-color: rgba(74,158,224,0.2); }
.alert-success { background: var(--success-bg); color: var(--success); border-color: rgba(61,184,122,0.2); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: rgba(212,160,23,0.2); }
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  border-color: rgba(224,85,85,0.2); }

/* ── Breadcrumb ─────────────────────────────────────────────────────────────── */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: .84rem; color: var(--text-muted); margin-bottom: 18px; }
.breadcrumb a { color: var(--maroon-bright); }
.breadcrumb .sep { color: var(--text-faint); }

/* ── Utilities ───────────────────────────────────────────────────────────────── */
.text-muted   { color: var(--text-muted) !important; }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.mt-2 { margin-top: 8px; }  .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.flex-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.empty-state {
  text-align: center;
  padding: 72px 24px;
  color: var(--text-muted);
  font-size: .92rem;
}
.empty-state p { margin-bottom: 16px; }
.divider { border: none; border-top: 1px solid var(--border-light); margin: 20px 0; }
code { font-family: var(--font-mono); font-size: .84em; background: rgba(155,25,41,0.12); color: #F07080; padding: 2px 6px; border-radius: 4px; border: 1px solid rgba(155,25,41,0.2); }

/* ── Spinner ─────────────────────────────────────────────────────────────────── */
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--maroon-bright); border-radius: 50%; animation: spin .65s linear infinite; vertical-align: middle; }
.spinner-sm { width: 14px; height: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Scrollbar ───────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--maroon); }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-bg::after { background: rgba(5,2,3,0.7); }
  .login-form-panel { border-left: none; background: rgba(10,4,5,0.95); padding: 40px 24px; min-height: 100vh; }
}
@media (max-width: 900px) { .chunk-browser { grid-template-columns: 1fr; } .grid-2 { grid-template-columns: 1fr; } .stats-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 640px) {
  .page-wrap { padding: 0 16px; } .navbar { padding: 0 16px; height: 56px; } .navbar__sub { display: none; }
  .main { padding: 20px 0 48px; } .card { padding: 16px; } .data-table { font-size: .82rem; }
  .data-table th, .data-table td { padding: 10px 12px; } .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-title { font-size: 1.3rem; } .modal { padding: 24px 20px; }
}

/* ── Background job progress banner ─────────────────────────────────────────── */
.bg-jobs-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.bg-jobs-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 10px;
}
.bg-job-row {
  padding: 8px 0;
  border-top: 1px solid var(--border);
}
.bg-job-row:first-of-type { border-top: none; }
.bg-job-info {
  display: flex;
  align-items: center;
  gap: 6px;
}
.bg-job-title {
  font-size: .88rem;
  font-weight: 500;
  color: var(--text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bg-job-dismiss {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
}
.bg-job-dismiss:hover { color: var(--danger); }

/* ── Upload scope selector ──────────────────────────────────────────────────── */
.scope-options { display: flex; gap: 10px; margin-top: 6px; }
.scope-option { flex: 1; cursor: pointer; }
.scope-option input[type=radio] { position: absolute; opacity: 0; pointer-events: none; }
.scope-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  transition: border-color .15s, background .15s;
}
.scope-card strong { font-size: .9rem; color: var(--text); }
.scope-card small  { font-size: .78rem; color: var(--text-muted); }
.scope-option input[type=radio]:checked + .scope-card {
  border-color: var(--maroon);
  background: rgba(155,25,41,0.06);
}
.scope-option:hover .scope-card { border-color: var(--maroon-bright); }
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: 5px; }
