/* fajr_scientific/patients/static/patients/css/fajr_unified.css */
/* Prevent overflow of long text in Smart View */
.patient-card,
.patient-card-body,
.patient-field .value {
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal !important;
  max-width: 100%;
}

.summary-block {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

/* Admin-like default edit view */
.admin-like-form .admin-section {
  margin-bottom: 1.25rem;
}

.admin-section-title {
  background: #79aec8;
  color: #fff;
  padding: 0.5rem 0.75rem;
  border-radius: 0.35rem;
  margin: 0 0 0.75rem 0;
  font-weight: 700;
  font-size: 0.95rem;
}

.admin-fieldset-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.admin-form-row {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.admin-form-row label {
  width: 220px;
  flex-shrink: 0;
  margin-top: 0.35rem;
}

.admin-form-row label.required::after {
  content: "*";
  color: #c00;
  margin-left: 4px;
}

.admin-field-widget {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.admin-field-widget input,
.admin-field-widget select,
.admin-field-widget textarea {
  width: 100%;
}

.admin-field-widget .help-text {
  margin: 0.1rem 0 0;
  color: #6b7280;
  font-size: 0.85rem;
}

.admin-form-row input[type="file"] {
  max-width: 320px;
}

/* Align clearable file inputs like Django admin */
.admin-field-widget .clearable-file-input {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  justify-content: flex-start;
}

.admin-field-widget .clearable-file-input label {
  display: inline-flex;
  align-items: center;
  margin: 0;
  gap: 0.25rem;
}

.admin-field-widget .clearable-file-input input[type="checkbox"] {
  margin: 0 0.2rem 0 0;
}

.admin-field-widget .clearable-file-input .file-upload {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.admin-field-widget .clearable-file-input br {
  display: none;
}

.admin-checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-checkbox-row label {
  width: auto;
  margin-top: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

/* =========================================================
   FAJR GLOBAL EMR — UNIFIED DESKTOP STYLESHEET
   fajr_unified.css
   ---------------------------------------------------------
   Depends on:
     - patients/css/theme.css       (tokens, colors, fonts)
     - patients/css/dark_mode.css  (optional dark theme)
   ---------------------------------------------------------
   Goals:
     - Full-width, stable layout at any zoom level
     - One consistent visual language for:
         • Top nav
         • Unified dashboard
         • Patient roster (card / table / sheet)
         • Patient profile + Full Medical View
         • Smart View
         • Patient editor
   ====================================================== */

/* ========== 1. GLOBAL LAYOUT & UTILITY ========== */

html {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  font-size: clamp(14px, 1vw, 18px);
}

body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body,
.unified-dashboard-container,
.dashboard-container,
.dashboard-main-grid,
.dashboard-roster-column,
.unified-toolbar,
.roster-toolbar,
.roster-controls,
.roster-quick-actions,
.dashboard-filter-row {
  max-width: 100% !important;
  overflow-x: hidden !important;
  min-width: 0 !important;
}

body.doctor-body {
  background: var(--color-bg-light, #f8fafc);
  font-family: var(--font-body, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
  color: var(--color-text, #1e293b);
  margin: 0;
}

/* Main content wrapper under topnav */
.fajr-main {
  width: 100%;
  min-height: calc(100vh - 64px); /* allow topnav to sit above */
  display: block;
}

/* Fluid pages (dashboards, ShamsGrid, Smart Search, etc.) */
.fajr-main.page-fluid {
  width: 100%;
  max-width: 100% !important;
  min-width: 0 !important;
  overflow-x: hidden !important;
  margin: 0;
  padding: clamp(1.25rem, 2vw, 1.75rem) clamp(1rem, 3vw, 2.25rem) 3rem;
}

/* “Max” pages (patient-centric, editor, smart view) */
.fajr-main.page-max {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 2rem 2.5rem 4rem;
}

.dashboard-container,
.dashboard-layout {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

/* Unified Dashboard layout */
.unified-dashboard-container {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: clamp(0.75rem, 2vw, 1.25rem) clamp(0.85rem, 3vw, 1.5rem) 3rem;
  overflow-x: hidden;
}

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

.dashboard-header h1 {
  margin: 0;
  font-size: clamp(1.6rem, 2.6vw, 2.4rem);
}

.dashboard-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dashboard-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.dashboard-hero-actions {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
}

.dashboard-title-stack h1 {
  margin: 0;
  font-size: clamp(1.7rem, 2.8vw, 2.5rem);
}

.dashboard-title-stack .muted {
  margin: 0;
}

.dashboard-main {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.dashboard-sidebar {
  position: relative;
  min-width: 0;
  max-width: 340px;
}

@media (min-width: 901px) {
  .dashboard-sidebar {
    position: sticky;
    top: 80px;
    align-self: flex-start;
  }
}

.dashboard-main-grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}

.dashboard-filter-column {
  position: relative;
  display: flex;
  align-items: stretch;
  width: var(--filter-width, 320px);
  min-width: 24px;
  max-width: 360px;
  transition: width 200ms ease;
  background: transparent;
  overflow: visible;
}

.dashboard-filter-panel-outer {
  width: 100%;
  max-width: 340px;
  background: transparent;
  border: none;
  overflow: hidden;
}

.dashboard-filter-column.collapsed {
  width: 32px;
}

.dashboard-filter-column.collapsed .dashboard-filter-panel-outer {
  display: none;
}

.filter-rail-toggle {
  position: absolute;
  top: 50%;
  left: 100%;
  right: auto;
  z-index: 2000;
  width: 34px;
  height: 38px;
  border-radius: 0 12px 12px 0;
  border: 1px solid #cbd5e1;
  background: linear-gradient(135deg, #ffffff, #eef2ff);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #4f46e5;
  transform: translate(-18px, -50%);
}

.dashboard-filter-column.collapsed .filter-rail-toggle {
  left: 100%;
  transform: translate(-18px, -50%);
}

.filter-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease;
  z-index: 99990;
}

.filter-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.dashboard-roster-column {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: hidden !important;
  min-width: 0 !important;
}

.dashboard-sidebar .dashboard-panel {
  margin-bottom: 1rem;
}

.dashboard-main,
.dashboard-main-grid,
.roster-content {
  min-width: 0;
  width: 100%;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(260px, 1.5fr);
  gap: clamp(1rem, 2vw, 1.25rem);
  width: 100%;
  max-width: none;
  margin: 0;
}

@media (max-width: 1300px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }
}

.dashboard-layout > *,
.dashboard-main-grid > * {
  min-width: 0 !important;
  max-width: 100% !important;
}

.unified-toolbar,
.roster-toolbar {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 0.75rem !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  overflow-x: hidden !important;
}

.unified-toolbar > *,
.roster-toolbar > * {
  min-width: 0 !important;
}

.roster-controls,
.roster-quick-actions {
  display: flex !important;
  flex-wrap: wrap !important;
  width: 100% !important;
  min-width: 0 !important;
}

.roster-controls > * {
  min-width: 0 !important;
}

/* Generic card shell */
.fajr-card {
  background: #fff;
  border-radius: 18px;
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.08);
  margin-bottom: 1.5rem;
}

/* Generic muted text */
.muted {
  color: #6b7280;
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

.dashboard-roster-column {
  position: relative;
}

.column-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: min(360px, 92vw);
  max-height: calc(100vh - 200px);
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.2);
  z-index: 200;
  overflow: hidden;
}

.column-drawer-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
}

.column-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.column-drawer-body {
  overflow-y: auto;
  max-height: calc(100vh - 340px);
  padding-right: 4px;
}

.column-drawer-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  border-top: 1px solid #e2e8f0;
  padding-top: 0.75rem;
}

.close-drawer-btn {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 1.2rem;
  cursor: pointer;
}

.column-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease;
  z-index: 150;
}

.column-backdrop.open {
  opacity: 1;
  visibility: visible;
}

@media (max-width: 1024px) {
  .column-drawer {
    position: fixed;
    top: 80px;
    right: 16px;
    left: 16px;
    width: auto;
    max-height: calc(100vh - 120px);
  }
}

/* Simple link button styles */
.btn-primary {
  background: #2563eb;
  color: #fff;
  padding: 0.7rem 1.3rem;
  border-radius: 0.8rem;
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
}

.btn-gradient {
  background: linear-gradient(120deg, #2563eb, #7c3aed);
  color: #fff;
  padding: 0.7rem 1.3rem;
  border-radius: 0.9rem;
  text-decoration: none;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  box-shadow: 0 16px 32px rgba(79, 70, 229, 0.25);
  cursor: pointer;
}

.btn-light {
  border: 1px solid #e5e7eb;
  padding: 0.5rem 1rem;
  border-radius: 0.8rem;
  text-decoration: none;
  color: #1f2937;
  background: #fff;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-ghost {
  border: 1px solid #e5e7eb;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  text-decoration: none;
  color: #1f2937;
  background: #fff;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.btn-ghost:hover {
  border-color: #c7d2fe;
  color: #312e81;
}

/* Full-width flex row for header sections */
.detail-header,
.doctor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.back-link {
  text-decoration: none;
  font-weight: 600;
  color: #1d4ed8;
}

/* Status badges (small pills) */
.status-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.status-badge {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
}

.status-badge.badge-success {
  background: rgba(34, 197, 94, 0.15);
  color: #15803d;
}

.status-badge.badge-warn {
  background: rgba(251, 191, 36, 0.2);
  color: #92400e;
}

.status-badge.badge-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #b91c1c;
}

/* ============================================================
   FAJR GLOBAL EMR — TOPNAV SYSTEM C (Hybrid Layout)
   Authoritative nav system. NOTHING overrides this.
   ============================================================ */

.fajr-topnav {
    width: 100%;
    background: linear-gradient(120deg, var(--color-primary), var(--color-purple));
    color: #fff;
    padding: 0.9rem 1.6rem;
    position: sticky;
    top: 0;
    z-index: 9999;
    box-shadow: 0 12px 28px rgba(15,23,42,0.25);
}

.fajr-topnav-inner {
    max-width: 1500px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 1.25rem;
}

/* LEFT — Brand */
.nav-left {
    flex: 0 0 auto;
    min-width: 0;
    display: flex;
    align-items: center;
}

.fajr-brand {
    display: flex;
    flex-direction: column;
    white-space: nowrap;
}

.fajr-brand .brand-title {
    font-weight: 800;
    font-size: 1.3rem;
}

.fajr-brand .brand-subtitle {
    font-size: 0.75rem;
    opacity: 0.85;
}

.role-badge {
    margin-top: 3px;
    background: rgba(255,255,255,0.25);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
}

/* CENTER — Search */
.nav-center {
    flex: 1 1 0;
    display: flex;
    justify-content: center;
    min-width: 320px;
}

.smart-search-form {
    width: min(600px, 100%);
    max-width: 100%;
    position: relative;
}

.smart-search-input {
    width: 100%;
    padding: 0.6rem 1rem;
    border-radius: 999px;
    border: none;
    background: rgba(255,255,255,0.2);
    color: #fff;
    font-size: 0.95rem;
    outline: none;
}

.smart-search-input::placeholder {
    color: rgba(255,255,255,0.85);
}

.smart-search-autocomplete {
    position: absolute;
    top: calc(100% + 6px);
    width: 100%;
    background: white;
    border-radius: 12px;
    padding: 8px 0;
    box-shadow: 0 12px 40px rgba(15,23,42,0.4);
    max-height: 360px;
    overflow-y: auto;
    z-index: 99999;
}

/* RIGHT — Links + Dark Mode + Lang */
.nav-right {
    flex: 0 1 40%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.65rem;
    row-gap: 0.35rem;
    min-width: 260px;
    max-width: 52%;
    margin-left: auto;
}

.nav-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    justify-content: flex-end;
    min-width: 220px;
    max-width: 100%;
    flex: 1 1 auto;
}

.nav-link {
    background: rgba(255,255,255,0.15);
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    color: #fff;
    text-decoration: none;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-link.active {
    background: #fff;
    color: var(--color-primary);
}

/* Dropdown */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    background: rgba(255,255,255,0.15);
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    cursor: pointer;
    color: #fff;
    font-size: 0.85rem;
}

.nav-dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: rgba(0,0,0,0.9);
    border-radius: 12px;
    padding: 8px;
    display: none;
    flex-direction: column;
    gap: 4px;
    min-width: 220px;
    z-index: 99999;
}

.nav-dropdown.open .nav-dropdown-menu {
    display: flex;
}

.nav-dropdown-menu .nav-link {
    background: transparent;
    border-radius: 8px;
}

.nav-dropdown-menu .nav-link:hover {
    background: rgba(255,255,255,0.15);
}

/* Actions (Dark / Lang / Quick-add) */
.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.dark-toggle,
.lang-toggle,
.nav-quick-add {
    border-radius: 999px;
    background: rgba(255,255,255,0.25);
    padding: 0.35rem 0.7rem;
    cursor: pointer;
    color: #fff;
}

/* Mobile */
@media (max-width: 900px) {

    .fajr-topnav-inner {
        flex-wrap: wrap;
        row-gap: 0.75rem;
    }

    .nav-center {
        order: 3;
        flex: 1 0 100%;
    }

    .nav-right {
        order: 4;
        flex: 1 0 100%;
        justify-content: flex-end;
        flex-wrap: wrap;
    }
}

/* ========== 3. UNIFIED DASHBOARD & ROSTER ========== */

/* Wrapper when using patient_dashboard_stats + unified patient roster */
.dashboard-wrapper {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Metrics blocks used on admin + unified dashboard */
.dashboard-panel {
  background: #ffffff;
  border-radius: 1.2rem;
  border: 1px solid #e2e8f0;
  padding: 1.5rem;
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.08);
}

.panel-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.panel-eyebrow,
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: #6366f1;
  font-size: 0.75rem;
  margin-bottom: 0.35rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.9rem;
  margin-top: 1.25rem;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.metric-card {
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  padding: clamp(0.35rem, 0.7vw, 0.7rem);
  text-decoration: none;
  color: inherit;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  font-size: clamp(0.75rem, 0.9vw, 1rem);
  min-width: 120px;
  flex: 1 1 auto;
  position: relative;
  cursor: pointer;
  pointer-events: auto;
}

.metric-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 15px 35px rgba(15, 23, 42, 0.15);
}

.metric-card.warning {
  border-color: #fbd38d;
  background: #fffbeb;
}
.metric-card.danger {
  border-color: #fecaca;
  background: #fef2f2;
}

.metric-icon {
  font-size: 1.05rem;
  font-weight: 600;
}

.metric-label {
  text-transform: uppercase;
  font-size: 0.7rem;
  color: #64748b;
  letter-spacing: 0.1em;
}

.metric-value {
  font-size: clamp(1.15rem, 1.6vw, 1.6rem);
  font-weight: 600;
}

.dashboard-metrics-row {
  display: flex;
  flex-wrap: nowrap;
  width: 100%;
  max-width: 100%;
  gap: 12px;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.35rem 0;
}

.metric-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.08);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  appearance: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.metric-pill .metric-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  color: #4b5563;
}

.metric-pill .metric-icon {
  font-size: 15px;
}

.metric-pill.active {
  background: linear-gradient(120deg, #eef2ff, #f3f0ff);
  border-color: #4f46e5;
  box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.25), 0 10px 20px rgba(79, 70, 229, 0.15);
}

.metric-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(15, 23, 42, 0.12);
}

.metric-add-btn {
  margin-left: auto;
  border-radius: 999px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #4f46e5;
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(79, 70, 229, 0.2);
}

.dashboard-filter-row {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)) !important;
  gap: 0.75rem !important;
  width: 100% !important;
  max-width: 100% !important;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  box-shadow: 0 12px 22px rgba(15, 23, 42, 0.08);
  overflow-x: hidden !important;
}

.dashboard-filter-row * {
  min-width: 0 !important;
  width: 100% !important;
}

.filter-row-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100% !important;
}

.filter-row-search input {
  width: 100%;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  font-size: 0.95rem;
}

.filter-row-select {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100% !important;
}

.filter-row-select label {
  font-weight: 600;
  font-size: 0.85rem;
  color: #475569;
}

.filter-row-select select {
  width: 100% !important;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  padding: 0.45rem 0.65rem;
  background: #f8fafc;
  font-weight: 600;
}

.filter-row-clear {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: 100% !important;
}

/* Patient filters + table */
.dashboard-filter-panel {
  padding: 1rem;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
  min-height: 100%;
  box-shadow: none;
  overflow-y: auto;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.filter-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.filter-panel-header h3 {
  margin: 0;
  font-size: 1rem;
}

.filter-panel-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-reset {
  padding: 0.35rem 0.65rem;
}

.filter-close-btn {
  display: inline-flex;
}

.dashboard-filter-panel details summary {
  font-weight: 600;
  cursor: pointer;
  padding: .5rem 0;
  font-size: 0.95rem;
}

.dashboard-filter-panel ul {
  list-style: none;
  margin: 0;
  padding-left: .75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.dashboard-filter-panel li {
  margin-bottom: 4px;
}

.dashboard-filter-panel li a {
  display: block;
  padding: .25rem 0;
  color: #1f2937;
  font-size: .9rem;
  font-weight: 600;
}

.dashboard-filter-panel li a:hover {
  text-decoration: underline;
}

.dashboard-filter-panel li a.active {
  color: #312e81;
}

.admin-search {
  margin-bottom: 1rem;
  width: 100%;
}

.search-input {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  width: 100%;
  min-width: 0;
}

.search-input input {
  flex: 1 1 auto;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  font-size: 0.95rem;
  min-width: 0;
}

.search-input button {
  border: none;
  background: linear-gradient(120deg, #1d4ed8, #7c3aed);
  color: #fff;
  padding: 0.55rem 0.9rem;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  flex-shrink: 0;
}

.filter-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.75rem;
}

/* Legacy filters layout (other roster views) */
.filters-panel {
  width: min(360px, 100%);
  flex-shrink: 0;
  position: sticky;
  top: 110px;
}

.table-panel {
  flex: 1;
  min-width: 0;
}

.filter-drawer-header {
  display: none;
}

body.drawer-open {
  overflow: hidden;
}

@media (max-width: 1023px) {
  .dashboard-main-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-filter-column {
    position: fixed;
    inset: 0;
    width: min(420px, 90vw);
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 300ms ease;
    z-index: 99999;
    background: #fff;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.4);
    display: block;
    max-width: none;
  }

  .dashboard-filter-column.open {
    transform: translateX(0);
  }

  .dashboard-filter-column.collapsed {
    width: min(420px, 90vw);
  }

  .dashboard-filter-panel-outer {
    height: 100%;
    max-width: none;
    border-radius: 0;
    box-shadow: none;
  }

  .filter-rail-toggle {
    display: none;
  }
}

/* Unified roster table */
.table-card {
  padding: 1.25rem;
}

.table-header h3 {
  margin: 0;
}

.table-responsive {
  width: 100%;
  max-width: 100% !important;
  overflow-x: auto !important;
}

.table-scroll {
  width: 100%;
  max-width: 100% !important;
  overflow-x: auto !important;
}

.fajr-table {
  width: max-content;
  border-collapse: separate;
  border-spacing: 0;
}

/* Long text clamping in roster cells */
.fajr-table .cell-text {
  display: block;
  width: 100%;
  max-width: 320px;
  min-width: 0;
  word-break: break-word;
  border: none;
  outline: none;
}
.fajr-table .cell-text.clamped {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fajr-table .cell-text.expanded,
.fajr-table .cell-text-expanded {
  white-space: normal;
  width: 100%;
  max-width: 320px;
  display: block;
  margin-top: 4px;
  word-break: break-word;
  border: none;
  outline: none;
}
.cell-expand-btn {
  background: none;
  border: none;
  color: #2563eb;
  cursor: pointer;
  padding: 0;
  margin-top: 4px;
  font-size: 0.8rem;
}

.fajr-table thead th {
  position: sticky !important;
  top: 0;
  left: 0;
  background: #fff;
  z-index: 1;
  max-width: 100% !important;
  box-sizing: border-box !important;
  text-align: left;
  font-size: 0.85rem;
  color: #6b7280;
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid #e5e7eb;
}
.fajr-table thead th:first-child,
.fajr-table tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
}

.fajr-table tbody td {
  padding: 0.85rem 0.5rem;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.95rem;
}

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

.table-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Color chips consistent with admin */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: #eef2ff;
  color: #312e81;
}

.status-green {
  background: #dcfce7;
  color: #166534;
}

.status-yellow {
  background: #fef9c3;
  color: #854d0e;
}

.status-purple {
  background: #ede9fe;
  color: #5b21b6;
}

.empty-table-state {
  padding: 1rem;
  text-align: center;
  color: #6b7280;
}

.roster-shell {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.roster-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.roster-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.roster-meta {
  font-size: 0.95rem;
}

.roster-quick-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.roster-quick-actions .pill {
  background: #eef2ff;
  color: #312e81;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  font-size: 0.85rem;
  font-weight: 600;
}

.roster-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(320px, 1fr));
  gap: 24px;
  align-items: stretch;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.roster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  align-items: stretch;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.roster-card {
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  padding: clamp(0.5rem, 1vw, 1rem);
  background: #fff;
  box-shadow: 0 18px 32px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  min-width: 220px;
  flex: 1 1 auto;
  min-width: 0;
}

.roster-card.success {
  background: linear-gradient(180deg, #f0fdf4, #fff);
}

.roster-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.roster-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.roster-card-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.column-selector {
  border: 1px dashed #e2e8f0;
  padding: 1rem;
  border-radius: 1rem;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.column-selector__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.column-selector__grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)) !important;
  gap: 0.5rem !important;
  width: 100% !important;
  min-width: 0 !important;
  overflow-x: hidden !important;
}

.column-chip {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.85rem;
  background: #fff;
  font-weight: 600;
  cursor: grab;
  user-select: none;
  min-width: 0 !important;
  max-width: 100%;
  word-break: break-word;
}

.column-chip input {
  width: 16px;
  height: 16px;
}

@media (max-width: 900px) {
  .column-selector {
    display: none;
  }
  .column-selector.open {
    display: block;
  }
}

@media (max-width: 1200px) {
  .roster-card-grid {
    grid-template-columns: repeat(2, minmax(280px, 1fr));
  }
}

@media (max-width: 768px) {
  .roster-controls {
    flex-direction: column;
    align-items: flex-start;
  }
  .roster-card-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .dashboard-hero-actions {
    justify-content: space-between;
  }
  .filter-row-select {
    flex: 1 1 calc(50% - 0.85rem);
  }
  .filter-row-clear {
    width: 100%;
    justify-content: flex-end;
  }
}

.editable-value {
  display: inline-flex;
  min-width: 80px;
}

.patient-table td[data-editable] {
  cursor: pointer;
  position: relative;
}

.patient-table td.editing {
  background: #eef2ff;
}

.inline-editor {
  width: 100%;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  font-size: 0.9rem;
  box-shadow: 0 8px 14px rgba(79, 70, 229, 0.1);
}

.inline-editor:focus {
  outline: 2px solid #818cf8;
}

.cell-title {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

/* === 3A. MEDEVAC ROSTER (doctor_patient_list) ================= */

.medevac-roster {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.doctor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  margin-bottom: 2rem;
}

.doctor-header .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: #6366f1;
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
}

.doctor-header h1 {
  margin: 0;
  font-size: 2rem;
}

.doctor-header .subtitle {
  color: #6b7280;
  margin-top: 0.25rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.active-count {
  display: flex;
  flex-direction: column;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 0.5rem 1.25rem;
  background: #fff;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.08);
}

.active-count .count {
  font-size: 2rem;
  font-weight: 600;
}

.btn-outline {
  border: 1px solid var(--color-primary, #2563eb);
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  color: var(--color-primary, #2563eb);
  text-decoration: none;
  background: #fff;
  font-weight: 600;
}

.btn-quick-add {
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  background: linear-gradient(120deg, #a855f7, #3b82f6);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.view-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.view-mode-buttons {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.75rem;
}

.view-mode-btn {
  border: 1px solid rgba(37, 99, 235, 0.4);
  background: #fff;
  color: #1d4ed8;
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.view-mode-btn.active {
  background: linear-gradient(120deg, #2563eb, #7c3aed);
  color: #fff;
  box-shadow: 0 10px 25px rgba(59, 130, 246, 0.25);
}

.medevac-roster .filters-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
  position: static;
  width: 100%;
}

.medevac-roster .filters-panel input,
.medevac-roster .filters-panel select {
  padding: 0.4rem 0.7rem;
  border-radius: 0.6rem;
  border: 1px solid #d1d5db;
  min-width: 150px;
}

.grid-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.column-menu {
  position: relative;
}

.column-menu button {
  padding: 0.45rem 0.9rem;
  border-radius: 0.6rem;
  border: 1px solid #d1d5db;
  background: #fff;
}

.column-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: #fff;
  border-radius: 0.8rem;
  box-shadow: 0 15px 40px rgba(15, 23, 42, 0.15);
  padding: 0.8rem;
  display: none;
  flex-direction: column;
  gap: 0.3rem;
  z-index: 20;
  min-width: 180px;
}

.column-dropdown.open {
  display: flex;
}

.doctor-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

.clinical-card {
  position: relative;
  padding: 1rem 1.05rem;
  border-radius: 1rem;
  background: #f8fbff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
  border-left: 3px solid transparent;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.25s ease;
  min-width: 0;
  word-break: break-word;
}

.clinical-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.12);
  border-color: #2563eb;
}

.clinical-card h3 {
  margin: 0;
  font-weight: 700;
  word-break: break-word;
}

.clinical-card.highlight {
  border-color: #22c55e;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.1);
}

.condition-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.condition-badge {
  border-radius: 999px;
  padding: 0.2rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  background: #eef2ff;
  color: #475569;
}

.urgency-pill {
  position: absolute;
  top: 1rem;
  right: 1rem;
  border-radius: 999px;
  padding: 0.2rem 0.75rem;
  font-weight: 700;
  color: #fff;
}

.urgency-pill.urgent {
  background: #dc2626;
}

.urgency-pill.routine {
  background: #facc15;
  color: #1f2937;
}

.destination-line {
  display: flex;
  align-items: center;
  margin-top: 0.75rem;
  gap: 0.4rem;
  color: #475569;
}

.action-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: 999px;
  background: linear-gradient(120deg, rgba(42, 127, 240, 0.12), rgba(123, 97, 255, 0.15));
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  width: 100%;
  min-width: 0;
}

.action-btn {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  color: #fff;
  text-decoration: none;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  min-width: 38px;
  flex: 0 0 38px;
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.2);
}

.action-btn .tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  border-radius: 0.4rem;
  white-space: normal;
  max-width: 220px;
  text-align: center;
  word-break: break-word;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  display: none;
  z-index: 5;
}

.action-btn:hover .tooltip {
  opacity: 1;
  transform: translate(-50%, -2px);
  display: block;
}

.icon-purple { background: linear-gradient(135deg, #a855f7, #7c3aed); }
.icon-blue { background: linear-gradient(135deg, #60a5fa, #2563eb); }
.icon-green { background: linear-gradient(135deg, #34d399, #10b981); }
.icon-teal { background: linear-gradient(135deg, #2dd4bf, #0d9488); }
.icon-navy { background: linear-gradient(135deg, #1e3a8a, #1d4ed8); }
.icon-orange { background: linear-gradient(135deg, #f97316, #ea580c); }
.icon-pink { background: linear-gradient(135deg, #fb7185, #ec4899); }
.icon-yellow { background: linear-gradient(135deg, #facc15, #eab308); color: #1f2937; }
.icon-indigo { background: linear-gradient(135deg, #818cf8, #4338ca); }
.icon-gray { background: linear-gradient(135deg, #94a3b8, #475569); }

.patient-grid-table {
  width: 100%;
  border-collapse: collapse;
  border-radius: 14px;
  overflow: hidden;
  background: #f8fbff;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.08);
  margin-top: 1rem;
}

.patient-grid-table th {
  background: linear-gradient(120deg, var(--color-primary, #2563eb), var(--color-purple, #7c3aed));
  color: #fff;
  padding: 12px;
  font-weight: 600;
  text-align: left;
  position: sticky;
  top: 0;
}

.patient-grid-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
}

.action-icons a {
  margin-right: 8px;
  font-size: 18px;
  transition: transform 0.2s ease;
  position: relative;
}

.action-icons a:hover {
  transform: translateY(-2px);
}

/* Simple tooltips for table action icons */
.patient-grid-table .action-icons a::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: #0f172a;
  color: #fff;
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  border-radius: 0.4rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.25);
  z-index: 10;
}

.patient-grid-table .action-icons a:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.hover-elevate {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-elevate:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 35px rgba(15, 23, 42, 0.12);
}

.slide-up {
  animation: fajr-fadein 0.4s ease-out;
}

.toast-stack {
  margin-bottom: 1rem;
}

.toast-item {
  padding: 0.6rem 0.8rem;
  border-radius: 0.8rem;
  margin-bottom: 0.3rem;
  background: #e0f2fe;
}

.toast-item.success { background: #d1fae5; }
.toast-item.error { background: #fee2e2; }

/* === 3B. SHEET VIEW (Excel-like) =============================== */

.doctor-sheet-container {
  width: 100%;
  border-radius: 1rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.08);
  overflow: visible;
  margin-top: 1.25rem;
}

.doctor-sheet-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e5e7eb;
}

.doctor-sheet-grid {
  display: block;
  overflow-x: auto;
  overflow-y: hidden;
  width: 100%;
  position: relative;
}

.doctor-sheet-grid table {
  table-layout: fixed !important;
}

.doctor-sheet-grid td {
  white-space: normal !important;
  word-break: break-word !important;
  overflow-wrap: break-word !important;
  max-width: 260px !important;
  min-width: 120px;
  padding: 6px 10px;
}

.doctor-sheet-grid th {
  max-width: 260px !important;
  white-space: normal !important;
  word-break: break-word !important;
}

.doctor-sheet-grid .doctor-sheet-table {
  width: max-content;
  min-width: 100%;
}

#doctor-sheet-grid {
  position: relative;
  overflow-x: auto;
  overflow-y: auto;
}

.doctor-sheet-container.fullscreen,
.doctor-sheet-container.doctor-sheet-fullscreen {
  position: fixed;
  z-index: 1100;
  top: 70px;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 0;
  background: #fff;
  max-width: none;
  max-height: none;
  border-radius: 1rem;
  box-shadow: 0 40px 90px rgba(15, 23, 42, 0.2);
  overflow: auto;
}

.doctor-sheet-container.fullscreen .doctor-sheet-grid,
.doctor-sheet-container.doctor-sheet-fullscreen .doctor-sheet-grid {
  height: calc(100vh - 140px);
}

body.doctor-sheet-no-scroll {
  overflow: hidden;
}

.doctor-sheet-container.doctor-sheet-fullscreen {
  position: fixed !important;
  top: 70px !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  max-width: 100vw !important;
  height: calc(100vh - 70px) !important;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 0 !important;
  z-index: 1100 !important;
  background: #ffffff !important;
  overflow: auto !important;
}

body.doctor-sheet-no-scroll .page-max,
body.doctor-sheet-no-scroll .doctor-container {
  max-width: 100vw !important;
  margin: 0 !important;
  padding: 0 !important;
}

.doctor-sheet-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1200px;
  font-size: 0.95rem;
  table-layout: auto;
}

.doctor-sheet-table th,
.doctor-sheet-table td {
  border: 1px solid #e5e7eb;
  padding: 0.55rem 0.65rem;
  white-space: nowrap;
  background: #fff;
  min-width: 120px;
}

/* === Unified Column Width Override (Fix Sticky Drift) ===
   Every column cell that belongs to a real data column now gets
   the SAME width across:
     • letter-row (A, B, C...)
     • group-row (section header)
     • label-row (field labels)
     • body cells
   This eliminates horizontal drift permanently.
*/
.doctor-sheet-table th[data-sheet-column],
.doctor-sheet-table td[data-sheet-column] {
  box-sizing: border-box;
  width: 140px;
  min-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===========================================
   SHEET VIEW — CUSTOM COLUMN WIDTH OVERRIDES
   =========================================== */

/* Wider columns by default (I, G, Q, R, S) */
.doctor-sheet-table th[data-col="I"],
.doctor-sheet-table td[data-col="I"],
.doctor-sheet-table th[data-col="G"],
.doctor-sheet-table td[data-col="G"],
.doctor-sheet-table th[data-col="Q"],
.doctor-sheet-table td[data-col="Q"],
.doctor-sheet-table th[data-col="R"],
.doctor-sheet-table td[data-col="R"],
.doctor-sheet-table th[data-col="S"],
.doctor-sheet-table td[data-col="S"] {
    width: 240px !important;
    min-width: 240px !important;
    max-width: 240px !important;
}

/* T, U = 3× wider — long text columns */
.doctor-sheet-table th[data-col="T"],
.doctor-sheet-table td[data-col="T"],
.doctor-sheet-table th[data-col="U"],
.doctor-sheet-table td[data-col="U"] {
    width: 480px !important;
    min-width: 480px !important;
    max-width: 480px !important;
    white-space: normal !important;
    overflow-wrap: break-word !important;
}

/* AK and AS – wider travel/visa sections */
.doctor-sheet-table th[data-col="AK"],
.doctor-sheet-table td[data-col="AK"],
.doctor-sheet-table th[data-col="AS"],
.doctor-sheet-table td[data-col="AS"] {
    width: 360px !important;
    min-width: 360px !important;
    max-width: 360px !important;
}

/* ===========================================
   STICKY: Letter Row + Group Row + Label Row
   =========================================== */

.doctor-sheet-table thead th {
    position: sticky;
    top: 0;
    z-index: 40;
}

/* Group row (2nd header row) */
.doctor-sheet-table thead tr.group-row th {
    top: 32px;  /* height of letter row */
    z-index: 39;
}

/* Label row (3rd header row) */
.doctor-sheet-table thead tr.label-row th {
    top: 64px;  /* height of first + second row */
    z-index: 38;
}

/* Ensure header backgrounds stay visible */
.doctor-sheet-table thead th {
    background: #f8fafc !important;
}

.doctor-sheet-table thead th {
  background: #f8fafc;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.doctor-sheet-table th.sheet-letter {
  background: #e2e8f0;
  font-weight: 600;
  text-transform: none;
}

.doctor-sheet-table th.sheet-group-cell {
  background: #e5e7eb;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
  padding: 0.4rem 0.6rem;
  border: 1px solid #d7dce3;
  white-space: nowrap;
}

.doctor-sheet-table thead tr.label-row th {
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  line-height: 1.25;
  vertical-align: bottom;
}

.doctor-sheet-table tbody tr:nth-child(odd) {
  background: #fdfefe;
}

.doctor-sheet-table tbody tr:hover td {
  background: #f1f5f9;
}

.doctor-sheet-table .sticky {
  position: sticky;
  z-index: 2;
  background: #f8fafc;
}

.doctor-sheet-table .sticky-id {
  position: sticky;
  z-index: 3;
  background: #f8fafc;
}

.doctor-sheet-table .sheet-gutter {
  width: 48px;
  min-width: 48px;
  text-align: center;
  font-weight: 600;
  color: #475569;
  background: #eef2ff;
  border-right: 1px solid #cbd5e1;
}

.doctor-sheet-table .hidden-column {
  display: none;
}

.sheet-row-actions {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.sheet-row-actions a {
  text-decoration: none;
  font-size: 1rem;
}

.sheet-show-more {
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 6px;
  padding: 0.15rem 0.45rem;
  cursor: pointer;
}

.sheet-detail-row td {
  background: #f8fafc;
}

.sheet-detail {
  padding: 0.75rem 0.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.35rem 0.75rem;
  color: #475569;
}

.sheet-cell-updated {
  animation: sheetUpdatedFlash 1.5s ease-out;
}

@keyframes sheetUpdatedFlash {
  0% { background: #dbeafe; }
  100% { background: transparent; }
}

.sheet-column-map {
  margin: 1rem 0 1.5rem;
  padding: 1rem 1.25rem;
  border: 1px dashed #cbd5e1;
  border-radius: 0.9rem;
  background: #f8fafc;
  color: #0f172a;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

.sheet-column-map h4 {
  margin: 0 0 0.35rem 0;
  font-size: 1rem;
}

.sheet-column-map pre {
  margin: 0;
  font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.88rem;
  white-space: pre-wrap;
  line-height: 1.25;
}

.col-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 10px;
  height: 100%;
  cursor: col-resize;
  opacity: 0;
  transition: opacity 0.1s ease;
}

.doctor-sheet-table th:hover .col-resize-handle {
  opacity: 1;
}

/* ========== 4. PATIENT DETAIL (SMART PROFILE) ========== */

.doctor-container {
  width: 100%;
  max-width: 1300px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* sticky header row inside patient detail */
.sticky-patient-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

/* Smart vs Full toggle chips */
.view-toggle-medical {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 1.5rem 0 1rem;
}

.med-toggle {
  border: 1px solid rgba(15, 23, 42, 0.15);
  background: #fff;
  color: #0f172a;
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.med-toggle.active {
  background: linear-gradient(120deg, #2563eb, #7c3aed);
  color: #fff;
  box-shadow: 0 12px 24px rgba(79, 70, 229, 0.35);
}

/* Overview vs Specialties tabs */
.patient-tab-bar {
  display: flex;
  gap: 0.5rem;
  margin: 1.5rem 0;
}

.tab-chip {
  border: 1px solid rgba(15, 23, 42, 0.15);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  color: #1f2937;
}

.tab-chip.active {
  background: linear-gradient(120deg, #2563eb, #7c3aed);
  color: #fff;
  box-shadow: 0 10px 20px rgba(79, 70, 229, 0.3);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Editable inline fields */
.inline-field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.75rem;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #f8fafc;
  border-radius: 0.75rem;
}

.field-label {
  font-weight: 600;
  flex: 0 0 45%;
  color: #475569;
}

.field-value {
  flex: 1;
  color: #0f172a;
}

.field-edit-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.95rem;
}

/* Specialties chips */
.specialty-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.specialty-chip {
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.15);
  color: #4338ca;
  font-weight: 600;
}

/* Patient cards grid */
.patient-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
}

/* could be changed to 2-cols for very wide screens if desired */
/*
@media (min-width: 1440px) {
  .patient-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
*/

.patient-card {
  background: #fff;
  border-radius: 1rem;
  border: 1px solid #e5e7eb;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.05);
}

.patient-card.full-width {
  grid-column: 1 / -1;
}

.patient-section-title {
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 600;
  color: #111827;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.patient-section-title .section-icon-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-icon-title span:first-child {
  font-size: 1.1rem;
}

.patient-card-body {
  padding: 1.2rem;
}

/* One-line field row */
.patient-field {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.6rem;
  gap: 0.75rem;
}

.patient-field .label {
  flex: 0 0 30%;
  font-weight: 600;
  color: #6b7280;
}

.patient-field .value {
  flex: 1;
  text-align: right;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

/* Long text field rows (notes, progress, etc.) */
.patient-field-long {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.25rem;
  margin-bottom: 0.8rem;
}

.patient-field-long .label {
  color: #6b7280;
  font-weight: 600;
}

.patient-field-long .value {
  color: #111827;
  background: #f9fafb;
  border-radius: 0.75rem;
  padding: 0.6rem 0.75rem;
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* Attachments */
.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.attachment-tile {
  border: 1px dashed #c7d2fe;
  border-radius: 0.9rem;
  padding: 0.75rem;
  text-align: center;
  background: #f8fafc;
}

.attachment-tile img,
.attachment-tile video {
  width: 100%;
  border-radius: 0.75rem;
  margin: 0.5rem 0;
}

.tile-label,
.attachment-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #4c1d95;
  text-transform: uppercase;
}

/* Diagnostic tables */
.lab-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}

.lab-table th,
.lab-table td {
  border-bottom: 1px solid #e5e7eb;
  padding: 0.5rem 0.5rem;
  text-align: left;
  font-size: 0.9rem;
}

.lab-flag {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.lab-flag-high,
.lab-flag-critical {
  background: rgba(220, 38, 38, 0.15);
  color: #b91c1c;
}

.lab-flag-low {
  background: rgba(59, 130, 246, 0.15);
  color: #1d4ed8;
}

/* Encounter/procedure rows */
.order-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #f1f5f9;
  padding: 0.6rem 0;
}

/* Care coordination row */
.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
  flex-wrap: wrap;
  width: 100%;
  min-width: 0;
}

/* ========== 5. FULL MEDICAL VIEW SHELL (FMV) ========== */

.full-medical-view .patient-detail-grid {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.full-medical-view .patient-card {
  width: 100%;
}

.scroll-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.long-text {
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* ========== 6. PATIENT EDITOR (FULL PAGE) ========== */

.editor-drawer-form .editor-section + .editor-section {
  margin-top: 1rem;
}

/* Use same patient-detail-grid / patient-card for editor; fields replaced by <input>/<select>/<textarea> */

.editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* ========== 7. SMART VIEW ========== */

.smartview-body {
  background: var(--color-bg-light, #f8fafc);
}

/* Smart view layout runs in page-max or page-fluid; here we just set inner width */
.smartview-layout {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  display: grid;
  gap: 1.5rem;
}

/* Hero header */
.smartview-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--color-white, #fff);
  padding: 1.5rem;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.hero-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Quick action chips under hero */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.quick-action {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.08);
  color: #0f172a;
  font-weight: 600;
}

/* Section nav (Summary, Alerts, Timeline, etc.) */
.smartview-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.smartview-nav a {
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: rgba(42, 127, 240, 0.08);
  text-decoration: none;
  color: var(--color-text, #1e293b);
  font-weight: 600;
}

/* Core cards */
.smartview-card {
  background: var(--color-white, #fff);
  border-radius: var(--radius-card);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.smartview-card .eyebrow,
.smartview-hero .eyebrow,
.summary-pill .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.75rem;
  color: var(--color-slate);
}

/* Summary layout */
.summary-grid,
.scroll-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
}

.summary-pill,
.mini-card {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: var(--radius-card);
  padding: 1rem;
  background: var(--color-bg-light, #f8fafc);
}

.long-text {
  max-height: 220px;
  overflow-y: auto;
  padding-right: 0.5rem;
  white-space: pre-wrap;
}

/* Alerts */
.alert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.alert-pill {
  border-radius: var(--radius-card);
  padding: 1rem;
  color: #fff;
}

.alert-pill.alert-danger {
  background: var(--color-danger, #dc2626);
}

.alert-pill.alert-warning {
  background: var(--color-warning, #f4b400);
  color: #1f2937;
}

/* Smart groups (identity / logistics / clinical) */
.smartview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1rem;
}

.grid-fields {
  display: grid;
  gap: 0.75rem;
}

/* Label/value rows inside Smart View */
.data-field {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.data-field .label {
  flex: 0 0 40%;
  max-width: 260px;
  font-weight: 600;
  color: var(--color-slate, #6b7280);
}

.data-field .value {
  flex: 1;
  min-width: 0;
  text-align: right;
}

/* Timeline chips */
.timeline-strip {
  display: flex;
  overflow-x: auto;
  gap: 1rem;
}

.timeline-chip {
  min-width: 150px;
  border-radius: var(--radius-card);
  padding: 0.8rem;
  background: rgba(123, 97, 255, 0.08);
}

/* Collapse behavior for cards */
.collapse-toggle {
  border: none;
  background: transparent;
  cursor: pointer;
  font-weight: 600;
  color: var(--color-primary, #2a7ff0);
}

[data-card] [data-card-body] {
  transition: max-height 0.3s ease, opacity 0.2s ease;
}

[data-card][data-collapsed="true"] [data-card-body] {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

/* === Milestone Timeline (Admin Change Patient) === */
.milestone-timeline {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.milestone-block {
  flex: 1 1 240px;
  border-radius: 1rem;
  border: 1px solid #e5e7eb;
  padding: 1rem;
  background: #fff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.milestone-block.complete {
  border-color: rgba(34, 197, 94, 0.6);
}

.milestone-title {
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.milestone-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
  margin: 0.25rem;
  cursor: pointer;
  border: 1px solid transparent;
  position: relative;
}

.milestone-chip.state-complete {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.4);
}

.milestone-chip.state-partial {
  background: rgba(250, 204, 21, 0.2);
  border-color: rgba(250, 204, 21, 0.5);
}

.milestone-chip.state-empty {
  background: rgba(148, 163, 184, 0.2);
  border-color: rgba(148, 163, 184, 0.4);
}

.chip-icon {
  font-size: 1rem;
}

.chip-tooltip {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 0.35rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  white-space: nowrap;
  z-index: 50;
}

.chip-tooltip::after {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid #0f172a;
}

/* ========== 8. EDITOR OVERLAY PANEL (if used) ========== */

.editor-overlay {
  min-height: calc(100vh - 120px);
  display: flex;
  align-items: stretch;
  background: linear-gradient(
    120deg,
    rgba(59, 130, 246, 0.1),
    rgba(139, 92, 246, 0.1)
  );
  padding: 2rem;
}

.editor-panel {
  margin-left: auto;
  width: min(520px, 100%);
  background: #fff;
  border-radius: 1.5rem;
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.2);
  animation: slide-in 0.35s ease-out;
  display: flex;
  flex-direction: column;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  padding: 1.75rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.editor-close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
  color: rgba(15, 23, 42, 0.6);
}

.editor-form {
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.editor-section h3 {
  margin-bottom: 0.75rem;
  color: #0f172a;
}

.form-grid {
  display: grid;
  gap: 1rem;
}

.form-grid.two-col {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.form-field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: #0f172a;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  border-radius: 0.75rem;
  border: 1px solid rgba(15, 23, 42, 0.2);
  padding: 0.6rem 0.85rem;
  font-size: 0.95rem;
}

/* ========== 9. RESPONSIVE OVERRIDES ========== */

@media (max-width: 1024px) {
  .dashboard-patient-view {
    flex-direction: column;
  }

  .filters-panel {
    width: 100%;
    position: static;
  }
}

/* Mobile tweaks */
@media (max-width: 768px) {
  .detail-header,
  .sticky-patient-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-actions,
  .form-actions {
    flex-wrap: wrap;
  }

.status-badges {
    width: 100%;
  }
}

/* === SHAMSGRID ISOLATION ===================================== */
.shamsgrid-shell {
  max-width: 100%;
  padding: 1.5rem 2rem;
  margin: 0 auto;
}

.shamsgrid-shell .fajr-card {
  box-shadow: none;
}

/* === UNIFIED TOOLBARS & SMART SEARCH === */
.unified-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  background: linear-gradient(90deg, #f5f7fb 0%, #eef2ff 100%);
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
  flex-wrap: wrap;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

.unified-toolbar .toolbar-title {
  font-weight: 700;
  color: #111827;
}

.unified-toolbar .toolbar-actions {
  display: inline-flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  min-width: 0;
}

.toolbar-btn {
  border: 1px solid #d1d5db;
  background: #fff;
  color: #111827;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.toolbar-btn.active,
.toolbar-btn:hover {
  background: #4f46e5;
  color: #fff;
  border-color: #4338ca;
}

.toolbar-back {
  font-weight: 700;
  color: #1f2937;
  text-decoration: none;
}

.toolbar-back:hover {
  text-decoration: underline;
}

.smart-search-snippet {
  font-size: 0.9rem;
  color: #374151;
  margin-top: 0.2rem;
}

.smart-search-meta {
  font-size: 0.8rem;
  color: #6b7280;
}

.search-highlight {
  background: #fff1a8;
  color: inherit;
}

.smart-search-autocomplete .smart-search-item {
  border-bottom: 1px solid #e5e7eb;
}

.smart-search-item {
  padding: 10px 14px;
  border-bottom: 1px solid #eef2f7;
  cursor: pointer;
}

.smart-search-item:hover {
  background: #f5f8ff;
}

.smart-search-item.active {
  background: #e5edff;
  outline: 1px solid #c7d2fe;
}

.smart-search-item-title {
  font-weight: 600;
  font-size: 15px;
}

.smart-search-item-sub {
  font-size: 13px;
  color: #64748b;
  margin-top: 4px;
  line-height: 1.3;
}

.viewer-modal {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: viewer-fade 0.15s ease;
}

.viewer-modal .viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.viewer-content {
  position: relative;
  width: 92%;
  max-width: 1300px;
  height: 90%;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  z-index: 1;
}

.viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
}

.viewer-title {
  font-weight: 700;
  color: #0f172a;
}

.viewer-close-btn {
  background: #0f172a;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.viewer-body {
  flex: 1;
  padding: 10px;
  background: #0f172a;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.viewer-pane {
  width: 100%;
  height: 100%;
  background: #0f172a;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.viewer-pane img,
.viewer-pane video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.image-rotate-btn {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  border: 1px solid #334155;
  cursor: pointer;
}

#pdf-canvas,
#multi-pdf-canvas {
  width: 100%;
  height: auto;
  background: #0b1220;
  border-radius: 12px;
}

#docx-viewer,
#multi-docx-viewer {
  background: #fff;
  color: #0f172a;
  padding: 16px;
  overflow: auto;
}

#fallback-viewer,
#multi-fallback-viewer {
  flex-direction: column;
  color: #e2e8f0;
  text-align: center;
  gap: 0.5rem;
}

#fallback-viewer a,
#multi-fallback-viewer a {
  color: #fff;
}

.viewer-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 10px;
  background: #111827;
  color: #e2e8f0;
  border-radius: 12px;
}

.viewer-toolbar .toolbar-group {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.viewer-toolbar button {
  background: #1f2937;
  color: #fff;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}

.viewer-toolbar span {
  font-weight: 600;
}

.multi-doc-content {
  max-width: 1400px;
  width: 95%;
  height: 92%;
}

.multi-doc-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 12px;
  height: calc(100% - 58px);
  padding: 10px;
  box-sizing: border-box;
}

.multi-doc-thumbnails {
  background: #f8fafc;
  border-radius: 12px;
  padding: 10px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  border: 1px solid #e5e7eb;
}

.multi-thumb {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
}

.multi-thumb:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
}

.multi-thumb.active {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.multi-thumb .label {
  font-size: 0.9rem;
  color: #0f172a;
}

.multi-doc-preview {
  background: #0b1220;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.multi-doc-title {
  color: #e2e8f0;
  font-weight: 700;
}

.viewer-locked {
  overflow: hidden;
}

.view-all-documents {
  margin-left: auto;
}

@media (max-width: 768px) {
  .viewer-content,
  .multi-doc-content {
    width: 98%;
    height: 90%;
  }
  .multi-doc-layout {
    grid-template-columns: 1fr;
  }
  .viewer-toolbar {
    justify-content: center;
  }
}

.metrics-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
}

.metrics-modal.hidden {
  display: none;
}

.metrics-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.metrics-content {
  position: relative;
  background: #ffffff;
  border-radius: 16px;
  max-width: 420px;
  margin: 80px auto 0;
  padding: 20px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
}

.search-modal.hidden {
  display: none;
}

.search-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.search-modal-content {
  position: relative;
  margin: 60px auto;
  width: 90%;
  max-width: 900px;
  max-height: 80%;
  background: #ffffff;
  border-radius: 12px;
  padding: 20px;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.flash-highlight {
  animation: fajr-highlight 1s ease;
  outline: 2px solid #4f46e5;
  outline-offset: 2px;
}

/* Compact mode */
body.compact-mode .unified-dashboard-container {
  padding: 1.5rem 1.75rem 2.5rem;
}

body.compact-mode .fajr-card {
  padding: 1rem;
}

body.compact-mode .metric-card {
  padding: 0.8rem 1rem;
  gap: 0.2rem;
}

body.compact-mode .table-card {
  padding: 0.9rem;
}

body.compact-mode .roster-card {
  padding: 0.85rem 1rem;
}

body.compact-mode .fajr-table tbody td {
  padding: 0.55rem 0.35rem;
}

body.compact-mode .metric-value {
  font-size: clamp(1.3rem, 1.8vw, 1.7rem);
}

/* ========== 10. ANIMATIONS ========== */

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

@keyframes fajr-shimmer {
  0% {
    left: -100%;
  }
  50% {
    left: 120%;
  }
  100% {
    left: 120%;
  }
}

@keyframes fajr-fadein {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes fajr-highlight {
  from {
    background-color: #eef2ff;
  }
  to {
    background-color: transparent;
  }
}

/* === FINAL OVERFLOW GUARDRAILS (scoped to dashboards only) =================== */
.unified-dashboard-container,
.dashboard-container,
.dashboard-main-grid,
.dashboard-filter-column,
.dashboard-filter-panel,
.dashboard-filter-panel-outer,
.dashboard-roster-column,
.roster-content,
.unified-toolbar,
.roster-toolbar,
.roster-controls,
.roster-quick-actions,
.dashboard-filter-row {
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
  box-sizing: border-box;
}

/* Explicitly allow patient/detail layouts to size naturally */
.doctor-container,
.patient-card,
.patient-field,
.patient-detail-grid,
.page-max,
.page-fluid {
  max-width: none;
  min-width: auto;
  overflow-x: visible;
}

.table-responsive,
.table-scroll,
.doctor-sheet-grid,
.sheet-panel,
.dashboard-sheet {
  max-width: 100% !important;
  min-width: 0 !important;
  overflow-x: auto !important;
  box-sizing: border-box;
}



:root {
    --color-primary: #2A7FF0;
    --color-purple: #7B61FF;
    --color-success: #16A34A;
    --color-warning: #F4B400;
    --color-danger: #DC2626;
    --color-slate: #6B7280;
    --color-navy: #1E293B;
    --color-light: #F3F4F6;
    --color-bg-light: #F8FAFC;
    --color-white: #FFFFFF;
    --color-text: #1E293B;
    --color-soft: #FFFFFF;
    --color-bg: #F8FAFC;
    --radius-card: 14px;
    --radius-button: 10px;
    --radius-badge: 999px;
    --shadow-card: 0 20px 40px rgba(15, 23, 42, 0.08);
    --shadow-hover: 0 25px 45px rgba(15, 23, 42, 0.12);
    --font-header: 'Inter', sans-serif;
    --font-body: 'Inter', sans-serif;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
}

body {
    font-family: var(--font-body);
    color: var(--color-text);
    background: var(--color-bg-light);
}

.card {
    background: var(--color-white);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
}

.btn-gradient {
    background: linear-gradient(135deg, var(--color-primary), var(--color-purple));
    color: #fff;
    border-radius: var(--radius-button);
    padding: 0.7rem 1.4rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.btn-gradient:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.badge-pill {
    display: inline-flex;
    align-items: center;
    border-radius: var(--radius-badge);
    padding: 0.2rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
}

.navbar-gradient {
    background: linear-gradient(120deg, var(--color-primary), var(--color-purple));
    color: #fff;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.3);
}

.dark-toggle {
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    padding: 0.3rem 0.65rem;
    background: transparent;
    color: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}


body.dark-mode {
    background: #0f172a;
    color: #f8fafc;
}

body.dark-mode .card,
body.dark-mode .patient-card,
body.dark-mode .clinical-card,
body.dark-mode .encounter-card {
    background: #1e293b;
    color: #f8fafc;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.8);
}

body.dark-mode .navbar-gradient { box-shadow: 0 4px 18px rgba(0,0,0,0.6); }
body.dark-mode .nav-link.active { background: rgba(255,255,255,0.2); }
body.dark-mode .lab-table th { background: #1f2937; }
body.dark-mode .lab-table td { border-color: #374151; }
body.dark-mode .btn-light { border-color: #475569; color: #f8fafc; }
body.dark-mode .patient-card-body { color: #e2e8f0; }
body.dark-mode .attachment-label { background: rgba(15,23,42,0.8); }
body.dark-mode .timeline-line { background: linear-gradient(#60a5fa,#a78bfa); }
body.dark-mode .encounter-event .icon-bubble { background: #7c3aed; }
body.dark-mode .vital-card { background: #0f172a; border-color: #1f2937; }
body.dark-mode .fajr-topnav {
    background: linear-gradient(120deg, #0f172a, #312e81);
    box-shadow: 0 16px 35px rgba(0, 0, 0, 0.7);
}
body.dark-mode .nav-link {
    color: rgba(226, 232, 240, 0.9);
}
body.dark-mode .nav-link.active {
    color: #fff;
}
body.dark-mode .nav-search input {
    background: rgba(15, 23, 42, 0.7);
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.5);
    color: #e2e8f0;
}
body.dark-mode .nav-search input::placeholder {
    color: rgba(226, 232, 240, 0.7);
}
body.dark-mode .nav-icon {
    filter: invert(0.15) drop-shadow(0 0 2px rgba(0, 0, 0, 0.45));
}
body.dark-mode .action-toolbar {
    background: linear-gradient(120deg, rgba(76, 29, 149, 0.35), rgba(30, 64, 175, 0.35));
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.5);
}
body.dark-mode .action-btn .tooltip {
    background: #1f2937;
}
body.dark-mode .patient-grid-table {
    background: #0f172a;
}
body.dark-mode .patient-grid-table td {
    border-color: #1f2937;
}
body.dark-mode .modal-card {
    background: #0f172a;
    color: #e2e8f0;
}
body.dark-mode .modal-field input,
body.dark-mode .modal-field select {
    background: #1f2937;
    border-color: #334155;
    color: #e2e8f0;
}
body.dark-mode .toggle-switch {
    background: rgba(148, 163, 184, 0.2);
}

/* =========================================
   CLINICAL COMMAND PANEL (Mega-Menu Style)
   ========================================= */

/* Ensure the wrapper allows a wider dropdown */
.clinical-dropdown-wrapper {
     position: relative;
}

/* The main panel container - Glassmorphism style */
.nav-dropdown-menu.command-panel {
    /* Size and Position */
    min-width: 360px; /* Wider than standard */
    max-width: 90vw; /* Mobile safe */
    padding: 0; /* Reset padding, we will handle inside */
    border-radius: 16px;
    overflow: hidden; /* For rounded corners */
    top: calc(100% + 10px);

    /* Glassmorphism Effect - Dark tint with blur */
    background: rgba(15, 23, 42, 0.85); /* Deep navy/slate translucent */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow:
        0 10px 30px -5px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255,255,255,0.05) inset;

    /* Layout */
    display: none; /* Hidden by default */
    flex-direction: column;
    /* Animation on open */
    transform-origin: top center;
    animation: commandPanelSlideIn 0.2s ease forwards;
}

/* Ensure it opens when parent has .open class (from your existing JS) */
.nav-dropdown.open .nav-dropdown-menu.command-panel {
    display: flex;
}

@keyframes commandPanelSlideIn {
    from { opacity: 0; transform: translateY(-8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- Header Section (Fixed at top of dropdown) --- */
.cmd-header-group {
    padding: 12px;
    background: rgba(0,0,0,0.2); /* Slightly darker header area */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* The fake search input trigger */
.cmd-search-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 12px;
    border-radius: 10px;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.7);
    transition: all 0.2s ease;
}

.cmd-search-trigger:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}

.search-icon { font-size: 1.1rem; }
.search-placeholder { flex: 1; font-size: 0.9rem; }
.search-shortcut {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.2);
}

/* The big "Add Encounter" button */
.cmd-hero-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    /* Vibrant gradient matching your brand */
    background: linear-gradient(135deg, var(--color-primary, #2563eb), var(--color-purple, #7c3aed));
    padding: 10px;
    border-radius: 10px;
    text-decoration: none;
    color: #fff;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cmd-hero-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.5);
}

/* --- Scrolling Content Area --- */
.cmd-scroller {
    padding: 12px;
    max-height: 60vh; /* Ensure it fits on mobile screens */
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.3) transparent;
}

/* Section Headers */
.cmd-section-header {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.5);
    margin: 16px 0 8px 4px;
    font-weight: 700;
}

.cmd-section-header:first-child { margin-top: 4px; }

.cmd-section-header.brand-accent {
     color: #a5b4fc; /* Light purple/blue accent for Mental Health */
}

/* --- Generic Command Items --- */
.cmd-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    transition: all 0.15s ease;
    font-size: 0.9rem;
    border: 1px solid transparent; /* Prevent layout shift on hover */
}

/* Hover state for items */
.cmd-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateX(2px);
}

.cmd-icon {
    font-size: 1.2rem;
    /* Fixed width for icons ensures perfect alignment */
    width: 24px;
    text-align: center;
}

/* Highlight item (for Add Assessment) */
.cmd-item.highlight-item {
    background: rgba(124, 58, 237, 0.15); /* Subtle purple bg */
    color: #c4b5fd;
    border: 1px solid rgba(124, 58, 237, 0.3);
}
.cmd-item.highlight-item:hover {
    background: rgba(124, 58, 237, 0.3);
    color: #fff;
}


/* --- Layout Variations --- */

/* 2-column grid row */
.cmd-grid-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin-bottom: 8px;
}

/* 3-column grid for compact items */
.cmd-grid-row.three-col {
     grid-template-columns: 1fr 1fr 1fr;
}
.cmd-item.compact {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
    font-size: 0.8rem;
    padding: 8px 4px;
}
.cmd-item.compact .cmd-icon { font-size: 1.1rem; }


/* Standard Vertical List Group */
.cmd-list-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* --- Footer (Roles) --- */
.cmd-section-footer {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cmd-footer-item {
    padding: 4px 10px;
    background: rgba(0,0,0,0.2);
    border-radius: 999px;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    border: 1px solid rgba(255,255,255,0.1);
    transition: all 0.2s ease;
}

.cmd-footer-item:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
    border-color: rgba(255,255,255,0.3);
}

/* --- Mobile adjustments --- */
@media (max-width: 480px) {
    .nav-dropdown-menu.command-panel {
        min-width: 300px;
        right: -60px; /* Shift left slightly on very small screens if needed */
    }
    .cmd-grid-row {
        grid-template-columns: 1fr; /* Stack grids on tiny screens */
    }
    .cmd-grid-row.three-col {
        grid-template-columns: 1fr 1fr 1fr; /* Keep workflow compact though */
    }
}

/* =========================================================
   FAJR GLOBAL EMR — UNIFIED ENHANCEMENTS
   Adds: Density Modes, Status Rings, Snapshot Panels
   ========================================================= */

/* --- 1. DENSITY MODES --- */

/* Normal Mode (Default) defined in base styles. 
   Compact Mode Overrides follow: */

body.compact-mode .unified-dashboard-container {
    padding-top: 1rem;
}

body.compact-mode .dashboard-hero {
    margin-bottom: 0.5rem;
}

body.compact-mode .dashboard-metrics-row {
    transform: scale(0.95);
    transform-origin: left top;
    margin-bottom: 0.5rem;
}

body.compact-mode .clinical-card {
    padding: 0.75rem;
    gap: 0.5rem;
}

body.compact-mode .clinical-card h3 {
    font-size: 1rem;
}

body.compact-mode .action-toolbar {
    padding: 0.25rem 0.5rem;
}

body.compact-mode .action-btn {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
}

/* --- 2. STATUS RING SYSTEM --- */

.status-ring-indicator {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 6px;
    border-radius: 12px 0 0 12px;
    background: #e2e8f0; /* Neutral default */
    transition: background 0.3s ease;
}

/* Status Colors */
.ring-success { background: #22c55e; box-shadow: 0 0 8px rgba(34, 197, 94, 0.4); }
.ring-urgent { background: #ef4444; box-shadow: 0 0 8px rgba(239, 68, 68, 0.4); }
.ring-neutral { background: #cbd5e1; }

/* Adjust card padding to accommodate ring */
.clinical-card {
    padding-left: 20px; /* Space for ring */
    position: relative;
    overflow: hidden; /* Ensure ring stays inside rounded corners */
}

/* --- 3. CARD LAYOUT & TYPOGRAPHY --- */

.patient-roster-card {
    --card-border: rgba(14, 116, 144, 0.25);
    --card-glow: rgba(14, 165, 233, 0.35);
    --card-sheen: rgba(56, 189, 248, 0.18);
    border-radius: 18px;
    border: 1px solid var(--card-border);
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.98), rgba(238, 247, 255, 0.92));
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.85);
    padding: 1.35rem 1.5rem 1.25rem 2rem;
    min-height: 230px;
    position: relative;
    overflow: hidden;
}

.patient-roster-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 12% 18%, var(--card-sheen), transparent 42%),
        radial-gradient(circle at 85% 0%, rgba(14, 116, 144, 0.16), transparent 50%),
        linear-gradient(120deg, rgba(148, 163, 184, 0.15), transparent 55%);
    opacity: 0.9;
    pointer-events: none;
}

.patient-roster-card::after {
    content: "";
    position: absolute;
    right: -80px;
    top: -80px;
    width: 180px;
    height: 180px;
    background: radial-gradient(circle, var(--card-glow), transparent 65%);
    filter: blur(6px);
    opacity: 0.6;
    pointer-events: none;
}

.patient-roster-card:hover {
    border-color: rgba(14, 165, 233, 0.55);
    box-shadow: 0 24px 50px rgba(15, 23, 42, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.patient-roster-card .status-ring-indicator {
    width: 8px;
    border-radius: 14px 0 0 14px;
}

.patient-roster-card .card-main-content,
.patient-roster-card .snapshot-panel {
    position: relative;
    z-index: 1;
}

.patient-roster-card .card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.65rem;
}

.patient-roster-card .card-identity h3 {
    margin: 0 0 0.25rem 0;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #0f172a;
}

.patient-roster-card .card-meta {
    font-size: 0.78rem;
    font-weight: 600;
    color: #556579;
    letter-spacing: 0.02em;
    display: flex;
    gap: 6px;
    align-items: center;
}

.patient-roster-card .card-primary-info {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 0.85rem;
    padding: 0.55rem 0.75rem;
    border-radius: 12px;
    background: rgba(248, 250, 252, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.patient-roster-card .info-group .label {
    font-size: 0.68rem;
    text-transform: uppercase;
    color: #8191a6;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.patient-roster-card .info-group .value {
    color: #1f2937;
    font-weight: 600;
}

.patient-roster-card .condition-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.6rem;
}

.patient-roster-card .condition-badge {
    border-radius: 999px;
    padding: 0.25rem 0.8rem;
    font-size: 0.78rem;
    font-weight: 700;
    background: rgba(226, 232, 240, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.3);
    color: #334155;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.patient-roster-card .condition-badge.success {
    background: rgba(34, 197, 94, 0.18);
    border-color: rgba(34, 197, 94, 0.35);
    color: #166534;
}

.patient-roster-card .urgency-pill {
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.18);
    backdrop-filter: blur(6px);
}

.patient-roster-card .urgency-pill.urgent {
    background: linear-gradient(135deg, #f97316, #ef4444);
}

.patient-roster-card .urgency-pill.routine {
    background: linear-gradient(135deg, #fde047, #facc15);
    color: #1f2937;
}

.patient-roster-card .action-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.85rem;
    padding: 0.6rem 0.85rem;
    border-radius: 14px;
    background: linear-gradient(120deg, rgba(14, 116, 144, 0.12), rgba(59, 130, 246, 0.1));
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
}

.patient-roster-card .action-btn {
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.35);
}

.patient-roster-card .expand-card-btn {
    border-color: rgba(148, 163, 184, 0.55);
    background: rgba(255, 255, 255, 0.7);
}

.patient-roster-card .expand-card-btn:hover {
    background: rgba(255, 255, 255, 0.95);
}

.patient-roster-card .snapshot-panel {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(148, 163, 184, 0.35);
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.92), rgba(226, 232, 240, 0.82));
    margin-left: -2rem;
    margin-right: -1.5rem;
    padding-left: 2rem;
    padding-right: 1.5rem;
    padding-bottom: 0.75rem;
    animation: slideDown 0.2s ease-out;
}

.patient-roster-card .snapshot-col h4 {
    font-size: 0.74rem;
    text-transform: uppercase;
    color: #64748b;
    margin: 0 0 0.5rem 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.35);
    padding-bottom: 2px;
}

.patient-roster-card .snapshot-list {
    font-size: 0.84rem;
    color: #334155;
    gap: 6px;
}

body.dark-mode .patient-roster-card {
    border-color: rgba(148, 163, 184, 0.2);
    background: linear-gradient(160deg, rgba(15, 23, 42, 0.98), rgba(30, 41, 59, 0.92));
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

body.dark-mode .patient-roster-card::before,
body.dark-mode .patient-roster-card::after {
    opacity: 0.25;
}

body.dark-mode .patient-roster-card .card-identity h3,
body.dark-mode .patient-roster-card .card-meta,
body.dark-mode .patient-roster-card .info-group .value,
body.dark-mode .patient-roster-card .snapshot-list {
    color: #e2e8f0;
}

body.dark-mode .patient-roster-card .info-group .label {
    color: #94a3b8;
}

body.dark-mode .patient-roster-card .card-primary-info {
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(148, 163, 184, 0.2);
}

body.dark-mode .patient-roster-card .condition-badge {
    background: rgba(15, 23, 42, 0.55);
    border-color: rgba(148, 163, 184, 0.25);
    color: #e2e8f0;
}

body.dark-mode .patient-roster-card .action-toolbar {
    background: linear-gradient(120deg, rgba(14, 116, 144, 0.25), rgba(59, 130, 246, 0.2));
    border-color: rgba(148, 163, 184, 0.2);
}

body.dark-mode .patient-roster-card .expand-card-btn {
    background: rgba(15, 23, 42, 0.7);
    color: #e2e8f0;
    border-color: rgba(148, 163, 184, 0.35);
}

body.dark-mode .patient-roster-card .snapshot-panel {
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.82), rgba(30, 41, 59, 0.72));
    border-top-color: rgba(148, 163, 184, 0.25);
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.card-identity h3 {
    margin: 0 0 0.25rem 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
}

.card-meta {
    font-size: 0.85rem;
    color: #64748b;
    display: flex;
    gap: 4px;
    align-items: center;
}

.meta-dot { color: #cbd5e1; }

.card-primary-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.info-group {
    display: flex;
    flex-direction: column;
}

.info-group .label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: #94a3b8;
    font-weight: 600;
}

.info-group .value {
    color: #334155;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- 4. SNAPSHOT PANEL (INLINE EXPANSION) --- */

.snapshot-panel {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed #e2e8f0;
    background: #f8fafc;
    margin-left: -20px; /* Bleed to edge */
    margin-right: -20px;
    padding-left: 20px;
    padding-right: 20px;
    padding-bottom: 0.5rem;
    animation: slideDown 0.2s ease-out;
}

.snapshot-panel[hidden] {
    display: none;
}

.snapshot-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.snapshot-col h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #64748b;
    margin: 0 0 0.5rem 0;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 2px;
}

.snapshot-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.85rem;
    color: #334155;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.text-danger { color: #dc2626; font-weight: 600; }

.snapshot-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

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

/* --- 5. INTERACTIVE ELEMENTS --- */

.expand-card-btn {
    margin-left: auto; /* Push to right */
    background: transparent;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    padding: 0 10px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: #475569;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.expand-card-btn:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.expand-card-btn .chevron {
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.active-filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 1rem;
    align-items: center;
}

.filter-chip {
    background: #eef2ff;
    color: #4f46e5;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.chip-remove {
    color: #4f46e5;
    text-decoration: none;
    font-weight: 700;
    opacity: 0.7;
}

.chip-remove:hover { opacity: 1; }

.clear-all-link {
    font-size: 0.85rem;
    color: #64748b;
    text-decoration: underline;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .snapshot-grid {
        grid-template-columns: 1fr;
    }
    .card-primary-info {
        grid-template-columns: 1fr;
    }
    .status-ring-indicator {
        width: 4px;
    }
    .clinical-card {
        padding-left: 14px;
    }
    .patient-roster-card {
        padding: 1.1rem 1.1rem 1rem 1.5rem;
    }
    .patient-roster-card .status-ring-indicator {
        width: 6px;
    }
    .patient-roster-card .snapshot-panel {
        margin-left: -1.5rem;
        margin-right: -1.1rem;
        padding-left: 1.5rem;
        padding-right: 1.1rem;
    }
}
