/* ============================================================
   ICU Drip Rate Calculator — Design System
   Theme: Medical Blue UI
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ── CSS Custom Properties ── */
:root {
  /* ── Medical Blue Palette ── */
  --blue-50: #EFF6FF;
  --blue-100: #DBEAFE;
  --blue-200: #BFDBFE;
  --blue-300: #93C5FD;
  --blue-400: #60A5FA;
  --blue-500: #2563EB;
  --blue-600: #1D4ED8;
  --blue-700: #1E40AF;
  --blue-800: #1E3A8A;
  --blue-900: #0F2B5B;
  --blue-950: #023B72;

  /* ── Slate / Charcoal Grey Palette ── */
  --slate-50: #F8FAFC;
  --slate-100: #F1F5F9;
  --slate-200: #E2E8F0;
  --slate-300: #CBD5E1;
  --slate-400: #94A3B8;
  --slate-500: #64748B;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1E293B;
  --slate-900: #0F172A;

  /* ── Mapped System Colors to Medical Blue ── */
  --orange-50: #EFF6FF;
  --orange-100: #DBEAFE;
  --orange-200: #BFDBFE;
  --orange-300: #93C5FD;
  --orange-400: #60A5FA;
  --orange-500: #2563EB;
  --orange-600: #1D4ED8;
  --orange-700: #1E40AF;
  --orange-800: #1E3A8A;
  --orange-900: #023B72;

  --white: #FFFFFF;
  --gray-50: #F8FAFC;
  --gray-100: #F1F5F9;
  --gray-200: #E2E8F0;
  --gray-300: #CBD5E1;
  --gray-400: #94A3B8;
  --gray-500: #64748B;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1E293B;
  --gray-900: #0F172A;

  --success: #10B981;
  --success-bg: #ECFDF5;
  --warning: #F59E0B;
  --warning-bg: #FFFBEB;
  --danger: #EF4444;
  --danger-bg: #FEF2F2;
  --info: #2563EB;
  --info-bg: #EFF6FF;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 8px 30px rgba(15, 23, 42, 0.12);
  --shadow-xl: 0 20px 50px rgba(15, 23, 42, 0.15);
  --shadow-orange: 0 4px 20px rgba(37, 99, 235, 0.35);
  --shadow-blue: 0 6px 24px rgba(2, 59, 114, 0.4);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Reset & Global ── */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(135deg, rgba(2, 59, 114, 0.82) 0%, rgba(15, 23, 42, 0.88) 100%), url('assets/bg.jpg') center/cover no-repeat;
  background-attachment: scroll;
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--blue-300); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--blue-400); }

/* ── ICU Telemetry Theme Header ── */
.app-header.icu-theme-header {
  background: linear-gradient(135deg, #022B54 0%, #0A3A6B 50%, #064E89 100%);
  color: var(--white);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 8px 30px rgba(2, 43, 84, 0.5), 0 2px 10px rgba(0, 0, 0, 0.3);
  transform: translateZ(0);
  will-change: transform;
  border-bottom: 1px solid rgba(34, 211, 238, 0.25);
  overflow: hidden;
}

/* ECG Pulse Heartbeat Wave Animation — sits behind the brand title */
.icu-ecg-bar {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.icu-ecg-wave {
  width: 200%;
  height: 100%;
  display: block;
  animation: ecgScroll 6s linear infinite;
}

@keyframes ecgScroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.header-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 14px 20px 10px;
  gap: 16px;
}

.header-left-space {
  grid-column: 1;
}

.header-brand.icu-monitor-frame {
  grid-column: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 8px 24px;
  background: linear-gradient(135deg, rgba(2, 35, 68, 0.82) 0%, rgba(8, 55, 102, 0.82) 100%);
  border: 1.5px solid rgba(34, 211, 238, 0.4);
  border-radius: var(--radius-xl);
  box-shadow: 0 8px 25px rgba(2, 35, 68, 0.6), inset 0 1px 2px rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-align: center;
}

.header-brand.icu-monitor-frame::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.15) 0%, transparent 65%);
  pointer-events: none;
  animation: telemetryPulseGlow 4s infinite ease-in-out;
}

@keyframes telemetryPulseGlow {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 0.95; transform: scale(1.1); }
}

.header-brand.icu-monitor-frame:hover {
  border-color: #22D3EE;
  box-shadow: 0 12px 32px rgba(34, 211, 238, 0.4), inset 0 1px 3px rgba(255, 255, 255, 0.4);
  transform: translateY(-2px);
}

.icu-brand-badge {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.3), rgba(37, 99, 235, 0.4));
  border: 1.5px solid rgba(34, 211, 238, 0.5);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #22D3EE;
  box-shadow: 0 4px 16px rgba(6, 182, 212, 0.4);
  backdrop-filter: blur(10px);
  transition: var(--transition-fast);
}

.icu-brand-badge:hover {
  transform: scale(1.08) rotate(5deg);
  border-color: #22D3EE;
  box-shadow: 0 6px 24px rgba(34, 211, 238, 0.6);
}

.header-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.icu-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
  padding: 2px 10px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: var(--radius-full);
}

.icu-live-dot {
  width: 7px;
  height: 7px;
  background: #10B981;
  border-radius: 50%;
  box-shadow: 0 0 10px #10B981, 0 0 4px #10B981;
  animation: livePulse 1.8s infinite ease-in-out;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.8); }
}

.icu-status-text {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: #22D3EE;
  text-transform: uppercase;
}

.header-title h1 {
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.25;
  background: linear-gradient(180deg, #FFFFFF 0%, #E0F2FE 55%, #BAE6FD 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
}

.header-title p {
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: #38BDF8;
  text-transform: uppercase;
  margin-top: 1px;
}

.header-actions {
  grid-column: 3;
  justify-self: end;
  display: flex;
  gap: 10px;
}

.icu-action-btn {
  width: 42px;
  height: 42px;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  backdrop-filter: blur(10px);
}

.icu-action-btn:hover {
  background: rgba(34, 211, 238, 0.25);
  border-color: rgba(34, 211, 238, 0.7);
  color: #22D3EE;
  transform: translateY(-3px) scale(1.08);
  box-shadow: 0 6px 20px rgba(34, 211, 238, 0.45);
}

.icu-action-btn:active {
  transform: scale(0.94);
}

.icu-action-btn svg {
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.icu-action-btn:hover svg {
  transform: rotate(8deg) scale(1.1);
}

/* ── Animated Search Bar ── */
.search-container {
  padding: 0 20px 14px;
}

.search-wrapper.icu-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.icu-search-icon {
  position: absolute;
  left: 16px;
  color: #93C5FD;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: transform 0.3s ease, color 0.3s ease;
}

.icu-search-wrapper:hover .icu-search-icon {
  color: #22D3EE;
  transform: scale(1.15) rotate(-5deg);
}

.icu-search-input {
  width: 100%;
  height: 46px;
  padding: 0 44px 0 46px;
  border: 1.5px solid rgba(147, 197, 253, 0.35);
  border-radius: var(--radius-full);
  background: rgba(2, 30, 58, 0.65);
  color: var(--white);
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
  backdrop-filter: blur(14px);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: searchGlowPulse 4s infinite ease-in-out;
}

@keyframes searchGlowPulse {
  0%, 100% { border-color: rgba(147, 197, 253, 0.35); box-shadow: 0 4px 15px rgba(2, 43, 84, 0.3); }
  50% { border-color: rgba(34, 211, 238, 0.55); box-shadow: 0 4px 20px rgba(34, 211, 238, 0.2); }
}

.icu-search-input::placeholder {
  color: rgba(219, 234, 254, 0.65);
  transition: opacity 0.25s ease;
}

.icu-search-input:focus::placeholder {
  opacity: 0.4;
}

.icu-search-input:focus {
  border-color: #22D3EE;
  background: rgba(2, 30, 58, 0.9);
  box-shadow: 0 0 25px rgba(34, 211, 238, 0.4), 0 0 0 4px rgba(34, 211, 238, 0.2);
  transform: translateY(-1px);
}
  font-size: 16px;
  opacity: 0.7;
  color: var(--orange-700);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 44px;
  padding: 0 44px 0 42px;
  border: 2px solid transparent;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.95);
  color: var(--gray-800);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition-fast);
}

.search-input::placeholder {
  color: var(--gray-400);
}

.search-input:focus {
  border-color: var(--orange-300);
  box-shadow: 0 0 0 3px rgba(249,115,22,0.15);
}

.search-clear {
  position: absolute;
  right: 10px;
  width: 28px;
  height: 28px;
  border: none;
  background: var(--gray-200);
  color: var(--gray-500);
  border-radius: 50%;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: var(--transition-fast);
}

.search-clear.visible {
  display: flex;
}

.search-clear:hover {
  background: var(--gray-300);
}

/* ── Category Pills ── */
.category-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px 14px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.category-bar::-webkit-scrollbar { display: none; }

.category-bar-btn {
  flex-shrink: 0;
}

.category-pills {
  display: flex;
  gap: 8px;
  min-width: max-content;
}

.category-pill {
  padding: 8px 18px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  background: rgba(2, 30, 58, 0.5);
  color: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  animation: pillEntrance 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

@keyframes pillEntrance {
  0% { opacity: 0; transform: translateY(12px) scale(0.92); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.category-pill:hover {
  background: rgba(34, 211, 238, 0.25);
  border-color: rgba(34, 211, 238, 0.6);
  color: #FFFFFF;
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 4px 14px rgba(34, 211, 238, 0.3);
}

.category-pill:active {
  transform: translateY(0) scale(0.97);
}

.category-pill.active {
  background: linear-gradient(135deg, #FFFFFF 0%, #EFF6FF 100%);
  color: #023B72;
  border-color: #FFFFFF;
  box-shadow: 0 4px 18px rgba(255, 255, 255, 0.4), 0 0 12px rgba(34, 211, 238, 0.5);
  animation: activePillGlow 3s infinite ease-in-out;
}

@keyframes activePillGlow {
  0%, 100% { box-shadow: 0 4px 18px rgba(255, 255, 255, 0.4), 0 0 12px rgba(34, 211, 238, 0.5); }
  50% { box-shadow: 0 6px 24px rgba(255, 255, 255, 0.6), 0 0 18px rgba(34, 211, 238, 0.8); }
}

/* ── Main Content Area ── */
.app-main {
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

/* ── Drug Grid ── */
.drug-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.drug-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 0;
  cursor: pointer;
  border: 2px solid var(--gray-100);
  transition: var(--transition-base);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateZ(0);
  contain: layout style paint;
}

.drug-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--card-accent, var(--blue-500));
  opacity: 0;
  transition: var(--transition-fast);
  z-index: 2;
}

.drug-card:hover {
  border-color: var(--blue-300);
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}

.drug-card:hover::before {
  opacity: 1;
}

.drug-card.selected {
  border-color: var(--blue-500);
  box-shadow: var(--shadow-blue);
}

.drug-card.selected::before {
  opacity: 1;
}

.drug-card-banner {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--blue-900);
  position: relative;
  overflow: hidden;
}

.drug-card-banner-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.drug-card:hover .drug-card-banner-img {
  transform: scale(1.06);
}

.drug-card-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(15, 23, 42, 0.85);
  color: var(--white);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  z-index: 1;
}

.drug-card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.drug-card-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 2px;
}

.drug-card-generic {
  font-size: 0.78rem;
  color: var(--gray-500);
  margin-bottom: 10px;
}

.drug-card-info {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.drug-card-tag {
  font-size: 0.72rem;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  gap: 4px;
}

.drug-card-tag span {
  font-size: 12px;
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  grid-column: 1 / -1;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 1.1rem;
  color: var(--gray-600);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 0.85rem;
  color: var(--gray-400);
}

/* ── Calculator Panel (Slide-in Overlay) ── */
.calc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-base);
  backdrop-filter: blur(4px);
}

.calc-overlay.open {
  opacity: 1;
  visibility: visible;
}

.calc-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(520px, 100vw);
  background: var(--white);
  z-index: 201;
  transform: translateX(100%);
  transition: var(--transition-slow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.calc-panel.open {
  transform: translateX(0);
}

.calc-panel-header {
  background: linear-gradient(180deg, rgba(2, 59, 114, 0.65) 0%, rgba(15, 23, 42, 0.92) 100%), #023B72;
  background-size: cover;
  background-position: center;
  color: var(--white);
  padding: 24px 20px 20px;
  flex-shrink: 0;
  position: relative;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  box-shadow: 0 4px 25px rgba(0, 0, 0, 0.35);
}

.calc-panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.calc-back-btn {
  width: 40px;
  height: 40px;
  border: 1.5px solid rgba(255, 255, 255, 0.5);
  background: rgba(2, 59, 114, 0.75);
  color: var(--white);
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: var(--transition-fast);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.calc-back-btn:hover {
  background: rgba(30, 64, 175, 0.95);
  border-color: rgba(255, 255, 255, 0.9);
  transform: scale(1.06);
}

/* ── Floating Medical Blue Back Button (Lower Right) ── */
.calc-floating-back-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: linear-gradient(135deg, rgba(2, 59, 114, 0.95), rgba(30, 64, 175, 0.95));
  color: var(--white);
  border: 1.5px solid rgba(255, 255, 255, 0.75);
  border-radius: var(--radius-full);
  box-shadow: 0 10px 30px rgba(2, 59, 114, 0.6), 0 4px 14px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
  outline: none;
  font-weight: 700;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: floatBtnPulse 3s infinite ease-in-out;
}

.calc-floating-back-btn:hover {
  background: linear-gradient(135deg, rgba(30, 64, 175, 0.95), rgba(37, 99, 235, 0.95));
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.6), 0 6px 16px rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.95);
}

.calc-floating-back-btn:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 4px 12px rgba(2, 59, 114, 0.4);
}

@keyframes floatBtnPulse {
  0%, 100% {
    box-shadow: 0 10px 30px rgba(2, 59, 114, 0.6), 0 4px 14px rgba(0, 0, 0, 0.3);
  }
  50% {
    box-shadow: 0 14px 36px rgba(37, 99, 235, 0.75), 0 6px 18px rgba(0, 0, 0, 0.4);
  }
}

.calc-drug-name {
  font-size: 1.2rem;
  font-weight: 700;
}

.calc-drug-generic {
  font-size: 0.78rem;
  opacity: 0.85;
}

.calc-drug-formulation {
  font-size: 0.75rem;
  opacity: 0.75;
  margin-top: 4px;
}

/* ── Mode Switcher ── */
.mode-switcher {
  display: flex;
  background: var(--gray-100);
  border-radius: var(--radius-full);
  padding: 4px;
  margin: 16px 20px;
  flex-shrink: 0;
}

.mode-btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition-fast);
  background: transparent;
  color: var(--gray-500);
}

.mode-btn.active {
  background: var(--orange-500);
  color: var(--white);
  box-shadow: var(--shadow-sm);
}

.mode-btn:not(.active):hover {
  color: var(--gray-700);
}

/* ── Calculator Body ── */
.calc-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 20px;
}

/* ── Input Sections ── */
.calc-section {
  margin-bottom: 20px;
}

.calc-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-400);
  margin-bottom: 10px;
  padding-top: 4px;
}

.input-group {
  margin-bottom: 14px;
}

.input-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.input-label-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-700);
}

.input-label-unit {
  font-size: 0.75rem;
  color: var(--gray-400);
  font-weight: 500;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-field {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--gray-800);
  background: var(--white);
  outline: none;
  transition: var(--transition-fast);
  -moz-appearance: textfield;
}

.input-field::-webkit-outer-spin-button,
.input-field::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.input-field:focus {
  border-color: var(--orange-400);
  box-shadow: 0 0 0 3px rgba(249,115,22,0.1);
}

.input-field.warning {
  border-color: var(--warning);
  box-shadow: 0 0 0 3px rgba(217,119,6,0.1);
}

.input-field.danger {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220,38,38,0.1);
}

.input-suffix {
  position: absolute;
  right: 14px;
  font-size: 0.82rem;
  color: var(--gray-400);
  font-weight: 500;
  pointer-events: none;
}

/* ── Concentration Selector ── */
.conc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.conc-option {
  padding: 10px 12px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: var(--white);
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: center;
}

.conc-option:hover {
  border-color: var(--orange-300);
  background: var(--orange-50);
}

.conc-option.active {
  border-color: var(--orange-500);
  background: var(--orange-50);
}

.conc-option-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--orange-600);
  margin-bottom: 2px;
}

.conc-option-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-800);
}

.conc-option-mix {
  font-size: 0.68rem;
  color: var(--gray-400);
  margin-top: 2px;
}

/* ── Volume Toggle ── */
.vol-toggle {
  display: flex;
  gap: 8px;
}

.vol-btn {
  flex: 1;
  padding: 10px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: var(--white);
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  transition: var(--transition-fast);
}

.vol-btn:hover {
  border-color: var(--orange-300);
}

.vol-btn.active {
  border-color: var(--orange-500);
  background: var(--orange-50);
}

.vol-btn-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gray-700);
}

.vol-btn-desc {
  font-size: 0.7rem;
  color: var(--gray-400);
  margin-top: 2px;
}

/* ── Result Display ── */
.result-card {
  background: linear-gradient(135deg, var(--orange-500), var(--orange-600));
  border-radius: var(--radius-lg);
  padding: 24px;
  color: var(--white);
  text-align: center;
  margin-top: 20px;
  position: relative;
  overflow: hidden;
}

.result-card::before {
  content: '';
  position: absolute;
  top: -30%;
  right: -20%;
  width: 160px;
  height: 160px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
}

.result-card::after {
  content: '';
  position: absolute;
  bottom: -20%;
  left: -10%;
  width: 120px;
  height: 120px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
}

.result-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.85;
  font-weight: 600;
  margin-bottom: 8px;
}

.result-value {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
  position: relative;
  z-index: 1;
}

.result-unit {
  font-size: 0.9rem;
  opacity: 0.85;
  font-weight: 500;
}

.result-details {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.2);
  display: flex;
  justify-content: center;
  gap: 24px;
  position: relative;
  z-index: 1;
}

.result-detail {
  text-align: center;
}

.result-detail-label {
  font-size: 0.68rem;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.result-detail-value {
  font-size: 1rem;
  font-weight: 700;
}

/* ── Dose Range Warning ── */
.dose-warning {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: 10px;
  animation: fadeIn var(--transition-base) ease;
}

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

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

.dose-warning.info {
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid #BFDBFE;
}

.dose-warning.success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid #BBF7D0;
}

.dose-warning-icon {
  font-size: 16px;
  flex-shrink: 0;
}

/* ── Mixing Instructions ── */
.mixing-card {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-top: 12px;
}

.mixing-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--orange-600);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mixing-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 0.82rem;
}

.mixing-label {
  color: var(--gray-500);
}

.mixing-value {
  font-weight: 600;
  color: var(--gray-800);
}

/* ── Dose Range Bar ── */
.dose-range-bar {
  margin-top: 12px;
}

.dose-range-track {
  height: 6px;
  background: var(--gray-200);
  border-radius: var(--radius-full);
  position: relative;
  overflow: visible;
}

.dose-range-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--success), var(--warning), var(--danger));
  border-radius: var(--radius-full);
  width: 100%;
}

.dose-range-marker {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  background: var(--white);
  border: 3px solid var(--orange-500);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: var(--transition-fast);
  box-shadow: var(--shadow-sm);
  z-index: 1;
}

.dose-range-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 0.7rem;
  color: var(--gray-400);
}

/* ── Electrolyte Calculator ── */
.electrolyte-result {
  background: var(--orange-50);
  border: 1px solid var(--orange-200);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 16px;
}

.electrolyte-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--orange-100);
}

.electrolyte-row:last-child {
  border-bottom: none;
  font-weight: 700;
  color: var(--orange-700);
  font-size: 1rem;
  padding-top: 10px;
}

/* ── Bolus Info Card ── */
.bolus-card {
  background: var(--info-bg);
  border: 1px solid #BFDBFE;
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 14px;
}

.bolus-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--info);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.bolus-text {
  font-size: 0.82rem;
  color: var(--gray-700);
  line-height: 1.5;
}

/* ── Quick Reference Panel ── */
.quick-ref-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 300;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-base);
  backdrop-filter: blur(4px);
}

.quick-ref-overlay.open {
  opacity: 1;
  visibility: visible;
}

.quick-ref-panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(420px, 90vw);
  background: var(--white);
  z-index: 301;
  transform: translateX(-100%);
  transition: var(--transition-slow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.quick-ref-panel.open {
  transform: translateX(0);
}

.quick-ref-header {
  background: linear-gradient(135deg, var(--orange-500), var(--orange-600));
  color: var(--white);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.quick-ref-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.quick-ref-close {
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255,255,255,0.15);
  color: var(--white);
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.quick-ref-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.ref-section {
  margin-bottom: 24px;
}

.ref-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--orange-600);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--orange-100);
}

.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.ref-table th {
  text-align: left;
  padding: 6px 10px;
  background: var(--orange-50);
  color: var(--orange-700);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ref-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}

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

/* ── Converter Widget ── */
.converter-widget {
  background: var(--gray-50);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 12px;
}

.converter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.converter-row:last-child {
  margin-bottom: 0;
}

.converter-input {
  flex: 1;
  height: 40px;
  padding: 0 12px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition-fast);
}

.converter-input:focus {
  border-color: var(--orange-400);
}

.converter-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gray-500);
  min-width: 40px;
}

.converter-arrow {
  font-size: 16px;
  color: var(--orange-400);
}

/* ── Swan-Ganz Table ── */
.swan-ganz-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.swan-ganz-table th,
.swan-ganz-table td {
  padding: 8px 10px;
  text-align: center;
  border: 1px solid var(--gray-200);
}

.swan-ganz-table th {
  background: var(--orange-50);
  color: var(--orange-700);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
}

/* ── Pupil Scale ── */
.pupil-scale {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  padding: 16px 0;
}

.pupil-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.pupil-dot {
  background: var(--gray-800);
  border-radius: 50%;
}

.pupil-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gray-500);
}

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

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

.drug-card {
  animation: fadeIn var(--transition-slow) ease both;
}

.drug-card:nth-child(1) { animation-delay: 0ms; }
.drug-card:nth-child(2) { animation-delay: 40ms; }
.drug-card:nth-child(3) { animation-delay: 80ms; }
.drug-card:nth-child(4) { animation-delay: 120ms; }
.drug-card:nth-child(5) { animation-delay: 160ms; }
.drug-card:nth-child(6) { animation-delay: 200ms; }
.drug-card:nth-child(7) { animation-delay: 240ms; }
.drug-card:nth-child(8) { animation-delay: 280ms; }
.drug-card:nth-child(9) { animation-delay: 320ms; }
.drug-card:nth-child(10) { animation-delay: 360ms; }
.drug-card:nth-child(11) { animation-delay: 400ms; }
.drug-card:nth-child(12) { animation-delay: 440ms; }
.drug-card:nth-child(13) { animation-delay: 480ms; }
.drug-card:nth-child(14) { animation-delay: 520ms; }
.drug-card:nth-child(15) { animation-delay: 560ms; }
.drug-card:nth-child(16) { animation-delay: 600ms; }

.result-card {
  animation: slideUp var(--transition-slow) ease;
}

/* ── Responsive: Tablets & Small Screens ── */
@media (max-width: 768px) {
  .drug-grid {
    grid-template-columns: 1fr;
  }

  .calc-panel {
    width: 100vw;
  }

  .quick-ref-panel {
    width: 100vw;
  }

  .result-value {
    font-size: 2.2rem;
  }

  .conc-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .app-main {
    padding: 16px 12px;
  }

  .header-top {
    padding: 12px 14px 10px;
  }

  .search-container {
    padding: 0 14px 10px;
  }

  .category-bar {
    padding: 0 14px 10px;
  }

  .vol-toggle {
    flex-wrap: wrap;
  }

  .vol-btn {
    min-width: calc(50% - 4px);
    flex: 0 0 auto;
  }

  .result-details {
    flex-wrap: wrap;
    gap: 12px;
  }
}

/* ── Responsive: Phones (≤ 480px) ── */
@media (max-width: 480px) {
  html {
    font-size: 15px;
  }

  /* Header compact for phones */
  .app-header {
    position: sticky;
    top: 0;
    z-index: 100;
  }

  .header-top {
    padding: 10px 12px 8px;
  }

  .header-icon {
    width: 34px;
    height: 34px;
    font-size: 17px;
    border-radius: 10px;
  }

  .header-brand {
    gap: 8px;
  }

  .header-title h1 {
    font-size: 0.88rem;
    line-height: 1.2;
  }

  .header-title p {
    font-size: 0.6rem;
  }

  .header-actions {
    gap: 6px;
  }

  .header-btn {
    width: 36px;
    height: 36px;
    font-size: 16px;
    border-radius: 10px;
  }

  /* Search bar compact */
  .search-container {
    padding: 0 12px 8px;
  }

  .search-input {
    height: 40px;
    font-size: 0.85rem;
    padding: 0 38px 0 36px;
  }

  .search-icon {
    left: 12px;
    font-size: 14px;
  }

  .search-clear {
    right: 8px;
    width: 24px;
    height: 24px;
    font-size: 12px;
  }

  /* Category pills compact */
  .category-bar {
    padding: 0 12px 8px;
  }

  .category-pill {
    padding: 6px 12px;
    font-size: 0.72rem;
  }

  /* Main content */
  .app-main {
    padding: 10px 8px;
  }

  .drug-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* Drug cards compact */
  .drug-card {
    padding: 14px;
    border-radius: 14px;
  }

  .drug-card-icon {
    width: 34px;
    height: 34px;
    font-size: 16px;
    border-radius: 10px;
  }

  .drug-card-name {
    font-size: 0.92rem;
  }

  .drug-card-generic {
    font-size: 0.72rem;
    margin-bottom: 6px;
  }

  .drug-card-badge {
    font-size: 0.6rem;
    padding: 2px 6px;
  }

  .drug-card-tag {
    font-size: 0.68rem;
  }

  .drug-card-tag span {
    font-size: 11px;
  }

  /* Calculator panel full-screen on phone */
  .calc-panel {
    width: 100vw;
    border-radius: 0;
  }

  .calc-panel-header {
    padding: 14px 12px;
  }

  .calc-drug-name {
    font-size: 1rem;
  }

  .calc-drug-generic {
    font-size: 0.72rem;
  }

  .calc-drug-formulation {
    font-size: 0.68rem;
  }

  .calc-back-btn {
    width: 34px;
    height: 34px;
    font-size: 16px;
  }

  /* Mode switcher compact */
  .mode-switcher {
    margin: 10px 12px;
  }

  .mode-btn {
    padding: 9px 10px;
    font-size: 0.78rem;
  }

  /* Calculator body */
  .calc-body {
    padding: 0 12px 16px;
  }
}

/* ── Formula Breakdown & Computation Card ── */
.formula-toggle-btn {
  width: 100%;
  margin-top: 12px;
  padding: 10px 14px;
  border: 2px solid var(--orange-300);
  border-radius: var(--radius-md);
  background: var(--orange-50);
  color: var(--orange-700);
  font-size: 0.82rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.formula-toggle-btn:hover {
  background: var(--orange-100);
  border-color: var(--orange-400);
  color: var(--orange-800);
  transform: translateY(-1px);
}

.formula-toggle-btn:active {
  transform: scale(0.98);
}

.formula-card {
  margin-top: 12px;
  background: var(--white);
  border: 2px solid var(--orange-200);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-md);
  animation: slideDown var(--transition-base) ease;
}

.formula-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px dashed var(--orange-200);
  padding-bottom: 10px;
  margin-bottom: 12px;
}

.formula-card-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--orange-700);
  display: flex;
  align-items: center;
  gap: 6px;
}

.formula-equation-box {
  background: linear-gradient(135deg, var(--gray-900), #1E293B);
  color: #FDBA74;
  padding: 12px;
  border-radius: var(--radius-md);
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 14px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
  word-break: break-word;
}

.formula-step-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.formula-step-item {
  background: var(--gray-50);
  border-left: 3px solid var(--orange-500);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 10px 12px;
}

.formula-step-num {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--orange-600);
  margin-bottom: 2px;
}

.formula-step-desc {
  font-size: 0.8rem;
  color: var(--gray-700);
  font-weight: 600;
}

.formula-step-math {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.82rem;
  color: var(--gray-900);
  font-weight: 700;
  margin-top: 4px;
  background: var(--white);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  word-break: break-word;
}

.formula-final-box {
  margin-top: 12px;
  background: var(--orange-500);
  color: var(--white);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 0.88rem;
}

.formula-final-val {
  font-size: 1.1rem;
  font-weight: 800;
}

  .calc-section {
    margin-bottom: 14px;
  }

  .calc-section-title {
    font-size: 0.68rem;
    margin-bottom: 8px;
  }

  /* Input fields — touch-friendly */
  .input-field {
    height: 46px;
    font-size: 1rem;
    padding: 0 14px;
    border-radius: 10px;
  }

  .input-label-text {
    font-size: 0.82rem;
  }

  .input-label-unit {
    font-size: 0.7rem;
  }

  .input-suffix {
    font-size: 0.78rem;
    right: 12px;
  }

  /* Volume toggle compact */
  .vol-toggle {
    gap: 6px;
    flex-wrap: wrap;
  }

  .vol-btn {
    padding: 8px;
    border-radius: 10px;
    min-width: calc(33.33% - 4px);
    flex: 1 1 auto;
  }

  .vol-btn-label {
    font-size: 0.78rem;
  }

  .vol-btn-desc {
    font-size: 0.65rem;
  }

  /* Concentration grid compact */
  .conc-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .conc-option {
    padding: 8px 8px;
    border-radius: 10px;
  }

  .conc-option-label {
    font-size: 0.68rem;
  }

  .conc-option-value {
    font-size: 0.82rem;
  }

  .conc-option-mix {
    font-size: 0.62rem;
  }

  /* Result card compact */
  .result-card {
    padding: 18px 14px;
    border-radius: 14px;
    margin-top: 14px;
  }

  .result-label {
    font-size: 0.72rem;
    margin-bottom: 6px;
  }

  .result-value {
    font-size: 2rem;
  }

  .result-unit {
    font-size: 0.82rem;
  }

  .result-details {
    margin-top: 12px;
    padding-top: 12px;
    gap: 14px;
    flex-wrap: wrap;
  }

  .result-detail-label {
    font-size: 0.65rem;
  }

  .result-detail-value {
    font-size: 0.85rem;
  }

  /* Mixing instructions compact */
  .mixing-card {
    padding: 12px;
    border-radius: 12px;
  }

  .mixing-title {
    font-size: 0.82rem;
  }

  .mixing-step {
    font-size: 0.78rem;
    padding: 6px 0;
  }

  /* Quick reference panel */
  .quick-ref-panel {
    width: 100vw;
    border-radius: 0;
  }

  /* Notes section */
  .notes-card {
    padding: 12px;
    border-radius: 12px;
  }

  /* Math calculator modal */
  .math-calc-modal {
    width: 95vw;
    max-width: 340px;
    border-radius: 16px;
  }

  .math-calc-header {
    padding: 12px 14px;
  }

  .math-calc-header h3 {
    font-size: 0.88rem;
  }

  .math-calc-close {
    width: 30px;
    height: 30px;
    font-size: 14px;
  }

  .math-calc-screen {
    padding: 12px 14px;
  }

  .math-calc-output {
    font-size: 1.8rem;
  }

  .math-calc-history {
    font-size: 0.72rem;
  }

  .math-calc-grid {
    padding: 10px;
    gap: 6px;
  }

  .math-btn {
    height: 48px;
    font-size: 1.05rem;
    border-radius: 10px;
  }

  .math-btn.equals {
    font-size: 1.2rem;
  }

  .math-btn.action {
    font-size: 0.85rem;
  }

  /* Empty state */
  .empty-state {
    padding: 40px 16px;
  }

  .empty-state-icon {
    font-size: 40px;
  }

  .empty-state h3 {
    font-size: 1rem;
  }

  .empty-state p {
    font-size: 0.78rem;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .drug-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1025px) {
  .drug-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ── Print Styles ── */
@media print {
  .app-header,
  .calc-overlay,
  .quick-ref-overlay,
  .math-calc-overlay {
    display: none;
  }

  .drug-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }
}

/* ── Liability Disclaimer Modal ── */
.disclaimer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-base);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.disclaimer-overlay.open {
  opacity: 1;
  visibility: visible;
}

.disclaimer-modal {
  width: min(480px, 95vw);
  max-height: 90vh;
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.92);
  transition: var(--transition-spring);
  border: 1px solid var(--gray-200);
}

.disclaimer-overlay.open .disclaimer-modal {
  transform: scale(1);
}

.disclaimer-header {
  background: linear-gradient(135deg, #B91C1C, #991B1B);
  color: var(--white);
  padding: 18px 22px;
  flex-shrink: 0;
}

.disclaimer-header h3 {
  font-size: 1.05rem;
  font-weight: 800;
}

.disclaimer-body {
  padding: 18px 22px;
  overflow-y: auto;
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--gray-700);
}

.disclaimer-body p {
  margin-bottom: 10px;
}

.disclaimer-body ul {
  margin: 0 0 10px 20px;
  padding: 0;
}

.disclaimer-body li {
  margin-bottom: 8px;
}

.disclaimer-footer {
  padding: 16px 22px 20px;
  flex-shrink: 0;
  border-top: 1px solid var(--gray-200);
}

.disclaimer-agree-btn {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #B91C1C, #991B1B);
  color: var(--white);
  font-size: 0.92rem;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition-fast);
}

.disclaimer-agree-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* ── Standard Clinical Math Calculator Modal ── */
.math-calc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 400;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-base);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.math-calc-overlay.open {
  opacity: 1;
  visibility: visible;
}

.math-calc-modal {
  width: min(340px, 95vw);
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.92);
  transition: var(--transition-spring);
  border: 1px solid var(--gray-200);
}

.math-calc-overlay.open .math-calc-modal {
  transform: scale(1);
}

/* ── Dosing Table & Spreadsheet Exporter Modal ── */
.dosing-table-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-base);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.dosing-table-overlay.open {
  opacity: 1;
  visibility: visible;
}

.dosing-table-modal {
  width: min(920px, 96vw);
  max-height: 90vh;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95);
  transition: var(--transition-spring);
}

.dosing-table-overlay.open .dosing-table-modal {
  transform: scale(1);
}

.dosing-table-header {
  background: linear-gradient(135deg, var(--orange-500), var(--orange-600));
  color: var(--white);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.dosing-table-header h3 {
  font-size: 1.05rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dosing-table-sub {
  font-size: 0.75rem;
  opacity: 0.9;
  font-weight: 500;
}

.dosing-table-toolbar {
  padding: 12px 20px;
  background: var(--orange-50);
  border-bottom: 1px solid var(--orange-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.dosing-table-btn {
  padding: 9px 16px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.dosing-table-btn-excel {
  background: #107C41;
  color: var(--white);
}

.dosing-table-btn-excel:hover {
  background: #0E6B37;
  transform: translateY(-1px);
}

.dosing-table-btn-sheets {
  background: #0F9D58;
  color: var(--white);
}

.dosing-table-btn-sheets:hover {
  background: #0B8043;
  transform: translateY(-1px);
}

.dosing-table-btn-print {
  background: #2563EB;
  color: var(--white);
}

.dosing-table-btn-print:hover {
  background: #1D4ED8;
  transform: translateY(-1px);
}

.dosing-table-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.dosing-info-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.dosing-info-box {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

.dosing-info-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--gray-500);
}

.dosing-info-val {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--gray-900);
}

.dosing-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.dosing-table th {
  background: var(--gray-100);
  color: var(--gray-700);
  font-weight: 700;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 2;
}

.dosing-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--gray-200);
  color: var(--gray-800);
}

.dosing-table tr:nth-child(even) td {
  background: var(--gray-50);
}

.dosing-table tr:hover td {
  background: var(--orange-50);
}

.dosing-table-highlight {
  font-weight: 800;
  color: var(--orange-600);
}

.dosing-table-math {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.78rem;
  color: var(--gray-600);
}


.math-calc-header {
  background: linear-gradient(135deg, var(--orange-500), var(--orange-600));
  color: var(--white);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.math-calc-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.math-calc-close {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255,255,255,0.2);
  color: var(--white);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: var(--transition-fast);
}

.math-calc-close:hover {
  background: rgba(255,255,255,0.35);
}

.math-calc-screen {
  background: #1E293B;
  color: #F8FAFC;
  padding: 16px;
  text-align: right;
  font-family: 'Inter', monospace;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.2);
}

.math-calc-history {
  font-size: 0.78rem;
  color: #94A3B8;
  min-height: 18px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.math-calc-output {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.2;
  word-break: break-all;
  overflow-x: auto;
}

.math-calc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 16px;
  background: var(--gray-50);
}

.math-btn {
  height: 52px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: var(--white);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--gray-800);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  user-select: none;
  box-shadow: var(--shadow-sm);
}

.math-btn:hover {
  background: var(--orange-50);
  border-color: var(--orange-300);
  color: var(--orange-600);
}

.math-btn:active {
  transform: scale(0.95);
  background: var(--orange-100);
}

.math-btn.op {
  background: var(--orange-100);
  color: var(--orange-700);
  border-color: var(--orange-200);
  font-weight: 700;
}

.math-btn.op:hover {
  background: var(--orange-500);
  color: var(--white);
}

.math-btn.action {
  background: #F1F5F9;
  color: var(--gray-700);
  font-size: 0.95rem;
  font-weight: 700;
}

.math-btn.equals {
  background: linear-gradient(135deg, var(--orange-500), var(--orange-600));
  color: var(--white);
  border: none;
  font-weight: 800;
  font-size: 1.4rem;
  box-shadow: var(--shadow-orange);
}

.math-btn.equals:hover {
  background: linear-gradient(135deg, var(--orange-600), var(--orange-700));
}

/* ============================================================
   AI Critical Care Pharmacy Assistant (Chatbot UI Styles)
   ============================================================ */

/* ── Floating Action Button (FAB) ── */
.chatbot-fab {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 990;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #0284C7 0%, #2563EB 100%);
  color: var(--white);
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-full);
  box-shadow: 0 8px 25px rgba(37, 99, 235, 0.45), inset 0 1px 2px rgba(255, 255, 255, 0.3);
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chatbot-fab:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.6), inset 0 1px 3px rgba(255, 255, 255, 0.5);
}

.chatbot-fab:active {
  transform: scale(0.96);
}

.chatbot-fab-icon {
  font-size: 1.2rem;
}

/* ── Chatbot Overlay & Drawer Modal ── */
.chatbot-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.chatbot-overlay.open {
  opacity: 1;
  visibility: visible;
}

.chatbot-modal {
  position: fixed;
  bottom: 80px;
  left: 24px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 480px;
  max-height: calc(100vh - 120px);
  background: linear-gradient(145deg, #0F172A 0%, #1E293B 100%);
  border: 1.5px solid rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.15);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(40px) scale(0.95);
  opacity: 0;
  visibility: hidden;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chatbot-modal.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  visibility: visible;
}

/* ── Chat Header ── */
.chatbot-header {
  background: linear-gradient(135deg, #024E89 0%, #0369A1 100%);
  color: var(--white);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(56, 189, 248, 0.25);
}

.chatbot-header-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chatbot-avatar {
  font-size: 1.6rem;
  background: rgba(255, 255, 255, 0.15);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.chatbot-header-title h3 {
  font-size: 0.95rem;
  font-weight: 800;
  color: #FFFFFF;
  margin: 0;
  line-height: 1.2;
}

.chatbot-status {
  font-size: 0.68rem;
  color: #BAE6FD;
  font-weight: 500;
  margin-top: 2px;
}

/* ── Quick Suggestions Bar ── */
.chatbot-suggestions {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.8);
  overflow-x: auto;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  scrollbar-width: none;
}

.chatbot-suggestions::-webkit-scrollbar {
  display: none;
}

.chatbot-suggestion-pill {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 600;
  color: #38BDF8;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.chatbot-suggestion-pill:hover {
  background: rgba(56, 189, 248, 0.25);
  color: #FFFFFF;
  border-color: #38BDF8;
}

/* ── Messages Container ── */
.chatbot-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(15, 23, 42, 0.6);
}

.chat-bubble {
  max-width: 86%;
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 0.82rem;
  line-height: 1.5;
  word-break: break-word;
  animation: fadeInMsg 0.25s ease-out;
}

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

.user-bubble {
  align-self: flex-end;
  background: linear-gradient(135deg, #0284C7 0%, #2563EB 100%);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
}

.bot-bubble {
  align-self: flex-start;
  background: rgba(30, 41, 59, 0.95);
  color: #F1F5F9;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
}

.bot-bubble .chat-h3 {
  font-size: 0.9rem;
  font-weight: 800;
  color: #38BDF8;
  margin: 0 0 6px 0;
  border-bottom: 1px solid rgba(56, 189, 248, 0.25);
  padding-bottom: 4px;
}

.bot-bubble .chat-h4 {
  font-size: 0.85rem;
  font-weight: 700;
  color: #38BDF8;
  margin: 4px 0;
}

.bot-bubble .chat-ul {
  margin: 6px 0 6px 16px;
  padding: 0;
}

.bot-bubble .chat-li {
  margin-bottom: 4px;
}

/* ── Animated Typing Dots ── */
.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 18px;
}

.typing-dots span {
  font-size: 1.5rem;
  line-height: 1;
  color: #38BDF8;
  animation: pulseDot 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulseDot {
  0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.2); }
}

/* ── Input Bar ── */
.chatbot-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: #0F172A;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.chatbot-input {
  flex: 1;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: #FFFFFF;
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition-fast);
}

.chatbot-input:focus {
  border-color: #38BDF8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
  background: rgba(30, 41, 59, 1);
}

.chatbot-input::placeholder {
  color: #94A3B8;
}

.chatbot-send-btn {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #0284C7 0%, #2563EB 100%);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.chatbot-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.5);
}

.chatbot-send-btn:active {
  transform: scale(0.95);
}

/* Mobile Responsive Adjustments for Chatbot */
@media (max-width: 600px) {
  .chatbot-modal {
    bottom: 75px;
    left: 12px;
    right: 12px;
    width: calc(100vw - 24px);
    max-width: 380px;
    height: 52vh;
    max-height: 420px;
    border-radius: 18px;
  }

  .chatbot-fab {
    bottom: 18px;
    left: 18px;
    padding: 10px 16px;
    font-size: 0.82rem;
  }
}

/* ── Interactive Chat Option Buttons ── */
.chat-options-container {
  margin-top: 10px;
  margin-bottom: 8px;
}

.chat-options-title {
  font-size: 0.76rem;
  font-weight: 800;
  color: #38BDF8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.chat-options-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chat-option-btn {
  background: rgba(15, 23, 42, 0.7);
  color: #E2E8F0;
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  font-size: 0.76rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.chat-option-btn:hover {
  background: linear-gradient(135deg, #0284C7 0%, #2563EB 100%);
  color: #FFFFFF;
  border-color: #38BDF8;
  transform: translateY(-1.5px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.chat-option-btn:active {
  transform: scale(0.96);
}



