/* ==========================================================================
   CarePulse EHR - Modern Clinical Design System & CSS Stylesheet
   ========================================================================== */

:root {
  /* Ayurvedic Color Palette - Dark Mode Default (Midnight Herbal Sanctuary) */
  --bg-primary: #091310;
  --bg-secondary: #0f1f1a;
  --bg-card: rgba(16, 32, 26, 0.85);
  --bg-card-hover: rgba(24, 48, 39, 0.9);
  --bg-card-border: rgba(16, 185, 129, 0.18);

  --text-main: #f0fdf4;
  --text-muted: #94a3b8;
  --text-inverse: #091310;

  --accent-blue: #3b82f6;
  --accent-blue-hover: #2563eb;
  --accent-blue-glow: rgba(59, 130, 246, 0.3);

  --accent-teal: #0d9488;
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.35);

  --accent-amber: #f59e0b;
  --accent-saffron: #d97706;
  --accent-copper: #c2410c;
  --accent-gold: #eab308;
  --accent-gold-glow: rgba(234, 179, 8, 0.3);

  --accent-rose: #ef4444;
  --accent-rose-glow: rgba(239, 68, 68, 0.25);
  --accent-purple: #8b5cf6;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 26px;

  --shadow-card: 0 12px 32px -6px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--bg-card-border);
  --shadow-modal: 0 25px 60px -12px rgba(0, 0, 0, 0.9);

  --font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition-fast: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Ayurvedic Light Theme Variables (Sacred Sandalwood & Silk Parchment) */
[data-theme="light"] {
  --bg-primary: #fbf9f4;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 253, 248, 0.92);
  --bg-card-hover: #ffffff;
  --bg-card-border: rgba(180, 83, 9, 0.16);

  --text-main: #1c1917;
  --text-muted: #78716c;
  --text-inverse: #ffffff;

  --shadow-card: 0 6px 24px -4px rgba(180, 83, 9, 0.08), 0 0 0 1px var(--bg-card-border);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Layout Setup */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header Styling */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.5rem;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--bg-card-border);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-teal));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px var(--accent-blue-glow);
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-text h1 span {
  color: var(--accent-blue);
}

.brand-tagline {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.header-center {
  flex: 1;
  max-width: 480px;
  margin: 0 2rem;
}

.global-search-container {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.global-search-container input {
  width: 100%;
  padding: 0.6rem 2.2rem 0.6rem 2.4rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  color: var(--text-main);
  font-size: 0.875rem;
  transition: var(--transition-fast);
}

.global-search-container input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--accent-blue-glow);
}

.clear-search-btn {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

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

/* Sync Badge */
.sync-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.35rem 0.75rem;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent-emerald);
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* Role Selector Dropdown */
.role-select {
  padding: 0.45rem 0.85rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

/* App Body Layout */
.app-body {
  display: flex;
  flex: 1;
}

/* Sidebar Navigation */
.app-sidebar {
  width: 240px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--bg-card-border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.25rem 0.75rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: left;
  width: 100%;
}

.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(20, 184, 166, 0.15));
  color: var(--accent-blue);
  font-weight: 600;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.admin-controls {
  padding: 0.75rem;
  background: rgba(139, 92, 246, 0.08);
  border: 1px dashed rgba(139, 92, 246, 0.3);
  border-radius: var(--radius-md);
}

.admin-badge {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent-purple);
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.user-profile-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem;
  background-color: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--bg-card-border);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.user-info {
  overflow: hidden;
}

.user-name {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.user-role-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background-color: rgba(59, 130, 246, 0.2);
  color: var(--accent-blue);
}

.user-role-badge.staff {
  background-color: rgba(20, 184, 166, 0.2);
  color: var(--accent-teal);
}

/* Main Content Area */
.app-main {
  flex: 1;
  padding: 1.5rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.view-section {
  display: none;
}

.view-section.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

.dashboard-header, .section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.dashboard-header h2, .section-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Metrics Cards Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.metric-card {
  background-color: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(10px);
  transition: var(--transition-fast);
}

.metric-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
}

.metric-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.metric-icon.blue { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.metric-icon.red { background: rgba(239, 68, 68, 0.15); color: var(--accent-rose); }
.metric-icon.green { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.metric-icon.purple { background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); }

.metric-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.metric-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Content Toolbar & Filter Pills */
.content-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.filter-pills {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-pill {
  padding: 0.4rem 0.9rem;
  border-radius: 9999px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--bg-card-border);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}

.filter-pill:hover {
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

.filter-pill.active {
  background-color: var(--accent-blue);
  color: white;
  border-color: var(--accent-blue);
  box-shadow: 0 2px 10px var(--accent-blue-glow);
}

/* Patients Grid */
.patients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
}

.patient-card {
  background-color: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.patient-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 35px -5px rgba(0, 0, 0, 0.6);
  border-color: rgba(59, 130, 246, 0.4);
}

.card-top-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.patient-name-box h3 {
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
}

.patient-name-box h3:hover {
  color: var(--accent-blue);
}

.patient-mrn {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: monospace;
}

.risk-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.risk-badge.low { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); border: 1px solid rgba(16, 185, 129, 0.3); }
.risk-badge.moderate { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); border: 1px solid rgba(245, 158, 11, 0.3); }
.risk-badge.high { background: rgba(239, 68, 68, 0.15); color: var(--accent-rose); border: 1px solid rgba(239, 68, 68, 0.3); }
.risk-badge.critical { background: rgba(239, 68, 68, 0.25); color: #ff6b6b; border: 1px solid var(--accent-rose); box-shadow: 0 0 10px var(--accent-rose-glow); }

.card-body-details {
  font-size: 0.825rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-muted);
}

.info-row span.val {
  color: var(--text-main);
  font-weight: 500;
}

.card-vitals-mini {
  display: flex;
  gap: 0.75rem;
  padding: 0.6rem;
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-md);
  margin-top: 0.25rem;
}

.vital-item {
  flex: 1;
  text-align: center;
}

.vital-item .v-lbl { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; }
.vital-item .v-val { font-size: 0.85rem; font-weight: 700; color: var(--accent-blue); }

.card-actions-bar {
  display: flex;
  gap: 0.5rem;
  border-top: 1px solid var(--bg-card-border);
  padding-top: 0.85rem;
}

/* Data Table Styling */
.table-container {
  background-color: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.data-table th {
  background-color: var(--bg-secondary);
  padding: 0.9rem 1.25rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--bg-card-border);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.data-table td {
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--bg-card-border);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-blue-hover));
  color: white;
  box-shadow: 0 4px 14px var(--accent-blue-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px var(--accent-blue-glow);
}

.btn-secondary {
  background-color: var(--bg-secondary);
  border: 1px solid var(--bg-card-border);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--bg-card-border);
  color: var(--text-muted);
}

.btn-outline:hover {
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
  background-color: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--accent-rose);
}

.btn-danger:hover {
  background-color: var(--accent-rose);
  color: white;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background-color: var(--bg-primary);
  border: 1px solid var(--bg-card-border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn:hover {
  color: var(--text-main);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  background-color: var(--bg-secondary);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.25s ease;
}

.modal-overlay.active .modal-container {
  transform: scale(1);
}

.modal-container.medium { max-width: 720px; }
.modal-container.large { max-width: 1050px; }
.modal-container.full-height { height: 90vh; }

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--bg-card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--bg-card-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Forms */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-group input, .form-group select, .form-group textarea {
  padding: 0.6rem 0.85rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 0.875rem;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--accent-blue-glow);
}

/* Patient Detailed Profile Modal Tabs & View */
.profile-summary-bar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.profile-avatar-big {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-teal));
  color: white;
  font-size: 1.4rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-main-meta h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.profile-meta-pills {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

.profile-tabs-bar {
  display: flex;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--bg-card-border);
  padding: 0 1.5rem;
  gap: 0.5rem;
}

.profile-tab {
  padding: 0.85rem 1.1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;

}

.profile-tab.active {
  color: var(--accent-blue);
  border-bottom-color: var(--accent-blue);
}

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

.profile-tab-pane {
  display: none;
}

.profile-tab-pane.active {
  display: block;
}

.pane-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

/* Vitals Cards Grid */
.vitals-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}

.v-stat-box {
  background-color: var(--bg-primary);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
}

.v-stat-box .title { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; }
.v-stat-box .num { font-size: 1.4rem; font-weight: 700; color: var(--accent-blue); margin: 0.25rem 0; }
.v-stat-box .unit { font-size: 0.75rem; color: var(--text-muted); }

/* Tags List */
.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.tag-item {
  padding: 0.3rem 0.75rem;
  border-radius: 9999px;
  background-color: var(--bg-primary);
  border: 1px solid var(--bg-card-border);
  font-size: 0.78rem;
  font-weight: 500;
}

.tag-item.severe { background: rgba(239, 68, 68, 0.15); color: var(--accent-rose); border-color: rgba(239, 68, 68, 0.3); }

/* Grid 2 Column Utility */
.grid-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.card-box {
  background-color: var(--bg-primary);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 1.1rem;
}

.card-box-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

/* SOAP Timeline */
.soap-timeline {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.soap-card {
  background-color: var(--bg-primary);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.soap-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--bg-card-border);
  padding-bottom: 0.5rem;
}

.soap-doctor { font-weight: 700; font-size: 0.9rem; }
.soap-date { font-size: 0.75rem; color: var(--text-muted); }

.soap-block {
  margin-bottom: 0.6rem;
}

.soap-block strong { color: var(--accent-blue); }

/* Prescriptions Cards */
.rx-cards-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.rx-card {
  background-color: var(--bg-primary);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.rx-title { font-size: 1.05rem; font-weight: 700; color: var(--accent-emerald); }
.rx-detail { font-size: 0.825rem; color: var(--text-muted); }

/* SVG Trend Chart Styling */
.trend-chart-box {
  margin-top: 0.5rem;
  height: 60px;
  width: 100%;
}

/* Print Only Stylesheet */
@media print {
  body * {
    visibility: hidden;
  }
  #printableSummary, #printableSummary * {
    visibility: visible;
  }
  #printableSummary {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    color: black;
    background: white;
    padding: 2rem;
  }
}

.mt-4 { margin-top: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }

/* ==================== LOGIN SCREEN ==================== */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  overflow: hidden;
}

.login-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 50%, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(16, 185, 129, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 50% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 50%);
  animation: loginBgPulse 8s ease-in-out infinite alternate;
}

@keyframes loginBgPulse {
  0% { opacity: 0.6; }
  100% { opacity: 1; }
}

.login-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 1.5rem;
}

.login-card {
  background: rgba(30, 41, 59, 0.85);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 2.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 18px;
  background: linear-gradient(135deg, #3b82f6, #10b981);
  margin-bottom: 1rem;
  color: #fff;
}

.login-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #f1f5f9;
  margin: 0 0 0.25rem 0;
}

.login-subtitle {
  font-size: 0.85rem;
  color: #94a3b8;
  margin: 0;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.login-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #94a3b8;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.login-field input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.6);
  color: #f1f5f9;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.login-field input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.login-field input::placeholder {
  color: #475569;
}

.password-input-wrapper {
  position: relative;
}

.password-input-wrapper input {
  padding-right: 2.75rem;
}

.toggle-password-btn {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
}

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

.login-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  color: #fca5a5;
  font-size: 0.85rem;
  text-align: center;
}

.login-submit-btn {
  width: 100%;
  padding: 0.85rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 10px;
  margin-top: 0.5rem;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border: none;
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
}

.login-submit-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.35);
}

.login-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.login-footer {
  text-align: center;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.login-footer p {
  font-size: 0.75rem;
  color: #475569;
  margin: 0;
}

/* ==================== USER SESSION INFO (Header) ==================== */
.user-session-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.session-user-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.session-user-role {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.session-user-role.staff {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

/* ==================== LIGHT THEME LOGIN ==================== */
[data-theme="light"] .login-screen {
  background: linear-gradient(135deg, #e2e8f0 0%, #f1f5f9 50%, #e2e8f0 100%);
}

[data-theme="light"] .login-screen::before {
  background:
    radial-gradient(circle at 20% 50%, rgba(59, 130, 246, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(16, 185, 129, 0.08) 0%, transparent 50%);
}

[data-theme="light"] .login-card {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .login-header h1 { color: #1e293b; }
[data-theme="light"] .login-subtitle { color: #64748b; }
[data-theme="light"] .login-field label { color: #64748b; }
[data-theme="light"] .login-field input {
  background: rgba(241, 245, 249, 0.8);
  border-color: rgba(0, 0, 0, 0.1);
  color: #1e293b;
}
[data-theme="light"] .login-field input::placeholder { color: #94a3b8; }
[data-theme="light"] .login-footer { border-color: rgba(0, 0, 0, 0.06); }
[data-theme="light"] .login-footer p { color: #94a3b8; }

/* ==================== PRINT STYLES ==================== */
#printSection {
  display: none;
}

@media print {
  html, body {
    background: #ffffff !important;
    color: #000000 !important;
    font-family: Arial, Helvetica, sans-serif !important;
    margin: 0 !important;
    padding: 0 !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* MODE 1: When printing explicit document via triggerPrintHTML (body has .printing-mode) */
  body.printing-mode > *:not(#printSection) {
    display: none !important;
  }

  body.printing-mode #printSection {
    display: block !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 15px !important;
    background: #ffffff !important;
    color: #000000 !important;
    box-sizing: border-box !important;
  }

  body.printing-mode #printSection * {
    visibility: visible !important;
    color: #000000 !important;
  }

  /* MODE 2: Fallback when printing directly via Ctrl+P (without .printing-mode) */
  body:not(.printing-mode) .app-sidebar,
  body:not(.printing-mode) .app-header,
  body:not(.printing-mode) .btn,
  body:not(.printing-mode) .modal-close-btn,
  body:not(.printing-mode) .form-actions,
  body:not(.printing-mode) #loginScreen,
  body:not(.printing-mode) .login-screen {
    display: none !important;
  }

  body:not(.printing-mode) .app-container {
    display: block !important;
    position: relative !important;
    width: 100% !important;
    background: #ffffff !important;
    color: #000000 !important;
  }

  body:not(.printing-mode) .modal-overlay.active {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    display: block !important;
    background: #ffffff !important;
    width: 100% !important;
    height: auto !important;
    backdrop-filter: none !important;
    opacity: 1 !important;
  }

  body:not(.printing-mode) .modal-overlay.active .modal-container,
  body:not(.printing-mode) .modal-overlay.active .modal-content {
    max-width: 100% !important;
    max-height: none !important;
    box-shadow: none !important;
    border: none !important;
    background: #ffffff !important;
    color: #000000 !important;
  }

  body:not(.printing-mode) .view-section.active {
    display: block !important;
  }

  body:not(.printing-mode) table.data-table,
  body:not(.printing-mode) .data-table th,
  body:not(.printing-mode) .data-table td {
    border: 1px solid #cbd5e1 !important;
    color: #000000 !important;
    background: #ffffff !important;
  }

  body:not(.printing-mode) * {
    color: #000000 !important;
  }

  @page {
    size: A4;
    margin: 15mm;
  }
}

/* ==================== AYURVEDA WELLNESS THEME DESIGN & TAB BACKGROUNDS ==================== */

/* Ambient Herbal Overlay & Background Texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: 
    radial-gradient(circle at 15% 15%, rgba(16, 185, 129, 0.08) 0%, transparent 45%),
    radial-gradient(circle at 85% 20%, rgba(217, 119, 6, 0.06) 0%, transparent 45%),
    radial-gradient(circle at 50% 85%, rgba(13, 148, 136, 0.08) 0%, transparent 50%);
}

/* Header Brand Ayurvedic Logo & Glow */
.brand-logo {
  background: linear-gradient(135deg, #059669 0%, #d97706 100%) !important;
  box-shadow: 0 4px 18px rgba(16, 185, 129, 0.35) !important;
}

.brand-text h1 span {
  color: var(--accent-emerald) !important;
}

/* Sidebar Active Nav Item - Herbal Botanical Glow */
.nav-item.active {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(217, 119, 6, 0.15)) !important;
  color: var(--accent-emerald) !important;
  border: 1px solid rgba(16, 185, 129, 0.3) !important;
  border-left: 4px solid var(--accent-emerald) !important;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.12) !important;
}

.nav-item:hover {
  background-color: rgba(16, 185, 129, 0.08) !important;
  color: var(--accent-emerald) !important;
}

/* CUSTOM AYURVEDIC BACKGROUND THEMES FOR EVERY VIEW TAB */

/* 1. Dashboard View - Herbal Emerald & Agni Glow */
#viewDashboard {
  background: 
    radial-gradient(circle at top right, rgba(16, 185, 129, 0.12), transparent 50%),
    radial-gradient(circle at bottom left, rgba(217, 119, 6, 0.08), transparent 50%);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  border: 1px solid rgba(16, 185, 129, 0.15);
}

/* 2. Patient Directory View - Sandalwood & Neem Texture */
#viewPatients {
  background: 
    radial-gradient(circle at top left, rgba(13, 148, 136, 0.14), transparent 45%),
    radial-gradient(circle at bottom right, rgba(16, 185, 129, 0.1), transparent 50%);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  border: 1px solid rgba(13, 148, 136, 0.15);
}

/* 3. Appointments View - Sunrise Saffron & Tejas Aura */
#viewAppointments {
  background: 
    radial-gradient(circle at top center, rgba(217, 119, 6, 0.14), transparent 50%),
    radial-gradient(circle at bottom right, rgba(234, 179, 8, 0.1), transparent 50%);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  border: 1px solid rgba(217, 119, 6, 0.18);
}

/* 4. IP Patient Directory & Wards View - Healing Neem & Tulsi Sanctuary */
#viewIPPatients {
  background: 
    radial-gradient(circle at top right, rgba(16, 185, 129, 0.16), transparent 50%),
    radial-gradient(circle at bottom left, rgba(13, 148, 136, 0.12), transparent 50%);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

/* 5. Diagnoses Catalog View - Classical Roga Nidana Wisdom */
#viewDiagnoses {
  background: 
    radial-gradient(circle at top left, rgba(13, 148, 136, 0.16), transparent 50%),
    radial-gradient(circle at bottom right, rgba(194, 65, 12, 0.12), transparent 50%);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  border: 1px solid rgba(13, 148, 136, 0.25);
}

/* 6. Billing & Invoices View - Golden Turmeric & Tamra Prosperity */
#viewInvoices {
  background: 
    radial-gradient(circle at top right, rgba(234, 179, 8, 0.15), transparent 50%),
    radial-gradient(circle at bottom left, rgba(217, 119, 6, 0.12), transparent 50%);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  border: 1px solid rgba(234, 179, 8, 0.2);
}

/* 7. Pharmacy Stock View - Medicinal Herbal Aushadhi Green */
#viewInventory {
  background: 
    radial-gradient(circle at top left, rgba(16, 185, 129, 0.18), transparent 50%),
    radial-gradient(circle at bottom right, rgba(13, 148, 136, 0.14), transparent 50%);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  border: 1px solid rgba(16, 185, 129, 0.28);
}

/* 8. User Management View - Sacred Temple Integrity */
#viewUsers {
  background: 
    radial-gradient(circle at top right, rgba(59, 130, 246, 0.12), transparent 50%),
    radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.1), transparent 50%);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

/* 9. Audit Trail View - Ancient Medical Chronicle Parchment */
#viewAudit {
  background: 
    radial-gradient(circle at top left, rgba(194, 65, 12, 0.12), transparent 50%),
    radial-gradient(circle at bottom right, rgba(217, 119, 6, 0.1), transparent 50%);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  border: 1px solid rgba(194, 65, 12, 0.2);
}

/* Patient Profile Modal - Ayurvedic Tab Bar & Card Accents */
.profile-tabs-bar {
  border-bottom: 2px solid rgba(16, 185, 129, 0.25) !important;
  background: rgba(15, 31, 26, 0.65) !important;
  padding: 0.5rem 1rem 0 1rem !important;
  gap: 0.4rem !important;
}

.profile-tab {
  border-radius: 10px 10px 0 0 !important;
  font-weight: 600 !important;
  transition: var(--transition-fast) !important;
}

.profile-tab.active {
  background: linear-gradient(135deg, #059669, #0d9488) !important;
  color: #ffffff !important;
  box-shadow: 0 -4px 14px rgba(16, 185, 129, 0.35) !important;
  border: none !important;
}

/* Metric Cards Ayurvedic Touch */
.metric-card {
  border: 1px solid var(--bg-card-border) !important;
  background: var(--bg-card) !important;
  backdrop-filter: blur(16px) !important;
  transition: transform 0.25s, box-shadow 0.25s !important;
}

.metric-card:hover {
  transform: translateY(-3px) !important;
  box-shadow: 0 12px 30px rgba(16, 185, 129, 0.18) !important;
  border-color: rgba(16, 185, 129, 0.35) !important;
}

/* Primary Buttons Herbal Gradient */
.btn-primary {
  background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
  border: none !important;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3) !important;
  color: #ffffff !important;
  font-weight: 600 !important;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45) !important;
}
