/* ==========================================================
   Dela Vega Healthcare Services - Patient Portal Stylesheet
   Modern, Mobile-First, Accessible & High-Vibrancy UI
   ========================================================== */

:root {
  /* Brand & Primary Colors */
  --primary-teal: #0e9a83;
  --primary-teal-hover: #0b7c69;
  --primary-blue: #1344fe;
  --primary-blue-hover: #0b2ed6;
  --primary-gradient: linear-gradient(135deg, #0e9a83 0%, #1344fe 100%);
  --primary-gradient-hover: linear-gradient(135deg, #0b7c69 0%, #0b2ed6 100%);
  --hero-gradient: linear-gradient(135deg, #092042 0%, #0e9a83 50%, #1344fe 100%);

  /* Blue Scale */
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-500: #3b82f6;
  --blue-600: #1344fe;
  --blue-700: #0b2ed6;
  --blue-800: #1e40af;

  /* Vibrant Metric Palette */
  --red: #ef4444;
  --red-dark: #b91c1c;
  --red-50: #fef2f2;
  --red-100: #fee2e2;
  --red-gradient: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);

  --orange: #f97316;
  --orange-dark: #c2410c;
  --orange-50: #fff7ed;
  --orange-100: #ffedd5;
  --orange-gradient: linear-gradient(135deg, #f97316 0%, #ea580c 100%);

  --green: #10b981;
  --green-dark: #047857;
  --green-50: #ecfdf5;
  --green-100: #d1fae5;
  --green-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);

  --cyan: #0284c7;
  --cyan-dark: #0369a1;
  --cyan-50: #f0f9ff;
  --cyan-100: #e0f2fe;
  --cyan-gradient: linear-gradient(135deg, #0284c7 0%, #06b6d4 100%);

  --purple: #8b5cf6;
  --purple-dark: #6d28d9;
  --purple-50: #f5f3ff;
  --purple-100: #ede9fe;
  --purple-gradient: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);

  --amber: #f59e0b;
  --amber-dark: #b45309;
  --amber-50: #fffbeb;
  --amber-100: #fef3c7;

  /* Neutrals & Surfaces */
  --ink-900: #0f172a;
  --ink-800: #1e293b;
  --ink-700: #334155;
  --ink-600: #475569;
  --ink-500: #64748b;
  --ink-400: #94a3b8;
  --ink-300: #cbd5e1;
  --ink-200: #e2e8f0;
  --ink-100: #f1f5f9;

  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --bg-tint: #f8fafc;
  --card-bg: #ffffff;

  /* Typography */
  --font-display: 'Bricolage Grotesque', 'Plus Jakarta Sans', 'Segoe UI', sans-serif;
  --font-body: 'Inter', 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;

  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  /* Elevation Shadows */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 2px 8px -2px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px -6px rgba(15, 23, 42, 0.12), 0 4px 8px -4px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 16px 36px -8px rgba(15, 23, 42, 0.16), 0 6px 16px -4px rgba(15, 23, 42, 0.08);
  --shadow-primary: 0 8px 20px -4px rgba(19, 68, 254, 0.35);
  --shadow-teal: 0 8px 20px -4px rgba(14, 154, 131, 0.35);
}

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

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink-800);
  background: var(--bg-tint);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Portal Layout ---- */
.portal-layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg-tint);
}

/* ---- Sidebar ---- */
.portal-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: #ffffff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
  box-shadow: 2px 0 16px rgba(15, 23, 42, 0.04);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.sidebar-logo a {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ink-900);
  text-decoration: none;
}

.sidebar-logo-img {
  height: 42px;
  width: auto;
  max-width: 175px;
  object-fit: contain;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-400);
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}
.sidebar-close:hover {
  background: var(--ink-100);
  color: var(--ink-900);
}

/* User Card in Sidebar */
.sidebar-user-card {
  margin: 14px 14px 4px;
  padding: 12px;
  background: linear-gradient(135deg, rgba(14, 154, 131, 0.08) 0%, rgba(19, 68, 254, 0.08) 100%);
  border: 1px solid var(--blue-100);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.sidebar-user-card:hover {
  transform: translateY(-1px);
  border-color: var(--blue-200);
  box-shadow: var(--shadow-sm);
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}
.sidebar-user-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.sidebar-user-role {
  font-size: 0.75rem;
  color: var(--primary-teal);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}
.sidebar-user-role::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 12px;
  overflow-y: auto;
}
.sidebar-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--ink-600);
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.16s, color 0.16s, transform 0.14s;
}
.sidebar-nav li a svg {
  color: var(--ink-400);
  transition: color 0.16s, transform 0.16s;
  flex-shrink: 0;
}
.sidebar-nav li a:hover {
  background: var(--blue-50);
  color: var(--blue-600);
}
.sidebar-nav li a:hover svg {
  color: var(--blue-600);
  transform: scale(1.1);
}
.sidebar-nav li a.active {
  background: linear-gradient(135deg, rgba(14, 154, 131, 0.12) 0%, rgba(19, 68, 254, 0.12) 100%);
  color: var(--blue-600);
  border-left: 3.5px solid var(--blue-600);
  padding-left: 10.5px;
  box-shadow: inset 0 0 0 1px rgba(19, 68, 254, 0.1);
}
.sidebar-nav li a.active svg {
  color: var(--blue-600);
}

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #ffffff;
}
.sidebar-print-link,
.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.16s, color 0.16s;
}
.sidebar-print-link {
  color: var(--ink-600);
  background: var(--ink-100);
}
.sidebar-print-link:hover {
  background: var(--blue-50);
  color: var(--blue-600);
}
.sidebar-logout {
  color: var(--red-dark);
  background: var(--red-50);
}
.sidebar-logout:hover {
  background: #fee2e2;
  color: #991b1b;
}

/* ---- Mobile Overlay ---- */
.portal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 190;
  opacity: 0;
  transition: opacity 0.28s ease;
}
.portal-overlay.visible {
  display: block;
  opacity: 1;
}

/* ---- Main Area ---- */
.portal-main {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left 0.28s;
}

/* ---- Topbar ---- */
.portal-topbar {
  height: 64px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.topbar-menu-btn {
  display: none;
  background: var(--ink-100);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--ink-800);
  padding: 8px;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.topbar-menu-btn:hover {
  background: var(--blue-50);
  color: var(--blue-600);
}

.topbar-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ink-900);
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  background: var(--blue-50);
  color: var(--blue-600);
  border-radius: var(--radius-full);
  border: 1px solid var(--blue-100);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.topbar-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px 5px 6px;
  background: var(--ink-100);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  text-decoration: none;
  color: var(--ink-800);
  font-size: 0.88rem;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}
.topbar-user-pill:hover {
  background: var(--blue-50);
  border-color: var(--blue-200);
  color: var(--blue-600);
}

.topbar-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-500);
  background: var(--ink-100);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background 0.15s, color 0.15s, transform 0.12s;
}
.topbar-logout:hover {
  background: var(--red-50);
  color: var(--red);
  transform: scale(1.05);
}

/* ---- Avatars ---- */
.patient-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: linear-gradient(135deg, #0e9a83, #1344fe);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.15);
  flex-shrink: 0;
}
.patient-avatar-sm { width: 28px; height: 28px; font-size: 0.75rem; }
.patient-avatar-md { width: 42px; height: 42px; font-size: 0.95rem; }
.patient-avatar-lg { width: 84px; height: 84px; font-size: 1.8rem; border-width: 3px; }
.patient-avatar-xl { width: 104px; height: 104px; font-size: 2.2rem; border-width: 4px; }

/* ---- Content Area ---- */
.portal-content {
  padding: 32px 32px 64px;
}

/* ---- Flash Messages ---- */
.portal-flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 20px;
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  animation: slideDown 0.25s ease-out;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.flash-success {
  background: #ecfdf5;
  color: #065f46;
  border: 1.5px solid #a7f3d0;
}
.flash-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1.5px solid #fecaca;
}
.flash-info {
  background: var(--blue-50);
  color: var(--blue-700);
  border: 1.5px solid var(--blue-200);
}
.flash-close {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  opacity: 0.7;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.14s, background 0.14s;
}
.flash-close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.06);
}

/* ---- Page Headers ---- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 28px;
}
.page-header h1 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--ink-900);
  letter-spacing: -0.02em;
  margin: 0;
}
.page-header p {
  margin: 6px 0 0;
  color: var(--ink-500);
  font-size: 0.95rem;
}

/* ---- Hero Welcome Card (Dashboard) ---- */
.hero-welcome-card {
  background: var(--hero-gradient);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 30px 32px;
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 12px 32px -4px rgba(14, 154, 131, 0.35);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.hero-welcome-card::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0) 70%);
  border-radius: 50%;
  pointer-events: none;
}
.hero-welcome-card::after {
  content: '';
  position: absolute;
  bottom: -30px;
  left: 20%;
  width: 160px;
  height: 160px;
  background: radial-gradient(circle, rgba(19, 68, 254, 0.25) 0%, rgba(19, 68, 254, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
}
.hero-welcome-content {
  display: flex;
  align-items: center;
  gap: 20px;
  position: relative;
  z-index: 2;
}
.hero-welcome-text h1 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 800;
  margin: 0 0 4px;
  color: #ffffff;
}
.hero-welcome-text p {
  margin: 0;
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.95rem;
}
.hero-welcome-actions {
  display: flex;
  gap: 12px;
  position: relative;
  z-index: 2;
  flex-wrap: wrap;
}
.hero-btn-light {
  background: #ffffff;
  color: var(--ink-900);
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.92rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
}
.hero-btn-light:hover {
  background: #f8fafc;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}
.hero-btn-glass {
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s, transform 0.15s;
}
.hero-btn-glass:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: translateY(-2px);
}

/* ---- Cards ---- */
.portal-card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, border-color 0.2s;
}
.portal-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--line-strong);
}
.portal-card + .portal-card {
  margin-top: 22px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink-900);
  margin: 0 0 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-title svg {
  color: var(--blue-600);
}

/* ---- Metric Cards & Stat Grid ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.stat-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
  transition: transform 0.16s, box-shadow 0.16s, border-color 0.16s;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stat-card-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-500);
}

.stat-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-card-icon svg {
  width: 18px;
  height: 18px;
  color: #ffffff;
}

/* Themed metric colors */
.metric-bp .stat-card-icon { background: var(--red-gradient); box-shadow: 0 4px 10px rgba(239, 68, 68, 0.35); }
.metric-bp { border-top: 3.5px solid var(--red); }

.metric-spo2 .stat-card-icon { background: var(--cyan-gradient); box-shadow: 0 4px 10px rgba(2, 132, 199, 0.35); }
.metric-spo2 { border-top: 3.5px solid var(--cyan); }

.metric-pulse .stat-card-icon { background: var(--orange-gradient); box-shadow: 0 4px 10px rgba(249, 115, 22, 0.35); }
.metric-pulse { border-top: 3.5px solid var(--orange); }

.metric-bmi .stat-card-icon { background: var(--green-gradient); box-shadow: 0 4px 10px rgba(16, 185, 129, 0.35); }
.metric-bmi { border-top: 3.5px solid var(--green); }

.metric-sugar .stat-card-icon { background: var(--purple-gradient); box-shadow: 0 4px 10px rgba(139, 92, 246, 0.35); }
.metric-sugar { border-top: 3.5px solid var(--purple); }

.stat-card-value {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--ink-900);
  line-height: 1.1;
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.stat-card-unit {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-400);
}

.stat-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--ink-500);
  border-top: 1px solid var(--ink-100);
  padding-top: 8px;
  margin-top: 2px;
}

.stat-trend-up   { color: var(--red); font-weight: 600; display: inline-flex; align-items: center; gap: 2px; }
.stat-trend-down { color: var(--green); font-weight: 600; display: inline-flex; align-items: center; gap: 2px; }
.stat-trend-flat { color: var(--ink-400); font-weight: 500; }

/* ---- Vital Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.badge-green { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.badge-amber { background: #fef9c3; color: #a16207; border: 1px solid #fef08a; }
.badge-red   { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.badge-muted { background: var(--ink-100); color: var(--ink-600); border: 1px solid var(--line); }
.badge-blue  { background: var(--blue-50); color: var(--blue-700); border: 1px solid var(--blue-200); }
.badge-purple{ background: var(--purple-50); color: var(--purple-dark); border: 1px solid var(--purple-100); }

.badge-pending   { background: #fef9c3; color: #a16207; border: 1px solid #fef08a; }
.badge-confirmed { background: var(--blue-50); color: var(--blue-700); border: 1px solid var(--blue-200); }
.badge-completed { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.badge-cancelled { background: var(--ink-100); color: var(--ink-500); border: 1px solid var(--line); }

/* Live calculation chips inside forms */
.live-vital-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  font-weight: 700;
  margin-top: 4px;
  transition: all 0.2s ease;
}

/* ---- Forms & Controls ---- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}
.form-grid-full { grid-column: 1 / -1; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.form-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink-800);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.form-label .req {
  color: var(--red);
  margin-left: 3px;
  font-weight: 800;
}

.form-control {
  padding: 12px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--ink-900);
  background: #ffffff;
  transition: border-color 0.16s, box-shadow 0.16s, background 0.16s;
  width: 100%;
  min-height: 46px; /* Accessible touch target */
}
.form-control:focus {
  outline: none;
  border-color: var(--blue-600);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(19, 68, 254, 0.14);
}
.form-control.is-invalid {
  border-color: var(--red);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12);
}
.form-error {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--red);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}
.form-hint {
  font-size: 0.82rem;
  color: var(--ink-500);
  margin-top: 2px;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23475569'%3E%3Cpath d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 18px;
  padding-right: 42px;
}
textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

/* Password Input with Show/Hide Toggle */
.password-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}
.password-input-wrap .form-control {
  padding-right: 48px;
}
.password-toggle-btn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-400);
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.password-toggle-btn:hover {
  color: var(--blue-600);
  background: var(--blue-50);
}

/* ---- Buttons (High Vibrancy & Contrast) ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid transparent;
  text-decoration: none;
  min-height: 46px; /* Accessible touch target */
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  user-select: none;
}
.btn:active {
  transform: scale(0.98);
}

/* Primary Button - Bright Blue/Teal Gradient with Glow */
.btn-primary {
  background: var(--primary-gradient) !important;
  color: #ffffff !important;
  border-color: transparent !important;
  box-shadow: var(--shadow-primary);
}
.btn-primary:hover {
  background: var(--primary-gradient-hover) !important;
  box-shadow: 0 10px 24px -2px rgba(19, 68, 254, 0.45);
  transform: translateY(-2px);
  color: #ffffff !important;
}

/* Enter Action Button Badge */
.btn-enter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  margin-left: 4px;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.btn-teal {
  background: linear-gradient(135deg, #0e9a83 0%, #059669 100%) !important;
  color: #ffffff !important;
  box-shadow: var(--shadow-teal);
}
.btn-teal:hover {
  box-shadow: 0 10px 24px -2px rgba(14, 154, 131, 0.45);
  transform: translateY(-2px);
}

.btn-outline {
  background: #ffffff;
  color: var(--blue-600);
  border-color: var(--blue-200);
  box-shadow: var(--shadow-xs);
}
.btn-outline:hover {
  background: var(--blue-50);
  border-color: var(--blue-500);
  color: var(--blue-700);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--red-50);
  color: var(--red-dark);
  border-color: var(--red-100);
}
.btn-danger:hover {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
  transform: translateY(-1px);
}

.btn-lg {
  padding: 14px 30px;
  font-size: 1.05rem;
  min-height: 52px;
  border-radius: var(--radius);
}
.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
  min-height: 38px;
}
.btn-icon {
  padding: 10px;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
}

.btn:disabled, .btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ---- Sticky Bottom Action Bar (Mobile & Desktop) ---- */
.sticky-action-bar {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 90;
  margin: 32px -28px -48px -28px;
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.08);
}
.sticky-action-bar .btn {
  min-width: 140px;
}

/* ---- Progress Bars ---- */
.progress-bar-wrap {
  background: var(--ink-100);
  border-radius: var(--radius-full);
  height: 10px;
  overflow: hidden;
  width: 100%;
  border: 1px solid var(--line);
}
.progress-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--primary-gradient);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--ink-600);
  margin-bottom: 8px;
  font-weight: 600;
}

/* ---- Completeness Banner ---- */
.completeness-wrap {
  background: linear-gradient(135deg, var(--blue-50) 0%, rgba(14, 154, 131, 0.08) 100%);
  border: 1.5px solid var(--blue-100);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-xs);
}
.completeness-wrap .progress-label {
  color: var(--blue-700);
  font-weight: 700;
}

/* ---- Tables ---- */
.portal-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #ffffff;
}
.portal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.portal-table th {
  text-align: left;
  padding: 13px 16px;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-500);
  background: var(--ink-100);
  border-bottom: 1.5px solid var(--line);
  white-space: nowrap;
}
.portal-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-700);
  vertical-align: middle;
}
.portal-table tr:last-child td {
  border-bottom: none;
}
.portal-table tr:hover td {
  background: var(--blue-50);
}
.portal-table tr.row-locked td {
  color: var(--ink-400);
  background: #fafafa;
}

/* ---- Auth Pages (Login / Register / Password Reset) ---- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #092042 0%, #0e9a83 50%, #1344fe 100%);
  padding: 24px;
  position: relative;
}
.auth-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}

.auth-card {
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  padding: 44px 40px;
  width: 100%;
  max-width: 460px;
  position: relative;
  z-index: 2;
  animation: scaleUp 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  margin-bottom: 24px;
}
.auth-logo-img {
  height: 56px;
  width: auto;
  max-width: 240px;
  object-fit: contain;
}

.auth-heading {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--ink-900);
  margin: 0 0 6px;
  text-align: center;
  letter-spacing: -0.02em;
}
.auth-subtext {
  color: var(--ink-500);
  font-size: 0.94rem;
  margin: 0 0 28px;
  text-align: center;
}

.auth-link-row {
  text-align: center;
  font-size: 0.9rem;
  color: var(--ink-500);
  margin-top: 22px;
}
.auth-link-row a {
  color: var(--blue-600);
  font-weight: 700;
  text-decoration: none;
  transition: color 0.15s;
}
.auth-link-row a:hover {
  color: var(--blue-700);
  text-decoration: underline;
}

/* Password Strength Meter */
.pw-strength {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.pw-strength-bar {
  flex: 1;
  height: 5px;
  border-radius: var(--radius-full);
  background: var(--line);
  transition: background 0.25s ease;
}
.pw-strength-text {
  font-size: 0.78rem;
  font-weight: 700;
  margin-top: 4px;
  display: block;
}

/* Dynamic Rows (Meds, Kin, Surgery) */
.med-rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}
.med-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 12px;
  align-items: end;
  background: var(--bg-tint);
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
.kin-row {
  background: var(--bg-tint);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
}
.kin-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.kin-row-header strong {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink-800);
}

/* Toggle Switch */
.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-info { flex: 1; }
.toggle-info strong { font-size: 0.96rem; color: var(--ink-900); display: block; font-weight: 700; }
.toggle-info small { font-size: 0.84rem; color: var(--ink-500); margin-top: 2px; display: block; }
.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
  margin-top: 2px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--ink-300);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--primary-gradient);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

/* Checkboxes & Radio Pills */
.check-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-700);
  background: #ffffff;
  transition: all 0.16s ease;
  user-select: none;
}
.check-item input[type="checkbox"],
.check-item input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--blue-600);
  flex-shrink: 0;
}
.check-item:hover {
  border-color: var(--blue-300);
  background: var(--blue-50);
}
.check-item:has(input:checked) {
  background: var(--blue-50);
  border-color: var(--blue-600);
  color: var(--blue-700);
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(19, 68, 254, 0.12);
}

/* Charts */
.chart-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 22px;
  margin-bottom: 28px;
}
.chart-box {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.chart-box-title {
  font-size: 0.88rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-600);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chart-box canvas {
  max-height: 240px;
}

/* Date Range Filter Bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.date-range-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.date-range-btns button {
  padding: 8px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 700;
  background: #ffffff;
  color: var(--ink-600);
  cursor: pointer;
  transition: all 0.14s ease;
  min-height: 38px;
}
.date-range-btns button.active,
.date-range-btns button:hover {
  background: var(--blue-600);
  border-color: var(--blue-600);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(19, 68, 254, 0.3);
}

/* ==========================================================
   Mobile & Responsive Breakpoints
   ========================================================== */

@media (max-width: 960px) {
  .portal-sidebar {
    transform: translateX(-280px);
  }
  .portal-sidebar.open {
    transform: translateX(0);
  }
  .sidebar-close {
    display: flex;
  }
  .portal-main {
    margin-left: 0;
  }
  .topbar-menu-btn {
    display: flex;
  }
  .portal-topbar {
    padding: 0 16px;
  }
  .portal-content {
    padding: 20px 16px 60px;
  }
  .sticky-action-bar {
    margin: 24px -16px -60px -16px;
    padding: 12px 16px;
  }
  .chart-row {
    grid-template-columns: 1fr;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .med-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .hero-welcome-card {
    padding: 22px 20px;
    flex-direction: column;
    align-items: flex-start;
  }
  .hero-welcome-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .hero-welcome-text h1 {
    font-size: 1.45rem;
  }
  .hero-welcome-actions {
    width: 100%;
  }
  .hero-welcome-actions .btn,
  .hero-welcome-actions a {
    width: 100%;
    justify-content: center;
  }

  .stat-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .auth-card {
    padding: 30px 20px;
    border-radius: var(--radius);
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .page-header h1 {
    font-size: 1.4rem;
  }
  .topbar-user-name {
    display: none;
  }
  .sticky-action-bar {
    flex-direction: column-reverse;
    gap: 10px;
  }
  .sticky-action-bar .btn {
    width: 100%;
  }
}

/* Print Styles */
@media print {
  .portal-sidebar,
  .portal-topbar,
  .portal-overlay,
  .btn,
  .filter-bar,
  .sticky-action-bar,
  .no-print {
    display: none !important;
  }
  .portal-main { margin-left: 0 !important; }
  .portal-content { padding: 0 !important; }
  .portal-card { box-shadow: none; border: 1px solid #ccc; }
  body { font-size: 12px; background: #fff; }
}
