/* ═══════════════════════════════════════════════════════════════════════════
   Core Data Manager — Modern UI Stylesheet
   ═══════════════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════════════
   THEME TOKENS — "Mission Control" dark console.
   The whole app is styled through these custom properties. To add a light
   variant later, redefine this same set under :root[data-theme="light"];
   no component rule needs to change. This build is deliberately dark-committed.
   ═══════════════════════════════════════════════════════════════════════════ */
:root {
  color-scheme: dark;

  /* Accent — the "signal" colour (petrol teal) + electric-blue secondary */
  --brand-primary:       #2fe0cf;
  --brand-primary-hover: #55efe0;
  --brand-primary-light: rgba(47,224,207,.12);
  --brand-primary-glow:  rgba(47,224,207,.28);
  --accent-blue:         #4f9dff;
  --accent-blue-soft:    rgba(79,157,255,.14);

  /* Sidebar / deepest surface */
  --sidebar-bg: #0a1017;
  --sidebar-width: 240px;
  --sidebar-collapsed: 0px;

  /* Surfaces — ground → panel → elevated */
  --surface-bg:    #080c11;
  --surface-card:  #0f1720;
  --surface-hover: #16212c;
  --surface-2:     #16212c;
  --surface-3:     #1c2a36;
  --surface-muted: #16212c;   /* inset/muted panel (dark) — was undefined, fell back to light */

  /* Text (cool off-white → dim → mute) */
  --text-primary:   #e2edf4;
  --text-secondary: #9fb4c4;
  --text-muted:     #63798b;

  /* Borders */
  --border-color:  #1f2d3a;
  --border-soft:   #17222d;
  --border-strong: #2a3b4a;
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --border-radius-xs: 6px;

  /* Semantic (kept separate from the accent) */
  --good: #35d68a;
  --warn: #ffb02e;
  --crit: #ff5d6c;
  --info: #4f9dff;

  /* Foreground for text/icons sitting ON a low-alpha semantic tint (chips, badges,
     stat values). --good/--warn/--crit are tuned as solid marks; these are the readable
     text colour over their own ~16% tint, which differs per theme. */
  --good-fg: #7cecb6;
  --warn-fg: #ffd07f;
  --crit-fg: #ffa3ac;

  /* Payout stat hues — the money row needs two marks the semantic triad doesn't cover
     (paid vs available), and "Available now" is the figure an admin comes here to read. */
  --money-paid:      #7882ff;
  --money-available: #f472b6;

  /* QC comparison grid. Telling E1 from E2 from a mismatch IS what that grid does, so
     these are first-class tokens, not inline literals: these alphas are tuned for the
     dark card and collapse into near-identical pastels over white. The ::after glyphs
     are the non-color fallback and must stay legible on both grounds. */
  --qc-e1:       rgba(79,157,255,.16);
  --qc-e2:       rgba(53,214,138,.16);
  --qc-final:    rgba(124,58,237,.14);
  --qc-mismatch: rgba(255,176,46,.18);
  --qc-needs:    rgba(255,93,108,.16);
  --qc-empty:    rgba(99,121,139,.16);
  --qc-final-fg: #c4b5fd;
  --qc-glyph-needs:    #ffa3ac;
  --qc-glyph-resolved: #7cecb6;
  --qc-glyph-mismatch: #ffd07f;

  /* Shadows — depth + a faint accent lift on hover */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.5);
  --shadow-md: 0 6px 18px rgba(0,0,0,.55);
  --shadow-lg: 0 14px 34px rgba(0,0,0,.6);
  --shadow-card-hover: 0 12px 30px rgba(0,0,0,.55), 0 0 0 1px rgba(47,224,207,.16);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(.4,0,.2,1);
  --transition-base: 250ms cubic-bezier(.4,0,.2,1);
  --transition-slow: 350ms cubic-bezier(.4,0,.2,1);

  /* Fonts */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', ui-monospace, 'SF Mono', Consolas, monospace;

  /* Topbar */
  --topbar-height: 56px;

  /* ── Map Bootstrap 5.3's dark-mode tokens onto the console palette so all
        Bootstrap components (cards, tables, dropdowns, modals, forms, badges)
        adopt this identity instead of Bootstrap's default slate dark. ── */
  --bs-body-bg: var(--surface-bg);
  --bs-body-color: var(--text-primary);
  --bs-border-color: var(--border-color);
  --bs-secondary-color: var(--text-secondary);
  --bs-secondary-bg: var(--surface-hover);
  --bs-tertiary-bg: var(--surface-card);
  --bs-emphasis-color: var(--text-primary);
  --bs-primary: var(--brand-primary);
  --bs-link-color: var(--brand-primary);
  --bs-link-hover-color: var(--brand-primary-hover);
}

/* ═══════════════════════════════════════════════════════════════════════════
   LIGHT THEME — redefine the same token set; no component rule changes. The
   sidebar rail stays dark on purpose (dark rail + light workspace) so its
   hand-tuned contrast holds; everything in the content column flips to light.
   Activated by data-theme="light" on <html> (set by the topbar toggle).
   ═══════════════════════════════════════════════════════════════════════════ */
:root[data-theme="light"] {
  color-scheme: light;

  /* Accent — deepen the teal so links/accents stay legible (AA) on white */
  --brand-primary:       #0a7d73;
  --brand-primary-hover: #086a61;
  --brand-primary-light: rgba(10,125,115,.10);
  --brand-primary-glow:  rgba(10,125,115,.18);
  --accent-blue:         #1f5fd0;
  --accent-blue-soft:    rgba(31,95,208,.10);

  /* --sidebar-bg intentionally NOT overridden — the rail stays dark */

  --surface-bg:    #eaeef3;
  --surface-card:  #ffffff;
  --surface-hover: #eef2f7;
  --surface-2:     #f2f5f9;
  --surface-3:     #e6ebf1;
  --surface-muted: #f2f5f9;

  /* Text — high contrast on white. primary ~16:1, secondary ~9:1, muted ~5.6:1 (AA). */
  --text-primary:   #0d141b;
  --text-secondary: #33414d;
  --text-muted:     #51606d;

  --border-color:  #d4dce4;
  --border-soft:   #e3e8ee;
  --border-strong: #b8c4d0;

  --good: #0f9d67;
  --warn: #b26a00;
  --crit: #d33646;
  --info: #2f6fe0;

  /* Chip/stat foregrounds — the dark theme's pastels run ~2:1 on white. */
  --good-fg: #0b7a50;
  --warn-fg: #8a5200;
  --crit-fg: #b3202f;

  --money-paid:      #4338ca;
  --money-available: #b8175f;

  /* QC grid — stronger fills over white (the dark theme's 14–18% alphas wash out to
     near-identical pastels here) and darker glyphs so the non-color cue survives. */
  --qc-e1:       rgba(47,111,224,.14);
  --qc-e2:       rgba(15,157,103,.16);
  --qc-final:    rgba(109,40,217,.12);
  --qc-mismatch: rgba(178,106,0,.20);
  --qc-needs:    rgba(211,54,70,.14);
  --qc-empty:    rgba(81,96,109,.12);
  --qc-final-fg: #5b21b6;
  --qc-glyph-needs:    #b3202f;
  --qc-glyph-resolved: #0b7a50;
  --qc-glyph-mismatch: #8a5200;

  --shadow-sm: 0 1px 2px rgba(16,24,40,.06);
  --shadow-md: 0 6px 18px rgba(16,24,40,.08);
  --shadow-lg: 0 14px 34px rgba(16,24,40,.12);
  --shadow-card-hover: 0 10px 26px rgba(16,24,40,.12), 0 0 0 1px rgba(15,157,146,.16);
}

/* Light workspace background + scrollbar (the dark defaults live on :root/body). */
:root[data-theme="light"] body {
  background:
    radial-gradient(1100px 560px at 82% -6%, rgba(47,111,224,.05), transparent 60%),
    radial-gradient(820px 460px at 4% 2%, rgba(15,157,146,.05), transparent 55%),
    var(--surface-bg);
}
:root[data-theme="light"] ::-webkit-scrollbar-thumb { background: #c4cfdb; }
:root[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: #aab8c6; }

/* Pale accent chips were authored for the dark theme and are near-invisible on
   white. Remap them to darker, same-hue text in light mode — both the class-based
   ones and the inline-styled ones (matched by their hardcoded colour). */
:root[data-theme="light"] .uwi-code {
  color: #0a6b62; background: rgba(10,125,115,.09); border-color: rgba(10,125,115,.30);
}
:root[data-theme="light"] .ocr-badge-good {
  color: #0b7a4f; background: rgba(15,157,103,.12); border-color: rgba(15,157,103,.35);
}
:root[data-theme="light"] .ocr-badge-bad {
  color: #c02636; background: rgba(211,54,70,.10); border-color: rgba(211,54,70,.35);
}
:root[data-theme="light"] .ocr-badge-unreviewed {
  color: #48555f; background: rgba(99,121,139,.14); border-color: rgba(99,121,139,.30);
}
:root[data-theme="light"] [style*="a6cbff"] { color: #1f5fd0 !important; background: rgba(31,95,208,.10) !important; }
:root[data-theme="light"] [style*="a9ece4"] { color: #0a6b62 !important; }
:root[data-theme="light"] [style*="7cecb6"] { color: #0b7a4f !important; }
:root[data-theme="light"] [style*="ffa3ac"] { color: #c02636 !important; }
:root[data-theme="light"] [style*="9fb4c4"] { color: #48555f !important; }
:root[data-theme="light"] [style*="ffd07f"] { color: #9a6a00 !important; }

/* ── Global Reset & Typography ───────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

* { box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background:
    radial-gradient(1100px 560px at 82% -6%, rgba(79,157,255,.07), transparent 60%),
    radial-gradient(820px 460px at 4% 2%, rgba(47,224,207,.06), transparent 55%),
    var(--surface-bg);
  background-attachment: fixed;
  color: var(--text-primary);
}

/* Numbers, codes and UWIs read as instrument telemetry in mono, aligned. */
.uwi-code, .stat-value, .stage-count, .num,
.table td .mono, code, kbd {
  font-variant-numeric: tabular-nums;
}

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #263646; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #33485c; }

/* ── Bootstrap utility reconciliation for the dark console ─────────────────────
   Templates written for the old light theme use bg-white / bg-light / text-dark
   in places. Remap those utilities to console surfaces so no light patches leak
   through. Semantic text utilities (text-muted/secondary) already resolve to
   our tokens via Bootstrap's dark-mode variables. */
.bg-white  { background-color: var(--surface-card) !important; }
.bg-light  { background-color: var(--surface-2) !important; }
.table-light, .table > :not(caption) > * > *.table-light {
  --bs-table-bg: var(--surface-hover);
  --bs-table-color: var(--text-secondary);
}
.table-light th, thead.table-light th {
  background: var(--surface-hover) !important;
  color: var(--text-secondary) !important;
}
.bg-body   { background-color: var(--surface-bg) !important; }
.text-dark { color: var(--text-primary) !important; }
.border, .border-top, .border-bottom, .border-start, .border-end {
  border-color: var(--border-color) !important;
}
.dropdown-menu {
  --bs-dropdown-bg: var(--surface-card);
  --bs-dropdown-border-color: var(--border-color);
  --bs-dropdown-link-color: var(--text-secondary);
  --bs-dropdown-link-hover-bg: var(--surface-hover);
  --bs-dropdown-link-hover-color: var(--text-primary);
  --bs-dropdown-header-color: var(--text-muted);
  box-shadow: var(--shadow-lg);
}
.modal { --bs-modal-bg: var(--surface-card); --bs-modal-border-color: var(--border-color); }
.list-group { --bs-list-group-bg: var(--surface-card); --bs-list-group-border-color: var(--border-color); --bs-list-group-color: var(--text-primary); }
.nav-tabs { --bs-nav-tabs-link-active-bg: var(--surface-card); --bs-nav-tabs-border-color: var(--border-color); }
hr { border-color: var(--border-color); opacity: 1; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width var(--transition-base), transform var(--transition-base);
}

.sidebar-brand {
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-brand-icon {
  width: 34px;
  height: 34px;
  background: radial-gradient(circle at 30% 25%, rgba(47,224,207,.4), rgba(47,224,207,.08));
  border: 1px solid rgba(47,224,207,.5);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 18px rgba(47,224,207,.28), inset 0 0 10px rgba(47,224,207,.12);
}

.sidebar-brand-icon i {
  font-size: 15px;
  color: var(--brand-primary);
}

.sidebar-brand-text {
  color: white;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.2;
}

.sidebar-brand-sub {
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: .02em;
}

/* Navigation */
.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #56697c;
  padding: 0 12px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--border-radius-sm);
  color: #94a3b8;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,.07);
  color: #e2e8f0;
  transform: translateX(2px);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(47,224,207,.16), rgba(47,224,207,.06));
  color: #7ff0e4;
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--brand-primary);
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 12px rgba(47,224,207,.6);
}

.nav-item i {
  font-size: 15px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.nav-item:hover i {
  transform: scale(1.1);
}

/* User footer */
.sidebar-user {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,.06);
  background: rgba(0,0,0,.15);
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #475569, #334155);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: white;
  font-size: 12px;
  flex-shrink: 0;
}

.sidebar-user-name {
  color: white;
  font-size: 13px;
  font-weight: 500;
}

.sidebar-user-role {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: capitalize;
}

.sidebar-logout {
  color: #64748b;
  transition: color var(--transition-fast);
}

.sidebar-logout:hover {
  color: #ef4444;
}

/* ── Mobile sidebar toggle ───────────────────────────────────────────────── */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  padding: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--border-radius-xs);
  transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.sidebar-overlay.show {
  opacity: 1;
}

@media (max-width: 991.98px) {
  .sidebar {
    position: fixed;
    transform: translateX(-100%);
    z-index: 200;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 25px rgba(0,0,0,.25);
  }
  .sidebar-toggle {
    display: flex;
  }
  .sidebar-overlay.show {
    display: block;
  }
}

/* ── Topbar ──────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--surface-card);
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 12px;
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

/* ── Main Content ────────────────────────────────────────────────────────── */
.main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface-bg);
}

.page-content {
  flex-grow: 1;
  padding: 24px;
  overflow-y: auto;
  animation: fadeInUp .3s ease-out;
}

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

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  --bs-card-bg: var(--surface-card);
  --bs-card-color: var(--text-primary);
  background: var(--surface-card);
  color: var(--text-primary);
  border-radius: var(--border-radius) !important;
  border: 1px solid var(--border-color) !important;
  box-shadow: var(--shadow-sm) !important;
  transition: box-shadow var(--transition-base), transform var(--transition-base);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-md) !important;
}

.card-hover:hover {
  box-shadow: var(--shadow-card-hover) !important;
  transform: translateY(-2px);
}

.card-body { padding: 20px; }

/* Stat Cards */
.stat-card {
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 100%;
  opacity: .04;
  background: linear-gradient(135deg, transparent, currentColor);
  pointer-events: none;
}

.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--transition-base);
}

.stat-card:hover .stat-icon {
  transform: scale(1.1);
}

.stat-card .stat-label {
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  margin-bottom: 2px;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
}

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table {
  margin-bottom: 0;
}

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text-primary);
  color: var(--text-primary);
}

.table th {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 10px 12px !important;
  border-bottom: 2px solid var(--border-color) !important;
  background: var(--surface-hover);
  white-space: nowrap;
}

.table td {
  font-size: 13.5px;
  padding: 10px 12px !important;
  vertical-align: middle;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-soft) !important;
  transition: background var(--transition-fast);
}

.table-hover tbody tr {
  transition: background var(--transition-fast);
}

.table-hover tbody tr:hover {
  background: rgba(47,224,207,.06) !important;
}

.table-hover tbody tr:hover td {
  border-bottom-color: rgba(47,224,207,.2) !important;
}

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  font-weight: 600;
  font-size: 11px;
  letter-spacing: .02em;
  padding: 4px 10px;
}

.badge.rounded-pill {
  border-radius: 20px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  font-weight: 500;
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-fast);
  font-size: 13.5px;
  letter-spacing: .01em;
}

.btn:active {
  transform: scale(.97);
}

.btn-primary {
  background: linear-gradient(135deg, #2fe0cf, #17b5a6);
  border-color: #2fe0cf;
  color: #04201d;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(47,224,207,.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #55efe0, #21c8b8);
  border-color: #55efe0;
  color: #04201d;
  box-shadow: 0 4px 16px rgba(47,224,207,.4);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  border-color: #16a34a;
  box-shadow: 0 1px 3px rgba(22,163,74,.3);
}

.btn-success:hover {
  background: linear-gradient(135deg, #16a34a, #15803d);
  box-shadow: 0 4px 12px rgba(22,163,74,.35);
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border-color: #dc2626;
  box-shadow: 0 1px 3px rgba(220,38,38,.3);
}

.btn-danger:hover {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  box-shadow: 0 4px 12px rgba(220,38,38,.35);
  transform: translateY(-1px);
}

.btn-outline-secondary {
  border-color: var(--border-strong);
  color: var(--text-secondary);
  background: transparent;
}

.btn-outline-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-outline-primary {
  border-color: rgba(47,224,207,.45);
  color: var(--brand-primary);
  background: transparent;
}

.btn-outline-primary:hover {
  background: var(--brand-primary-light);
  border-color: var(--brand-primary);
  color: var(--brand-primary-hover);
}

.btn-sm {
  padding: 5px 14px;
  font-size: 12.5px;
  border-radius: var(--border-radius-xs);
}

/* ── Form Controls ───────────────────────────────────────────────────────── */
.form-control, .form-select {
  border-radius: var(--border-radius-sm);
  background: var(--surface-2);
  border-color: var(--border-strong);
  font-size: 13.5px;
  padding: 8px 12px;
  transition: all var(--transition-fast);
  color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
  background: var(--surface-2);
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-primary-glow);
  color: var(--text-primary);
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.form-text {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-control-sm, .form-select-sm {
  padding: 5px 10px;
  font-size: 12.5px;
  border-radius: var(--border-radius-xs);
}

/* Section dividers in forms */
.form-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding-bottom: 6px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

/* ── Alerts / Flash Messages ─────────────────────────────────────────────── */
.alert {
  border-radius: var(--border-radius-sm);
  border: none;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 16px;
  animation: slideDown .3s ease-out;
  position: relative;
  overflow: hidden;
}

.alert::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
}

.alert-success::before { background: var(--good); }
.alert-danger::before  { background: var(--crit); }
.alert-warning::before { background: var(--warn); }
.alert-info::before    { background: var(--info); }

.alert-success { background: rgba(53,214,138,.12); color: #7cecb6; border: 1px solid rgba(53,214,138,.25); }
.alert-danger  { background: rgba(255,93,108,.12); color: #ffa3ac; border: 1px solid rgba(255,93,108,.25); }
.alert-warning { background: rgba(255,176,46,.12); color: #ffd07f; border: 1px solid rgba(255,176,46,.25); }
.alert-info    { background: rgba(79,157,255,.12); color: #a6cbff; border: 1px solid rgba(79,157,255,.25); }

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

/* ── Empty States ────────────────────────────────────────────────────────── */
.empty-state {
  padding: 48px 24px;
  text-align: center;
}

.empty-state-icon {
  font-size: 3rem;
  color: #33485c;
  margin-bottom: 12px;
  display: block;
}

.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

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

/* ── Pipeline / Stage Progress ───────────────────────────────────────────── */
.pipeline-stage {
  text-align: center;
  padding: 12px 16px;
  border-radius: var(--border-radius-sm);
  background: var(--surface-hover);
  min-width: 90px;
  flex: 1;
  transition: all var(--transition-base);
  position: relative;
}

.pipeline-stage:hover {
  background: var(--surface-3);
  transform: translateY(-2px);
}

.pipeline-stage .stage-count {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}

.pipeline-stage .stage-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 2px;
}

/* Pipeline connector arrows */
.pipeline-connector {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  flex-shrink: 0;
  font-size: 18px;
}

/* ── Workload Avatars ────────────────────────────────────────────────────── */
.workload-avatar {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, var(--surface-3), var(--surface-2));
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.workload-row {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
  transition: all var(--transition-fast);
  border-radius: var(--border-radius-xs);
}

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

.workload-row:hover {
  background: var(--surface-hover);
  padding-left: 6px;
}

/* ── Avatar in Tables ────────────────────────────────────────────────────── */
.table-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--surface-3), var(--surface-2));
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* ── Code / UWI Display ──────────────────────────────────────────────────── */
code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 12.5px;
  font-weight: 500;
}

.uwi-code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  color: #a9ece4;
  background: rgba(47,224,207,.08);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(47,224,207,.2);
  letter-spacing: .03em;
}

/* ── Filter Bars ─────────────────────────────────────────────────────────── */
.filter-bar {
  padding: 10px 16px;
  background: var(--surface-card);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

/* ── Detail Page Definition Lists ────────────────────────────────────────── */
dl.detail-list dt {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
  padding: 6px 0;
}

dl.detail-list dd {
  font-size: 13.5px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-soft);
}

dl.detail-list dd:last-of-type {
  border-bottom: none;
}

/* ── Split-Screen Views (Data Entry / QC) ────────────────────────────────── */
.split-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.split-toolbar {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-color);
  background: var(--surface-card);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  min-height: 44px;
}

.split-status {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--surface-2);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
}

.split-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border-color);
  background: var(--surface-card);
  flex-shrink: 0;
}

/* File viewer background */
.viewer-area {
  flex: 1;
  overflow: auto;
  background: #1e293b;
  display: flex;
  align-items: flex-start;
  /* flex-start + auto margins on children (not justify-content:center): centers
     content narrower than the pane, but keeps a zoomed-past-100% document fully
     scrollable — centering an overflowing flex child clips its left edge. */
  justify-content: flex-start;
  padding: 10px;
}
.viewer-area > * {
  margin-left: auto;
  margin-right: auto;
}

/* ── Data Entry Layout System ────────────────────────────────────────────── */
.de-split-container {
  display: flex;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.de-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: none; /* no transition during drag */
}

.de-viewer-panel {
  flex: 1 1 55%;
  min-width: 200px;
  border-right: 1px solid var(--border-color);
}

.de-entry-panel {
  flex: 1 1 45%;
  min-width: 300px;
  position: relative;
}

/* ── Resize Handle ───────────────────────────────────────────────────────── */
.de-resize-handle {
  width: 6px;
  cursor: col-resize;
  background: var(--border-color);
  position: relative;
  flex-shrink: 0;
  z-index: 20;
  transition: background var(--transition-fast);
}

.de-resize-handle:hover,
.de-resize-handle.dragging {
  background: var(--brand-primary);
}

.de-resize-handle::after {
  content: '';
  position: absolute;
  left: -4px;
  right: -4px;
  top: 0;
  bottom: 0;
}

.de-resize-grip {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 4px;
  height: 32px;
  border-radius: 2px;
  background: #94a3b8;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.de-resize-handle:hover .de-resize-grip,
.de-resize-handle.dragging .de-resize-grip {
  opacity: 1;
}

/* ── Layout Controls ─────────────────────────────────────────────────────── */
.de-layout-controls {
  display: flex;
  align-items: center;
  gap: 2px;
}

.de-layout-divider {
  width: 1px;
  height: 20px;
  background: var(--border-color);
  margin: 0 6px;
}

.de-layout-btn {
  width: 30px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--border-radius-xs);
  background: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 14px;
  transition: all var(--transition-fast);
}

.de-layout-btn:hover {
  background: var(--surface-hover);
  color: var(--text-secondary);
  border-color: var(--border-color);
}

.de-layout-btn.active {
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  border-color: rgba(47,224,207,.4);
}

/* ── Layout Modes ────────────────────────────────────────────────────────── */

/* Viewer only */
.de-split-container.layout-viewer .de-entry-panel,
.de-split-container.layout-viewer .de-resize-handle {
  display: none;
}

.de-split-container.layout-viewer .de-viewer-panel {
  flex: 1 1 100%;
  border-right: none;
}

/* Table only */
.de-split-container.layout-table .de-viewer-panel,
.de-split-container.layout-table .de-resize-handle {
  display: none;
}

.de-split-container.layout-table .de-entry-panel {
  flex: 1 1 100%;
}

/* Stacked mode (file top, table bottom) */
.de-split-container.layout-stacked {
  flex-direction: column;
}

.de-split-container.layout-stacked .de-viewer-panel {
  flex: 1 1 50%;
  min-width: 0;
  min-height: 150px;
  border-right: none;
  border-bottom: 1px solid var(--border-color);
}

.de-split-container.layout-stacked .de-entry-panel {
  flex: 1 1 50%;
  min-width: 0;
  min-height: 150px;
}

.de-split-container.layout-stacked .de-resize-handle {
  width: auto;
  height: 6px;
  cursor: row-resize;
}

.de-split-container.layout-stacked .de-resize-handle .de-resize-grip {
  width: 32px;
  height: 4px;
}

/* Float mode */
.de-split-container.layout-float .de-viewer-panel {
  flex: 1 1 100% !important;
  border-right: none !important;
}

.de-split-container.layout-float .de-resize-handle {
  display: none !important;
}

.de-split-container.layout-float .de-entry-panel {
  position: fixed !important;
  z-index: 500;
  flex: none !important;
  display: flex !important;
  flex-direction: column !important;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  box-shadow: 0 20px 60px rgba(0,0,0,.2), 0 4px 12px rgba(0,0,0,.1);
  background: var(--surface-card);
  overflow: hidden;
  min-width: 480px;
  min-height: 250px;
}

/* Make the table wrapper fill available space in float */
.de-split-container.layout-float #entry-table-wrap {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  overflow: auto !important;
}

.de-split-container.layout-float .de-entry-panel.minimized {
  min-height: unset !important;
  height: auto !important;
  min-width: 320px !important;
}

.de-split-container.layout-float .de-entry-panel.minimized #entry-table-wrap,
.de-split-container.layout-float .de-entry-panel.minimized #entry-status-bar,
.de-split-container.layout-float .de-entry-panel.minimized #entry-footer {
  display: none !important;
}

/* Float title bar — hidden by default, shown in float mode */
.de-float-titlebar {
  display: none;
  padding: 6px 10px;
  background: linear-gradient(to bottom, var(--surface-3), var(--surface-2));
  border-bottom: 1px solid var(--border-color);
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
}

.de-split-container.layout-float .de-float-titlebar {
  display: flex;
}

.de-float-btn {
  width: 26px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  transition: all var(--transition-fast);
}

.de-float-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

/* Float resize corner — hidden by default, shown in float mode */
.de-float-resize {
  display: none;
  position: absolute;
  bottom: 0;
  right: 0;
  width: 28px;
  height: 28px;
  cursor: nwse-resize;
  z-index: 10;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 2px;
}

.de-float-resize::after {
  content: '';
  display: block;
  width: 12px;
  height: 12px;
  border-right: 2px solid #94a3b8;
  border-bottom: 2px solid #94a3b8;
  border-radius: 0 0 3px 0;
  opacity: .6;
  transition: opacity var(--transition-fast);
}

.de-float-resize:hover::after {
  opacity: 1;
  border-color: var(--brand-primary);
}

.de-split-container.layout-float .de-float-resize {
  display: flex;
}

.de-split-container.layout-float .de-entry-panel.minimized .de-float-resize {
  display: none !important;
}

/* ── Spreadsheet Data Entry ──────────────────────────────────────────────── */

/* Row base */
.ss-row {
  transition: background 200ms;
}

.ss-row-active {
  background: rgba(47,224,207,.06) !important;
}

.ss-row:hover {
  background: rgba(255,255,255,.025);
}

/* Row number cell */
.ss-row-num {
  text-align: center;
  color: #94a3b8;
  font-size: 10px;
  font-weight: 600;
  user-select: none;
  white-space: nowrap;
  padding: 2px 4px !important;
  position: relative;
  width: 36px;
  min-width: 36px;
}

.ss-row-label {
  display: inline;
}

/* Row status dots */
.ss-status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 3px;
  vertical-align: middle;
}

.ss-status-new      { background: #94a3b8; }
.ss-status-modified { background: #f59e0b; }
.ss-status-saved    { background: #22c55e; }
.ss-status-error    { background: #ef4444; }

/* Cell base */
.ss-cell {
  padding: 0 !important;
  border-bottom: 1px solid var(--border-soft) !important;
  position: relative;
}

/* Active cell — a soft shade only, no ring/boundary: the grid stays quiet and
   the lit cell still reads instantly. */
.ss-cell-active {
  background: rgba(47,224,207,.14) !important;
  z-index: 5;
  position: relative;
}

/* Modified cell triangle */
.ss-cell-modified::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 6px 6px 0;
  border-color: transparent var(--brand-primary) transparent transparent;
  pointer-events: none;
}

/* Error cell */
.ss-cell-error {
  background: rgba(255,93,108,.14) !important;
}

.ss-cell-error::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--crit);
  pointer-events: none;
  z-index: 1;
}

/* Input base */
.ss-input {
  width: 100%;
  border: none;
  padding: 3px 5px;
  font-size: 11.5px;
  background: transparent;
  outline: none;
  font-family: 'Inter', sans-serif;
  transition: background 100ms;
  color: var(--text-primary);
}

.ss-input:focus {
  background: rgba(47,224,207,.1);
}

/* Delete button */
.ss-cell-del {
  text-align: center;
  padding: 0 !important;
  width: 36px;
  border-bottom: 1px solid var(--border-soft) !important;
  border-left: 1px solid var(--border-soft) !important;
  background: var(--surface-2);
}

.ss-del-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 22px;
  border: 1px solid rgba(255,93,108,.3);
  background: rgba(255,93,108,.12);
  color: #ff8a95;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  font-size: 11px;
  border-radius: 4px;
  opacity: .7;
  transition: all 150ms;
}

.ss-del-btn:hover {
  opacity: 1;
  background: var(--crit);
  color: #2a0409;
  border-color: var(--crit);
  transform: scale(1.1);
  box-shadow: 0 2px 10px rgba(255, 93, 108, .4);
}

.ss-row:hover .ss-del-btn,
.ss-row-active .ss-del-btn {
  opacity: 1;
}

.ss-row-active .ss-cell-del {
  background: rgba(255,93,108,.1);
}

/* Table header */
#entry-table th {
  background: var(--surface-hover);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 6px 5px !important;
  white-space: nowrap;
  border-bottom: 2px solid var(--border-strong) !important;
  user-select: none;
}

/* Column resize handle */
.ss-col-resize {
  position: absolute;
  right: -2px;
  top: 0;
  bottom: 0;
  width: 5px;
  cursor: col-resize;
  z-index: 5;
  transition: background var(--transition-fast);
}

/* Left-edge twin: grabs the boundary from the other side (resizes the column
   BEFORE it), so any column border can be dragged from either side. */
.ss-col-resize-left {
  right: auto;
  left: -2px;
}

.ss-col-resize:hover,
.ss-col-resize.active {
  background: var(--brand-primary);
}

/* Header wrap toggle: multi-line headers so narrow columns can match a report */
#entry-table.th-wrap thead th {
  white-space: normal;
  overflow-wrap: break-word;
  line-height: 1.25;
}

/* Direct header manipulation: hover × to hide, drag to reorder */
#entry-table th .th-hide-btn {
  position: absolute;
  top: 0;
  right: 7px;              /* clear of the edge resize handle */
  display: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.2;
  padding: 0 3px;
  border-radius: 3px;
  z-index: 6;
}

#entry-table th:hover .th-hide-btn {
  display: inline-block;
}

#entry-table th .th-hide-btn:hover {
  color: var(--crit);
  background: var(--surface-hover);
}

#entry-table th.th-dragging {
  opacity: .45;
}

#entry-table th.th-dragover {
  background: var(--brand-primary-light) !important;
  box-shadow: inset 0 -2px 0 var(--brand-primary);
}

/* Guide sliders — explicitly styled thumbs so the two controls are always
   tellable apart (green = darkness, blue = thickness), independent of the
   browser's accent-color support/theme. */
.guide-slider {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
  outline: none;
  vertical-align: middle;
  cursor: pointer;
}
.guide-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: none;
  background: var(--gs-color, #16a34a);
}
.guide-slider::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: none;
  background: var(--gs-color, #16a34a);
}
#col-guides-alpha { --gs-color: #3b82f6; }   /* matches the guide-line color */
#col-guides-thick { --gs-color: #64748b; }

/* "Order by ticks" mode */
.ss-tick-order-bar {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-color);
  background: var(--surface-hover);
  position: sticky;
  top: 0;
  z-index: 2;
}

.ss-tick-seq {
  display: inline-block;
  min-width: 18px;
  margin-left: 6px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--brand-primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
}

/* ── Context Menu ────────────────────────────────────────────────────────── */
#ss-context-menu {
  position: fixed;
  z-index: 1000;
  background: var(--surface-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  box-shadow: 0 10px 30px rgba(0,0,0,.15), 0 2px 8px rgba(0,0,0,.08);
  padding: 4px;
  min-width: 200px;
  display: none;
  animation: ctxAppear .12s ease-out;
}

#ss-context-menu.show {
  display: block;
}

@keyframes ctxAppear {
  from { opacity: 0; transform: scale(.96) translateY(-4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.ss-ctx-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 12.5px;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: var(--border-radius-xs);
  transition: background var(--transition-fast);
}

.ss-ctx-item:hover {
  background: var(--brand-primary-light);
  color: var(--brand-primary);
}

.ss-ctx-item i {
  font-size: 13px;
  width: 16px;
  text-align: center;
  color: var(--text-muted);
}

.ss-ctx-item:hover i {
  color: var(--brand-primary);
}

.ss-ctx-key {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-muted);
  font-family: monospace;
}

.ss-ctx-disabled {
  opacity: .4;
  cursor: not-allowed;
}

.ss-ctx-disabled:hover {
  background: none;
  color: var(--text-primary);
}

.ss-ctx-divider {
  height: 1px;
  background: var(--border-color);
  margin: 3px 8px;
}

/* ── QC Table ────────────────────────────────────────────────────────────── */
#qc-table th {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 5px 4px;
  white-space: nowrap;
  border-bottom: 2px solid var(--border-strong);
  background: var(--surface-hover);
}

#qc-table .final-row input {
  font-family: 'Inter', sans-serif;
  transition: background var(--transition-fast);
}

#qc-table .final-row input:focus {
  background: rgba(47,224,207,.1) !important;
  box-shadow: inset 0 0 0 1.5px var(--brand-primary);
}

/* ── QC Legend ────────────────────────────────────────────────────────────── */
.qc-legend {
  padding: 6px 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--surface-card);
  flex-shrink: 0;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.qc-legend-item {
  font-size: 10.5px;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  font-weight: 500;
}

.qc-legend-swatch {
  width: 12px;
  height: 12px;
  display: inline-block;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ── Login Page ──────────────────────────────────────────────────────────── */
.login-bg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  position: relative;
  overflow: hidden;
}

.login-bg::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(37,99,235,.15), transparent 70%);
  top: -200px;
  right: -100px;
  pointer-events: none;
}

.login-bg::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(99,102,241,.1), transparent 70%);
  bottom: -100px;
  left: -100px;
  pointer-events: none;
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 1rem;
  position: relative;
  z-index: 1;
  animation: loginAppear .5s ease-out;
}

.login-card .card {
  border: 1px solid rgba(255,255,255,.08) !important;
  background: rgba(30,41,59,.85) !important;
  backdrop-filter: blur(20px);
  box-shadow: 0 25px 50px rgba(0,0,0,.4) !important;
}

.login-card .card-body {
  padding: 32px;
}

.login-card .form-control {
  background: rgba(15,23,42,.6);
  border-color: rgba(255,255,255,.1);
  color: white;
}

.login-card .form-control:focus {
  background: rgba(15,23,42,.8);
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,.2);
  color: white;
}

.login-card .form-control::placeholder {
  color: #64748b;
}

.login-card .form-label {
  color: #94a3b8;
}

.login-card .btn-primary {
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
}

.login-brand-text {
  color: white;
  font-weight: 700;
  font-size: 18px;
}

.login-brand-sub {
  color: #64748b;
  font-size: 13px;
}

@keyframes loginAppear {
  from { opacity: 0; transform: translateY(20px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Password toggle */
.password-wrapper {
  position: relative;
}

.password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 4px;
  font-size: 14px;
  transition: color var(--transition-fast);
}

.password-toggle:hover {
  color: #94a3b8;
}

/* ── Page Header ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

/* ── Tooltips for notes ──────────────────────────────────────────────────── */
[title] {
  cursor: help;
}

/* ── Column Settings Panel ────────────────────────────────────────────────── */
.ss-gear-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-xs);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  transition: all var(--transition-fast);
}

.ss-gear-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.ss-col-settings-panel {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 500;
  width: 320px;
  background: var(--surface-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: 0 12px 40px rgba(0,0,0,.15);
  animation: ctxAppear .15s ease-out;
}

.ss-col-settings-panel.show {
  display: block;
}

.ss-col-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 4px;
}

.ss-col-reset-btn {
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all var(--transition-fast);
}

.ss-col-reset-btn:hover {
  background: var(--surface-hover);
  color: var(--brand-primary);
}

.ss-col-settings-hint {
  font-size: 10.5px;
  padding: 0 14px 6px;
  border-bottom: 1px solid var(--border-color);
}

.ss-col-settings-list {
  max-height: 360px;                 /* fallback for old browsers */
  max-height: calc(100vh - 240px);   /* long column lists get the whole screen */
  overflow-y: auto;
  padding: 6px;
}

.ss-col-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: var(--border-radius-xs);
  cursor: grab;
  transition: background var(--transition-fast);
  border: 1px solid transparent;
}

.ss-col-item:hover {
  background: var(--surface-hover);
}

.ss-col-item.ss-col-dragging {
  opacity: .4;
}

.ss-col-item.ss-col-dragover {
  border-color: var(--brand-primary);
  background: var(--brand-primary-light);
}

.ss-col-drag {
  color: var(--text-muted);
  font-size: 14px;
  cursor: grab;
  flex-shrink: 0;
}

.ss-col-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  flex-grow: 1;
  cursor: pointer;
  margin: 0;
}

.ss-col-label .form-check-input {
  width: 14px;
  height: 14px;
  margin: 0;
  cursor: pointer;
}

.ss-col-move-btns {
  display: flex;
  gap: 1px;
  flex-shrink: 0;
}

.ss-col-move-btn {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 3px;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  transition: all var(--transition-fast);
}

.ss-col-move-btn:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.ss-col-move-btn:disabled {
  opacity: .2;
  cursor: not-allowed;
}

/* ── Sidebar nav badge (e.g. rejected count) ──────────────────────────────── */
.nav-badge {
  margin-left: auto;
  background: #dc2626;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  box-shadow: 0 0 0 0 rgba(220,38,38,.6);
  animation: nav-badge-pulse 2.4s ease-in-out infinite;
}

@keyframes nav-badge-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(220,38,38,.6); }
  60%  { box-shadow: 0 0 0 5px rgba(220,38,38,0); }
  100% { box-shadow: 0 0 0 0   rgba(220,38,38,0); }
}

/* ── Rejected Wells Cards ─────────────────────────────────────────────────── */
.rejection-card-pending {
  border-left: 4px solid #dc2626 !important;
}

.rejection-card-resolved {
  border-left: 4px solid #94a3b8 !important;
  opacity: .75;
}

.rejection-notes {
  background: rgba(255,176,46,.1);
  border-left: 3px solid var(--warn);
  padding: 10px 12px;
  border-radius: 6px;
}

/* ── Status Pills (Dashboard progress indicators) ─────────────────────────── */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.status-pill i {
  font-size: 10px;
}

.status-progress {
  background: rgba(255,176,46,.14);
  color: #ffd07f;
  border-color: rgba(255,176,46,.3);
}

.status-not-started {
  background: rgba(99,121,139,.16);
  color: #9fb4c4;
  border-color: rgba(99,121,139,.3);
}

.status-done {
  background: rgba(53,214,138,.14);
  color: #7cecb6;
  border-color: rgba(53,214,138,.3);
}

.status-waiting {
  background: rgba(79,157,255,.14);
  color: #a6cbff;
  border-color: rgba(79,157,255,.3);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #eab308;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot-pulse {
  animation: status-pulse 1.6s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(234, 179, 8, .6);
}

@keyframes status-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(234, 179, 8, .6); }
  70%  { box-shadow: 0 0 0 6px rgba(234, 179, 8, 0); }
  100% { box-shadow: 0 0 0 0   rgba(234, 179, 8, 0); }
}

/* ── Keyboard hint badges ────────────────────────────────────────────────── */
.ss-kbd {
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
  color: var(--text-secondary);
  font-family: inherit;
  margin-right: 2px;
}

/* ── Loading Spinner ─────────────────────────────────────────────────────── */
.spinner-border-sm {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

/* ── Responsive Tweaks ───────────────────────────────────────────────────── */
@media (max-width: 575.98px) {
  .page-content { padding: 16px; }
  .card-body { padding: 16px; }
  .stat-card .stat-value { font-size: 1.4rem; }
}

/* ── OCR Quality Badges ──────────────────────────────────────────────────── */
.ocr-badge-good {
  background: rgba(53,214,138,.14);
  color: #7cecb6;
  border: 1px solid rgba(53,214,138,.3);
}

.ocr-badge-bad {
  background: rgba(255,93,108,.14);
  color: #ffa3ac;
  border: 1px solid rgba(255,93,108,.3);
}

.ocr-badge-unreviewed {
  background: rgba(99,121,139,.16);
  color: #9fb4c4;
  border: 1px solid rgba(99,121,139,.3);
}

/* ── File Review Status Boxes ────────────────────────────────────────────── */
.review-status-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--border-radius-sm);
  font-size: 13px;
  font-weight: 600;
}

.review-status-good {
  background: rgba(53,214,138,.12);
  color: #7cecb6;
  border: 1px solid rgba(53,214,138,.28);
}

.review-status-bad {
  background: rgba(255,93,108,.12);
  color: #ffa3ac;
  border: 1px solid rgba(255,93,108,.28);
}

.review-status-unreviewed {
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
}

/* ── Bulk Assign Bar ─────────────────────────────────────────────────────── */
.bulk-assign-bar {
  position: fixed;
  bottom: -80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  background: var(--sidebar-bg);
  color: white;
  padding: 12px 24px;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.06);
  min-width: 380px;
  transition: bottom var(--transition-base);
  backdrop-filter: blur(12px);
}

.bulk-assign-bar.show {
  bottom: 24px;
}

.bulk-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2fe0cf, #17b5a6);
  color: #04201d;
  font-weight: 700;
  font-size: 13px;
  padding: 0 6px;
}

/* Sortable table headers (templates/_sortable.html). The muted arrows mark a column as
   sortable before it's clicked; the active one takes the brand colour. */
.sort-header {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  cursor: pointer;
}
.sort-header:hover { color: var(--brand-primary) !important; }
.sort-header:hover .bi { opacity: 1 !important; }
.text-brand { color: var(--brand-primary) !important; }

/* Checkbox row highlight. Class must match the checkboxes in wells.html
   (.row-select) — it read .well-select, which no template uses, so the whole block
   was dead and bulk selections had no visual confirmation of WHICH rows. */
.row-select:checked {
  accent-color: var(--brand-primary);
}

tr:has(.row-select:checked) {
  background: var(--brand-primary-light) !important;
}

tr:has(.row-select:checked) td {
  border-bottom-color: rgba(47,224,207,.2) !important;
}

/* ── Print ───────────────────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .sidebar-overlay { display: none !important; }
  .main-content { margin: 0; }
  .page-content { padding: 0; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* ── Grid copy/paste selection (grid_clipboard.js) ───────────────────────── */
.gc-selected {
  outline: 2px solid var(--brand-primary) !important;
  outline-offset: -2px;
  background: rgba(47, 224, 207, 0.12) !important;
}
.gc-copied {
  outline: 2px dashed var(--good) !important;
  outline-offset: -2px;
}

/* ── Collapsible sidebar (desktop) ───────────────────────────────────────────
   Toggled by a class on <html> so it applies before first paint (no flash). */
.sidebar-collapse-btn,
.topbar-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 5px 9px;
  border-radius: var(--border-radius-xs);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.sidebar-collapse-btn:hover,
.topbar-back:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

@media (max-width: 991.98px) {
  /* On mobile the drawer toggle handles things; hide the desktop collapse btn. */
  .sidebar-collapse-btn { display: none; }
}

html.nav-collapsed .sidebar { width: var(--sidebar-collapsed-w, 66px); }
html.nav-collapsed .sidebar-brand-text,
html.nav-collapsed .sidebar-brand-sub,
html.nav-collapsed .nav-section-label,
html.nav-collapsed .sidebar-user-name,
html.nav-collapsed .sidebar-user-role,
html.nav-collapsed .nav-badge { display: none; }
html.nav-collapsed .sidebar-brand,
html.nav-collapsed .sidebar-user { justify-content: center; }
html.nav-collapsed .sidebar-brand > div { justify-content: center; }
html.nav-collapsed .nav-item {
  font-size: 0;                 /* hide the text node, keep the icon */
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}
html.nav-collapsed .nav-item i { font-size: 18px; margin-right: 0; }

/* ── Popout window (Document Picture-in-Picture) ─────────────────────────────── */
.popout-window {
  margin: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface-bg, #f8fafc);
}
.popout-window .de-panel,
.popout-window .split-panel {
  width: 100% !important;
  height: 100vh !important;
  flex: 1 1 auto !important;
  position: static !important;
  border: none !important;
}
.popout-window .de-float-titlebar { display: none !important; }

.popout-placeholder {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 220px;
  background: var(--surface-bg, #f8fafc);
  border-left: 1px dashed var(--border-color);
}
.popout-placeholder-inner {
  text-align: center;
  color: var(--text-secondary);
  padding: 24px;
}
.popout-placeholder-inner i { font-size: 2rem; opacity: .5; }
.popout-placeholder-inner p { margin: 10px 0 12px; font-size: 13px; }
