/* ─── MedOps Platform — App Styles ──────────────────────────────────────────
   Bootstrap 5.3 base · Inter font · Dark sidebar · Light workspace
   ─────────────────────────────────────────────────────────────────────────── */

:root {
  --sidebar-width:   240px;
  --sidebar-bg:      #0f1623;
  --sidebar-border:  rgba(255,255,255,0.06);
  --sidebar-hover:   rgba(255,255,255,0.07);
  --sidebar-active:  rgba(255,255,255,0.13);
  --topbar-height:   56px;
  --body-bg:         #f0f2f7;
  --card-radius:     0.5rem;
  --card-shadow:     0 1px 3px rgba(0,0,0,0.07), 0 1px 8px rgba(0,0,0,0.05);
  --card-shadow-md:  0 4px 16px rgba(0,0,0,0.10);
  --transition:      0.16s ease;
  --font-sans:       'Inter', system-ui, -apple-system, sans-serif;
  --color-red:       #ef4444;
  --color-amber:     #f59e0b;
  --color-green:     #22c55e;
  --color-purple:    #8b5cf6;
  --color-blue:      #3b82f6;
  --text-muted:      #64748b;

  /* ─── Standardised theme variables (light) ───────────────────────────────
     Two-tier surface system: --bg sits below --surface (cards), with
     --surface-muted for nested panels and subtle backgrounds. All dark
     mode overrides live inside [data-bs-theme="dark"] below — prefer
     these tokens over hardcoded hex when adding new components. */
  --bg:              #f0f2f7;
  --surface:         #ffffff;
  --surface-muted:   #f8fafc;
  --surface-raised:  #ffffff;
  --text:            #0f172a;
  --text-strong:     #0f172a;
  --border:          #e5e7eb;
  --border-muted:    #f1f5f9;
  --primary:         #2563eb;
  --primary-hover:   #1d4ed8;
  --danger:          #dc2626;
  --warning:         #d97706;
  --success:         #16a34a;
  --info:            #0284c7;
  --input-bg:        #ffffff;
  --input-text:      #0f172a;
  --input-border:    #d1d5db;
  --input-placeholder: #94a3b8;
  --table-header:    #f8fafc;
  --table-border:    #f1f5f9;
  --table-hover:     #f8fafc;
  --modal-bg:        #ffffff;
  --link:            #2563eb;
  --focus-ring:      rgba(59, 130, 246, 0.25);
}

/* ─── Base typography ────────────────────────────────────────────────────────── */

body {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { font-family: var(--font-sans); }

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

body.app-body {
  background: var(--body-bg);
  margin: 0;
  overflow: hidden;
}

body.login-body {
  background: var(--body-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  transition: transform var(--transition);
  z-index: 1000;
  border-right: 1px solid rgba(255,255,255,0.04);
}

.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

.sidebar-brand {
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar .nav-link {
  color: rgba(255,255,255,0.58);
  font-size: 0.838rem;
  font-weight: 500;
  padding: 0.42rem 0.75rem;
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 1px;
  letter-spacing: 0.01em;
}

.sidebar .nav-link i {
  opacity: 0.7;
  transition: opacity var(--transition);
}

.sidebar .nav-link:hover {
  background: var(--sidebar-hover);
  color: rgba(255,255,255,0.9);
}

.sidebar .nav-link:hover i { opacity: 1; }

.sidebar .nav-link.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
}

.sidebar .nav-link.active i { opacity: 1; }

.sidebar .nav-link.disabled {
  opacity: 0.35;
  pointer-events: none;
  cursor: default;
}

.sidebar-section-label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: rgba(255,255,255,0.25);
  padding: 1rem 0.75rem 0.3rem;
  list-style: none;
}

.sidebar hr { border-color: var(--sidebar-border); }

.sidebar-user {
  background: rgba(0,0,0,0.25);
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ─── Main content ────────────────────────────────────────────────────────────── */

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ─── Topbar ─────────────────────────────────────────────────────────────────── */

.topbar {
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e9ecef;
  flex-shrink: 0;
  gap: 0.75rem;
}

.topbar-clock {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-family: 'Courier New', monospace;
  letter-spacing: 0.02em;
}

/* ─── Page content ───────────────────────────────────────────────────────────── */

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.page-content::-webkit-scrollbar { width: 6px; }
.page-content::-webkit-scrollbar-track { background: transparent; }
.page-content::-webkit-scrollbar-thumb { background: #dee2e6; border-radius: 3px; }

/* ─── Page header ────────────────────────────────────────────────────────────── */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  gap: 1rem;
}

.page-header h4 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
  color: #0f172a;
}

.page-header .page-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

/* ─── Cards ──────────────────────────────────────────────────────────────────── */

.card {
  border-radius: var(--card-radius) !important;
  box-shadow: var(--card-shadow);
}

.card-header {
  border-radius: var(--card-radius) var(--card-radius) 0 0 !important;
  font-size: 0.875rem;
}

.card-header h6 {
  font-size: 0.875rem;
  font-weight: 600;
}

/* ─── Filter card ────────────────────────────────────────────────────────────── */

.filter-card {
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  box-shadow: none !important;
}

/* ─── Stat cards ─────────────────────────────────────────────────────────────── */

.stat-card {
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  border: 1px solid rgba(0,0,0,0.04) !important;
}

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

.stat-card .card-body {
  padding: 1rem 1.1rem;
}

.stat-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 0.5rem !important;
  font-size: 1.25rem;
}

.stat-value {
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1;
  color: #0f172a;
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 3px;
}

/* ─── Quick actions ──────────────────────────────────────────────────────────── */

.quick-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.quick-actions .btn {
  font-size: 0.8rem;
  font-weight: 500;
}

/* ─── Tables ─────────────────────────────────────────────────────────────────── */

.table > :not(caption) > * > * {
  padding: 0.6rem 0.85rem;
}

.table th {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  white-space: nowrap;
  background: #f8fafc;
  border-bottom: 2px solid #e9ecef !important;
}

.table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background var(--transition);
}

.table-hover tbody tr:hover {
  background: #f8fafc !important;
}

.table-row-active {
  background-color: rgba(255,193,7,0.03);
}

/* Priority-coloured left border on CAD table rows */
.priority-row-red    { border-left: 3px solid var(--color-red) !important; }
.priority-row-amber  { border-left: 3px solid var(--color-amber) !important; }
.priority-row-green  { border-left: 3px solid var(--color-green) !important; }
.priority-row-purple { border-left: 3px solid var(--color-purple) !important; }

/* ─── Empty states ───────────────────────────────────────────────────────────── */

.empty-state {
  padding: 2.5rem 1rem;
  text-align: center;
  color: #94a3b8;
}

.empty-state i {
  font-size: 2.25rem;
  display: block;
  margin-bottom: 0.6rem;
  opacity: 0.45;
}

.empty-state p {
  font-size: 0.875rem;
  margin: 0;
}

/* ─── Status badges ──────────────────────────────────────────────────────────── */

.status-badge {
  font-weight: 600;
  letter-spacing: 0.02em;
  font-size: 0.7rem;
  padding: 0.28em 0.65em;
}

/* Deployment response-workflow statuses — matched to the visual style sheet
   provided by the user. Light theme. */
/* Manual row-level flags on the deployments list — RED = urgent / blocker,
   AMBER = needs attention. Subtle tint so the status badge still pops. */
.deployments-table tr.row-flag-red   { background-color: rgba(220, 38, 38, 0.08); }
.deployments-table tr.row-flag-red:hover   { background-color: rgba(220, 38, 38, 0.14) !important; }
.deployments-table tr.row-flag-amber { background-color: rgba(245, 158, 11, 0.10); }
.deployments-table tr.row-flag-amber:hover { background-color: rgba(245, 158, 11, 0.16) !important; }
[data-bs-theme="dark"] .deployments-table tr.row-flag-red   { background-color: rgba(220, 38, 38, 0.18); }
[data-bs-theme="dark"] .deployments-table tr.row-flag-amber { background-color: rgba(245, 158, 11, 0.20); }

.status-PRE_DEPLOYMENT                 { background: #e2e8f0 !important; color: #334155 !important; }
.status-FOR_RESPONSE                   { background: #991b1b !important; color: #fff      !important; }
.status-TEAM_ACTIVATED                 { background: #bfdbfe !important; color: #1e3a8a !important; }
.status-TEAM_MOBILISED                 { background: #1f2937 !important; color: #fff      !important; }
.status-TEAM_ARRIVED                   { background: #7c3aed !important; color: #fff      !important; }
.status-CLEARED_MISSION                { background: #15803d !important; color: #fff      !important; }
.status-MISSION_COMPLETE               { background: #3f3712 !important; color: #fff      !important; }
.status-STAND_DOWN                     { background: #fde68a !important; color: #78350f !important; }
.status-REJECTED                       { background: #fecaca !important; color: #7f1d1d !important; }

.status-PLANNED,   .status-RECEIVED    { background: #e2e8f0 !important; color: #475569 !important; }
.status-CONFIRMED, .status-MOBILE      { background: #dbeafe !important; color: #1d4ed8 !important; }
.status-ACTIVE,    .status-AVAILABLE,
.status-COMPLETED, .status-PATIENT_CONTACT { background: #dcfce7 !important; color: #15803d !important; }
.status-DISPATCHED,.status-MAINTENANCE { background: #fef9c3 !important; color: #854d0e !important; }
.status-DEFECT,    .status-CANCELLED,
.status-DEPART_SCENE                   { background: #fee2e2 !important; color: #b91c1c !important; }
.status-DECOMMISSIONED, .status-LEFT,
.status-CLEAR                          { background: #f1f5f9 !important; color: #64748b !important; }
.status-DEPLOYED,  .status-ON_SCENE,
.status-ARRIVE_DESTINATION             { background: #ede9fe !important; color: #6d28d9 !important; }
.status-DRAFT                          { background: #f1f5f9 !important; color: #64748b !important; }
.status-EXPORTED                       { background: #dbeafe !important; color: #1d4ed8 !important; }
.status-INACTIVE,  .status-SUSPENDED   { background: #fee2e2 !important; color: #b91c1c !important; }

/* ─── Priority badges (CAD) ──────────────────────────────────────────────────── */

.priority-red    { background: #ef4444 !important; color: #fff !important; }
.priority-amber  { background: #f59e0b !important; color: #fff !important; }
.priority-green  { background: #22c55e !important; color: #fff !important; }
.priority-purple { background: #8b5cf6 !important; color: #fff !important; }

/* P1-P4 labels used on the control-room dashboard.
   P1 = purple (most urgent), P2 = red, P3 = amber, P4 = green. */
.priority-p1     { background: #8b5cf6 !important; color: #fff !important; }
.priority-p2     { background: #ef4444 !important; color: #fff !important; }
.priority-p3     { background: #f59e0b !important; color: #fff !important; }
.priority-p4     { background: #22c55e !important; color: #fff !important; }

/* New incident statuses — extend the colour scheme without breaking the old ones. */
.status-PENDING_DISPATCH { background: #fef3c7 !important; color: #92400e !important; }
.status-ASSIGNED         { background: #dbeafe !important; color: #1d4ed8 !important; }
.status-AT_PATIENT       { background: #dcfce7 !important; color: #15803d !important; }

/* CAD resource status chips. */
.cad-res-status-AVAILABLE      { background: #dcfce7; color: #166534; }
.cad-res-status-ASSIGNED       { background: #dbeafe; color: #1d4ed8; }
.cad-res-status-MOBILE         { background: #e0e7ff; color: #3730a3; }
.cad-res-status-ON_SCENE       { background: #ede9fe; color: #6d28d9; }
.cad-res-status-AT_PATIENT     { background: #fce7f3; color: #9d174d; }
.cad-res-status-CONVEYING      { background: #fef3c7; color: #92400e; }
.cad-res-status-AT_DESTINATION { background: #fed7aa; color: #9a3412; }
.cad-res-status-CLEAR          { background: #f1f5f9; color: #475569; }
.cad-res-status-UNAVAILABLE    { background: #fee2e2; color: #b91c1c; }
.cad-res-status-OFF_DUTY       { background: #f1f5f9; color: #64748b; }

/* ─── CAD Control Room layout ─────────────────────────────────────────────── */

/* Desktop: 4-column grid — resources | call-stack+map | detail.
   Tablet (<1280px): collapsible left + right panels.
   Mobile (<768px): everything stacks. */
.cad-cr {
  display: grid;
  grid-template-columns: 320px 1fr 360px;
  grid-template-rows:    auto 1fr auto;
  grid-template-areas:
    "left  topbar  right"
    "left  stack   right"
    "left  map     right";
  gap: 12px;
  height: calc(100vh - 140px);
  min-height: 640px;
}
.cad-cr__topbar { grid-area: topbar; }
.cad-cr__left   { grid-area: left;  overflow: hidden; display: flex; flex-direction: column; }
.cad-cr__stack  { grid-area: stack; overflow: hidden; display: flex; flex-direction: column; }
.cad-cr__map    { grid-area: map;   min-height: 240px; }
.cad-cr__right  { grid-area: right; overflow: hidden; display: flex; flex-direction: column; }

.cad-cr__panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}
.cad-cr__panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}
.cad-cr__panel-body {
  padding: 8px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}

/* Resource card in left rail */
.cad-res-card {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: #fff;
  cursor: grab;
  user-select: none;
}
.cad-res-card.dragging  { opacity: 0.5; cursor: grabbing; }
.cad-res-card.selected  { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37, 99, 235, .15); }
.cad-res-card__callsign { font-weight: 700; font-size: 0.95rem; letter-spacing: 0.01em; }
.cad-res-card__type     { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: #64748b; }
.cad-res-card__staff    { font-size: 0.75rem; color: #475569; margin-top: 2px; }

/* Incident card in call stack */
.cad-call-card {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: #fff;
  cursor: pointer;
  transition: border-color 80ms ease;
}
.cad-call-card:hover      { border-color: #cbd5e1; }
.cad-call-card.selected   { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37, 99, 235, .15); }
.cad-call-card.drop-target,
.cad-res-card.drop-target { border-color: #10b981; background: #ecfdf5; }
.cad-call-card__top       { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.cad-call-card__num       { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; font-size: 0.85rem; }
.cad-call-card__cc        { font-weight: 600; margin-top: 4px; line-height: 1.2; }
.cad-call-card__meta      { font-size: 0.75rem; color: #64748b; margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.cad-call-card__actions   { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.cad-call-card__resources { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; font-size: 0.7rem; }
.cad-call-card__resources .res-chip {
  background: #e0e7ff; color: #3730a3;
  padding: 1px 6px; border-radius: 999px;
}

/* Empty state */
.cad-cr__empty { color: #94a3b8; font-size: 0.85rem; text-align: center; padding: 24px 8px; }

@media (max-width: 1279.98px) {
  .cad-cr {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "stack"
      "map"
      "left"
      "right";
    height: auto;
  }
  .cad-cr__left, .cad-cr__right { max-height: 520px; }
}

/* ─── Flag warning banner & pills ─────────────────────────────────────────── */

.cad-flag-banner {
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.cad-flag-banner__row {
  padding: 10px 14px;
  display: flex; align-items: center; gap: 4px;
  font-size: 0.9rem;
}
.cad-flag-banner__row + .cad-flag-banner__row { border-top: 1px solid rgba(0,0,0,.08); }

/* Flag colour palette — shared between banner rows and admin chips. */
.cad-flag-red    { background: #fee2e2; color: #991b1b; border-left: 4px solid #dc2626; }
.cad-flag-orange { background: #ffedd5; color: #9a3412; border-left: 4px solid #ea580c; }
.cad-flag-yellow { background: #fef9c3; color: #854d0e; border-left: 4px solid #ca8a04; }
.cad-flag-blue   { background: #dbeafe; color: #1e3a8a; border-left: 4px solid #2563eb; }
.cad-flag-purple { background: #ede9fe; color: #5b21b6; border-left: 4px solid #7c3aed; }

/* Compact chip variant used in the admin list. */
.badge.cad-flag-red    { background: #dc2626 !important; color: #fff !important; border: 0 !important; }
.badge.cad-flag-orange { background: #ea580c !important; color: #fff !important; border: 0 !important; }
.badge.cad-flag-yellow { background: #ca8a04 !important; color: #fff !important; border: 0 !important; }
.badge.cad-flag-blue   { background: #2563eb !important; color: #fff !important; border: 0 !important; }
.badge.cad-flag-purple { background: #7c3aed !important; color: #fff !important; border: 0 !important; }

/* ─── Category 1 (P1 — purple) pulsing border on call cards ──────────────── */

@keyframes cad-cat1-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.55); }
  50%      { box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.0);  }
}
.cad-call-card--cat1 {
  border-color: #7c3aed;
  animation: cad-cat1-pulse 1.6s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .cad-call-card--cat1 { animation: none; border-width: 2px; }
}


/* ─── Badges general ────────────────────────────────────────────────────────── */

.badge { font-size: 0.7rem; }

/* ─── CAD Timeline ───────────────────────────────────────────────────────────── */

.cad-timeline { gap: 0.4rem; }

.cad-stamp {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.4rem 0.65rem;
  border-radius: 0.375rem;
  min-width: 85px;
  border: 1px solid #dee2e6;
}

.stamp-done {
  background: #dcfce7;
  border-color: #86efac;
}

.stamp-pending {
  background: #f8fafc;
  border-color: #e2e8f0;
  opacity: 0.55;
}

.stamp-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
  white-space: nowrap;
}

.stamp-time {
  font-size: 0.78rem;
  font-family: 'Courier New', monospace;
  font-weight: 700;
  color: #111827;
  margin-top: 2px;
}

.stamp-pending .stamp-time { color: #9ca3af; }

/* ─── Incident notes log ──────────────────────────────────────────────────────── */

.notes-log { max-height: 400px; overflow-y: auto; }
.note-entry:last-child { border-bottom: none !important; }

/* ─── EPRF brand button — purple to match the EPRF stat-card tone ──────────── */

.btn-eprf {
  background-color: #7c3aed;
  border-color:     #7c3aed;
  color:            #fff;
}
.btn-eprf:hover,
.btn-eprf:focus {
  background-color: #6d28d9;
  border-color:     #6d28d9;
  color:            #fff;
}
.btn-eprf:active { background-color: #5b21b6 !important; border-color: #5b21b6 !important; color: #fff !important; }

/* ─── Clinician dashboard hero ───────────────────────────────────────────────── */

.clinician-hero {
  background: linear-gradient(135deg, #1d4ed8 0%, #4f46e5 50%, #7c3aed 100%);
  color: #fff;
  border-radius: 0.75rem;
}
.clinician-hero h3 { color: #fff; }
.clinician-hero .opacity-85 { opacity: .85; }
.clinician-hero .badge.bg-white { color: #4338ca !important; font-weight: 600; }
.clinician-hero .bg-white-subtle { background: rgba(255,255,255,0.18) !important; }
.clinician-hero .border-white-50 { border-color: rgba(255,255,255,0.3) !important; }
.clinician-hero .btn-light:hover { background: #e0e7ff; }

.clinician-hero-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: rgba(255,255,255,0.22);
  border: 2px solid rgba(255,255,255,0.35);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.65rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

/* Personal-panel stat cards */
.personal-stat-card { transition: transform .15s ease, box-shadow .15s ease; }
.personal-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 .5rem 1rem rgba(0,0,0,0.08) !important;
}
.personal-stat-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
}

[data-bs-theme="dark"] .clinician-hero {
  background: linear-gradient(135deg, #1e3a8a 0%, #3730a3 50%, #5b21b6 100%);
}
[data-bs-theme="dark"] .personal-stat-card { background: var(--card-bg, #1f2937); }

/* ─── Detail list ─────────────────────────────────────────────────────────────── */

.detail-list dt {
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 0.3rem 0;
}

.detail-list dd {
  font-size: 0.875rem;
  padding: 0.3rem 0;
  margin-bottom: 0;
}

/* Newer icon+label+value row pattern used on the deployment show page +
   client cards. Replaces the dl pattern where icons help scanability. */
.detail-rows li        { font-size: 0.875rem; }
.detail-rows li .small { font-size: 0.78rem; }
.detail-rows .text-muted.small { color: var(--text-muted); }
[data-bs-theme="dark"] .detail-rows .text-muted { color: rgba(226, 232, 240, 0.55) !important; }
[data-bs-theme="dark"] .detail-rows a.text-body { color: #e2e8f0 !important; }

/* ─── Staff avatar ───────────────────────────────────────────────────────────── */

.staff-avatar-lg {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ─── Form improvements ──────────────────────────────────────────────────────── */

.form-control, .form-select {
  font-size: 0.875rem;
  border-color: #d1d5db;
}

.form-control:focus, .form-select:focus {
  border-color: var(--color-blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.35rem;
}

.form-label.required::after {
  content: ' *';
  color: #ef4444;
}

.form-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ─── Buttons ────────────────────────────────────────────────────────────────── */

.btn {
  font-size: 0.85rem;
  font-weight: 500;
}

.btn-sm  { font-size: 0.78rem; }
.btn-xs  { font-size: 0.72rem; padding: 0.1rem 0.35rem; line-height: 1.3; }

/* ─── Login page ─────────────────────────────────────────────────────────────── */

.login-wrapper {
  width: 100%;
  max-width: 420px;
  padding: 1rem;
}

.login-card {
  border-radius: 0.75rem !important;
  border: 1px solid #e9ecef !important;
}

.login-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  background: #fff;
  border: 2px solid #fee2e2;
  border-radius: 50%;
}

/* ─── Breadcrumb ─────────────────────────────────────────────────────────────── */

.breadcrumb { font-size: 0.82rem; }

.breadcrumb-item a {
  text-decoration: none;
  color: var(--text-muted);
  transition: color var(--transition);
}

.breadcrumb-item a:hover { color: #111827; }

/* ─── Error pages ─────────────────────────────────────────────────────────────── */

.error-page {
  padding: 2rem;
  max-width: 480px;
  margin: 0 auto;
}

/* ─── Nav tabs ────────────────────────────────────────────────────────────────── */

.nav-tabs .nav-link {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.nav-tabs .nav-link.active {
  font-weight: 600;
  color: #111827;
}

/* ─── Monospace utility ───────────────────────────────────────────────────────── */

.font-monospace { font-family: 'Courier New', monospace; }

/* ─── Mobile responsive ──────────────────────────────────────────────────────── */

@media (max-width: 991.98px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    z-index: 1050;
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1040;
    backdrop-filter: blur(2px);
  }

  .sidebar-overlay.show { display: block; }

  body.app-body { overflow: auto; }

  .app-layout {
    height: auto;
    overflow: visible;
  }

  .main-content { height: 100vh; }

  .page-header { flex-wrap: wrap; }
  .page-content { padding: 1rem; }

  .quick-actions { margin-bottom: 1rem; }
}

@media (max-width: 575.98px) {
  .stat-value { font-size: 1.6rem; }
  .stat-icon { width: 40px; height: 40px; font-size: 1.1rem; }
}

/* ─── EPRF — status badges ───────────────────────────────────────────────────── */

.status-DRAFT       { background: #94a3b8 !important; color: #fff !important; }
.status-IN_PROGRESS { background: #f59e0b !important; color: #fff !important; }
.status-SUBMITTED   { background: #3b82f6 !important; color: #fff !important; }
.status-COMPLETED   { background: #22c55e !important; color: #fff !important; }
.status-LOCKED      { background: #334155 !important; color: #f8fafc !important; }
.status-ARCHIVED    { background: #6b7280 !important; color: #fff !important; }

/* ─── EPRF editor — save status bar ─────────────────────────────────────────── */

.eprf-save-bar {
  position: sticky;
  top: 0;
  z-index: 200;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.35rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8rem;
  min-height: 36px;
}

.eprf-save-bar .save-indicator {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  transition: color 0.2s;
}

.eprf-save-bar.state-saving  .save-indicator { color: #f59e0b; }
.eprf-save-bar.state-saved   .save-indicator { color: #22c55e; }
.eprf-save-bar.state-failed  .save-indicator { color: #ef4444; }
.eprf-save-bar.state-local   .save-indicator { color: #8b5cf6; }

.eprf-save-bar .save-spinner {
  display: none;
  width: 12px; height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.eprf-save-bar.state-saving .save-spinner { display: inline-block; }

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

/* ─── EPRF editor — tab completion dots ──────────────────────────────────────── */

.eprf-tab-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-left: 5px;
  vertical-align: middle;
  flex-shrink: 0;
  background: #cbd5e1;
  transition: background 0.2s;
}

.eprf-tab-dot.dot-partial  { background: #f59e0b; }
.eprf-tab-dot.dot-complete { background: #22c55e; }

.eprf-tab-lock {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #ef4444;
  margin-left: 3px;
  vertical-align: middle;
  animation: lock-pulse 1.5s ease-in-out infinite;
}

@keyframes lock-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ─── EPRF — Co-editors presence bar ────────────────────────────────────────── */

.eprf-coeditors-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  font-size: .8rem;
}

.coeditors-label {
  color: #6c757d;
  font-weight: 500;
  margin-right: 4px;
}

.coeditor-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px 3px 6px;
  border-radius: 20px;
  border: 1.5px solid var(--chip-color, #6c757d);
  background: color-mix(in srgb, var(--chip-color, #6c757d) 10%, transparent);
  color: #212529;
  font-size: .8rem;
}

.coeditor-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  animation: presence-pulse 2s ease-in-out infinite;
}

.coeditor-section {
  color: #6c757d;
  font-weight: 400;
  margin-left: 2px;
}

@keyframes presence-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* ─── EPRF — Section lock banner ─────────────────────────────────────────────── */

.eprf-lock-banner {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  margin-bottom: 16px;
  border-radius: 6px;
  background: #fff3cd;
  border: 1px solid #ffc107;
  color: #664d03;
  font-size: .85rem;
}

.eprf-lock-banner i { color: #e67e22; font-size: 1rem; }

/* ─── EPRF — Section attribution badge ───────────────────────────────────────── */

.eprf-section-attr {
  display: inline-flex;
  align-items: center;
  font-size: .72rem;
  color: #6c757d;
  margin-bottom: 12px;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 4px;
  padding: 2px 8px;
}

.nav-tabs .nav-link {
  display: flex;
  align-items: center;
  gap: 0;
  white-space: nowrap;
  font-size: 0.82rem;
  padding: 0.45rem 0.85rem;
}

/* Scrollable tab bar on mobile */
.eprf-tabs-wrapper {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.eprf-tabs-wrapper::-webkit-scrollbar { display: none; }
.eprf-tabs-wrapper .nav-tabs {
  flex-wrap: nowrap;
  min-width: max-content;
  border-bottom: 2px solid #dee2e6;
}

/* ─── EPRF — GCS group ───────────────────────────────────────────────────────── */

.gcs-group {
  background: #f8fafc;
  border-color: #e2e8f0 !important;
}

.gcs-group .form-select {
  font-size: 0.78rem;
}

/* ─── EPRF — Incident opened stamp ──────────────────────────────────────────── */

.incident-opened-stamp {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 3px solid #64748b;
  border-radius: 0.375rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  color: #475569;
}

.incident-opened-at {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: #64748b;
  font-size: 0.8rem;
}

/* ─── EPRF editor — submitted management banner ──────────────────────────────── */

.eprf-submitted-banner {
  background: #eff6ff;
  border: 1px solid #3b82f6;
  color: #1e3a8a;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

/* ─── EPRF — section nav ─────────────────────────────────────────────────────── */

.eprf-section-nav {
  position: sticky;
  top: -1px;
  z-index: 100;
  background: var(--body-bg);
  padding: 0.4rem 0;
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  border-bottom: 1px solid #e2e8f0;
}

.eprf-section-nav a {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.2rem 0.6rem;
  border-radius: 0.3rem;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
}

.eprf-section-nav a:hover {
  background: #fff;
  color: #111827;
  border-color: #d1d5db;
}

.eprf-section-target { scroll-margin-top: 52px; }

/* ─── EPRF — banners ─────────────────────────────────────────────────────────── */

.eprf-safeguarding-banner {
  background: #fef2f2;
  border: 2px solid #ef4444;
  color: #b91c1c;
  border-radius: 0.5rem;
  padding: 0.6rem 1rem;
  font-size: 0.875rem;
}

.eprf-locked-banner {
  background: #fefce8;
  border: 1px solid #f59e0b;
  color: #78350f;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

/* ─── EPRF — Observations ABCDE form ────────────────────────────────────────── */

.obs-form-panel {
  background: #f8fafc;
  padding: 1.25rem;
}

.obs-section-group {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
}

.obs-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.obs-label-a { color: #3b82f6; }
.obs-label-c { color: #ef4444; }
.obs-label-d { color: #8b5cf6; }
.obs-label-e { color: #f59e0b; }

/* Larger touch targets for obs inputs on mobile */
.obs-input,
.obs-select {
  font-size: 1rem !important;
  min-height: 2.5rem !important;
  padding: 0.4rem 0.6rem !important;
}

@media (min-width: 768px) {
  .obs-input,
  .obs-select {
    font-size: 0.875rem !important;
    min-height: unset !important;
    padding: 0.25rem 0.5rem !important;
  }
}

/* ─── EPRF — NEWS2 / PEWS scoring ───────────────────────────────────────────── */

.obs-score-preview {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.375rem;
  padding: 0.6rem 0.9rem;
}

/* Severity badge variants */
.obs-score-badge-empty  { background: #94a3b8 !important; color: #fff !important; }
.obs-score-badge-ok     { background: #22c55e !important; color: #fff !important; }
.obs-score-badge-low    { background: #38bdf8 !important; color: #0c4a6e !important; }
.obs-score-badge-med    { background: #f59e0b !important; color: #1c1917 !important; }
.obs-score-badge-high   { background: #ef4444 !important; color: #fff !important; }

.obs-score-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 0.55rem 0.75rem;
  min-width: 140px;
}

.obs-score-card-latest {
  background: #eff6ff;
  border-color: #93c5fd;
}

.obs-score-card-time {
  font-size: 0.72rem;
  font-weight: 600;
  color: #475569;
}

/* ─── EPRF — Complaint selector display chip ─────────────────────────────────── */

.complaint-display-chip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 0.375rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  color: #166534;
  gap: 0.25rem;
}

/* ─── EPRF — Complaint list picker ──────────────────────────────────────────── */

.complaint-list-box {
  border: 1px solid #e2e8f0;
  border-radius: 0.375rem;
  max-height: 320px;
  overflow-y: auto;
  background: #fff;
}

.complaint-list-placeholder {
  padding: 1rem;
}

.complaint-list-group-label {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.3rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
}

.complaint-list-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid #f1f5f9;
  padding: 0.45rem 0.75rem;
  font-size: 0.83rem;
  color: #1e293b;
  cursor: pointer;
  transition: background 0.1s;
}

.complaint-list-item:hover {
  background: #eff6ff;
  color: #1d4ed8;
}

.complaint-list-item mark {
  background: #fef08a;
  color: inherit;
  padding: 0;
}

/* ─── EPRF — CAVPU toggle buttons ───────────────────────────────────────────── */

.obs-cavpu-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  border-radius: 0.375rem;
  padding: 0.3rem 0.6rem;
  border: 1.5px solid #e2e8f0;
  background: #f8fafc;
  transition: border-color 0.12s, background 0.12s;
  user-select: none;
}

.obs-cavpu-btn:hover { border-color: #94a3b8; background: #f1f5f9; }

.obs-cavpu-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 0.25rem;
  font-weight: 800;
  font-size: 0.8rem;
  font-family: var(--bs-font-monospace);
  color: #fff;
  flex-shrink: 0;
}

.obs-cavpu-c { background: #dc2626; }
.obs-cavpu-a { background: #16a34a; }
.obs-cavpu-v { background: #2563eb; }
.obs-cavpu-p { background: #d97706; }
.obs-cavpu-u { background: #7c3aed; }

.obs-cavpu-desc { font-size: 0.72rem; color: #64748b; font-weight: 500; }

.obs-cavpu-btn:has(.obs-cavpu-radio:checked) { background: #f0f9ff; }
.obs-cavpu-btn:has(input[value="C"]:checked) { border-color: #dc2626; background: #fef2f2; }
.obs-cavpu-btn:has(input[value="A"]:checked) { border-color: #16a34a; background: #f0fdf4; }
.obs-cavpu-btn:has(input[value="V"]:checked) { border-color: #2563eb; background: #eff6ff; }
.obs-cavpu-btn:has(input[value="P"]:checked) { border-color: #d97706; background: #fffbeb; }
.obs-cavpu-btn:has(input[value="U"]:checked) { border-color: #7c3aed; background: #f5f3ff; }

/* CAVPU badge in obs table */
.obs-cavpu-badge-c { background-color: #dc2626 !important; color: #fff !important; }
.obs-cavpu-badge-a { background-color: #16a34a !important; color: #fff !important; }
.obs-cavpu-badge-v { background-color: #2563eb !important; color: #fff !important; }
.obs-cavpu-badge-p { background-color: #d97706 !important; color: #fff !important; }
.obs-cavpu-badge-u { background-color: #7c3aed !important; color: #fff !important; }

/* ─── EPRF — Pupils grid ──────────────────────────────────────────────────────── */

.obs-pupils-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
  align-items: start;
}

@media (max-width: 575px) {
  .obs-pupils-grid { grid-template-columns: 1fr; }
}

.obs-pupils-side-block {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.obs-pupils-eye-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: #1e293b;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 1.6rem;
}

/* ─── EPRF — Completion progress bar ────────────────────────────────────────── */

.eprf-completion-track {
  height: 6px;
  width: 80px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}

.eprf-completion-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease, background 0.3s ease;
}

/* ─── EPRF — Clinical concern flag checkboxes ────────────────────────────────── */

.form-check-concern {
  padding: 0.3rem 0.5rem;
  border-radius: 0.375rem;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.form-check-concern .form-check-input { margin: 0; flex-shrink: 0; cursor: pointer; }
.concern-label { font-size: 0.8rem; margin: 0; cursor: pointer; line-height: 1.3; }
.concern-label.concern-danger  { color: #dc2626; }
.concern-label.concern-warning { color: #d97706; }

/* Obs-label-flags — red tint */
.obs-label-flags { color: #dc2626; }

/* ─── EPRF — Obs row clinical concern flag badges ────────────────────────────── */

.obs-flag-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.12em 0.45em;
  border-radius: 0.25rem;
  line-height: 1.5;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.obs-flag-danger  { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.obs-flag-warning { background: #fffbeb; color: #92400e; border: 1px solid #fcd34d; }
.obs-flag-muted   { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }

/* ─── EPRF — NEWS2 component score breakdown ─────────────────────────────────── */

.vital-score-breakdown { margin-top: 0.4rem; }

.vital-score-comps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.vital-score-comp {
  font-size: 0.68rem;
  padding: 0.1em 0.45em;
  border-radius: 0.25rem;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  white-space: nowrap;
}

.vital-score-comp.comp-abnormal {
  background: #fff7ed;
  color: #c2410c;
  border-color: #fed7aa;
}

.vital-score-comp strong { color: inherit; font-weight: 700; }

/* ─── Print (EPRF) ───────────────────────────────────────────────────────────── */

@media print {
  .sidebar, .topbar, .btn, form { display: none !important; }
  .main-content { overflow: visible; }
  .page-content { padding: 0; }
  .card { break-inside: avoid; }
}

/* ─── Dark mode overrides ─────────────────────────────────────────────────────
   Bootstrap 5.3 handles native components via data-bs-theme="dark" out of the
   box (cards, dropdowns, modals, form controls, etc.). The block below covers
   custom-styled surfaces that aren't tied to Bootstrap variables. */

[data-bs-theme="dark"] {
  --bs-body-bg: #0f172a;
  --bs-body-color: #e2e8f0;
  --bs-secondary-color: rgba(226, 232, 240, 0.6);
  --bs-tertiary-color: rgba(226, 232, 240, 0.4);
  --bs-border-color: #1e293b;
  --bs-tertiary-bg: #1e293b;
  --bs-secondary-bg: #1e293b;

  /* Mirror of :root tokens — same names, dark values. New components
     should reference these (var(--surface), var(--text), …) and pick
     up dark mode automatically without bespoke selectors. */
  --bg:              #0f172a;
  --surface:         #111827;
  --surface-muted:   #1e293b;
  --surface-raised:  #1e293b;
  --text:            #e2e8f0;
  --text-strong:     #f8fafc;
  --text-muted:      rgba(226, 232, 240, 0.62);
  --border:          #1e293b;
  --border-muted:    #1e293b;
  --primary:         #3b82f6;
  --primary-hover:   #2563eb;
  --danger:          #ef4444;
  --warning:         #f59e0b;
  --success:         #22c55e;
  --info:            #38bdf8;
  --input-bg:        #0b1220;
  --input-text:      #e2e8f0;
  --input-border:    #334155;
  --input-placeholder: rgba(226, 232, 240, 0.35);
  --table-header:    #1e293b;
  --table-border:    #1e293b;
  --table-hover:     rgba(255, 255, 255, 0.035);
  --modal-bg:        #0f172a;
  --link:            #93c5fd;
  --focus-ring:      rgba(59, 130, 246, 0.35);
}

/* Layout shell */
[data-bs-theme="dark"] body.app-body          { background: #0f172a; color: #e2e8f0; }
[data-bs-theme="dark"] .main-content          { background: #0f172a; }
[data-bs-theme="dark"] .page-content          { background: transparent; }

/* Sidebar */
[data-bs-theme="dark"] .sidebar               { background: #0b1220; border-right: 1px solid #1e293b; }
[data-bs-theme="dark"] .sidebar .nav-link     { color: rgba(226, 232, 240, 0.78); }
[data-bs-theme="dark"] .sidebar .nav-link:hover,
[data-bs-theme="dark"] .sidebar .nav-link.active { background: #1e293b; color: #fff; }
[data-bs-theme="dark"] .sidebar-section-label { color: rgba(226, 232, 240, 0.45); }
[data-bs-theme="dark"] .sidebar-user          { border-top: 1px solid #1e293b; }

/* Topbar */
[data-bs-theme="dark"] .topbar                { background: #0b1220; border-bottom: 1px solid #1e293b; }
[data-bs-theme="dark"] .topbar a,
[data-bs-theme="dark"] .topbar .breadcrumb-item { color: rgba(226, 232, 240, 0.85); }

/* Cards + headers */
[data-bs-theme="dark"] .card                  { background: #111827; border-color: #1e293b; color: #e2e8f0; }
[data-bs-theme="dark"] .card-header.bg-white  { background: #0f172a !important; border-color: #1e293b; color: #e2e8f0; }
[data-bs-theme="dark"] .card-footer.bg-white  { background: #0f172a !important; border-color: #1e293b; }
[data-bs-theme="dark"] .border-bottom         { border-color: #1e293b !important; }

/* Tables */
[data-bs-theme="dark"] .table                 { --bs-table-bg: transparent; color: #e2e8f0; }
[data-bs-theme="dark"] .table-light,
[data-bs-theme="dark"] .table > thead         { --bs-table-bg: #1e293b; color: #e2e8f0; }
[data-bs-theme="dark"] .table-hover > tbody > tr:hover { --bs-table-hover-bg: rgba(255, 255, 255, 0.04); color: inherit; }
[data-bs-theme="dark"] .table-row-active      { background: rgba(59, 130, 246, 0.08); }

/* Forms */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select           { background: #0b1220; border-color: #1e293b; color: #e2e8f0; }
[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus     { background: #0b1220; border-color: #2563eb; color: #fff; box-shadow: 0 0 0 0.15rem rgba(37, 99, 235, 0.25); }
[data-bs-theme="dark"] .form-control::placeholder { color: rgba(226, 232, 240, 0.35); }
[data-bs-theme="dark"] .form-text             { color: rgba(226, 232, 240, 0.6); }
[data-bs-theme="dark"] .form-label            { color: rgba(226, 232, 240, 0.9); }

/* Buttons */
[data-bs-theme="dark"] .btn-outline-secondary { color: #cbd5e1; border-color: #334155; }
[data-bs-theme="dark"] .btn-outline-secondary:hover { background: #1e293b; border-color: #475569; color: #fff; }
[data-bs-theme="dark"] .btn-link              { color: #93c5fd; }
[data-bs-theme="dark"] .btn-close             { filter: invert(1) grayscale(1) brightness(1.5); }

/* Alerts + bg-* utilities */
[data-bs-theme="dark"] .alert-light,
[data-bs-theme="dark"] .alert.bg-light        { background: #1e293b !important; color: #e2e8f0 !important; }
[data-bs-theme="dark"] .alert-warning         { background: #422006; color: #fde68a; border-color: #92400e; }
[data-bs-theme="dark"] .alert-info            { background: #082f49; color: #bae6fd; border-color: #0c4a6e; }
[data-bs-theme="dark"] .alert-danger          { background: #450a0a; color: #fecaca; border-color: #991b1b; }
[data-bs-theme="dark"] .alert-success         { background: #052e16; color: #bbf7d0; border-color: #166534; }
[data-bs-theme="dark"] .text-muted            { color: rgba(226, 232, 240, 0.55) !important; }
[data-bs-theme="dark"] .text-body             { color: #e2e8f0; }
[data-bs-theme="dark"] .bg-white              { background: #111827 !important; color: #e2e8f0; }
[data-bs-theme="dark"] .bg-light              { background: #1e293b !important; color: #e2e8f0; }
[data-bs-theme="dark"] code                   { background: #1e293b; color: #fde68a; }

/* CAD control room */
[data-bs-theme="dark"] .cad-cr__panel         { background: #111827; border-color: #1e293b; }
[data-bs-theme="dark"] .cad-cr__panel-header  { background: #0b1220; border-color: #1e293b; color: #e2e8f0; }
[data-bs-theme="dark"] .cad-cr__empty         { color: #64748b; }
[data-bs-theme="dark"] .cad-res-card,
[data-bs-theme="dark"] .cad-call-card         { background: #1e293b; border-color: #334155; color: #e2e8f0; }
[data-bs-theme="dark"] .cad-res-card.selected,
[data-bs-theme="dark"] .cad-call-card.selected { border-color: #3b82f6; }
[data-bs-theme="dark"] .cad-call-card.drop-target,
[data-bs-theme="dark"] .cad-res-card.drop-target { background: #064e3b; border-color: #10b981; }
[data-bs-theme="dark"] .cad-res-card__type    { color: #94a3b8; }
[data-bs-theme="dark"] .cad-res-card__staff   { color: #cbd5e1; }
[data-bs-theme="dark"] .cad-call-card__meta   { color: #94a3b8; }
[data-bs-theme="dark"] .cad-call-card__resources .res-chip { background: #1e3a8a; color: #bfdbfe; }

/* Resource status chips — keep colour cues, lower brightness */
[data-bs-theme="dark"] .cad-res-status-AVAILABLE      { background: #064e3b; color: #bbf7d0; }
[data-bs-theme="dark"] .cad-res-status-ASSIGNED       { background: #1e3a8a; color: #bfdbfe; }
[data-bs-theme="dark"] .cad-res-status-MOBILE         { background: #312e81; color: #c7d2fe; }
[data-bs-theme="dark"] .cad-res-status-ON_SCENE       { background: #4c1d95; color: #ddd6fe; }
[data-bs-theme="dark"] .cad-res-status-AT_PATIENT     { background: #831843; color: #fbcfe8; }
[data-bs-theme="dark"] .cad-res-status-CONVEYING      { background: #78350f; color: #fde68a; }
[data-bs-theme="dark"] .cad-res-status-AT_DESTINATION { background: #7c2d12; color: #fed7aa; }
[data-bs-theme="dark"] .cad-res-status-CLEAR          { background: #334155; color: #cbd5e1; }
[data-bs-theme="dark"] .cad-res-status-UNAVAILABLE    { background: #7f1d1d; color: #fecaca; }
[data-bs-theme="dark"] .cad-res-status-OFF_DUTY       { background: #1e293b; color: #94a3b8; }

/* Status badges — tone the muted ones for legibility */
[data-bs-theme="dark"] .status-PRE_DEPLOYMENT { background: #334155 !important; color: #cbd5e1 !important; }
[data-bs-theme="dark"] .status-TEAM_ACTIVATED { background: #1e3a8a !important; color: #bfdbfe !important; }
[data-bs-theme="dark"] .status-STAND_DOWN     { background: #78350f !important; color: #fde68a !important; }
[data-bs-theme="dark"] .status-REJECTED       { background: #7f1d1d !important; color: #fecaca !important; }
/* FOR_RESPONSE, TEAM_MOBILISED, TEAM_ARRIVED, CLEARED_MISSION,
   MISSION_COMPLETE already use dark backgrounds with white text — they
   work as-is in dark mode. */

[data-bs-theme="dark"] .status-PLANNED,
[data-bs-theme="dark"] .status-RECEIVED       { background: #334155 !important; color: #cbd5e1 !important; }
[data-bs-theme="dark"] .status-CLEAR,
[data-bs-theme="dark"] .status-DECOMMISSIONED,
[data-bs-theme="dark"] .status-LEFT,
[data-bs-theme="dark"] .status-DRAFT          { background: #1e293b !important; color: #94a3b8 !important; }
[data-bs-theme="dark"] .status-PENDING_DISPATCH { background: #422006 !important; color: #fde68a !important; }
[data-bs-theme="dark"] .status-ASSIGNED       { background: #1e3a8a !important; color: #bfdbfe !important; }
[data-bs-theme="dark"] .status-AT_PATIENT     { background: #064e3b !important; color: #bbf7d0 !important; }

/* Empty states + detail-list */
[data-bs-theme="dark"] .empty-state           { color: #64748b; }
[data-bs-theme="dark"] .empty-state i         { color: #475569; }
[data-bs-theme="dark"] .detail-list dt        { color: rgba(226, 232, 240, 0.55); }
[data-bs-theme="dark"] .detail-list dd        { color: #e2e8f0; }

/* Modals */
[data-bs-theme="dark"] .modal-content         { background: #0f172a; color: #e2e8f0; border: 1px solid #1e293b; }
[data-bs-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-footer          { border-color: #1e293b; }

/* Leaflet — attribution + popups */
[data-bs-theme="dark"] .leaflet-control-attribution,
[data-bs-theme="dark"] .leaflet-control-layers { background: rgba(15, 23, 42, 0.85) !important; color: #e2e8f0 !important; }
[data-bs-theme="dark"] .leaflet-control-attribution a { color: #93c5fd !important; }
[data-bs-theme="dark"] .leaflet-popup-content-wrapper { background: #0f172a; color: #e2e8f0; }
[data-bs-theme="dark"] .leaflet-popup-tip     { background: #0f172a; }

/* Filter card + text utilities */
[data-bs-theme="dark"] .filter-card           { background: #111827 !important; border-color: #1e293b; }
[data-bs-theme="dark"] .text-white            { color: #e2e8f0 !important; }
[data-bs-theme="dark"] .text-white-50         { color: rgba(226, 232, 240, 0.5) !important; }

/* Onboarding review sub-panels — referee cards, link previews. */
.onboarding-subpanel { background: #f8f9fa; border: 1px solid #dee2e6; }
[data-bs-theme="dark"] .onboarding-subpanel { background: #1e293b !important; border-color: #334155 !important; color: #e2e8f0; }

/* Badge variants used as inline status chips throughout the app —
   these were unreadable in dark mode until now. */
[data-bs-theme="dark"] .badge.bg-light        { background: #334155 !important; color: #e2e8f0 !important; border-color: #475569 !important; }
[data-bs-theme="dark"] .badge.bg-light.text-dark,
[data-bs-theme="dark"] .badge.bg-light.text-body { color: #e2e8f0 !important; }
[data-bs-theme="dark"] .badge.bg-success-subtle  { background: #052e16 !important; color: #bbf7d0 !important; border-color: #166534 !important; }
[data-bs-theme="dark"] .badge.bg-danger-subtle   { background: #450a0a !important; color: #fecaca !important; border-color: #991b1b !important; }
[data-bs-theme="dark"] .badge.bg-warning-subtle  { background: #422006 !important; color: #fde68a !important; border-color: #92400e !important; }
[data-bs-theme="dark"] .badge.bg-info-subtle     { background: #082f49 !important; color: #bae6fd !important; border-color: #0c4a6e !important; }
[data-bs-theme="dark"] .badge.bg-secondary-subtle { background: #1e293b !important; color: #cbd5e1 !important; border-color: #334155 !important; }
[data-bs-theme="dark"] .badge.bg-primary-subtle  { background: #1e3a8a !important; color: #bfdbfe !important; border-color: #2563eb !important; }

/* Text-emphasis variants used with the -subtle badges. */
[data-bs-theme="dark"] .text-success-emphasis   { color: #bbf7d0 !important; }
[data-bs-theme="dark"] .text-danger-emphasis    { color: #fecaca !important; }
[data-bs-theme="dark"] .text-warning-emphasis   { color: #fde68a !important; }
[data-bs-theme="dark"] .text-info-emphasis      { color: #bae6fd !important; }
[data-bs-theme="dark"] .text-secondary-emphasis { color: #cbd5e1 !important; }

/* ─── Dark mode — gap-fill pass ──────────────────────────────────────────────
   Everything below was added in the cross-app dark-mode review. Each block
   targets a component that previously had no dark-mode rule. Grouped by
   area for navigation. */

/* Login / auth / error pages.
   These use body.login-body, not body.app-body, so the existing app-shell
   override above doesn't reach them. */
[data-bs-theme="dark"] body.login-body            { background: #0f172a; color: #e2e8f0; }
[data-bs-theme="dark"] .login-card                { background: #111827; border-color: #1e293b !important; }
[data-bs-theme="dark"] .login-logo                { background: #1e293b; border-color: rgba(239, 68, 68, 0.35); }
[data-bs-theme="dark"] .error-page                { color: #e2e8f0; }
[data-bs-theme="dark"] .error-page .display-1.text-muted { color: rgba(226, 232, 240, 0.35) !important; }
[data-bs-theme="dark"] .input-group-text          { background: #1e293b; border-color: #334155; color: #cbd5e1; }

/* Page header + stat cards. Both hardcoded slate-900 in light mode. */
[data-bs-theme="dark"] .page-header h4            { color: #f8fafc; }
[data-bs-theme="dark"] .stat-value                { color: #f8fafc; }
[data-bs-theme="dark"] .stat-card                 { border-color: #1e293b !important; }
[data-bs-theme="dark"] .breadcrumb-item a:hover   { color: #f8fafc; }
[data-bs-theme="dark"] .breadcrumb-item.active    { color: rgba(226, 232, 240, 0.7); }

/* Nav tabs — active label loses contrast with default #111827. */
[data-bs-theme="dark"] .nav-tabs                  { border-bottom-color: #1e293b; }
[data-bs-theme="dark"] .nav-tabs .nav-link        { color: rgba(226, 232, 240, 0.6); border-color: transparent; }
[data-bs-theme="dark"] .nav-tabs .nav-link:hover  { border-color: #334155 #334155 transparent; color: #e2e8f0; }
[data-bs-theme="dark"] .nav-tabs .nav-link.active { color: #f8fafc; background: #111827; border-color: #334155 #334155 #111827; }

/* Tables — borders defaulted to #f1f5f9 / #f8fafc which are invisible on dark. */
[data-bs-theme="dark"] .table > thead             { background: #1e293b; }
[data-bs-theme="dark"] .table th                  { background: #1e293b; color: rgba(226, 232, 240, 0.7); border-bottom-color: #334155 !important; }
[data-bs-theme="dark"] .table tbody tr            { border-bottom-color: #1e293b; }
[data-bs-theme="dark"] .table-hover tbody tr:hover { background: rgba(255, 255, 255, 0.035) !important; }
[data-bs-theme="dark"] .table-row-active          { background: rgba(59, 130, 246, 0.10); }
[data-bs-theme="dark"] .empty-state               { color: rgba(226, 232, 240, 0.45); }
[data-bs-theme="dark"] .empty-state i             { color: rgba(226, 232, 240, 0.25); }

/* Scrollbars on the main content pane — invisible grey thumb on dark bg. */
[data-bs-theme="dark"] .page-content::-webkit-scrollbar-thumb { background: #334155; }
[data-bs-theme="dark"] .sidebar::-webkit-scrollbar-thumb       { background: rgba(255,255,255,0.10); }

/* Form-label + form-text + input focus. Already partly covered above —
   adding the validation feedback colours and disabled state. */
[data-bs-theme="dark"] .form-control:disabled,
[data-bs-theme="dark"] .form-select:disabled,
[data-bs-theme="dark"] .form-control[readonly]    { background: #1e293b; color: rgba(226, 232, 240, 0.55); border-color: #334155; }
[data-bs-theme="dark"] .form-check-input          { background-color: #0b1220; border-color: #475569; }
[data-bs-theme="dark"] .form-check-input:checked  { background-color: #2563eb; border-color: #2563eb; }
[data-bs-theme="dark"] .form-check-label          { color: #e2e8f0; }
[data-bs-theme="dark"] .invalid-feedback          { color: #fca5a5; }
[data-bs-theme="dark"] .valid-feedback            { color: #86efac; }
[data-bs-theme="dark"] .form-control.is-invalid,
[data-bs-theme="dark"] .form-select.is-invalid    { border-color: #ef4444; }
[data-bs-theme="dark"] .form-control.is-valid,
[data-bs-theme="dark"] .form-select.is-valid      { border-color: #22c55e; }
/* Date / time / native pickers — the calendar indicator is invisible on
   dark inputs by default. Filter inverts it without flipping the input
   colour itself. */
[data-bs-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
[data-bs-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator,
[data-bs-theme="dark"] input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(0.85);
}

/* Dropdowns + menus — Bootstrap's dark theme already handles these, but
   custom menu items occasionally drift. Pin the surface to --surface. */
[data-bs-theme="dark"] .dropdown-menu             { background: #111827; border-color: #334155; }
[data-bs-theme="dark"] .dropdown-item             { color: #e2e8f0; }
[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus       { background: #1e293b; color: #fff; }
[data-bs-theme="dark"] .dropdown-divider          { border-top-color: #334155; }

/* Inline ".bg-light"-styled subpanels used as inner cards/borders.
   Bootstrap's own `.bg-light` dark override above flips the bg, but
   borders defaulting to bs-border-color need explicit handling for
   any element with both bg-light AND a hardcoded light border. */
[data-bs-theme="dark"] .border                    { border-color: #334155 !important; }
[data-bs-theme="dark"] .border-light              { border-color: #334155 !important; }

/* ─── CAD timeline stamps ───────────────────────────────────────────────── */
[data-bs-theme="dark"] .cad-stamp                 { border-color: #334155; background: #1e293b; }
[data-bs-theme="dark"] .stamp-done                { background: #052e16; border-color: #166534; }
[data-bs-theme="dark"] .stamp-pending             { background: #1e293b; border-color: #334155; }
[data-bs-theme="dark"] .stamp-label               { color: rgba(226, 232, 240, 0.6); }
[data-bs-theme="dark"] .stamp-time                { color: #f8fafc; }
[data-bs-theme="dark"] .stamp-pending .stamp-time { color: rgba(226, 232, 240, 0.35); }
[data-bs-theme="dark"] .stamp-done .stamp-label,
[data-bs-theme="dark"] .stamp-done .stamp-time    { color: #bbf7d0; }

/* CAD flag banners — pastel backgrounds need darker tints for legibility. */
[data-bs-theme="dark"] .cad-flag-red              { background: #450a0a; color: #fecaca; }
[data-bs-theme="dark"] .cad-flag-orange           { background: #431407; color: #fed7aa; }
[data-bs-theme="dark"] .cad-flag-yellow           { background: #422006; color: #fde68a; }
[data-bs-theme="dark"] .cad-flag-blue             { background: #172554; color: #bfdbfe; }
[data-bs-theme="dark"] .cad-flag-purple           { background: #2e1065; color: #ddd6fe; }

/* Status badges — fill in the variants the existing block missed. */
[data-bs-theme="dark"] .status-CONFIRMED,
[data-bs-theme="dark"] .status-MOBILE             { background: #1e3a8a !important; color: #bfdbfe !important; }
[data-bs-theme="dark"] .status-ACTIVE,
[data-bs-theme="dark"] .status-AVAILABLE,
[data-bs-theme="dark"] .status-COMPLETED,
[data-bs-theme="dark"] .status-PATIENT_CONTACT    { background: #052e16 !important; color: #bbf7d0 !important; }
[data-bs-theme="dark"] .status-DISPATCHED,
[data-bs-theme="dark"] .status-MAINTENANCE        { background: #422006 !important; color: #fde68a !important; }
[data-bs-theme="dark"] .status-DEFECT,
[data-bs-theme="dark"] .status-CANCELLED,
[data-bs-theme="dark"] .status-DEPART_SCENE,
[data-bs-theme="dark"] .status-INACTIVE,
[data-bs-theme="dark"] .status-SUSPENDED          { background: #450a0a !important; color: #fecaca !important; }
[data-bs-theme="dark"] .status-DEPLOYED,
[data-bs-theme="dark"] .status-ON_SCENE,
[data-bs-theme="dark"] .status-ARRIVE_DESTINATION { background: #2e1065 !important; color: #ddd6fe !important; }
[data-bs-theme="dark"] .status-EXPORTED           { background: #1e3a8a !important; color: #bfdbfe !important; }
[data-bs-theme="dark"] .status-IN_PROGRESS        { background: #422006 !important; color: #fde68a !important; }
[data-bs-theme="dark"] .status-SUBMITTED          { background: #1e3a8a !important; color: #bfdbfe !important; }

/* ─── EPRF / observations / clinical surfaces ───────────────────────────── */
[data-bs-theme="dark"] .eprf-save-bar             { background: #0b1220; border-bottom-color: #1e293b; color: #e2e8f0; }
[data-bs-theme="dark"] .eprf-save-bar .save-indicator { color: rgba(226, 232, 240, 0.6); }
[data-bs-theme="dark"] .eprf-coeditors-bar        { background: #0b1220; border-bottom-color: #1e293b; }
[data-bs-theme="dark"] .coeditors-label,
[data-bs-theme="dark"] .coeditor-section          { color: rgba(226, 232, 240, 0.55); }
[data-bs-theme="dark"] .coeditor-chip             { color: #e2e8f0; }
[data-bs-theme="dark"] .eprf-section-attr        { background: #1e293b; border-color: #334155; color: rgba(226, 232, 240, 0.6); }
[data-bs-theme="dark"] .eprf-tabs-wrapper .nav-tabs { border-bottom-color: #334155; }

/* Banners */
[data-bs-theme="dark"] .eprf-lock-banner          { background: #422006; border-color: #92400e; color: #fde68a; }
[data-bs-theme="dark"] .eprf-lock-banner i        { color: #fb923c; }
[data-bs-theme="dark"] .eprf-locked-banner        { background: #422006; border-color: #f59e0b; color: #fde68a; }
[data-bs-theme="dark"] .eprf-submitted-banner     { background: #172554; border-color: #2563eb; color: #bfdbfe; }
[data-bs-theme="dark"] .eprf-safeguarding-banner  { background: #450a0a; border-color: #ef4444; color: #fecaca; }

/* Section nav (sticky tab strip below page header) */
[data-bs-theme="dark"] .eprf-section-nav          { background: #0f172a; border-bottom-color: #1e293b; }
[data-bs-theme="dark"] .eprf-section-nav a        { color: rgba(226, 232, 240, 0.7); }
[data-bs-theme="dark"] .eprf-section-nav a:hover  { background: #1e293b; border-color: #334155; color: #f8fafc; }

/* Observations / ABCDE panels */
[data-bs-theme="dark"] .obs-form-panel            { background: #0b1220; }
[data-bs-theme="dark"] .obs-section-group         { background: #111827; border-color: #1e293b; }
[data-bs-theme="dark"] .obs-section-label         { color: rgba(226, 232, 240, 0.6); }
[data-bs-theme="dark"] .obs-score-preview         { background: #111827; border-color: #1e293b; }
[data-bs-theme="dark"] .obs-score-card            { background: #111827; border-color: #1e293b; }
[data-bs-theme="dark"] .obs-score-card-latest     { background: #172554; border-color: #2563eb; }
[data-bs-theme="dark"] .obs-score-card-time       { color: rgba(226, 232, 240, 0.65); }

/* CAVPU buttons + selected states */
[data-bs-theme="dark"] .obs-cavpu-btn             { background: #111827; border-color: #334155; color: #e2e8f0; }
[data-bs-theme="dark"] .obs-cavpu-btn:hover       { background: #1e293b; border-color: #475569; }
[data-bs-theme="dark"] .obs-cavpu-desc            { color: rgba(226, 232, 240, 0.6); }
[data-bs-theme="dark"] .obs-cavpu-btn:has(input[value="C"]:checked) { background: #450a0a; border-color: #ef4444; }
[data-bs-theme="dark"] .obs-cavpu-btn:has(input[value="A"]:checked) { background: #052e16; border-color: #22c55e; }
[data-bs-theme="dark"] .obs-cavpu-btn:has(input[value="V"]:checked) { background: #172554; border-color: #3b82f6; }
[data-bs-theme="dark"] .obs-cavpu-btn:has(input[value="P"]:checked) { background: #431407; border-color: #f59e0b; }
[data-bs-theme="dark"] .obs-cavpu-btn:has(input[value="U"]:checked) { background: #2e1065; border-color: #8b5cf6; }

/* Pupils */
[data-bs-theme="dark"] .obs-pupils-eye-label      { background: #334155; color: #f8fafc; }

/* Complaint picker */
[data-bs-theme="dark"] .complaint-list-box        { background: #111827; border-color: #1e293b; }
[data-bs-theme="dark"] .complaint-list-group-label { background: #1e293b; border-bottom-color: #334155; color: rgba(226, 232, 240, 0.65); }
[data-bs-theme="dark"] .complaint-list-item       { background: transparent; color: #e2e8f0; border-bottom-color: #1e293b; }
[data-bs-theme="dark"] .complaint-list-item:hover { background: #172554; color: #bfdbfe; }
[data-bs-theme="dark"] .complaint-list-item mark  { background: #422006; color: #fde68a; }
[data-bs-theme="dark"] .complaint-display-chip    { background: #052e16; border-color: #166534; color: #bbf7d0; }

/* GCS group + incident-opened stamp + concern checkboxes */
[data-bs-theme="dark"] .gcs-group                 { background: #111827 !important; border-color: #1e293b !important; }
[data-bs-theme="dark"] .incident-opened-stamp     { background: #111827; border-color: #1e293b; border-left-color: #475569; color: rgba(226, 232, 240, 0.78); }
[data-bs-theme="dark"] .incident-opened-at        { color: rgba(226, 232, 240, 0.55); }
[data-bs-theme="dark"] .form-check-concern        { background: #111827; border-color: #1e293b; }
[data-bs-theme="dark"] .form-check-concern:hover  { background: #1e293b; border-color: #334155; }
[data-bs-theme="dark"] .concern-label             { color: #e2e8f0; }
[data-bs-theme="dark"] .concern-label.concern-danger  { color: #fca5a5; }
[data-bs-theme="dark"] .concern-label.concern-warning { color: #fcd34d; }

/* NEWS2 component score breakdown */
[data-bs-theme="dark"] .vital-score-comp          { background: #1e293b; border-color: #334155; color: rgba(226, 232, 240, 0.75); }
[data-bs-theme="dark"] .vital-score-comp.comp-abnormal { background: #431407; border-color: #c2410c; color: #fed7aa; }

/* Obs flag badges in obs table */
[data-bs-theme="dark"] .obs-flag-danger           { background: #450a0a; color: #fecaca; border-color: #991b1b; }
[data-bs-theme="dark"] .obs-flag-warning          { background: #422006; color: #fde68a; border-color: #92400e; }
[data-bs-theme="dark"] .obs-flag-muted            { background: #1e293b; color: #cbd5e1; border-color: #334155; }

/* Completion progress track */
[data-bs-theme="dark"] .eprf-completion-track     { background: #1e293b; }

/* EPRF NEWS2/PEWS score badge — low variant uses dark blue text on light
   blue which becomes near-invisible on a dark surface. Bump contrast. */
[data-bs-theme="dark"] .obs-score-badge-low       { color: #0c4a6e !important; }
[data-bs-theme="dark"] .obs-score-badge-med       { color: #1c1917 !important; }
[data-bs-theme="dark"] .obs-score-badge-empty     { background: #334155 !important; color: #cbd5e1 !important; }

/* EPRF tab dots — `cbd5e1` for incomplete is invisible against dark tabs. */
[data-bs-theme="dark"] .eprf-tab-dot              { background: #334155; }

/* ─── Recruitment flag-alert utility (replaces hardcoded inline styles
   in applications/show.ejs). Light + dark variants live together. */
.flag-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 0.375rem;
  margin-bottom: 0.5rem;
  border-left-width: 4px;
  border-left-style: solid;
}
.flag-alert-danger    { background: #fee2e2; border-left-color: #dc2626; color: #7f1d1d; }
.flag-alert-warning   { background: #fef3c7; border-left-color: #f59e0b; color: #78350f; }
.flag-alert-manual    { background: #fff7ed; border-left-color: #f97316; color: #7c2d12; }
[data-bs-theme="dark"] .flag-alert-danger    { background: #3b0b0b; border-left-color: #ef4444; color: #fecaca; }
[data-bs-theme="dark"] .flag-alert-warning   { background: #3a2406; border-left-color: #f59e0b; color: #fde68a; }
[data-bs-theme="dark"] .flag-alert-manual    { background: #381502; border-left-color: #f97316; color: #fed7aa; }

/* Topbar user chip — primary-subtle pill needs decent dark contrast. */
[data-bs-theme="dark"] .topbar .badge.bg-primary-subtle {
  background: #172554 !important;
  color: #bfdbfe !important;
  border-color: #1e3a8a !important;
}

/* ─── Applicant onboarding portal (Credentially-style) ─────────────────────
   Layout is two-column on desktop (sections + sticky messages aside) and
   stacks on mobile. Section blocks group related tasks, task rows replace
   the old flat card grid so dense status lists stay scannable. */

.portal-page { padding-bottom: 6rem; }      /* room for the sticky save bar on task pages */

/* ── Hero / progress ring ── */
.portal-hero { background: linear-gradient(180deg, var(--surface,#fff) 0%, var(--surface-muted,#f8fafc) 100%); }
[data-bs-theme="dark"] .portal-hero { background: linear-gradient(180deg, #111827 0%, #0b1220 100%); }

.portal-progress-ring {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 96px;
}
.portal-progress-ring__pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-strong, #0f172a);
}
[data-bs-theme="dark"] .portal-progress-ring__pct { color: #f8fafc; }

/* ── Section blocks ── */
.portal-section {
  background: var(--surface,#fff);
  border: 1px solid var(--border,#e5e7eb);
  border-radius: 0.75rem;
  overflow: hidden;
}
.portal-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0.85rem 1rem;
  background: var(--surface-muted, #f8fafc);
  border-bottom: 1px solid var(--border,#e5e7eb);
}
.portal-section__icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #eef2ff;
  color: #4338ca;
  font-size: 1.05rem;
  flex-shrink: 0;
}
.portal-section__count {
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}
.portal-section__tasks { display: flex; flex-direction: column; }
[data-bs-theme="dark"] .portal-section { background: #111827; border-color: #1e293b; }
[data-bs-theme="dark"] .portal-section__header { background: #0b1220; border-color: #1e293b; }
[data-bs-theme="dark"] .portal-section__icon { background: #1e1b4b; color: #c7d2fe; }

/* ── Task rows ── */
.portal-task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--border-muted, #f1f5f9);
  color: var(--text, #0f172a);
  text-decoration: none;
  transition: background .12s ease;
}
.portal-task-row:first-child { border-top: 0; }
.portal-task-row:hover { background: var(--surface-muted, #f8fafc); color: var(--text-strong, #0f172a); }
.portal-task-row__icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.portal-task-row__body { flex: 1; min-width: 0; }
.portal-task-row__title { font-size: 0.92rem; }
.portal-task-row__summary { font-size: 0.78rem; }
.portal-task-row__status {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  font-size: 0.78rem;
}
[data-bs-theme="dark"] .portal-task-row { border-top-color: #1e293b; color: #e2e8f0; }
[data-bs-theme="dark"] .portal-task-row:hover { background: #1e293b; }

/* ── Messages aside (compliance thread) ── */
.portal-messages {
  background: var(--surface,#fff);
}
.portal-thread {
  max-height: 50vh;
  overflow-y: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.portal-thread::-webkit-scrollbar { width: 4px; }
.portal-thread::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }
[data-bs-theme="dark"] .portal-thread::-webkit-scrollbar-thumb { background: #334155; }

/* Chat-style message rows. Each .portal-msg is a flex column so the meta
   strip sits ABOVE the bubble, and the column is aligned end (mine) or
   start (theirs). align-items: flex-end/start prevents the bubble from
   stretching to the full width of the thread — it sizes to content. */
.portal-msg {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.portal-msg--mine   { align-items: flex-end; }
.portal-msg--theirs { align-items: flex-start; }

.portal-msg__meta {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 0 4px;
  font-size: 0.7rem;
  line-height: 1.2;
  color: var(--text-muted, #64748b);
  max-width: 100%;
}
.portal-msg__meta strong { font-weight: 600; color: var(--text, #0f172a); }
.portal-msg__meta .badge { font-weight: 600; }

.portal-msg__bubble {
  display: inline-block;
  width: fit-content;
  max-width: min(85%, 360px);
  border-radius: 14px;
  padding: 8px 12px;
  font-size: 0.85rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 1px rgba(0,0,0,0.04);
}
.portal-msg--mine .portal-msg__bubble {
  background: #2563eb;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.portal-msg--theirs .portal-msg__bubble {
  background: var(--surface-muted, #f1f5f9);
  color: var(--text, #0f172a);
  border-bottom-left-radius: 4px;
}
[data-bs-theme="dark"] .portal-msg__meta { color: rgba(226, 232, 240, 0.55); }
[data-bs-theme="dark"] .portal-msg__meta strong { color: #e2e8f0; }
[data-bs-theme="dark"] .portal-msg--theirs .portal-msg__bubble { background: #1e293b; color: #e2e8f0; }
[data-bs-theme="dark"] .portal-msg--mine   .portal-msg__bubble { background: #3b82f6; color: #fff; }

/* ── Sticky save bar (task page) ── */
.portal-save-bar {
  position: fixed;
  left: var(--sidebar-width, 240px);
  right: 0;
  bottom: 0;
  background: var(--surface,#fff);
  border-top: 1px solid var(--border,#e5e7eb);
  padding: 0.75rem 1.25rem;
  z-index: 50;
}
[data-bs-theme="dark"] .portal-save-bar { background: #0b1220; border-top-color: #1e293b; }
@media (max-width: 991.98px) {
  .portal-save-bar { left: 0; }
}

/* ── Task hero ── */
.portal-task-hero { background: linear-gradient(180deg, var(--surface,#fff) 0%, var(--surface-muted,#f8fafc) 100%); }
[data-bs-theme="dark"] .portal-task-hero { background: linear-gradient(180deg, #111827 0%, #0b1220 100%); }

@media (max-width: 575.98px) {
  .portal-task-row { padding: 0.7rem 0.75rem; gap: 8px; }
  .portal-task-row__status .badge { font-size: 0.62rem; }
}

/* Dashboard UK threat-level banner — inline background comes from a
   server-computed pastel keyed to the threat level (LOW…CRITICAL). The
   pastel is unreadable against a dark workspace, so swap it for a dark
   surface here. The coloured 4px border-left and pip-bar stay intact
   as the status cue; we just neutralise the page-wide pastel wash. */
[data-bs-theme="dark"] .threat-banner             { background: #111827 !important; color: #e2e8f0; }
[data-bs-theme="dark"] .threat-banner-label       { color: rgba(226, 232, 240, 0.6) !important; }
[data-bs-theme="dark"] .threat-banner-meaning     { color: #e2e8f0 !important; }
/* Threat level label uses a dark coloured text matched to the threat
   level for light mode — those colours go invisible against the dark
   surface. Force a bright white that still leaves the coloured pip-bar
   and 4px border-left as the status cue. */
[data-bs-theme="dark"] .threat-banner-level       { color: #f8fafc !important; }
[data-bs-theme="dark"] .text-primary-emphasis   { color: #bfdbfe !important; }
