/* ==========================================================================
   MomCare Design System - Modern Glassmorphism & High-Aesthetic UI
   ========================================================================== */

:root {
  /* Color Palette */
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-light: #EEF2FF;
  --primary-focus: rgba(79, 70, 229, 0.2);
  
  --secondary: #EC4899;
  --secondary-light: #FDF2F8;
  
  --success: #10B981;
  --success-bg: #ECFDF5;
  --warning: #F59E0B;
  --warning-bg: #FFFBEB;
  --danger: #EF4444;
  --danger-bg: #FEF2F2;
  --info: #06B6D4;
  --info-bg: #ECFEFF;

  /* Excel Specific Highlight Tones */
  --excel-green-bg: #DCFCE7;
  --excel-green-text: #166534;
  --excel-yellow-bg: #FEF08A;
  --excel-yellow-text: #854D0E;
  --excel-pink-bg: #FCE7F3;
  --excel-pink-text: #9D174D;
  --excel-red-bg: #FEE2E2;
  --excel-red-text: #991B1B;
  --excel-blue-bg: #E0E7FF;
  --excel-blue-text: #3730A3;

  /* Neutrals & Dark/Light */
  --bg-main: #F8FAFC;
  --bg-card: rgba(255, 255, 255, 0.92);
  --bg-card-glass: rgba(255, 255, 255, 0.75);
  --border-color: #E2E8F0;
  --border-glass: rgba(226, 232, 240, 0.8);
  
  --text-main: #0F172A;
  --text-muted: #64748B;
  --text-light: #94A3B8;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
  --shadow-glow: 0 0 20px rgba(79, 70, 229, 0.15);

  /* Radius & Transitions */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Global Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Prompt', 'Kanit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(236, 72, 153, 0.08) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(16, 185, 129, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.6;
  font-size: 15px;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Prompt', sans-serif;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-hover);
}

/* Container */
.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 24px 80px 24px;
}

/* Top Navbar */
.top-navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: var(--bg-card-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  position: sticky;
  top: 16px;
  z-index: 100;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #4F46E5 0%, #EC4899 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #fff;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.brand-info h1 {
  font-size: 1.25rem;
  line-height: 1.2;
  background: linear-gradient(90deg, #1E1B4B, #4F46E5);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-info span {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Live Database Status Indicator */
.db-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.76rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: #fff;
  transition: all var(--transition-fast);
  user-select: none;
}

.db-status-badge.db-online {
  background: #F0FDF4;
  border-color: #BBF7D0;
  color: #15803D;
}

.db-status-badge.db-offline {
  background: #FEF2F2;
  border-color: #FECACA;
  color: #B91C1C;
  animation: pulse 1.5s infinite;
}

.db-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22C55E;
}

.db-status-badge.db-offline .db-dot {
  background: #EF4444;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(241, 245, 249, 0.8);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(226, 232, 240, 0.6);
}

.nav-item {
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.nav-item.active {
  background: #fff;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.nav-user-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* User Switcher Pill */
.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 8px;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.user-pill:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.user-avatar-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
}

.user-pill-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Notification Bell */
.notif-bell-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.notif-bell-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.notif-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  border: 2px solid #fff;
}

.dropdown-item-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  font-size: 0.88rem;
  font-family: inherit;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast);
}

.dropdown-item-btn:hover {
  background: #F1F5F9;
}

/* Caregiver Duty Counter Summary Cards (ตรงกับคอลัมน์ขวาใน Excel) */
.duty-summary-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.duty-stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  cursor: pointer;
}

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

.duty-stat-card.active-filter {
  border-color: var(--primary);
  background: var(--primary-light);
}

.caregiver-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.caregiver-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.caregiver-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.duty-count-pill {
  font-size: 0.95rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  background: #F1F5F9;
  color: var(--text-main);
}

/* Card Containers */
.app-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 24px;
}

.card-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 1.2rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 8px rgba(79, 70, 229, 0.3);
}

.btn-secondary {
  background: #fff;
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: #F8FAFC;
  border-color: #CBD5E1;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #DC2626;
}

.btn-export-excel {
  background: linear-gradient(135deg, #10B981 0%, #059669 100%);
  color: #fff;
  border: 1px solid #047857;
  font-weight: 600;
  box-shadow: 0 2px 5px rgba(5, 150, 105, 0.25);
}

.btn-export-excel:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  box-shadow: 0 4px 10px rgba(5, 150, 105, 0.35);
  transform: translateY(-1px);
  color: #fff;
}

.btn-export-pdf {
  background: linear-gradient(135deg, #F43F5E 0%, #E11D48 100%);
  color: #fff;
  border: 1px solid #BE123C;
  font-weight: 600;
  box-shadow: 0 2px 5px rgba(225, 29, 72, 0.25);
}

.btn-export-pdf:hover {
  background: linear-gradient(135deg, #E11D48 0%, #BE123C 100%);
  box-shadow: 0 4px 10px rgba(225, 29, 72, 0.35);
  transform: translateY(-1px);
  color: #fff;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.btn-pill {
  border-radius: var(--radius-full);
}

/* Search and Filters Bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.search-input {
  flex: 1;
  min-width: 220px;
  padding: 9px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-family: inherit;
  background: #fff;
  transition: border-color var(--transition-fast);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-focus);
}

.filter-select {
  padding: 9px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-family: inherit;
  background: #fff;
  cursor: pointer;
}

/* Excel-like Data Table (ตารางดูแลแม่) */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: #fff;
}

.mom-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
}

.mom-table th {
  background: #F8FAFC;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 12px 14px;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

.mom-table td {
  padding: 12px 14px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.mom-table tr:last-child td {
  border-bottom: none;
}

.mom-table tr:hover td {
  background: rgba(248, 250, 252, 0.8);
}

/* Row Highlight Classes (High-Contrast Priority Colors) */
.mom-table tbody tr.row-critical,
.mom-table tbody tr.row-surgery {
  background-color: #FFE4E6 !important; /* ชมพู/แดง วิกฤต/ผ่าตัด */
  border-left: 5px solid #E11D48 !important;
}

.mom-table tbody tr.row-walkin {
  background-color: #FEE2E2 !important; /* แดง Walk In/ฉุกเฉิน */
  border-left: 5px solid #DC2626 !important;
}

.mom-table tbody tr.row-postponed {
  background-color: #FFEDD5 !important; /* ส้มเลื่อนนัด */
  border-left: 5px solid #EA580C !important;
}

.mom-table tbody tr.row-emergency,
.mom-table tbody tr.row-hospital-stay,
.mom-table tbody tr.row-recovery {
  background-color: #FEF08A !important; /* เหลืองสดใส ฉุกเฉิน/ปรับยา/นอนรพ. */
  border-left: 5px solid #CA8A04 !important;
}

.mom-table tbody tr.row-completed {
  background-color: #DCFCE7 !important; /* เขียวอ่อน เสร็จสิ้น */
  border-left: 5px solid #16A34A !important;
}

.mom-table tbody tr.row-normal,
.mom-table tbody tr.row-pending {
  background-color: #FFFFFF !important; /* ขาว/ปกติ นัดหมายทั่วไป */
  border-left: 5px solid #64748B !important;
}

/* Tags & Badges */
.badge-caregiver {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.83rem;
  font-weight: 500;
  background: #F1F5F9;
  color: var(--text-main);
}

.badge-tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-critical {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #FECACA;
}

.badge-high {
  background: var(--warning-bg);
  color: #B45309;
  border: 1px solid #FDE68A;
}

.badge-normal {
  background: var(--excel-green-bg);
  color: var(--excel-green-text);
}

/* Modal Popup */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
  padding: 16px;
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  transform: scale(0.95);
  transition: transform var(--transition-fast);
}

.modal-backdrop.active .modal-box {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

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

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-family: inherit;
  background: #fff;
  transition: border-color var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-focus);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast-msg {
  background: #fff;
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 14px 18px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s forwards;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ======================================================= */
/* Thai Buddhist Era DatePicker (ปฏิทิน พ.ศ.)               */
/* ======================================================= */
.thai-datepicker-popup {
  position: absolute;
  width: 320px;
  background: #FFFFFF;
  border-radius: 14px;
  box-shadow: 0 12px 30px -4px rgba(0, 0, 0, 0.18), 0 6px 12px -4px rgba(0, 0, 0, 0.08);
  border: 1px solid #E2E8F0;
  padding: 14px;
  z-index: 2100;
  user-select: none;
  font-family: 'Prompt', sans-serif;
  animation: tdpFadeIn 0.15s ease-out;
}

@keyframes tdpFadeIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.tdp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.tdp-select {
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid #CBD5E1;
  font-size: 0.88rem;
  font-weight: 600;
  color: #1E293B;
  background: #F8FAFC;
  cursor: pointer;
  outline: none;
  font-family: inherit;
}
.tdp-select:focus {
  border-color: var(--primary);
}

.tdp-nav-btn {
  background: #F1F5F9;
  border: none;
  border-radius: 8px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: bold;
  color: #475569;
  transition: all 0.15s;
}
.tdp-nav-btn:hover {
  background: var(--primary);
  color: #FFFFFF;
}

.tdp-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: #64748B;
  margin-bottom: 6px;
  padding: 4px 0;
  border-bottom: 1px solid #F1F5F9;
}
.tdp-weekdays span:first-child { color: #EF4444; }
.tdp-weekdays span:last-child { color: #8B5CF6; }

.tdp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.tdp-day {
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.86rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s;
  color: #1E293B;
}
.tdp-day:hover:not(.empty) {
  background: #EEF2FF;
  color: var(--primary);
  font-weight: 600;
}
.tdp-day.selected {
  background: var(--primary) !important;
  color: #FFFFFF !important;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.35);
}
.tdp-day.today {
  border: 1.5px solid var(--primary);
  font-weight: 700;
  color: var(--primary);
}
.tdp-day.today.selected {
  color: #FFFFFF;
}
.tdp-day.other-month {
  color: #CBD5E1;
}

.tdp-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #F1F5F9;
}

/* ==========================================================================
   Vitals Timeframe Filters & Stats Ribbon & Pagination
   ========================================================================== */

.vitals-filter-toolbar {
  background: #F8FAFC;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

.vitals-filter-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.vitals-filter-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.vitals-filter-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.vitals-pill {
  padding: 7px 15px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: #FFFFFF;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
  font-family: inherit;
  box-shadow: var(--shadow-sm);
}

.vitals-pill:hover {
  background: #EEF2FF;
  border-color: #C7D2FE;
  color: var(--primary);
  transform: translateY(-1px);
}

.vitals-pill.active {
  background: linear-gradient(135deg, #4F46E5 0%, #4338CA 100%);
  color: #FFFFFF;
  border-color: #3730A3;
  font-weight: 600;
  box-shadow: 0 3px 8px rgba(79, 70, 229, 0.3);
}

.vitals-custom-range {
  padding-top: 10px;
  border-top: 1px dashed var(--border-color);
  animation: fadeIn 0.2s ease-in-out;
}

.range-inputs-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.range-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.range-field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* KPI Summary Cards Grid */
.vitals-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.vitals-stat-card {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

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

.vitals-stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.vitals-stat-card.stat-bp::before { background: #4F46E5; }
.vitals-stat-card.stat-sugar::before { background: #F59E0B; }
.vitals-stat-card.stat-hr::before { background: #EC4899; }
.vitals-stat-card.stat-spo2::before { background: #06B6D4; }
.vitals-stat-card.stat-count::before { background: #10B981; }

.vitals-stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.vitals-stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.vitals-stat-sub {
  font-size: 0.76rem;
  color: var(--text-light);
  margin-top: 4px;
}

/* Vitals Chart Card */
.vitals-chart-card {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.chart-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.chart-legend-items {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.chart-legend-badge {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.legend-sys { color: #4F46E5; background: #EEF2FF; }
.legend-dia { color: #06B6D4; background: #ECFEFF; }
.legend-sugar { color: #D97706; background: #FFFBEB; }
.legend-hr { color: #E11D48; background: #FFF1F2; }

.chart-range-info {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
  background: #F1F5F9;
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.vitals-chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(8px);
  color: #FFFFFF;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.15);
  z-index: 100;
  transform: translate(-50%, -120%);
  transition: opacity 0.1s ease;
  white-space: nowrap;
}

.vitals-chart-tooltip .tt-title {
  font-weight: 700;
  color: #93C5FD;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  padding-bottom: 3px;
}

.vitals-chart-tooltip .tt-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 2px;
}

/* Pagination Bar */
.vitals-pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 10px;
}

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

.pagination-nav {
  display: flex;
  gap: 4px;
  align-items: center;
}

.page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #FFFFFF;
  color: var(--text-main);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.page-btn:hover:not(:disabled) {
  background: #EEF2FF;
  color: var(--primary);
  border-color: #C7D2FE;
}

.page-btn.active {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
  font-weight: 700;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
}

.page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: #F8FAFC;
}

/* Value Status Classes in Table */
.val-high-bp {
  color: #DC2626;
  font-weight: 700;
  background: #FEE2E2;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  display: inline-block;
}

.val-high-sugar {
  color: #B45309;
  font-weight: 700;
  background: #FEF3C7;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  display: inline-block;
}

.val-low-spo2 {
  color: #DC2626;
  font-weight: 700;
  background: #FEE2E2;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  display: inline-block;
}

/* Print Stylesheet for PDF Export */
@media print {
  body {
    background: #FFFFFF !important;
    color: #000000 !important;
    font-size: 12pt;
  }

  .top-navbar,
  .mobile-bottom-nav,
  .fab-btn,
  .vitals-filter-toolbar,
  .vitals-table-controls,
  .vitals-pagination-bar,
  .card-header-flex button,
  #dbOfflineBanner,
  .nav-user-actions,
  #patientSelectorContainer {
    display: none !important;
  }

  .app-container {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .app-card {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
  }

  .table-responsive {
    border: 1px solid #CBD5E1 !important;
    overflow: visible !important;
  }

  .mom-table th {
    background: #F1F5F9 !important;
    color: #0F172A !important;
    border-bottom: 2px solid #94A3B8 !important;
  }

  .mom-table td {
    border-bottom: 1px solid #E2E8F0 !important;
  }
}
