/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy: #0f172a;
  --navy-light: #1e293b;
  --blue: #3b82f6;
  --blue-light: #eff6ff;
  --teal: #14b8a6;
  --teal-bg: #ccfbf1;
  --green: #22c55e;
  --green-bg: #dcfce7;
  --yellow: #eab308;
  --yellow-bg: #fef9c3;
  --orange: #f97316;
  --orange-bg: #ffedd5;
  --red: #ef4444;
  --red-bg: #fce8e8;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --white: #ffffff;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1), 0 4px 10px rgba(0,0,0,0.05);
  --radius: 10px;
  --radius-lg: 14px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ── */
header {
  background: linear-gradient(135deg, var(--navy) 0%, #1a2744 100%);
  color: var(--white);
  padding: 14px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 16px rgba(0,0,0,0.2);
  position: relative;
  z-index: 10;
}

.header-left { display: flex; align-items: center; gap: 16px; }
.header-left h1 { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.header-subtitle { font-size: 12px; color: var(--gray-400); font-weight: 500; }

.header-right { display: flex; align-items: flex-start; gap: 16px; }
.header-clinical-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.header-admin-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}
.header-admin-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.advanced-menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.08);
  color: var(--white);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
  font-family: inherit;
}
.advanced-menu-toggle:hover {
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.22);
}
.advanced-menu-toggle[aria-expanded="true"] {
  background: rgba(255,255,255,0.16);
  border-color: rgba(255,255,255,0.22);
}
/* ── User menu ── */
.user-menu { position: relative; }
.user-menu-toggle {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.14);
  border-radius: 20px; padding: 5px 12px 5px 5px;
  color: var(--white); cursor: pointer; font-size: 13px; font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}
.user-menu-toggle:hover { background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.22); }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--blue); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; letter-spacing: 0.5px; flex-shrink: 0;
}
.user-menu-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-chevron { font-size: 14px; opacity: 0.7; }
.user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 1000;
  min-width: 220px; background: #1e293b; border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  padding: 12px 0; color: #e2e8f0;
}
.user-dropdown-header { padding: 4px 16px 8px; display: flex; align-items: center; gap: 8px; }
.user-dropdown-name { font-weight: 600; font-size: 14px; }
.user-dropdown-role-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 2px 8px; border-radius: 10px;
  background: rgba(59,130,246,0.15); color: var(--blue);
}
.user-dropdown-email { padding: 0 16px 8px; font-size: 12px; color: #94a3b8; }
.user-dropdown-divider { height: 1px; background: rgba(255,255,255,0.1); margin: 4px 0; }
.user-dropdown-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 16px; background: none; border: none;
  color: var(--text); font-size: 13px; cursor: pointer; text-align: left;
  transition: background 0.12s;
}
.user-dropdown-item { color: #e2e8f0; }
.user-dropdown-item:hover { background: rgba(255,255,255,0.08); }
.user-dropdown-signout { color: #ef4444; }
.user-dropdown-signout:hover { background: rgba(239,68,68,0.1); }

/* ── Profile modal ── */
.modal-content-profile { max-width: 600px; max-height: 90vh; display: flex; flex-direction: column; }
.modal-content-profile .modal-body { overflow-y: auto; padding: 20px 28px; flex: 1; min-height: 0; }
.modal-content-profile .modal-header { padding: 16px 28px; flex-shrink: 0; }
.modal-content-profile .modal-footer { padding: 14px 28px; flex-shrink: 0; border-top: 1px solid rgba(255,255,255,0.08); }
.profile-section { margin-bottom: 20px; }
.profile-section h3 { font-size: 14px; font-weight: 600; color: var(--blue); margin-bottom: 10px; border-bottom: 1px solid rgba(255,255,255,0.08); padding-bottom: 6px; }
.profile-hint { font-size: 12px; color: #94a3b8; margin-bottom: 8px; }
.profile-success { color: #22c55e; font-size: 13px; margin-top: 8px; }

/* Duplicate-patient alerts */
.duplicate-alerts-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 6px; margin-left: 6px;
  border-radius: 10px; background: #f59e0b; color: #fff;
  font-size: 11px; font-weight: 700; line-height: 1;
}
.duplicate-suggestions-list { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.duplicate-suggestion-card {
  border: 1px solid rgba(245, 158, 11, 0.4); border-radius: 8px; padding: 12px;
  background: rgba(245, 158, 11, 0.08);
}
.duplicate-suggestion-reasons {
  display: inline-flex; gap: 6px; font-size: 11px; color: #b45309; font-weight: 600;
  background: rgba(245, 158, 11, 0.2); padding: 2px 10px; border-radius: 12px; margin-bottom: 8px;
}
.duplicate-suggestion-pair {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px;
}
.duplicate-suggestion-side {
  border: 1px solid #e2e8f0; border-radius: 6px; padding: 10px;
  background: #fff; font-size: 12px;
}
.duplicate-suggestion-side strong { display: block; color: #0f172a; margin-bottom: 4px; font-size: 13px; }
.duplicate-suggestion-side .field-row { color: #475569; margin: 2px 0; font-size: 11px; }
.duplicate-suggestion-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; justify-content: flex-end; }
.duplicate-suggestion-actions .btn-secondary,
.duplicate-suggestion-actions .btn-primary { font-size: 12px; padding: 6px 12px; }

.advanced-menu-toggle-label {
  white-space: nowrap;
}
.advanced-menu-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 520px;
  max-width: min(82vw, 760px);
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--gray-200);
  background: var(--white);
  box-shadow: var(--shadow-lg);
  z-index: 60;
}
.advanced-menu-panel .header-control-label {
  color: var(--gray-400);
}
.advanced-menu-panel .header-admin-row {
  margin-top: 10px;
}
.advanced-menu-panel .integration-status {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
}
.advanced-menu-panel .integration-item {
  color: var(--gray-700);
}
.advanced-menu-panel .btn-secondary {
  background: var(--gray-50);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}
.advanced-menu-panel .btn-secondary:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}
.advanced-menu-panel #btn-demo {
  box-shadow: none;
}
.header-control-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray-400);
}

/* ── Integration Status Indicators ── */
.integration-status {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 14px;
  background: rgba(255,255,255,0.06);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
}
.integration-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--gray-300);
  font-weight: 500;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.connected {
  background: var(--green);
  box-shadow: 0 0 6px rgba(34,197,94,0.5);
  animation: pulse-dot 2s ease-in-out infinite;
}
.status-dot.disconnected {
  background: var(--gray-400);
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.lang-toggle { display: flex; gap: 2px; background: rgba(255,255,255,0.08); border-radius: 8px; padding: 3px; }
.lang-btn {
  padding: 5px 14px;
  border: none;
  background: transparent;
  color: var(--gray-400);
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.lang-btn.active { background: var(--blue); color: var(--white); box-shadow: 0 1px 4px rgba(59,130,246,0.4); }

.btn-primary {
  padding: 8px 20px;
  background: linear-gradient(135deg, var(--blue) 0%, #2563eb 100%);
  color: var(--white);
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 1px 4px rgba(59,130,246,0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(59,130,246,0.4); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* ── Secondary Button ── */
.btn-secondary {
  padding: 8px 16px;
  background: rgba(255,255,255,0.08);
  color: var(--gray-300);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-secondary:hover { background: rgba(255,255,255,0.14); color: var(--white); }
.btn-secondary:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Test Profiles Dropdown ── */
.test-dropdown-wrapper {
  position: relative;
}

.btn-test {
  padding: 8px 16px;
  background: linear-gradient(135deg, var(--teal) 0%, #0d9488 100%);
  color: var(--white);
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 1px 4px rgba(20,184,166,0.3);
  font-family: inherit;
}
.btn-test:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(20,184,166,0.4); }

.test-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 380px;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-200);
  z-index: 50;
  overflow: hidden;
}

.test-panel-header {
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-400);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.test-profile-list {
  max-height: 320px;
  overflow-y: auto;
}

.test-profile-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: var(--white);
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--gray-100);
  text-align: left;
  font-family: inherit;
  gap: 12px;
}
.test-profile-btn:last-child { border-bottom: none; }
.test-profile-btn:hover { background: var(--gray-50); }

.test-profile-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.test-profile-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
}

.test-profile-desc {
  font-size: 11px;
  color: var(--gray-400);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Main Layout ── */
main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ── Sidebar ── */
#sidebar {
  width: 290px;
  min-width: 290px;
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: width 0.22s ease, min-width 0.22s ease, opacity 0.18s ease, border-color 0.18s ease;
}

#sidebar h2 {
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

body.sidebar-collapsed #sidebar {
  width: 0;
  min-width: 0;
  opacity: 0;
  border-right-color: transparent;
  overflow: hidden;
}

.empty-state {
  padding: 24px 20px;
  color: var(--gray-400);
  font-size: 13px;
  line-height: 1.6;
}

.patient-item {
  padding: 14px 20px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: all 0.15s;
}
.patient-item:hover { background: var(--gray-50); }
.patient-item.selected {
  background: var(--blue-light);
  border-left: 3px solid var(--blue);
}

.patient-item .patient-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}
.patient-name-text {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.patient-name-alias {
  margin-left: 28px;
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.3;
  color: var(--gray-400);
}
.note-source-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--blue-light);
  color: var(--blue);
  font-size: 11px;
  font-weight: 700;
}
.patient-item .patient-meta {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ── Detail Panel ── */
#detail {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  background: var(--gray-100);
}
.detail-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.sidebar-reopen-btn,
.btn-sidebar-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-600);
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.18s ease;
}
.sidebar-reopen-btn:hover,
.btn-sidebar-toggle:hover {
  color: var(--gray-800);
  border-color: var(--gray-300);
  background: var(--gray-50);
}
.btn-sidebar-toggle {
  margin-left: auto;
  padding: 6px 10px;
}
.sidebar-reopen-btn {
  padding: 7px 11px;
}
body.sidebar-collapsed .sidebar-reopen-btn {
  display: inline-flex;
}

.empty-detail {
  display: flex;
  min-height: 60vh;
  color: var(--gray-400);
}
.dashboard-empty {
  align-items: stretch;
  justify-content: flex-start;
}
#dashboard-content {
  width: 100%;
}
.dashboard-loading,
.dashboard-error-state {
  min-height: 56vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.dashboard-loading {
  color: var(--gray-500);
  font-size: 15px;
}
.dashboard-error-icon {
  font-size: 40px;
  margin-bottom: 12px;
  color: var(--gray-400);
}
.dashboard-error-state h2 {
  margin: 0 0 8px;
  color: var(--gray-700);
  font-size: 22px;
}
.dashboard-error-state p {
  margin: 0;
  max-width: 420px;
  color: var(--gray-500);
  line-height: 1.6;
}
.dashboard-hero {
  margin-bottom: 20px;
}
.dashboard-hero-copy,
.dashboard-card,
.dashboard-footer-note {
  animation: dashboardRise 480ms ease-out both;
}
.dashboard-card:nth-child(2) { animation-delay: 40ms; }
.dashboard-card:nth-child(3) { animation-delay: 80ms; }
.dashboard-card:nth-child(4) { animation-delay: 120ms; }
.dashboard-card:nth-child(5) { animation-delay: 160ms; }
.dashboard-hero-copy {
  position: relative;
  overflow: hidden;
  border-radius: 30px;
  padding: 34px 36px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 28px 72px rgba(15, 23, 42, 0.16);
  background:
    radial-gradient(circle at 12% 18%, rgba(56, 189, 248, 0.34), transparent 24%),
    radial-gradient(circle at 85% 22%, rgba(251, 191, 36, 0.18), transparent 20%),
    linear-gradient(135deg, #07111f 0%, #0f2742 38%, #0f766e 100%);
  color: #f8fafc;
}
.dashboard-hero-copy::after {
  content: '';
  position: absolute;
  inset: auto -8% -30% auto;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.12), transparent 62%);
  pointer-events: none;
}
.dashboard-hero-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.dashboard-hero-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12);
  font-size: 24px;
}
.dashboard-hero-kicker {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
  color: rgba(248, 250, 252, 0.8);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.dashboard-hero h1 {
  margin: 0 0 14px;
  max-width: 840px;
  font-size: clamp(34px, 4.8vw, 58px);
  line-height: 0.98;
  letter-spacing: -0.045em;
}
.dashboard-subtitle {
  margin: 0;
  max-width: 760px;
  color: rgba(248, 250, 252, 0.9);
  font-size: clamp(16px, 1.9vw, 20px);
  line-height: 1.55;
}
.dashboard-stats-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 18px;
}
.dashboard-card {
  grid-column: span 4;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-radius: 24px;
  padding: 24px;
  background:
    radial-gradient(circle at top right, rgba(59, 130, 246, 0.12), transparent 28%),
    linear-gradient(180deg, #ffffff 0%, #f3f8fc 100%);
  border: 1px solid rgba(30, 41, 59, 0.08);
  box-shadow: 0 20px 46px rgba(15, 23, 42, 0.1);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}
.dashboard-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 26px 54px rgba(15, 23, 42, 0.14);
  border-color: rgba(14, 116, 144, 0.2);
}
.dashboard-card-attention {
  background:
    radial-gradient(circle at top right, rgba(239, 68, 68, 0.22), transparent 26%),
    linear-gradient(180deg, #fff8f7 0%, #fff1ef 100%);
  border-color: rgba(239, 68, 68, 0.2);
}
.dashboard-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.dashboard-card-icon {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: #e0f2fe;
  color: #075985;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.45);
  font-size: 21px;
}
.dashboard-card-attention .dashboard-card-icon {
  background: #fee2e2;
  color: #b91c1c;
}
.dashboard-card-title {
  color: var(--gray-800);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.dashboard-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.dashboard-metrics-single {
  grid-template-columns: minmax(0, 1fr);
}
.dashboard-metric {
  padding: 12px 0 0;
  border-top: 1px solid rgba(30, 41, 59, 0.08);
  min-width: 0;
}
.dashboard-metric-value {
  color: #0f172a;
  font-size: clamp(20px, 2.3vw, 28px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.05em;
  overflow-wrap: anywhere;
}
.dashboard-metric-label {
  margin-top: 8px;
  color: var(--gray-500);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.dashboard-card-note {
  margin: 0;
  color: var(--gray-500);
  font-size: 13px;
  line-height: 1.6;
}
.dashboard-footer-note {
  margin-top: 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,0.96) 0%, rgba(241,245,249,0.96) 100%);
  border: 1px solid rgba(30, 41, 59, 0.08);
  color: var(--gray-600);
  font-size: 12px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}
.dashboard-footer-note i {
  color: #0f766e;
}
@keyframes dashboardRise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hidden { display: none !important; }

/* ── Cards ── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px 26px;
  margin-bottom: 16px;
  border: 1px solid var(--gray-200);
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow-md); }
.card h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card h3 .card-icon {
  font-size: 16px;
  opacity: 0.6;
}

/* ── Classification Grid ── */
.classification-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.class-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  background: var(--gray-50);
  border-radius: 8px;
  border: 1px solid var(--gray-100);
}
.class-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-400);
  font-weight: 700;
}
.class-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-800);
}
.surgical-disclaimer {
  font-size: 11px;
  color: var(--gray-400);
  font-style: italic;
  margin: 2px 0 0;
  line-height: 1.4;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  width: fit-content;
}
.badge-critical { background: var(--red-bg); color: var(--red); }
.badge-high { background: var(--orange-bg); color: var(--orange); }
.badge-medium { background: var(--yellow-bg); color: var(--yellow); }
.badge-low { background: var(--green-bg); color: var(--green); }
.badge-immediate { background: var(--red-bg); color: var(--red); }
.badge-priority { background: var(--orange-bg); color: var(--orange); }
.badge-routine { background: var(--green-bg); color: var(--green); }

/* ── Risk Flags ── */
.flag-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 8px;
}
.flag-item:last-child { margin-bottom: 0; }
.flag-critical { background: var(--red-bg); }
.flag-high { background: var(--orange-bg); }
.flag-medium { background: var(--yellow-bg); }
.flag-low { background: var(--green-bg); }

.flag-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}
.flag-text { flex: 1; }
.flag-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
}
.flag-detail {
  font-size: 12px;
  color: var(--gray-600);
  margin-top: 2px;
  line-height: 1.5;
}

/* ── Doctor Summary ── */
.summary-content {
  font-size: 14px;
  line-height: 1.6;
  color: var(--gray-700);
}
.summary-content br + br { display: none; }
.summary-content h2 {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
  margin: 18px 0 8px;
  padding: 8px 12px;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-radius: 6px;
  border-left: 3px solid var(--blue);
}
.summary-content h2:first-child { margin-top: 0; }
.summary-content h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin: 12px 0 6px;
  padding-left: 8px;
  border-left: 2px solid var(--teal);
}
.summary-content ul {
  padding-left: 22px;
  margin: 4px 0 8px;
  list-style-type: disc;
}
.summary-content li {
  margin-bottom: 3px;
  line-height: 1.45;
  padding-left: 2px;
}
.summary-content p {
  margin: 4px 0;
  line-height: 1.5;
}

/* ── Pain Profile Visual Bars ── */
.pain-profile-visual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}
.pain-bar-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pain-bar-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.pain-bar-score {
  font-size: 11px;
  font-weight: 700;
  min-width: 28px;
  text-align: right;
}
.pain-bar-track {
  height: 8px;
  background: var(--gray-100);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.pain-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}
.pain-bar-fill.pain-low { background: linear-gradient(90deg, #86efac, #22c55e); }
.pain-bar-fill.pain-moderate { background: linear-gradient(90deg, #fde047, #eab308); }
.pain-bar-fill.pain-high { background: linear-gradient(90deg, #fdba74, #f97316); }
.pain-bar-fill.pain-severe { background: linear-gradient(90deg, #fca5a5, #ef4444); }

/* ── Detail Tabs (Raw Data / AI Analysis) ── */
.detail-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 4px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}
.detail-tab-btn {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: transparent;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--gray-400);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  position: relative;
}
.detail-tab-btn:first-child { border-right: 1px solid var(--gray-200); }
.detail-tab-btn.active {
  color: var(--blue);
  background: var(--blue-light);
}
.detail-tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--blue);
}
.detail-tab-btn:hover:not(.active) { background: var(--gray-50); }
.detail-tab-panel { display: none; }
.detail-tab-panel.active { display: block; padding-top: 16px; }

/* ── Raw Data Table ── */
.raw-data-table {
  width: 100%;
  border-collapse: collapse;
}
.raw-data-submission-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 14px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
}
.raw-data-submission-card-amber {
  background: linear-gradient(135deg, #fffbeb 0%, #ffffff 100%);
  border-color: #fcd34d;
}
.raw-data-submission-card-teal {
  background: linear-gradient(135deg, #f0fdfa 0%, #ffffff 100%);
  border-color: #5eead4;
}
.raw-data-submission-card-blue {
  background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%);
  border-color: #93c5fd;
}
.raw-data-submission-card-rose {
  background: linear-gradient(135deg, #fff1f2 0%, #ffffff 100%);
  border-color: #fda4af;
}
.raw-data-submission-card-violet {
  background: linear-gradient(135deg, #f5f3ff 0%, #ffffff 100%);
  border-color: #c4b5fd;
}
.raw-data-submission-card-emerald {
  background: linear-gradient(135deg, #ecfdf5 0%, #ffffff 100%);
  border-color: #86efac;
}
.raw-data-submission-card:last-child {
  margin-bottom: 0;
}
.raw-data-submission-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.raw-data-submission-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-800);
}
.raw-data-submission-meta {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 2px;
}
.raw-data-submission-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.raw-data-submission-status {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  border: 1px solid transparent;
}
.raw-data-submission-status-included {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}
.raw-data-submission-status-pending {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}
.raw-data-submission-status-historical {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}
.raw-data-submission-status-error {
  background: #fecaca;
  color: #7f1d1d;
  border-color: #f87171;
}
.raw-data-submission-status-neutral {
  background: var(--gray-50);
  color: var(--gray-600);
  border-color: var(--gray-200);
}
.raw-data-submission-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--gray-50);
  color: var(--gray-600);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.raw-data-table tr {
  border-bottom: 1px solid var(--gray-100);
}
.raw-data-table tr:last-child { border-bottom: none; }
.raw-data-label {
  padding: 10px 14px 10px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  vertical-align: top;
  width: 180px;
}
.raw-data-value {
  padding: 10px 0;
  font-size: 14px;
  color: var(--gray-800);
  line-height: 1.5;
  word-break: break-word;
}

/* ── Patient Detail Header ── */
.patient-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px 16px;
  margin-bottom: 8px;
  background: var(--gray-50);
  border-radius: 8px;
  border: 1px solid var(--gray-100);
}
.patient-detail-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  transition: color 0.2s;
}
.patient-detail-name:hover {
  color: var(--blue);
}
.patient-name-reveal-icon {
  font-size: 13px;
  color: var(--gray-300);
  transition: color 0.2s;
}
.patient-detail-name:hover .patient-name-reveal-icon {
  color: var(--blue);
}
.patient-detail-name.revealed {
  cursor: default;
}
.patient-detail-name.revealed .patient-name-reveal-icon {
  display: none;
}
.patient-detail-date {
  font-size: 12px;
  color: var(--gray-400);
  padding-top: 4px;
}
.patient-detail-tools {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.patient-detail-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--gray-400);
  font-size: 11px;
  padding: 2px 0;
  cursor: pointer;
  transition: color 0.2s ease;
}
.patient-detail-tool:hover {
  color: var(--gray-700);
}
.patient-detail-tool-danger:hover {
  color: var(--red);
}

.patient-attention-summary {
  background: linear-gradient(135deg, #fff7ed 0%, #ffffff 100%);
  border: 1px solid #fed7aa;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.patient-attention-header h3 {
  margin-bottom: 10px;
  padding-bottom: 0;
  border-bottom: none;
  color: var(--gray-800);
}
.patient-attention-lead {
  font-size: 14px;
  line-height: 1.6;
  color: var(--gray-700);
  margin-bottom: 12px;
}
.patient-attention-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.patient-attention-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.9);
  border: 1px solid #fdba74;
  color: var(--gray-700);
  font-size: 12px;
  font-weight: 600;
}
.patient-attention-chip i {
  color: var(--orange);
}

.patient-input-status {
  background: linear-gradient(135deg, #fffaf0 0%, #ffffff 100%);
  border: 1px solid #fcd34d;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.patient-input-status-header h3 {
  margin-bottom: 6px;
  padding-bottom: 0;
  border-bottom: none;
  color: #92400e;
}
.patient-input-status-summary {
  margin: 0;
  color: var(--gray-700);
  font-size: 13px;
  line-height: 1.5;
}
.patient-input-status-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}
.patient-input-status-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.92);
  border: 1px solid transparent;
}
.patient-input-status-item-danger {
  border-color: rgba(239,68,68,0.22);
}
.patient-input-status-item-warning {
  border-color: rgba(245,158,11,0.26);
}
.patient-input-status-icon {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(245,158,11,0.12);
  color: #b45309;
}
.patient-input-status-item-danger .patient-input-status-icon {
  background: rgba(239,68,68,0.12);
  color: #b91c1c;
}
.patient-input-status-copy {
  min-width: 0;
}
.patient-input-status-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 3px;
}
.patient-input-status-detail {
  font-size: 12px;
  line-height: 1.5;
  color: var(--gray-700);
}
.btn-action-inline-reanalyze {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 8px 13px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: linear-gradient(135deg, #0f766e 0%, #0ea5a4 100%) !important;
  color: #ffffff !important;
  border: 1px solid #0f766e !important;
  box-shadow: 0 8px 18px rgba(13, 148, 136, 0.24);
}
.btn-action-inline-reanalyze:hover {
  background: linear-gradient(135deg, #115e59 0%, #0f766e 100%) !important;
  color: #ffffff !important;
  border-color: #115e59 !important;
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.3);
}

.critical-alerts-strip {
  background: linear-gradient(135deg, #fef2f2 0%, #fff1f2 100%);
  border: 1px solid #fecaca;
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.critical-alerts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.critical-alerts-header h3 {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
  color: #991b1b;
}
.critical-alerts-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(239,68,68,0.12);
  color: #b91c1c;
  font-size: 12px;
  font-weight: 800;
}
.critical-alerts-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.critical-alert-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(239,68,68,0.18);
  background: rgba(255,255,255,0.9);
}
.critical-alert-pill i {
  color: #dc2626;
  font-size: 16px;
  flex-shrink: 0;
}
.critical-alert-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.critical-alert-label {
  font-size: 12px;
  font-weight: 700;
  color: #7f1d1d;
}
.critical-alert-detail {
  font-size: 12px;
  color: var(--gray-700);
  line-height: 1.45;
}

/* ── AI Pending State ── */
.ai-pending-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--gray-400);
  text-align: center;
}
.ai-pending-state p {
  font-size: 14px;
  font-weight: 500;
}
.ai-pending-sub {
  font-size: 12px !important;
  font-weight: 400 !important;
  color: var(--gray-300);
  margin-top: 4px;
}
.ai-processing-animation {
  position: relative;
  margin-bottom: 16px;
}
.ai-processing-dots {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-top: 8px;
}
.ai-processing-dots span {
  width: 6px;
  height: 6px;
  background: var(--blue);
  border-radius: 50%;
  animation: ai-dot-pulse 1.4s ease-in-out infinite;
}
.ai-processing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-processing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ai-dot-pulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.2); }
}

/* ── AI Not Analyzed State ── */
.ai-not-analyzed-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--gray-400);
}
.ai-not-analyzed-icon {
  font-size: 40px;
  color: var(--gray-200);
  margin-bottom: 12px;
}
.ai-not-analyzed-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-500);
  margin: 0 0 8px;
}
.ai-not-analyzed-state p {
  font-size: 13px;
  max-width: 360px;
  line-height: 1.5;
  margin: 0 0 20px;
}
.btn-run-analysis {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.btn-run-analysis:hover {
  background: #2563eb;
  transform: translateY(-1px);
}
.btn-run-analysis:active {
  transform: translateY(0);
}

/* ── Sidebar Pending/Error Badges ── */
.badge-pending {
  background: var(--blue-light);
  color: var(--blue);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.badge-error {
  background: var(--red-bg);
  color: var(--red);
}
.badge-unprocessed {
  background: var(--gray-100, #f3f4f6);
  color: var(--gray-500, #6b7280);
  font-size: 11px;
}

/* ── Pagination ── */
.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}
.pagination-btn {
  background: var(--bg-secondary, #f9fafb);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 14px;
  transition: background 0.15s;
}
.pagination-btn:hover:not(:disabled) {
  background: var(--bg-hover, #e5e7eb);
}
.pagination-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.pagination-info {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ── Small inline spinner ── */
.spinner-small {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── Tabs ── */
.tab-header {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--gray-100);
}
.tab-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-400);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Email & WhatsApp Content ── */
.email-content, .whatsapp-content {
  font-size: 14px;
  line-height: 1.7;
  color: var(--gray-700);
  white-space: pre-wrap;
  padding: 16px 18px;
  background: var(--gray-50);
  border-radius: 10px;
  border: 1px solid var(--gray-200);
  margin-bottom: 12px;
}

.whatsapp-content {
  background: linear-gradient(135deg, #dcf8c6 0%, #d4f4bc 100%);
  border-color: #b5d9a0;
  border-radius: 14px;
  font-size: 14px;
}

/* ── Action Buttons Row ── */
.btn-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-copy {
  padding: 7px 14px;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.btn-copy:hover { background: var(--gray-200); }

button.btn-send {
  padding: 7px 16px;
  border: none;
  outline: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  line-height: 1.4;
}
button.btn-send:hover { transform: translateY(-1px); }
button.btn-send:active { transform: translateY(0); }

button.btn-send.btn-send-whatsapp {
  background: #25D366;
  color: #ffffff;
  box-shadow: 0 1px 4px rgba(37,211,102,0.3);
}
button.btn-send.btn-send-whatsapp:hover { background: #20bd5a; box-shadow: 0 3px 8px rgba(37,211,102,0.4); }

button.btn-send.btn-send-email {
  background: #3b82f6;
  color: #ffffff;
  box-shadow: 0 1px 4px rgba(59,130,246,0.3);
}
button.btn-send.btn-send-email:hover { background: #2563eb; box-shadow: 0 3px 8px rgba(59,130,246,0.4); }

/* ── Loading State ── */
#detail-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 40vh;
  color: var(--gray-400);
}
.loader {
  width: 40px;
  height: 40px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Sidebar loading state */
.sidebar-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 0;
  color: var(--blue);
}
.sidebar-loading-spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
}
.sidebar-loading-bar {
  flex: 1;
  height: 100%;
  background: var(--blue);
  min-height: 2px;
  width: 30%;
  animation: sidebar-load 1.5s ease-in-out infinite;
}
@keyframes sidebar-load {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

/* ── Toast Notification System ── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 380px;
}
.toast-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: white;
  border-radius: 10px;
  border-left: 4px solid var(--gray-300);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12), 0 1px 4px rgba(0,0,0,0.08);
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  pointer-events: auto;
  animation: toastSlideIn 0.3s ease-out;
  transition: opacity 0.25s, transform 0.25s;
}
.toast-item.toast-dismiss {
  opacity: 0;
  transform: translateX(40px);
}
.toast-item-icon {
  flex-shrink: 0;
  font-size: 18px;
  line-height: 1;
}
.toast-item-message { flex: 1; line-height: 1.4; }
.toast-item-close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  font-size: 15px;
  padding: 2px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.toast-item-close:hover { color: var(--gray-600); background: var(--gray-100); }

/* Type variants */
.toast-item-success { border-left-color: #22c55e; }
.toast-item-success .toast-item-icon { color: #22c55e; }
.toast-item-error { border-left-color: #ef4444; }
.toast-item-error .toast-item-icon { color: #ef4444; }
.toast-item-warning { border-left-color: #f59e0b; }
.toast-item-warning .toast-item-icon { color: #f59e0b; }
.toast-item-info { border-left-color: #3b82f6; }
.toast-item-info .toast-item-icon { color: #3b82f6; }

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Footer ── */
footer {
  padding: 12px 24px;
  text-align: center;
  font-size: 11px;
  color: var(--gray-400);
  border-top: 1px solid var(--gray-200);
  background: var(--white);
}

/* ── AI Disclaimer Banner ── */
.ai-disclaimer-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: linear-gradient(135deg, #eff6ff 0%, #e0f2fe 100%);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--gray-600);
}
.ai-disclaimer-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--blue);
  flex-shrink: 0;
}

/* ── AI Badge ── */
.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
  color: #4338ca;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-radius: 20px;
  border: 1px solid #a5b4fc;
}

/* ── Card Header Row (title + actions) ── */
.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-100);
}
.card-header-row h3 {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}
.card-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Edit Toggle Button ── */
.btn-edit-toggle {
  padding: 5px 12px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-edit-toggle:hover {
  background: var(--blue-light);
  border-color: var(--blue);
  color: var(--blue);
}
.btn-edit-toggle.active {
  background: var(--blue);
  color: var(--white);
  border-color: var(--blue);
}

/* ── Editable State ── */
.card.editing [data-editable],
.card.editing .summary-content,
.card.editing .flag-detail {
  outline: 2px dashed #93c5fd;
  outline-offset: 2px;
  background: #fefce8;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: text;
  min-height: 1.5em;
  transition: outline-color 0.2s, background 0.2s;
}
.card.editing [data-editable]:focus,
.card.editing .summary-content:focus,
.card.editing .flag-detail:focus {
  outline-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

/* Classification edit dropdowns */
.class-edit-select {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border: 2px solid #93c5fd;
  border-radius: 8px;
  background: #fefce8;
  color: var(--gray-800);
  cursor: pointer;
  margin-top: 4px;
  outline: none;
}
.class-edit-select:focus {
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ── Section Background Colors ── */
.card-section-classification {
  background: linear-gradient(135deg, #ffffff 0%, #f0f9ff 100%);
  border-left: 4px solid var(--blue);
}
.card-section-pain {
  background: linear-gradient(135deg, #ffffff 0%, #fff7ed 100%);
  border-left: 4px solid #f97316;
}
.card-section-risk {
  background: linear-gradient(135deg, #ffffff 0%, #fff7ed 100%);
  border-left: 4px solid var(--orange);
}
.card-section-missing {
  background: linear-gradient(135deg, #ffffff 0%, #fafafa 100%);
  border-left: 4px solid var(--gray-400);
}
.missing-data-desc {
  font-size: 13px;
  color: var(--gray-600);
  margin-bottom: 12px;
}
.missing-data-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.missing-data-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 13px;
  color: var(--gray-600);
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 4px 10px;
}
.missing-data-item .ti {
  color: var(--gray-400);
  font-size: 14px;
}
.missing-data-detail {
  width: 100%;
  margin-left: 20px;
  font-size: 12px;
  color: var(--gray-500);
}
.card-header-date {
  margin-top: 4px;
  font-size: 12px;
  color: var(--gray-500);
}
.card-section-summary {
  background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
  border-left: 4px solid var(--teal);
}
.card-section-scores {
  background: linear-gradient(135deg, #ffffff 0%, #faf5ff 100%);
  border-left: 4px solid #8b5cf6;
}
.card-section-feedback {
  background: linear-gradient(135deg, #ffffff 0%, #faf5ff 100%);
  border-left: 4px solid #8b5cf6;
}
.card-section-email {
  background: linear-gradient(135deg, #ffffff 0%, #eff6ff 100%);
  border-left: 4px solid var(--blue);
}
.card-section-whatsapp {
  background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
  border-left: 4px solid #25D366;
}

/* ── Feedback Section ── */
.feedback-description {
  font-size: 13px;
  color: var(--gray-600);
  margin-bottom: 14px;
  line-height: 1.5;
}
.feedback-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-feedback {
  padding: 8px 18px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  background: var(--white);
  color: var(--gray-700);
}
.btn-feedback:hover { transform: translateY(-1px); }
.btn-feedback-accurate:hover {
  background: var(--green-bg);
  border-color: var(--green);
  color: #15803d;
}
.btn-feedback-partial:hover {
  background: var(--yellow-bg);
  border-color: var(--yellow);
  color: #a16207;
}
.btn-feedback-incorrect:hover {
  background: var(--red-bg);
  border-color: var(--red);
  color: #dc2626;
}
.btn-feedback.selected {
  transform: scale(1.02);
}
.btn-feedback-accurate.selected {
  background: var(--green-bg);
  border-color: var(--green);
  color: #15803d;
}
.btn-feedback-partial.selected {
  background: var(--yellow-bg);
  border-color: var(--yellow);
  color: #a16207;
}
.btn-feedback-incorrect.selected {
  background: var(--red-bg);
  border-color: var(--red);
  color: #dc2626;
}
.feedback-detail {
  margin-top: 14px;
}
.feedback-textarea {
  width: 100%;
  min-height: 80px;
  padding: 12px 14px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.6;
  color: var(--gray-700);
  resize: vertical;
  transition: border-color 0.2s;
}
.feedback-textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.btn-feedback-submit {
  margin-top: 10px;
  padding: 9px 22px;
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  color: var(--white);
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  box-shadow: 0 1px 4px rgba(139, 92, 246, 0.3);
}
.btn-feedback-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(139, 92, 246, 0.4);
}
.feedback-thanks {
  margin-top: 14px;
  padding: 12px 16px;
  background: var(--green-bg);
  border: 1px solid #86efac;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #15803d;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── WhatsApp Task Planning ── */
.whatsapp-task-plan {
  margin: 16px 0;
  padding: 18px 20px;
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border: 1px solid #bbf7d0;
  border-radius: 12px;
}
.whatsapp-task-plan h4 {
  font-size: 14px;
  font-weight: 700;
  color: #15803d;
  margin-bottom: 14px;
}
.task-plan-list {
  list-style: none;
  padding: 0;
  margin: 0 0 14px 0;
}
.task-plan-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #dcfce7;
}
.task-plan-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.task-step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  background: #25D366;
  color: var(--white);
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  margin-top: 2px;
}
.task-step-content {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.task-step-content strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
}
.task-step-content .task-step-desc {
  font-size: 12px;
  color: var(--gray-600);
  line-height: 1.5;
}
.task-plan-actions {
  display: flex;
  gap: 8px;
  padding-top: 4px;
}

/* ── Patient Search ── */
.search-wrapper {
  position: relative;
}
.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 10px;
  color: var(--gray-400);
  font-size: 15px;
  pointer-events: none;
}
.search-input {
  padding: 7px 32px 7px 32px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  font-size: 13px;
  background: rgba(255,255,255,0.08);
  color: var(--white);
  width: 320px;
  transition: border-color 0.2s, background 0.2s, width 0.2s;
}
.search-input::placeholder { color: var(--gray-400); }
.search-input:focus {
  outline: none;
  border-color: var(--blue);
  background: rgba(255,255,255,0.12);
  width: 280px;
}
.search-clear {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  line-height: 1;
}
.search-clear:hover { color: var(--white); }
.search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 280px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--gray-200);
}
.search-item {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
}
.search-item:last-child { border-bottom: none; }
.search-item.search-result {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.search-item.search-result:hover { background: var(--blue-light); }
.search-result-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.search-result-name {
  font-weight: 600;
  font-size: 13px;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}
.search-result-date {
  font-size: 11px;
  color: var(--gray-400);
}
.search-loaded-badge {
  font-size: 11px;
  color: var(--green);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 3px;
  font-weight: 500;
}
.search-result-alias {
  font-size: 11px;
  color: var(--gray-400);
  font-weight: 400;
  line-height: 1.3;
}
.search-status-badge {
  font-size: 12px;
  flex-shrink: 0;
}
.search-status-processed { color: var(--green); }
.search-status-unprocessed { color: var(--gray-300); }
.search-loading, .search-empty, .search-error {
  text-align: center;
  color: var(--gray-400);
  padding: 16px 14px;
}
.search-loading i { margin-right: 6px; }
.search-error { color: var(--red); }

/* ── Changelog Modal ── */
.changelog-icon-new { color: var(--yellow); }
.changelog-version-badge {
  background: rgba(59, 130, 246, 0.15);
  color: var(--blue);
  border-color: rgba(59, 130, 246, 0.3);
}
.changelog-footer {
  display: flex;
  justify-content: center;
  padding: 16px 28px 20px;
}
.changelog-dismiss-btn {
  min-width: 200px;
  justify-content: center;
  font-size: 14px;
  padding: 10px 24px;
}
.auth-feature-list li > i.ti-search,
.auth-feature-list li > i.ti-refresh,
.auth-feature-list li > i.ti-message-chatbot,
.auth-feature-list li > i.ti-language,
.auth-feature-list li > i.ti-device-mobile {
  color: var(--blue);
}

/* ── Pull Controls ── */
.pull-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pull-input {
  width: 48px;
  padding: 6px 8px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 13px;
  text-align: center;
  background: white;
}
.pull-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ── Clinical Report ── */
.card-section-report {
  border-left-color: var(--teal) !important;
}
.card-section-patient-summary {
  background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
  border-left: 4px solid #22c55e;
}
.patient-summary-desc {
  font-size: 12px;
  color: var(--gray-500);
  margin: 0 0 10px;
}
.clinical-report-content {
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--gray-800);
}
.clinical-report-content h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  margin: 20px 0 8px 0;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--primary-light);
}
.clinical-report-content h2:first-child {
  margin-top: 4px;
}
.clinical-report-content h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
  margin: 16px 0 6px 0;
}
.clinical-report-content p {
  margin: 4px 0;
}
.clinical-report-content ul {
  margin: 4px 0;
  padding-left: 20px;
}
.clinical-report-content li {
  margin: 2px 0;
}
.report-lang-toggle {
  display: flex;
  gap: 2px;
}
.lang-btn.small {
  padding: 2px 8px;
  font-size: 11px;
  min-width: 28px;
}

/* Report Tables */
.table-wrapper {
  overflow-x: auto;
  margin: 8px 0;
}
.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.report-table th {
  background: var(--gray-100);
  font-weight: 600;
  text-align: left;
  padding: 6px 10px;
  border: 1px solid var(--gray-200);
  color: var(--gray-700);
  white-space: nowrap;
}
.report-table td {
  padding: 5px 10px;
  border: 1px solid var(--gray-200);
  color: var(--gray-700);
}
.report-table tbody tr:nth-child(even) {
  background: var(--gray-50, #f9fafb);
}
.report-table tbody tr:hover {
  background: rgba(20, 184, 166, 0.05);
}

/* ── Score Gauges ── */
.scores-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}
.score-gauge-item {
  padding: 14px 16px;
  background: var(--white);
  border-radius: 10px;
  border: 1px solid var(--gray-200);
  transition: box-shadow 0.2s;
}
.score-gauge-item:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.score-gauge-wide {
  grid-column: 1 / -1;
}
.score-gauge-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.score-gauge-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-600);
}
.score-flag-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--red);
  background: var(--red-bg);
  padding: 2px 8px;
  border-radius: 10px;
  animation: pulse-flag 2s infinite;
}
@keyframes pulse-flag {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
.score-gauge-bar-track {
  height: 10px;
  background: var(--gray-200);
  border-radius: 5px;
  overflow: hidden;
}
.score-gauge-bar-track.small {
  height: 6px;
}
.score-gauge-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
/* gauge colors now solid — see bottom of file */
/* gauge colors now solid — see bottom of file */
.gauge-orange-dark { background: #ea580c; }
.score-gauge-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}
.score-gauge-source {
  margin-top: 8px;
  font-size: 12px;
  color: var(--gray-500);
}
.score-gauge-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-800);
}
.score-gauge-interp {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 10px;
}
.interp-green { color: #15803d; background: var(--green-bg); }
.interp-yellow { color: #a16207; background: var(--yellow-bg); }
.interp-orange { color: #c2410c; background: var(--orange-bg, #ffedd5); }
.interp-orange-dark { color: #c2410c; background: var(--orange-bg, #ffedd5); }
.interp-red { color: #dc2626; background: var(--red-bg); }

/* BPI Severity sub-grid */
.bpi-severity-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.bpi-severity-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.bpi-sev-label {
  font-size: 11px;
  color: var(--gray-600);
  min-width: 80px;
  flex-shrink: 0;
}
.bpi-sev-value {
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-700);
  min-width: 32px;
  text-align: right;
}

/* ── Action Bar ── */
/* Sticky wrapper for action bar + tabs */
.sticky-controls-wrapper {
  position: sticky;
  top: 0;
  z-index: 8;
  padding-bottom: 4px;
  transition: background 0.2s ease, backdrop-filter 0.2s ease, -webkit-backdrop-filter 0.2s ease;
}
.sticky-controls-wrapper.is-stuck {
  background: rgba(248, 250, 252, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 0 0 14px 14px;
}
.sticky-controls-wrapper.is-stuck .action-bar {
  background: rgba(255, 255, 255, 0.88);
}


.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 12px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  margin-bottom: 0;
}
.action-bar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.distribution-panel-shell {
  position: relative;
}
.btn-action {
  padding: 5px 10px;
  min-height: 32px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--white);
  color: var(--gray-700);
  white-space: nowrap;
}
.btn-action:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.btn-action i {
  font-size: 16px;
}
.btn-action-secondary {
  background: linear-gradient(135deg, #fffaf0 0%, #ffffff 100%);
  border-color: #fcd34d;
  color: #92400e;
}
.btn-action-secondary-muted {
  opacity: 0.9;
}
.btn-action-secondary-ready {
  border-color: #86efac;
  color: #166534;
  background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
}
.btn-action-pdf {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  color: var(--white);
  border-color: transparent;
}
.btn-action-pdf:hover { box-shadow: 0 3px 8px rgba(220,38,38,0.3); }
.btn-action-word {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: var(--white);
  border-color: transparent;
}
.btn-action-word:hover { box-shadow: 0 3px 8px rgba(37,99,235,0.3); }
.btn-action-share {
  background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
  color: var(--white);
  border-color: transparent;
}
.btn-action-share:hover { box-shadow: 0 3px 8px rgba(20,184,166,0.3); }
.btn-action-email {
  background: var(--gray-50);
  border-color: var(--blue);
  color: var(--blue);
}
.btn-action-email:hover { background: var(--blue-light); }
.btn-action-whatsapp {
  background: var(--gray-50);
  border-color: #25D366;
  color: #15803d;
}
.btn-action-whatsapp:hover { background: #f0fdf4; }
.btn-action-regen {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  color: var(--white);
  border-color: transparent;
}
.btn-action-regen:hover { box-shadow: 0 3px 8px rgba(124,58,237,0.3); }
.distribution-panel-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  margin-left: 2px;
}
.distribution-panel-badge-draft {
  background: #fef3c7;
  color: #92400e;
}
.distribution-panel-badge-ready {
  background: #dcfce7;
  color: #166534;
}
.distribution-panel-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: min(360px, calc(100vw - 40px));
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--gray-200);
  background: rgba(255,255,255,0.98);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14);
  z-index: 20;
}
.distribution-panel-header {
  margin-bottom: 12px;
}
.distribution-panel-status {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
}
.distribution-panel-status-draft {
  color: #92400e;
}
.distribution-panel-status-ready {
  color: #166534;
}
.distribution-panel-copy {
  margin: 0;
  color: var(--gray-700);
  font-size: 12px;
  line-height: 1.5;
}
.distribution-panel-actions {
  display: grid;
  gap: 8px;
}
.distribution-panel-actions .btn-action {
  justify-content: center;
}

/* ── Re-Generate Modal ── */
.modal-content-regenerate { width: 740px; }
.regen-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-600);
  margin-bottom: 8px;
  padding: 0 24px;
}
.regen-mode { padding: 0 0 8px; }
.regen-textarea-short {
  display: block;
  width: calc(100% - 48px);
  margin: 0 24px;
  min-height: 120px;
  padding: 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  color: var(--gray-800);
}
.regen-textarea-short:focus, .regen-textarea-full:focus {
  outline: none;
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}
.regen-textarea-full {
  display: block;
  width: calc(100% - 48px);
  margin: 0 24px;
  min-height: 340px;
  max-height: 50vh;
  padding: 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-family: 'Menlo', 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
  color: var(--gray-800);
}
.modal-actions-split {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
}
.modal-actions-right { display: flex; gap: 10px; }
.modal-actions-right .btn-primary,
.modal-actions-right .btn-secondary {
  min-height: 42px;
}
#btn-note-submit {
  min-width: 210px;
  justify-content: center;
  white-space: normal;
  text-align: center;
  line-height: 1.25;
}
.regen-label-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  color: var(--gray-400);
  font-size: 11px;
}
.regen-label-inline {
  display: inline;
  padding: 0;
  margin: 0;
  cursor: pointer;
}
.regen-prompt-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 4px 24px 8px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  color: var(--gray-600);
  transition: color 0.15s;
}
.regen-prompt-toggle:hover { color: #7c3aed; }
.regen-prompt-toggle:hover .regen-label-inline { color: #7c3aed; }
.regen-prompt-toggle i { font-size: 16px; transition: transform 0.2s; }
.regen-prompt-hint {
  font-size: 11px;
  color: var(--gray-400);
  margin-left: auto;
}
.regen-prompt-container { padding: 0 0 4px; }
.regen-prompt-note {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--gray-400);
  padding: 6px 24px 0;
}
.regen-prompt-note i { font-size: 14px; color: #7c3aed; }
.btn-regen-submit {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%) !important;
  border-color: transparent !important;
}
.btn-regen-submit:hover { box-shadow: 0 3px 8px rgba(124,58,237,0.3); }

/* ── Re-Generation Indicator ── */
.regen-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(124,58,237,0.06);
  border: 1px solid rgba(124,58,237,0.15);
  border-radius: var(--radius);
  font-size: 13px;
  color: #6d28d9;
  margin-bottom: 12px;
}
.regen-indicator i { font-size: 16px; }
.regen-indicator-date { color: var(--gray-400); font-size: 12px; }

/* ── Highlight flash for scroll-to ── */
@keyframes highlight-flash {
  0% { box-shadow: 0 0 0 0 rgba(59,130,246,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(59,130,246,0.15); }
  100% { box-shadow: var(--shadow); }
}
.highlight-flash {
  animation: highlight-flash 1.5s ease;
}

/* ── Tabler icon alignment ── */
i.ti {
  vertical-align: middle;
  line-height: 1;
}
.card-icon i {
  font-size: 18px;
}
.detail-tab-btn i {
  font-size: 16px;
  margin-right: 2px;
}
.tab-btn i {
  font-size: 14px;
  margin-right: 2px;
}
.integration-item i {
  font-size: 14px;
  opacity: 0.8;
}
#sidebar h2 i {
  font-size: 14px;
  opacity: 0.5;
  margin-right: 4px;
}
.patient-name i {
  font-size: 14px;
  opacity: 0.4;
  margin-right: 3px;
}
.btn-primary i, .btn-secondary i {
  font-size: 15px;
  margin-right: 2px;
}
.btn-feedback-submit i {
  font-size: 14px;
  margin-right: 3px;
}
.ai-badge i {
  font-size: 11px;
}
.test-panel-header i {
  font-size: 12px;
  margin-right: 3px;
}

/* ── Export PDF Button ── */
.btn-export-pdf {
  padding: 5px 14px;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: var(--white);
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.btn-export-pdf:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.3);
}

/* ── PDF Report Body (rendered in hidden container) ── */
.pdf-report-body h2 {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  margin: 14px 0 6px 0;
  padding-bottom: 3px;
  border-bottom: 1px solid #e2e8f0;
}
.pdf-report-body h3 {
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  margin: 10px 0 4px 0;
}
.pdf-report-body p {
  margin: 3px 0;
}
.pdf-report-body ul {
  margin: 3px 0;
  padding-left: 18px;
}
.pdf-report-body .report-table {
  font-size: 10px;
}
.pdf-report-body .report-table th,
.pdf-report-body .report-table td {
  padding: 3px 6px;
}

/* ── Manual Patient Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-content {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 680px;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--gray-200);
}
.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-800);
  margin: 0;
  padding: 0;
  border: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--gray-400);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: all 0.15s;
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-700); }
.modal-desc {
  padding: 14px 24px 0;
  font-size: 13px;
  color: var(--gray-600);
  line-height: 1.5;
}
.modal-textarea {
  margin: 14px 24px;
  flex: 1;
  
  padding: 14px 16px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--gray-800);
  resize: vertical;
  tab-size: 2;
}
.modal-textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
}

/* ── Auth / Welcome Modal ── */
.modal-content-auth {
  width: 540px;
  max-height: 90vh;
  overflow-y: auto;
}
.auth-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  background: linear-gradient(135deg, var(--navy) 0%, #1a2744 100%);
  color: var(--white);
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.auth-brand > i {
  font-size: 32px;
  color: var(--teal);
}
.auth-brand h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  padding: 0;
  border: none;
  color: var(--white);
}
.auth-brand span {
  font-size: 12px;
  color: var(--gray-300);
  font-weight: 400;
}
.auth-badge {
  font-size: 11px;
  font-weight: 600;
  background: rgba(20, 184, 166, 0.15);
  color: var(--teal);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(20, 184, 166, 0.3);
}
.auth-modal-body {
  padding: 24px 28px;
}
.auth-section {
  margin-bottom: 20px;
}
.auth-section h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.auth-section h4 > i {
  font-size: 16px;
}
.auth-section h4:first-child > i { color: var(--green); }
.auth-feature-list,
.auth-roadmap-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.auth-feature-list li,
.auth-roadmap-list li {
  font-size: 13px;
  color: var(--gray-700);
  line-height: 1.5;
  padding: 5px 0;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.auth-feature-list li > i {
  color: var(--green);
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}
.auth-roadmap-list li > i {
  color: var(--blue);
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 2px;
}
.auth-feature-list li strong {
  color: var(--gray-800);
}
.auth-login-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-200);
}
.auth-login-section label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  display: block;
  margin-bottom: 8px;
}
.auth-input-row {
  display: flex;
  gap: 8px;
}
.auth-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  color: var(--gray-800);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.auth-input.shake {
  animation: shake 0.4s ease-in-out;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.auth-submit-btn {
  white-space: nowrap;
  padding: 10px 20px;
}
.is-loading {
  cursor: wait;
}
.spin {
  display: inline-block;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.auth-error {
  color: var(--red);
  font-size: 12px;
  margin-top: 8px;
}
.pw-strength-meter { display: flex; align-items: center; gap: 8px; margin: 6px 0 2px; }
.pw-strength-track { flex: 1; height: 5px; background: #e2e8f0; border-radius: 3px; overflow: hidden; }
.pw-strength-bar { height: 100%; width: 0; border-radius: 3px; transition: width .3s, background-color .3s; }
.pw-strength-label { font-size: 11px; font-weight: 600; min-width: 60px; }
.auth-update-body {
  margin: 0;
  color: var(--gray-600);
  font-size: 13px;
  line-height: 1.6;
  background: linear-gradient(180deg, rgba(240,249,255,0.95) 0%, rgba(236,253,245,0.95) 100%);
  border: 1px solid rgba(14,116,144,0.12);
  border-radius: 12px;
  padding: 12px 14px;
}
.auth-modal-footer {
  padding: 14px 28px;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
}
.auth-modal-footer p {
  font-size: 11px;
  color: var(--gray-400);
  text-align: center;
  font-style: italic;
}

/* ── Mobile Menu Toggle ── */
.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--white);
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.mobile-menu-toggle:hover { background: rgba(255,255,255,0.1); }

/* Mobile back button in detail view */
.mobile-back-btn {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  margin-bottom: 12px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  color: var(--blue);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ── Responsive: Tablet (max-width: 1024px) ── */
@media (max-width: 1024px) {
  header { padding: 12px 16px; }
  .header-left h1 { font-size: 17px; }
  .integration-status { display: none; }
  .header-right { flex-direction: column; align-items: stretch; }
  .header-admin-controls { align-self: flex-end; }
  .advanced-menu-panel {
    left: auto;
    right: 0;
    min-width: 440px;
  }
  #sidebar { width: 240px; min-width: 240px; }
  #detail { padding: 20px; }
  .dashboard-hero { grid-template-columns: 1fr; }
  .dashboard-card { grid-column: span 6; }
  .card { padding: 18px 20px; }
  .scores-grid { grid-template-columns: 1fr 1fr; }
  .test-panel { width: 340px; }
  .action-bar { flex-wrap: wrap; gap: 8px; }
  .action-bar-group { flex-wrap: wrap; }
}

/* ── Responsive: Mobile (max-width: 768px) ── */
@media (max-width: 768px) {
  /* Header */
  header { padding: 8px 12px; flex-wrap: wrap; gap: 6px; }
  .header-left { gap: 10px; }
  .header-left h1 { font-size: 15px; }
  .header-subtitle { display: none; }
  .header-right {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.1);
  }
  .header-right.mobile-open { display: flex; }
  .mobile-menu-toggle { display: block; }
  .integration-status { display: none; }
  .header-clinical-controls { width: 100%; }
  .header-admin-controls {
    width: 100%;
    align-self: stretch;
  }
  .advanced-menu-toggle {
    width: 100%;
    justify-content: space-between;
    min-height: 44px;
  }
  .advanced-menu-panel {
    position: static;
    min-width: 100%;
    max-width: 100%;
    padding: 12px 0 0;
    border: none;
    border-top: 1px solid rgba(255,255,255,0.1);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
  .advanced-menu-panel .header-control-label {
    color: var(--gray-400);
  }
  .advanced-menu-panel .header-admin-row { width: 100%; margin-top: 10px; }
  .advanced-menu-panel .integration-status {
    width: 100%;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
  }
  .advanced-menu-panel .integration-item { color: var(--gray-300); }
  .advanced-menu-panel .btn-secondary {
    background: rgba(255,255,255,0.08);
    color: var(--gray-300);
    border: 1px solid rgba(255,255,255,0.15);
  }
  .advanced-menu-panel .btn-secondary:hover {
    background: rgba(255,255,255,0.14);
    color: var(--white);
  }

  .lang-toggle { align-self: flex-start; }
  .search-wrapper { width: 100%; }
  .search-input { width: 100%; }
  .search-input:focus { width: 100%; }
  .search-dropdown { min-width: 100%; }
  .pull-controls { flex-wrap: wrap; width: 100%; }
  .pull-controls .btn-secondary { flex: 1; min-height: 44px; }
  #btn-check-new { width: 100%; min-height: 44px; justify-content: center; }
  #btn-demo { width: 100%; min-height: 44px; justify-content: center; }
  .test-dropdown-wrapper { width: 100%; }
  .btn-test { width: 100%; min-height: 44px; justify-content: center; }
  .test-panel { width: 100%; position: fixed; top: auto; bottom: 0; left: 0; right: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 60vh; }
  .test-profile-list { max-height: 50vh; }

  /* Layout: stack sidebar + detail */
  main { flex-direction: column; }
  #sidebar {
    width: 100%;
    min-width: 100%;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--gray-200);
    opacity: 1;
  }
  body.sidebar-collapsed #sidebar {
    width: 100%;
    min-width: 100%;
    opacity: 1;
    border-right: none;
  }
  /* On mobile, hide sidebar when a patient is selected, show detail */
  #sidebar.mobile-hidden { display: none; }
  #detail.mobile-hidden { display: none; }
  .btn-sidebar-toggle,
  .sidebar-reopen-btn { display: none !important; }
  .mobile-back-btn { display: flex; }
  .patient-detail-header { flex-direction: column; gap: 10px; }
  .patient-detail-date { padding-top: 0; }
  .critical-alerts-header { align-items: flex-start; }
  .critical-alerts-list { flex-direction: column; }
  .critical-alert-pill { width: 100%; }
  .patient-attention-items { flex-direction: column; }
  .patient-attention-chip { border-radius: 12px; }

  /* Detail */
  #detail { padding: 14px; }
  .dashboard-hero-copy,
  .dashboard-card { padding: 18px; border-radius: 18px; }
  .dashboard-stats-grid { grid-template-columns: 1fr; }
  .dashboard-card { grid-column: span 1; }
  .dashboard-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-metrics-single { grid-template-columns: 1fr; }
  .dashboard-hero h1 { font-size: 34px; }
  .dashboard-subtitle { font-size: 16px; }
  .dashboard-footer-note {
    display: flex;
    width: 100%;
    border-radius: 16px;
    align-items: flex-start;
  }
  .card { padding: 16px; margin-bottom: 12px; }
  .card h3 { font-size: 13px; }
  .card-header-row { flex-wrap: wrap; gap: 8px; }
  .card-header-actions { flex-wrap: wrap; gap: 6px; }

  /* Classification grid */
  .classification-grid { grid-template-columns: 1fr; gap: 12px; }
  .class-item { padding: 10px 12px; }

  /* Scores grid */
  .scores-grid { grid-template-columns: 1fr; }
  .bpi-severity-grid { grid-template-columns: 1fr; }

  /* Pain profile */
  .pain-profile-visual { grid-template-columns: 1fr; }

  /* Action bar */
  .action-bar { flex-direction: column; gap: 8px; padding: 8px 10px; }
  .action-bar-group {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .btn-action {
    width: 100%;
    min-height: 40px;
    justify-content: center;
    font-size: 11.5px;
    padding: 7px 8px;
    white-space: normal;
    line-height: 1.2;
  }
  .distribution-panel-shell { width: 100%; }
  .distribution-panel-menu { position: static; width: 100%; margin-top: 8px; }

  /* Detail tabs */
  .detail-tabs {
    overflow-x: auto;
    scrollbar-width: none;
  }
  .detail-tabs::-webkit-scrollbar { display: none; }
  .detail-tab-btn {
    flex: 0 0 auto;
    min-width: 132px;
    padding: 9px 10px;
    font-size: 12px;
  }

  /* Communication tabs */
  .tab-header { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab-btn { padding: 8px 12px; font-size: 12px; white-space: nowrap; min-height: 44px; }

  /* Buttons: ensure 44px min touch targets */
  .btn-primary, .btn-secondary, .btn-test, .btn-copy, button.btn-send, .btn-feedback, .btn-feedback-submit, .btn-edit-toggle, .lang-btn {
    min-height: 44px;
    min-width: 44px;
  }
  .lang-btn { padding: 8px 16px; font-size: 13px; }
  .btn-copy { padding: 10px 14px; }
  button.btn-send { padding: 10px 16px; }
  .btn-feedback { padding: 10px 16px; }
  .btn-actions { flex-wrap: wrap; }

  /* Email/WhatsApp content */
  .email-content, .whatsapp-content { padding: 12px 14px; font-size: 13px; }

  /* Modals: full-width on mobile */
  .modal-content { width: 100%; max-width: 100%; max-height: 100vh; border-radius: 0; }
  .modal-content-auth { width: 100%; max-height: 100vh; }
  .modal-textarea { min-height: 200px; margin: 10px 14px; font-size: 13px; }
  .modal-header { padding: 14px 16px; }
  .modal-desc { padding: 10px 16px 0; }
  .modal-actions { padding: 12px 16px; }
  .auth-modal-header { padding: 16px 18px; flex-wrap: wrap; gap: 10px; }
  .auth-brand > i { font-size: 26px; }
  .auth-brand h2 { font-size: 16px; }
  .auth-modal-body { padding: 16px 18px; }
  .auth-modal-footer { padding: 12px 18px; }
  .auth-input-row { flex-direction: column; }
  .auth-submit-btn { width: 100%; min-height: 48px; justify-content: center; }

  /* Toast */
  .toast-container { left: 14px; right: 14px; max-width: none; }

  /* Footer */
  footer { padding: 10px 14px; font-size: 10px; }

  /* Sidebar items: bigger touch targets */
  .patient-item { padding: 16px; }
  .patient-item .patient-name { font-size: 15px; }

  /* Feedback buttons */
  .feedback-options { flex-direction: column; }
  .feedback-options .btn-feedback { width: 100%; justify-content: center; }

  /* Task plan */
  .whatsapp-task-plan { padding: 14px; }
  .task-plan-actions { flex-direction: column; }
  .task-plan-actions button { width: 100%; justify-content: center; }

  /* Raw data table: stack on mobile */
  .raw-data-table tr { display: flex; flex-direction: column; padding: 8px 0; }
  .raw-data-label { width: auto; padding: 0 0 4px 0; font-size: 11px; }
  .raw-data-value { padding: 0; font-size: 13px; }

  /* AI disclaimer */
  .ai-disclaimer-banner { font-size: 12px; padding: 12px 14px; }

  /* Re-generate modal */
  .modal-content-regenerate { width: 100%; }
  .regen-label { padding: 0 16px; }
  .regen-textarea-short, .regen-textarea-full { width: calc(100% - 32px); margin: 0 16px; }
  .regen-textarea-short { min-height: 100px; }
  .regen-textarea-full { min-height: 240px; }
  .modal-actions-split { flex-direction: column; gap: 12px; padding: 12px 16px; }
  .modal-actions-right { width: 100%; justify-content: flex-end; }
  .workspace-header { flex-direction: column; }
  .workspace-layout { grid-template-columns: 1fr; }
  .workspace-panel { padding: 14px; }
  .emr-summary-strip { grid-template-columns: 1fr 1fr; }
  .entry-action-menu { width: 100%; }
  .entry-action-dropdown { position: static; margin-top: 8px; width: 100%; min-width: 100%; }
  .specialty-filters { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .notes-reanalyze-prompt { flex-direction: column; align-items: flex-start; }
  .side-chat-messages { max-height: 360px; }
  .form-row-2col { grid-template-columns: 1fr; }
  .modal-content-add-note { width: 100%; }
  .rx-template-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .rx-template-actions {
    width: 100%;
  }
  .rx-template-actions .btn-secondary {
    flex: 1;
  }
  .rx-summary-grid {
    grid-template-columns: 1fr;
  }
  .rx-section-header,
  .rx-template-save-footer {
    flex-direction: column;
    align-items: stretch;
  }
  .rx-template-editor-actions {
    flex-direction: column;
  }
  .rx-template-editor-actions .btn-primary,
  .rx-template-editor-actions .btn-secondary {
    width: 100%;
  }

  /* Report tables scroll horizontally */
  .table-wrapper { margin: 8px -16px; padding: 0 16px; }
}

/* ── Responsive: Small phones (max-width: 380px) ── */
@media (max-width: 380px) {
  header { padding: 8px 10px; }
  .header-left h1 { font-size: 15px; }
  #detail { padding: 10px; }
  .card { padding: 12px; }
  .card-header-row { flex-direction: column; align-items: flex-start; gap: 6px; }
  .action-bar-group { grid-template-columns: 1fr; }
  .btn-action { width: 100%; }
  .class-item { padding: 8px 10px; }
  .classification-grid { gap: 8px; }
  .auth-brand h2 { font-size: 14px; }
  .auth-brand > i { font-size: 22px; }
  .auth-badge { font-size: 10px; }
}

/* ── Clinical Notes Tab ── */
.notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.workspace-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.notes-title { font-size: 15px; font-weight: 600; color: var(--navy); margin: 0; }
.notes-title i { margin-right: 6px; }
.workspace-subtitle {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--gray-500);
  max-width: 760px;
}
.workspace-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.9fr);
  gap: 18px;
  align-items: start;
}
.workspace-record-shell {
  display: block;
}
.emr-summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.emr-summary-card {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border: 1px solid #dbe7f3;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.emr-summary-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gray-500);
  margin-bottom: 6px;
}
.emr-summary-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.3;
  word-break: break-word;
}
.workspace-panel {
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  border: 1px solid var(--gray-200);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
}
.workspace-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.workspace-panel-header h4 {
  margin: 0;
  font-size: 14px;
  color: var(--navy);
}
.workspace-panel-header p {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--gray-500);
}
.workspace-analysis-status {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.55;
  font-weight: 600;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}
.workspace-analysis-status i {
  font-size: 18px;
  margin-top: 1px;
  flex-shrink: 0;
}
.workspace-analysis-status-updating {
  background: linear-gradient(135deg, #dbeafe 0%, #eff6ff 100%);
  border: 2px solid #60a5fa;
  color: #1d4ed8;
}
.workspace-analysis-status-success {
  background: linear-gradient(135deg, #d1fae5 0%, #ecfdf5 100%);
  border: 2px solid #34d399;
  color: #047857;
}
.workspace-analysis-status-error {
  background: linear-gradient(135deg, #fee2e2 0%, #fef2f2 100%);
  border: 2px solid #f87171;
  color: #b91c1c;
}
.workspace-analysis-status-queued {
  background: linear-gradient(135deg, #ffedd5 0%, #fff7ed 100%);
  border: 2px solid #fb923c;
  color: #c2410c;
}
.analysis-last-updated {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  white-space: nowrap;
}
.specialty-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.specialty-filter-chip {
  border: 1px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-600);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.specialty-filter-chip.active {
  background: #e0f2fe;
  border-color: #7dd3fc;
  color: #075985;
}
.workspace-filter-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  padding: 32px 20px;
  color: var(--gray-400);
}
.workspace-filter-empty i {
  font-size: 28px;
}
.notes-empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--gray-400);
  font-size: 14px;
}
.notes-empty-state i { font-size: 40px; display: block; margin-bottom: 12px; }

.btn-action-add-note {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: var(--white);
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}
.btn-action-add-note:hover { box-shadow: 0 3px 8px rgba(5,150,105,0.3); }
.entry-action-menu {
  position: relative;
}
.entry-action-menu-review {
  display: inline-flex;
}
.entry-action-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: #ffffff;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.14);
  padding: 8px;
  z-index: 12;
}
.entry-action-item {
  width: 100%;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--gray-700);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.entry-action-item:hover {
  background: #f8fafc;
  color: var(--navy);
}
.entry-action-item i {
  color: #0f766e;
  font-size: 16px;
}
.note-mode-switcher {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  margin-bottom: 10px;
}
.note-mode-btn {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.note-mode-btn-simple { background: #f3f4f6; color: #374151; }
.note-mode-btn-nom { background: #e0f2fe; color: #075985; }
.note-mode-btn-psoap { background: #ecfccb; color: #3f6212; }
.note-mode-btn.active {
  box-shadow: inset 0 0 0 2px rgba(15, 23, 42, 0.18);
}
.note-mode-helper {
  font-size: 12px;
  color: var(--gray-500);
  margin-bottom: 14px;
  line-height: 1.5;
}

.tab-badge {
  background: var(--blue);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 4px;
  min-width: 16px;
  text-align: center;
}

/* Notes Timeline */
.notes-timeline { display: flex; flex-direction: column; gap: 12px; }
.note-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.note-card-focused {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.16);
}
.note-card-blue   { border-left-color: var(--blue); }
.note-card-purple { border-left-color: #8b5cf6; }
.note-card-orange { border-left-color: var(--orange); }
.note-card-teal   { border-left-color: var(--teal); }
.note-card-green  { border-left-color: var(--green); }
.note-card-pink   { border-left-color: #ec4899; }
.note-card-gray   { border-left-color: var(--gray-400); }

.note-card-excluded {
  background: var(--gray-50);
  border-color: var(--gray-200);
  border-left-color: var(--gray-300);
}
.note-card-excluded .note-meta,
.note-card-excluded .note-text,
.note-card-excluded .note-date,
.note-card-excluded .doc-card-body { color: var(--gray-400); }

.note-include-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--gray-100);
  border-radius: 6px;
  font-size: 12px;
  color: var(--gray-400);
}
.note-include-banner .ti-flask-off { font-size: 15px; }
.note-include-banner span { flex: 1; }
.btn-include-in-analysis {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  background: white;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-include-in-analysis:hover {
  background: var(--primary);
  color: white;
}

.analysis-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  font-size: 16px;
  color: var(--gray-400);
  transition: background 0.15s, color 0.15s;
}
.analysis-toggle:hover { background: var(--gray-100); }
.analysis-toggle input { display: none; }
.analysis-toggle input:checked + i { color: var(--primary); }

.analysis-toggle-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-500);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  background: var(--gray-50);
  transition: all 0.15s;
  user-select: none;
}
.analysis-toggle-checkbox:hover {
  border-color: var(--primary);
  background: #eff6ff;
}
.analysis-toggle-checkbox:has(input:checked) {
  color: var(--primary);
  border-color: var(--primary);
  background: #eff6ff;
}
.analysis-toggle-checkbox:has(input:checked) .ti { color: var(--primary); }
.analysis-toggle-checkbox .ti {
  font-size: 16px;
  color: var(--gray-400);
}
.analysis-toggle-checkbox input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
}
.modal-actions-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.note-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px;
}
.note-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.note-header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.note-specialty-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.note-specialty-blue   { background: var(--blue-light); color: var(--blue); }
.note-specialty-purple { background: #ede9fe; color: #6d28d9; }
.note-specialty-orange { background: #fff7ed; color: #c2410c; }
.note-specialty-teal   { background: #f0fdfa; color: #0f766e; }
.note-specialty-green  { background: #f0fdf4; color: #15803d; }
.note-specialty-pink   { background: #fce7f3; color: #be185d; }
.note-specialty-gray   { background: var(--gray-100); color: var(--gray-600); }
.note-input-type-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: #f1f5f9;
  color: #334155;
  padding: 2px 8px;
  border-radius: 999px;
}

.note-doctor { font-size: 13px; font-weight: 600; color: var(--gray-800); }
.note-phase-tag {
  font-size: 11px;
  color: var(--gray-600);
  background: var(--gray-100);
  padding: 2px 8px;
  border-radius: 10px;
}
.note-date { font-size: 11px; color: var(--gray-400); white-space: nowrap; }
.note-edit-btn,
.note-delete-btn {
  background: none;
  border: none;
  color: var(--gray-300);
  cursor: pointer;
  padding: 2px;
  font-size: 14px;
  border-radius: 4px;
}
.note-edit-btn:hover { color: var(--blue); background: #eff6ff; }
.note-delete-btn:hover { color: var(--red); background: #fef2f2; }
.note-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--gray-700);
  white-space: pre-wrap;
}
.note-structured {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.note-structured-header {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px 12px;
  padding: 12px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}
.note-structured-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.note-structured-meta-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gray-500);
}
.note-structured-meta-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
  white-space: pre-wrap;
}
.note-section {
  border-top: 1px solid #edf2f7;
  padding-top: 10px;
}
.note-section:first-of-type {
  border-top: none;
  padding-top: 0;
}
.note-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #0f4c81;
  margin-bottom: 5px;
}
.note-section-body {
  font-size: 13px;
  line-height: 1.6;
  color: var(--gray-700);
  white-space: pre-wrap;
}
.note-empty-value {
  color: var(--gray-400);
  font-style: italic;
}

/* Note AI/New badges */
.note-ai-badge {
  font-size: 10px;
  font-weight: 600;
  color: #6d28d9;
  background: #ede9fe;
  padding: 1px 7px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.note-ai-badge i { font-size: 11px; }
.note-new-badge {
  font-size: 10px;
  font-weight: 600;
  color: #b45309;
  background: #fef3c7;
  padding: 1px 7px;
  border-radius: 10px;
}
.note-edited-badge {
  font-size: 10px;
  font-weight: 600;
  color: #0f766e;
  background: #ccfbf1;
  padding: 1px 7px;
  border-radius: 10px;
}

/* Re-analyze prompt in notes tab */
.notes-reanalyze-prompt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 10px;
  margin-top: 4px;
}
.notes-reanalyze-text {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #0c4a6e;
}
.notes-reanalyze-text i { font-size: 18px; color: #0891b2; flex-shrink: 0; }
.btn-action-reanalyze-notes {
  background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
  color: var(--white);
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.btn-action-reanalyze-notes:hover { box-shadow: 0 3px 8px rgba(8,145,178,0.3); }

/* Add Note Modal */
.modal-content-add-note {
  width: 760px;
  min-height: 600px;
  max-height: min(88vh, 860px);
  display: flex;
  flex-direction: column;
  margin-top: 12px;
}
.modal-content-add-note .modal-body {
  padding: 0 24px 16px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}
.modal-content-add-note .modal-actions-split {
  position: sticky;
  bottom: 0;
  background: #ffffff;
  z-index: 2;
}
.form-row-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--gray-700); }
.modal-input, .modal-select {
  padding: 9px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--white);
  color: var(--gray-800);
}
.modal-input:focus, .modal-select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.emr-template-block {
  border: 1px solid #dbe7f3;
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
}
.nom-note-ai-status {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-size: 13px;
  line-height: 1.5;
  font-weight: 600;
}
.nom-note-ai-status-ready {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}
.emr-template-header {
  margin-bottom: 12px;
}
.emr-template-header h4 {
  margin: 0 0 4px;
  font-size: 14px;
  color: var(--navy);
}
.emr-template-header p {
  margin: 0;
  font-size: 12px;
  color: var(--gray-500);
  line-height: 1.5;
}
.modal-textarea-section {
  min-height: 84px;
}

/* Add Note Button (action bar) */
.btn-action-add-note-bar {
  background: var(--white);
  color: var(--gray-700);
  border-color: var(--gray-300);
}
.btn-action-add-note-bar:hover { background: var(--gray-50); border-color: var(--gray-400); }

/* Re-analyze Button */
.btn-action-reanalyze {
  position: relative;
  background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
  color: var(--white);
  border-color: transparent;
  align-items: center;
}
.btn-action-label-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  line-height: 1.1;
}
.btn-action-reanalyze #btn-reanalyze-text {
  text-align: left;
}
.btn-action-reanalyze .analysis-last-updated {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.82);
  white-space: normal;
  line-height: 1.2;
}
.btn-action-reanalyze:hover { box-shadow: 0 3px 8px rgba(8,145,178,0.3); }
.btn-action-reanalyze.has-new-notes {
  animation: pulse-glow 2s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(8,145,178,0); }
  50% { box-shadow: 0 0 0 4px rgba(8,145,178,0.25); }
}
.btn-action-reanalyze:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}
.btn-action-reanalyze:disabled:hover {
  box-shadow: none;
}
.reanalyze-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 10px;
  background: #ef4444;
  color: white;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.btn-reanalyze-submit {
  background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%) !important;
}

/* Re-analyze modal info box */
.reanalyze-info {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  padding: 12px 16px;
  margin: 0 24px 16px;
}
.reanalyze-info-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #0c4a6e;
}
.reanalyze-info-item i { font-size: 18px; }
.reanalyze-instructions-required {
  margin: 8px 24px 0;
  font-size: 12px;
  line-height: 1.45;
  color: #b45309;
}
.regen-textarea-short.is-required {
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.12);
}

/* Re-analyze modal note previews */
.reanalyze-notes-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 24px 16px;
  max-height: 200px;
  overflow-y: auto;
}
.reanalyze-note-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-left: 3px solid var(--blue);
  border-radius: 6px;
  padding: 10px 12px;
}
.reanalyze-note-card-blue   { border-left-color: var(--blue); }
.reanalyze-note-card-purple { border-left-color: #8b5cf6; }
.reanalyze-note-card-orange { border-left-color: var(--orange); }
.reanalyze-note-card-teal   { border-left-color: var(--teal); }
.reanalyze-note-card-green  { border-left-color: var(--green); }
.reanalyze-note-card-pink   { border-left-color: #ec4899; }
.reanalyze-note-card-gray   { border-left-color: var(--gray-400); }
.reanalyze-note-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.reanalyze-note-doctor { font-size: 12px; font-weight: 600; color: var(--gray-700); }
.reanalyze-note-date { font-size: 11px; color: var(--gray-400); margin-left: auto; }
.reanalyze-note-preview { font-size: 12px; color: var(--gray-500); line-height: 1.4; }

/* Side chat */
.workspace-chat-banner {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  padding: 10px 12px;
  color: #9a3412;
  font-size: 12px;
  line-height: 1.5;
  margin-bottom: 12px;
}
.card-section-next-actions {
  border-left: 4px solid #0f766e;
}
.card-section-evolution-summary {
  border-left: 4px solid #0ea5e9;
}
.next-actions-desc {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--gray-500);
  line-height: 1.5;
}
.next-actions-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.btn-action-view-record {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #334155;
}
.btn-action-view-record:hover {
  background: #f1f5f9;
}
.btn-action-chat-nav {
  background: #f8fafc;
  border-color: #bae6fd;
  color: #0369a1;
}
.btn-action-chat-nav:hover {
  background: #f0f9ff;
}
.btn-action-clear-chat {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #c2410c;
}
.btn-action-clear-chat:hover {
  background: #ffedd5;
}
/* ── Floating Chat Modal ── */
.chat-modal {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 420px;
  max-height: 520px;
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
  border: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  z-index: 100;
  animation: chatSlideUp 0.2s ease-out;
}
.chat-modal.hidden { display: none; }
@keyframes chatSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
}
.chat-modal-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-700);
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat-modal-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-modal-expand,
.chat-modal-clear,
.chat-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  color: var(--gray-400);
  font-size: 16px;
  transition: all 0.15s;
}
.chat-modal-expand:hover { color: var(--blue); background: #eff6ff; }
.chat-modal-clear:hover { color: #c2410c; background: #fff7ed; }
.chat-modal-close:hover { color: var(--gray-600); background: var(--gray-100); }
/* Expanded chat modal */
.chat-modal.chat-modal-expanded {
  width: 560px;
  max-height: 70vh;
}
.chat-modal.chat-modal-expanded .side-chat-messages {
  max-height: 50vh;
}
.chat-modal .side-chat-messages {
  flex: 1;
  min-height: 120px;
  max-height: 320px;
  overflow-y: auto;
  padding: 10px 14px;
  gap: 8px;
}
.chat-modal .side-chat-empty {
  padding: 24px 14px;
  font-size: 12px;
}
.chat-modal-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--gray-200);
  flex-shrink: 0;
}
.chat-modal-composer .side-chat-input {
  flex: 1;
  min-height: 36px;
  max-height: 100px;
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 8px;
  resize: none;
}
.chat-modal-send {
  padding: 8px 12px;
  border-radius: 8px;
  min-height: 36px;
  flex-shrink: 0;
}
@media (max-width: 768px) {
  .chat-modal {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 70vh;
    border-radius: 16px 16px 0 0;
  }
}

.side-chat-empty {
  text-align: center;
  color: var(--gray-400);
  font-size: 13px;
  padding: 20px 10px;
}
.side-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 220px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 4px;
}
.side-chat-messages-empty {
  min-height: 0;
  max-height: none;
  overflow: visible;
}
.side-chat-message {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.side-chat-message-user {
  align-items: flex-end;
}
.side-chat-message-assistant {
  align-items: flex-start;
}
.side-chat-message-meta {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--gray-400);
  flex-wrap: wrap;
}
.side-chat-promoted-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  font-weight: 600;
}
.side-chat-bubble {
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
  border: 1px solid var(--gray-200);
  overflow-wrap: anywhere;
}
.side-chat-message-user .side-chat-bubble {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e3a8a;
}
.side-chat-message-assistant .side-chat-bubble {
  background: #f8fafc;
  color: var(--gray-700);
}
.side-chat-message-actions {
  display: flex;
}
.side-chat-message-user .side-chat-message-actions {
  justify-content: flex-end;
}
.side-chat-promote-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #bfdbfe;
  background: #f8fbff;
  color: #1d4ed8;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.side-chat-promote-btn:hover {
  background: #eff6ff;
  border-color: #93c5fd;
}
.side-chat-composer {
  margin-top: 12px;
  border-top: 1px solid var(--gray-200);
  padding-top: 12px;
}
.side-chat-input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  resize: none;
}
.side-chat-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.side-chat-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.side-chat-hint {
  font-size: 11px;
  color: var(--gray-400);
}
.side-chat-bubble p,
.side-chat-bubble ul,
.side-chat-bubble ol,
.side-chat-bubble h2,
.side-chat-bubble h3,
.side-chat-bubble h4,
.side-chat-bubble hr,
.side-chat-bubble .table-wrapper {
  margin: 0 0 8px;
}
.side-chat-bubble p:last-child,
.side-chat-bubble ul:last-child,
.side-chat-bubble ol:last-child,
.side-chat-bubble h2:last-child,
.side-chat-bubble h3:last-child,
.side-chat-bubble h4:last-child,
.side-chat-bubble hr:last-child,
.side-chat-bubble .table-wrapper:last-child {
  margin-bottom: 0;
}
.side-chat-bubble ul,
.side-chat-bubble ol {
  padding-left: 18px;
}
.side-chat-bubble code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: rgba(15, 23, 42, 0.06);
  padding: 1px 4px;
  border-radius: 4px;
}
.side-chat-bubble .report-table {
  font-size: 12px;
}
.side-chat-message-user .side-chat-bubble .report-table th,
.side-chat-message-user .side-chat-bubble .report-table td {
  background: rgba(255, 255, 255, 0.55);
}

/* Notes Context Card (below Classification in AI tab) */
.card-section-notes-context {
  border-left: 4px solid #8b5cf6;
}
.notes-context-desc {
  font-size: 12px;
  color: var(--gray-500);
  margin: 0 0 12px 0;
}
.notes-context-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}
@media (max-width: 768px) {
  .notes-context-list { grid-template-columns: 1fr; }
}
.notes-context-item {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-left: 3px solid var(--blue);
  border-radius: 6px;
  padding: 10px 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.notes-context-item[role="button"] {
  cursor: pointer;
}
.notes-context-item[role="button"]:hover {
  border-color: var(--gray-300);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
  transform: translateY(-1px);
}
.notes-context-item-blue   { border-left-color: var(--blue); }
.notes-context-item-purple { border-left-color: #8b5cf6; }
.notes-context-item-orange { border-left-color: var(--orange); }
.notes-context-item-teal   { border-left-color: var(--teal); }
.notes-context-item-green  { border-left-color: var(--green); }
.notes-context-item-pink   { border-left-color: #ec4899; }
.notes-context-item-gray   { border-left-color: var(--gray-400); }
.notes-context-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.notes-context-doctor { font-size: 12px; font-weight: 600; color: var(--gray-700); }
.notes-context-date { font-size: 11px; color: var(--gray-400); margin-left: auto; }
.notes-context-preview { font-size: 12px; color: var(--gray-500); line-height: 1.4; }

/* Clinical report formatting */
.clinical-report-content hr {
  border: none;
  border-top: 1px solid var(--gray-200);
  margin: 16px 0;
}
.report-section-delimiter {
  text-align: center;
  margin: 20px 0 12px;
  padding: 8px 0;
  border-top: 2px solid #8b5cf6;
  border-bottom: 2px solid #8b5cf6;
  background: #faf5ff;
}
.report-section-delimiter span {
  font-size: 12px;
  font-weight: 700;
  color: #6d28d9;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.report-note-header {
  background: var(--gray-50);
  border-left: 3px solid #8b5cf6;
  padding: 8px 12px;
  margin: 14px 0 6px;
  border-radius: 0 6px 6px 0;
  font-size: 13px;
  color: var(--gray-700);
}
.report-note-header strong {
  color: #6d28d9;
}
.clinical-report-content h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  margin: 14px 0 6px;
}

/* Lock indicator hidden — Phase 1 */
.lock-indicator { display: none; }

/* Version History */
.version-history-section {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}
.version-history-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  user-select: none;
}
.version-history-header:hover { background: var(--gray-100); }
.version-badge {
  margin-left: auto;
  background: var(--blue);
  color: white;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 700;
}
.version-history-list { padding: 0 12px 12px; }
.version-item {
  display: block;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  margin-top: 8px;
  border: 1px solid transparent;
}
.version-item:hover { background: var(--gray-100); }
.version-item-current { background: var(--blue-light); font-weight: 600; cursor: pointer; border-color: #93c5fd; }
.version-item-current:hover { background: #dbeafe; }
.version-item-main { display: flex; flex-direction: column; gap: 6px; }
.version-item-topline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.version-number {
  font-weight: 700;
  font-size: 11px;
  color: var(--gray-500);
  background: var(--gray-100);
  border-radius: 999px;
  padding: 2px 7px;
}
.evolution-state-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #dbeafe;
  color: #1d4ed8;
  border-radius: 999px;
  padding: 3px 8px;
}
.evolution-state-badge-past {
  background: #f1f5f9;
  color: #475569;
}
.evolution-item-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
}
.evolution-item-detail {
  font-size: 12px;
  color: var(--gray-500);
  line-height: 1.5;
}
.evolution-diff-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.evolution-impact-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.evolution-impact-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 999px;
  padding: 3px 8px;
}
.evolution-impact-major {
  background: #fee2e2;
  color: #b91c1c;
}
.evolution-impact-minor {
  background: #e0f2fe;
  color: #075985;
}
.version-collapsed-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0;
  padding: 12px 14px;
  border: 1px dashed var(--gray-300);
  border-radius: 10px;
  background: var(--gray-50);
  color: var(--gray-600);
  font-size: 12px;
}
.version-history-toggle-inline {
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.version-history-toggle-inline:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}
.evolution-summary-text {
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-700);
}
.evolution-diff-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.evolution-diff-chip {
  font-size: 11px;
  font-weight: 600;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #334155;
  border-radius: 999px;
  padding: 4px 9px;
}
.evolution-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.evolution-trigger-text {
  font-size: 11px;
  color: var(--gray-500);
  line-height: 1.5;
}
.version-trigger { color: var(--gray-600); }
.version-notes-count {
  font-size: 11px;
  background: #ede9fe;
  color: #6d28d9;
  padding: 1px 6px;
  border-radius: 8px;
}
.version-note-labels {
  font-size: 10px;
  color: var(--gray-500);
  font-style: italic;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.version-date { font-size: 11px; color: var(--gray-400); white-space: nowrap; }

/* Version Detail Modal */
.modal-content-version-detail { width: 820px; max-height: 85vh; overflow-y: auto; }
.version-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 8px 24px;
  background: var(--gray-50);
  border-radius: 8px;
  font-size: 12px;
  color: var(--gray-600);
  margin-bottom: 16px;
}
#version-detail-body {
  font-size: 13px;
  line-height: 1.7;
  max-height: 60vh;
  overflow-y: auto;
  padding: 0 24px 8px;
}

/* ── Clinical report textarea ── */
.clinical-report-textarea {
  width: 100%;
  min-height: 400px;
  font-family: monospace;
  font-size: 13px;
  padding: 12px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  resize: vertical;
  box-sizing: border-box;
}

/* ── Save edits floating bar ── */
.save-edits-bar {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
  padding: 12px 20px;
  display: flex;
  gap: 10px;
  align-items: center;
  border-radius: 12px;
  z-index: 1000;
  animation: saveBarSlideIn 0.3s ease-out;
}
@keyframes saveBarSlideIn {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Version detail sections ── */
.version-section {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--gray-100);
}
.version-section:last-child {
  border-bottom: none;
}
.version-section:empty {
  display: none;
}
.version-section h4 {
  margin-bottom: 8px;
  color: var(--gray-600);
  font-size: 14px;
}
.version-classification-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ── Stale Analysis Banner ── */
.stale-analysis-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  margin: 8px 0;
  background: #fffbeb;
  border: 1px solid #fbbf24;
  border-left: 4px solid #f59e0b;
  border-radius: 8px;
}
.stale-analysis-banner.hidden { display: none; }
.stale-analysis-content {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.stale-analysis-content > i {
  color: #d97706;
  font-size: 18px;
  margin-top: 1px;
  flex-shrink: 0;
}
.stale-analysis-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stale-analysis-text strong { font-size: 13px; color: #92400e; }
.stale-analysis-text span { font-size: 12px; color: #a16207; }
.stale-analysis-banner .btn-action {
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Version Stale Dot ── */
.version-stale-dot {
  color: #d97706;
  font-size: 14px;
  margin-left: 4px;
}
.version-stale-dot.hidden { display: none; }

/* ── Deleted Notes in Context ── */
.notes-context-item-deleted {
  opacity: 0.6;
  border-style: dashed !important;
}
.notes-context-deleted-label {
  font-size: 11px;
  font-style: italic;
  color: #9ca3af;
  margin-left: auto;
}

/* ── Version Modal Deleted Notes Info ── */
.version-notes-deleted-info {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 8px 10px;
  background: #f3f4f6;
  border-radius: 6px;
  font-size: 12px;
  color: #6b7280;
}
.version-notes-deleted-info i {
  font-size: 14px;
  flex-shrink: 0;
}

/* ── Version History Help Text ── */
.version-history-help {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 16px 4px;
  font-size: 11px;
  color: var(--gray-400);
  line-height: 1.4;
}
.version-history-help.hidden { display: none; }
.version-history-help i { font-size: 13px; flex-shrink: 0; margin-top: 1px; }
.version-history-help-extra {
  margin-left: auto;
}

/* ── Version History Footer (Reset) ── */
.version-history-footer {
  padding: 6px 12px 10px;
  text-align: center;
  border-top: 1px solid var(--gray-200);
}
.version-history-footer.hidden { display: none; }
.btn-reset-history {
  background: none;
  border: none;
  color: var(--gray-400);
  font-size: 11px;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.btn-reset-history:hover {
  color: #dc2626;
  background: #fef2f2;
}
.btn-reset-history i { font-size: 12px; }

/* ── Document Upload ── */
.doc-card-body { margin-top: 6px; }
.doc-filename {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: 6px;
  word-break: break-all;
}
.doc-filename i { font-size: 18px; color: var(--gray-400); flex-shrink: 0; }
.doc-dates {
  display: flex;
  gap: 14px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--gray-500);
}
.doc-dates i { font-size: 13px; }
.doc-file-size {
  font-size: 11px;
  color: var(--gray-500);
  font-weight: 500;
}

/* File input styling */
input[type="file"].modal-input {
  padding: 10px 12px;
  background: var(--gray-50);
  cursor: pointer;
}
input[type="file"].modal-input::file-selector-button {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-right: 10px;
}
input[type="file"].modal-input::file-selector-button:hover {
  box-shadow: 0 2px 6px rgba(37,99,235,0.3);
}

.workspace-header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.btn-action-upload-doc {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: var(--white);
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}
.btn-action-upload-doc:hover { box-shadow: 0 3px 8px rgba(37,99,235,0.3); }
.workspace-documents-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-200);
}
.workspace-documents-section .workspace-panel-header h4 {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Document reanalysis banner */
.doc-reanalysis-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 100%);
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  font-size: 13px;
  color: #1e40af;
}
.doc-reanalysis-banner.hidden { display: none; }
.doc-reanalysis-banner i.spin-slow { animation: spin-slow 3s linear infinite; }
@keyframes spin-slow { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.btn-doc-reanalyze-now {
  margin-left: auto;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-doc-reanalyze-now:hover { background: #1d4ed8; }

/* Document viewer modal */
.modal-content-doc-viewer {
  width: 90vw;
  max-width: 1100px;
  height: 85vh;
  display: flex;
  flex-direction: column;
}
.doc-viewer-body {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-100);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}
.doc-viewer-body iframe {
  width: 100%;
  height: 100%;
  border: none;
}
.doc-viewer-body img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* ── Prescription Builder ── */
.modal-content-prescription {
  width: 820px;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-content-prescription .btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}
.modal-content-prescription .btn-secondary:hover {
  background: var(--gray-200);
  color: var(--gray-800);
}
.prescription-body {
  padding: 18px 24px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.prescription-patient-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f0f9ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 16px;
}
.prescription-patient-name { font-size: 15px; font-weight: 700; color: var(--gray-800); }
.prescription-patient-date { font-size: 13px; color: var(--gray-500); }

.rx-section-card {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--gray-200);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}
.rx-section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.rx-section-header-inline {
  margin-top: 14px;
}
.rx-section-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--gray-800);
}
.rx-section-subtitle {
  margin-top: 2px;
  font-size: 12px;
  color: var(--gray-500);
  line-height: 1.4;
}
.rx-summary-card {
  padding: 12px 14px;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}
.rx-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
}
.rx-summary-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.rx-summary-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.rx-summary-value {
  font-size: 13px;
  color: var(--gray-800);
  word-break: break-word;
}
.rx-template-bar { display: flex; gap: 8px; align-items: center; }
.rx-template-select { flex: 1; font-size: 13px; }
.rx-template-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.rx-template-edit-btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}
.rx-template-new-btn { flex-shrink: 0; }
.rx-template-context {
  margin-top: 6px;
  padding: 8px 12px;
  background: var(--blue-50, #eff6ff);
  border-left: 3px solid var(--primary, #2563eb);
  border-radius: 0 6px 6px 0;
  font-size: 12px;
  color: var(--gray-600);
  line-height: 1.4;
}
.rx-diagnosis-input {
  margin-bottom: 10px;
}
.rx-template-save-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}
.rx-template-delete-btn {
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.rx-editor-shell {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--blue-100, #dbeafe);
  border-radius: 14px;
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
}
.rx-template-editor {
  margin-top: 10px;
  padding: 14px;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
}
.rx-template-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--gray-700);
}
.rx-template-editor-status {
  font-size: 12px;
  color: var(--gray-500);
}
.rx-template-context-input {
  margin: 0;
  min-height: 74px;
}
.rx-template-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.rx-search-wrapper { position: relative; }
.rx-drug-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 0 0 8px 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  max-height: 280px;
  overflow-y: auto;
  z-index: 210;
}
.rx-drug-dropdown.hidden { display: none; }
.rx-drug-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
  transition: background 0.1s;
}
.rx-drug-item:hover { background: var(--gray-50); }
.rx-drug-item-name { font-weight: 600; font-size: 13px; color: var(--gray-800); }
.rx-drug-item-brand { font-size: 12px; color: var(--gray-500); margin-left: 6px; }
.rx-drug-item-group {
  display: inline-block;
  font-size: 10px;
  background: var(--gray-100);
  color: var(--gray-600);
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
}
/* Multi-dosage form selector */
.rx-drug-item-multi { padding: 0; }
.rx-drug-item-multi .rx-drug-item-header { padding: 10px 14px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.rx-dose-badge {
  font-size: 10px;
  background: var(--blue-100, #dbeafe);
  color: var(--primary, #2563eb);
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: auto;
  font-weight: 500;
}
.rx-dose-chips {
  display: none;
  padding: 6px 14px 10px;
  gap: 6px;
  flex-wrap: wrap;
  border-top: 1px dashed var(--gray-200);
  background: var(--gray-50, #f9fafb);
}
.rx-drug-item-multi.rx-expanded .rx-dose-chips { display: flex; }
.rx-dose-chip {
  display: inline-block;
  font-size: 12px;
  padding: 5px 12px;
  background: #fff;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--gray-700);
}
.rx-dose-chip:hover {
  background: var(--primary, #2563eb);
  color: #fff;
  border-color: var(--primary, #2563eb);
}

.rx-meds-container { margin-bottom: 14px; min-height: 60px; }
.rx-meds-empty { text-align: center; color: var(--gray-400); font-size: 13px; padding: 24px 0; }
.rx-meds-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rx-meds-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 6px;
  border-bottom: 2px solid var(--gray-200);
}
.rx-meds-table td { padding: 8px 6px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.rx-meds-table input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  font-size: 13px;
  font-family: inherit;
  padding: 4px 6px;
  border-radius: 4px;
  transition: border-color 0.15s;
}
.rx-meds-table input:hover,
.rx-meds-table input:focus { border-color: var(--gray-300); background: var(--gray-50); outline: none; }
.rx-med-name-cell { min-width: 140px; }
.rx-med-name-generic { font-weight: 600; color: var(--gray-800); font-size: 13px; }
.rx-med-name-brand { font-size: 11px; color: var(--gray-500); }
.rx-med-delete {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 4px;
}
.rx-med-delete:hover { color: #dc2626; background: #fef2f2; }
.rx-notes-textarea { min-height: 48px; margin: 0; resize: vertical; }
#btn-rx-preview {
  background: linear-gradient(135deg, #e0f2fe 0%, #dbeafe 100%);
  color: #0f4c81;
  border-color: #93c5fd;
}
#btn-rx-preview:hover {
  background: linear-gradient(135deg, #bae6fd 0%, #bfdbfe 100%);
  color: #0c4a6e;
}
#btn-rx-cancel {
  background: #f8fafc;
  color: var(--gray-700);
  border-color: var(--gray-300);
}
#btn-rx-cancel:hover {
  background: #e2e8f0;
  color: var(--gray-800);
}
.btn-action-prescription {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  color: var(--white);
  border-color: transparent;
}
.btn-action-prescription:hover { box-shadow: 0 3px 8px rgba(124,58,237,0.3); }

/* ── 1.1 Collapsible Cards ── */
.card-collapsible .card-header-row,
.card-collapsible > h3 {
  cursor: pointer;
  user-select: none;
}
.card-collapsible .card-header-row::before,
.card-collapsible > h3::before {
  content: '\ea5f'; /* ti-chevron-down */
  font-family: 'tabler-icons';
  font-size: 16px;
  color: var(--gray-400);
  transition: transform 0.25s ease;
  margin-right: 4px;
  flex-shrink: 0;
}
.card-collapsible.card-collapsed .card-header-row::before,
.card-collapsible.card-collapsed > h3::before {
  transform: rotate(-90deg);
}
.card-collapsible .card-body {
  transition: max-height 0.3s ease, opacity 0.2s ease;
  overflow: hidden;
}
.card-collapsible.card-collapsed .card-body {
  max-height: 0 !important;
  opacity: 0;
  margin: 0;
  padding: 0;
}
.card-collapsible .card-header-row {
  margin-bottom: 16px;
  padding-bottom: 10px;
}
.card-collapsible.card-collapsed .card-header-row,
.card-collapsible.card-collapsed > h3 {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom-color: transparent;
}

.card-section-classification .card-header-row h3,
.card-section-risk .card-header-row h3,
.card-section-report .card-header-row h3,
.card-section-summary .card-header-row h3,
.card-section-patient-summary .card-header-row h3,
#version-classification h4,
#version-flags h4,
#version-report h4,
#version-patient-summary h4 {
  width: 100%;
  text-align: left;
  justify-content: flex-start;
}
.card-section-report .card-header-row > div:first-child {
  flex: 1 1 auto;
  min-width: 0;
}

/* ── 1.2 Sticky Action Bar ── */
.action-bar {
  position: sticky;
  top: 0;
  z-index: 8;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border-bottom: 2px solid var(--gray-200);
}

/* ── 1.4 Toast z-index fix ── */
.toast-container {
  z-index: 10001;
}

/* ── 2.3 Simplified Score Gauges ── */
.score-gauge-bar-fill {
  background: none;
}
.gauge-green { background: #22c55e; }
.gauge-yellow { background: #eab308; }
.gauge-orange { background: #f97316; }
.gauge-red { background: #ef4444; }

/* ── 3.1 True Mobile Layout ── */
@media (max-width: 768px) {
  body.mobile-detail-open #sidebar { display: none; }
  body.mobile-detail-open #detail { display: block; }
  body:not(.mobile-detail-open) #sidebar { display: block; width: 100%; }
  body:not(.mobile-detail-open) #detail { display: none; }
  .mobile-back-btn { display: flex !important; }
}

/* ── 3.3 Mobile Bottom-Sheet Modals ── */
@media (max-width: 768px) {
  .modal-content {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 90vh;
    border-radius: 16px 16px 0 0;
    animation: sheetSlideUp 0.3s ease-out;
    margin: 0;
    width: 100%;
    max-width: 100%;
  }
  @keyframes sheetSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
  .modal-close {
    position: sticky;
    top: 0;
    right: 0;
    z-index: 2;
  }
}

/* ── 4.2 Processing Status Redesign ── */
.ai-processing-steps {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-400);
}
.ai-processing-step {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 16px;
  background: var(--gray-100);
  transition: all 0.3s ease;
}
.ai-processing-step.active {
  background: var(--blue-light);
  color: var(--blue);
}
.ai-processing-step.done {
  background: var(--green-bg);
  color: var(--green);
}
.ai-processing-step-arrow {
  color: var(--gray-300);
  font-size: 14px;
}
.ai-processing-eta {
  margin-top: 8px;
  font-size: 11px;
  color: var(--gray-300);
}

/* ── 4.3 Consult Workspace Clarity ── */
.card-section-next-actions {
  border-left: 4px dashed #0f766e;
  background: #f0fdfa;
}
.consult-exploratory-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 10px;
  background: #ccfbf1;
  color: #0f766e;
}
.consult-info-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f0fdfa;
  border: 1px dashed #99f6e4;
  border-radius: 8px;
  font-size: 12px;
  color: #115e59;
  margin-bottom: 12px;
}

/* ── 4.1 Inline Editing — Classification ── */
.class-item .badge[data-inline-editable] {
  cursor: pointer;
  transition: outline 0.15s, background 0.15s;
}
.class-item .badge[data-inline-editable]:hover {
  outline: 2px dashed #93c5fd;
  outline-offset: 2px;
}
.class-item .class-edit-select.inline-active {
  display: block !important;
  margin-top: 4px;
}

/* ── 5.1 WCAG Fixes ── */
.score-gauge-interp { font-weight: 600; }
.badge { position: relative; }
.flag-severity-text {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 4px;
}

/* ── 4.4 Batch Actions ── */
.sidebar-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--gray-100);
}
.sidebar-header-row h2 { margin: 0; padding: 0; border-bottom: none; }
.btn-batch-toggle {
  background: none;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--gray-400);
  font-size: 16px;
  transition: all 0.15s;
}
.btn-batch-toggle:hover { color: var(--blue); border-color: var(--blue); }
.btn-batch-toggle.active { color: var(--blue); background: var(--blue-light); border-color: var(--blue); }
.batch-actions-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--blue-light);
  border-bottom: 1px solid var(--gray-200);
  font-size: 12px;
}
.batch-count { font-weight: 600; color: var(--blue); flex: 1; }
.btn-batch-action {
  padding: 4px 10px;
  background: var(--blue);
  color: var(--white);
  border: none;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-batch-action:hover { opacity: 0.9; }
.btn-batch-cancel {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 14px;
  padding: 2px;
}
.patient-item .batch-checkbox {
  display: none;
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
  cursor: pointer;
  flex-shrink: 0;
}
body.batch-mode .patient-item .batch-checkbox { display: block; }
body.batch-mode .patient-item .patient-name { gap: 6px; }

/* ── 2.4 Missing Data Impact Callout ── */
.missing-data-callout {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #9a3412;
  line-height: 1.5;
  margin-bottom: 10px;
  list-style: none;
}
.missing-data-callout i {
  color: #f97316;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── 5.4 Loading Skeleton ── */
.skeleton-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 22px 26px;
  margin-bottom: 16px;
  border: 1px solid var(--gray-200);
}
.skeleton-line {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s infinite;
  margin-bottom: 10px;
}
.skeleton-line:last-child { margin-bottom: 0; }
.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 70%; }
@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
