:root {
  /* Medical Sky Blue & White Clinical Theme */
  --bg-page: #f0f7fc;
  --bg-card: #ffffff;
  --bg-card-border: #e2e8f0;
  --bg-card-hover: #f8fafc;
  --bg-input: #f8fafc;
  --bg-input-focus: #ffffff;

  --border-subtle: #cbd5e1;
  --border-card: #e2e8f0;
  --border-focus: #0284c7;

  /* Typography */
  --text-main: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  /* Medical Sky Blue Palette */
  --medical-sky-50: #f0f9ff;
  --medical-sky-100: #e0f2fe;
  --medical-sky-200: #bae6fd;
  --medical-sky-300: #7dd3fc;
  --medical-sky-400: #38bdf8;
  --medical-sky-500: #0ea5e9;
  --medical-sky-600: #0284c7;
  --medical-sky-700: #0369a1;
  --medical-sky-800: #075985;
  --medical-sky-glow: rgba(14, 165, 233, 0.18);

  /* Trust Green & WhatsApp Accent */
  --wa-green: #16a34a;
  --wa-green-hover: #15803d;
  --wa-green-light: #f0fdf4;
  --wa-green-border: #bbf7d0;
  --wa-green-glow: rgba(22, 163, 74, 0.2);

  /* Functional Accents */
  --accent-danger: #ef4444;
  --accent-danger-bg: #fef2f2;
  --accent-warning: #f59e0b;

  /* Sizing and Radii */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Soft Clinical Shadows */
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-card: 0 10px 30px -5px rgba(2, 132, 199, 0.08), 0 4px 12px -2px rgba(15, 23, 42, 0.04);
  --shadow-float: 0 20px 40px -10px rgba(2, 132, 199, 0.14), 0 8px 16px -4px rgba(15, 23, 42, 0.05);
  --shadow-btn: 0 4px 14px rgba(2, 132, 199, 0.25);
  --shadow-wa: 0 4px 14px rgba(22, 163, 74, 0.25);

  /* Layout dimensions */
  --sidebar-width: 280px;
  --mobile-header-height: 64px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-body);
  line-height: 1.5;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  background-image: 
    radial-gradient(circle at 12% 15%, rgba(14, 165, 233, 0.08) 0%, transparent 45%),
    radial-gradient(circle at 88% 85%, rgba(2, 132, 199, 0.06) 0%, transparent 45%),
    linear-gradient(180deg, #f8fafc 0%, #f0f7fc 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   Login View Screen
   ============================================================ */
.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px 16px;
}

.auth-panel {
  width: 100%;
  max-width: 480px;
  background: #ffffff;
  border: 1px solid var(--medical-sky-200);
  border-radius: var(--radius-xl);
  padding: 36px 28px;
  box-shadow: var(--shadow-float);
  animation: fadeIn 0.3s ease-out;
}

.auth-brand-badge {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px dashed var(--medical-sky-200);
}

.auth-logo-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--medical-sky-500) 0%, var(--medical-sky-700) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 8px 24px rgba(2, 132, 199, 0.28);
  margin-bottom: 14px;
}

.auth-brand-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.03em;
  margin-bottom: 2px;
}

.auth-brand-tagline {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--medical-sky-600);
  letter-spacing: 0.01em;
}

.auth-inner-header {
  border-bottom: none;
  margin-bottom: 20px;
  padding-bottom: 0;
}

.auth-inner-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.auth-inner-header p {
  font-size: 0.86rem;
  color: var(--text-muted);
}

.whatsapp-signup-notice {
  margin-top: 24px;
  padding: 16px 18px;
  background: var(--wa-green-light);
  border: 1px solid var(--wa-green-border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 14px;
}

.wa-icon-box {
  width: 40px;
  height: 40px;
  background: var(--wa-green);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px var(--wa-green-glow);
}

.wa-notice-content {
  display: flex;
  flex-direction: column;
}

.wa-notice-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--wa-green);
}

.wa-notice-text {
  font-size: 0.88rem;
  color: var(--text-body);
  margin-top: 2px;
}

.wa-notice-text strong a {
  color: var(--wa-green-hover);
  text-decoration: none;
  font-weight: 700;
}

/* Demo Mode Pill in Login */
.demo-hint-box {
  margin-top: 16px;
  padding: 10px 14px;
  background: var(--medical-sky-50);
  border: 1px solid var(--medical-sky-200);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--medical-sky-800);
}

.demo-hint-btn {
  background: var(--medical-sky-600);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-xs);
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.demo-hint-btn:hover {
  background: var(--medical-sky-700);
}

/* ============================================================
   Clinical Portal Layout (Desktop + Mobile Responsive)
   ============================================================ */
.portal-container {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* MOBILE TOP HEADER BAR (Hidden on Desktop, Visible on Tablet/Mobile) */
.mobile-top-bar {
  display: none;
}

/* LEFT SIDEBAR (Desktop Default) */
.portal-sidebar {
  width: var(--sidebar-width);
  background: #ffffff;
  border-right: 1px solid var(--border-card);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: var(--shadow-sm);
  z-index: 50;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-card);
}

.logo-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--medical-sky-500) 0%, var(--medical-sky-700) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: var(--shadow-btn);
  flex-shrink: 0;
}

.brand-text h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.brand-sub {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--medical-sky-600);
}

/* Mobile drawer header is hidden on desktop */
.drawer-close-row {
  display: none;
}

/* SIDEBAR NAVIGATION ITEMS */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px 14px;
  flex: 1;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-body);
  font-family: inherit;
  font-size: 0.93rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: left;
  width: 100%;
  min-height: 44px;
}

.sidebar-nav-item:hover {
  background: var(--medical-sky-50);
  color: var(--medical-sky-700);
}

.sidebar-nav-item.active {
  background: var(--medical-sky-100);
  color: var(--medical-sky-800);
  border-color: var(--medical-sky-300);
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.08);
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  flex-shrink: 0;
}

.nav-label {
  flex: 1;
}

.nav-badge {
  font-size: 0.65rem;
  font-weight: 700;
  background: var(--medical-sky-500);
  color: #ffffff;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* SIDEBAR FOOTER (DOCTOR PROFILE) */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-card);
  background: #fcfdfe;
}

.doctor-profile-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--medical-sky-50);
  border: 1px solid var(--medical-sky-200);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.doc-avatar {
  font-size: 1.3rem;
  background: #ffffff;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  flex-shrink: 0;
}

.doc-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
}

.doc-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.doc-hospital {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--medical-sky-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-logout {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 8px;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  transition: all 0.2s;
}

.btn-logout:hover {
  color: var(--accent-danger);
  background: var(--accent-danger-bg);
}

/* Mobile backdrop overlay */
.mobile-nav-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.mobile-nav-backdrop.active {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

/* ============================================================
   RIGHT MAIN WORKSPACE
   ============================================================ */
.portal-main {
  flex: 1;
  padding: 36px 48px;
  max-width: 920px;
  margin: 0 auto;
  overflow-y: auto;
  width: 100%;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-xl);
  padding: 36px;
  box-shadow: var(--shadow-float);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--bg-card-border);
}

.panel-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.prescription-icon {
  background: var(--medical-sky-100);
  color: var(--medical-sky-600);
}

.drive-icon {
  background: rgba(56, 189, 248, 0.14);
  color: var(--medical-sky-600);
}

.snap-icon {
  background: var(--wa-green-light);
  color: var(--wa-green);
}

.panel-header h2 {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.panel-header p {
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* Quick active tab breadcrumb badge on mobile */
.mobile-screen-indicator {
  display: none;
}

/* ============================================================
   Forms & Inputs
   ============================================================ */
.form-group {
  margin-bottom: 20px;
}

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

.required {
  color: var(--accent-danger);
}

.optional {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: normal;
}

.label-with-action {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.label-with-action label {
  margin-bottom: 0;
}

.btn-text-link {
  background: transparent;
  border: none;
  color: var(--medical-sky-600);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 0;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
}

.btn-text-link:hover {
  color: var(--medical-sky-800);
  text-decoration: underline;
}

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

.field-icon {
  position: absolute;
  left: 14px;
  color: var(--text-dim);
  pointer-events: none;
}

.password-input-wrapper input {
  padding-right: 44px;
}

.password-toggle-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  line-height: 1;
}

.password-toggle-btn:hover {
  color: var(--medical-sky-600);
  background-color: var(--bg-hover);
}

.password-toggle-btn:focus-visible {
  outline: 2px solid var(--medical-sky-500);
  outline-offset: 1px;
}

.password-toggle-btn .eye-icon {
  pointer-events: none;
  display: block;
}

/* Note: 16px minimum font-size prevents iOS Safari from automatically zooming into the input */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
select,
textarea {
  width: 100%;
  background-color: var(--bg-input);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: inherit;
  font-size: 16px;
  padding: 12px 14px 12px 42px;
  transition: all 0.2s ease;
  outline: none;
  min-height: 44px;
}

input:focus,
select:focus,
textarea:focus {
  background-color: var(--bg-input-focus);
  border-color: var(--medical-sky-500);
  box-shadow: 0 0 0 4px var(--medical-sky-glow);
}

.phone-input-group {
  display: flex;
  gap: 10px;
}

.country-selector {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-main);
  flex-shrink: 0;
  min-height: 44px;
}

.phone-wrapper input {
  padding-left: 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
}

.select-wrapper {
  position: relative;
}

.select-wrapper::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--text-muted);
  pointer-events: none;
}

.select-wrapper select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  padding-right: 36px;
}

.textarea-wrapper textarea {
  padding: 14px;
  resize: vertical;
  min-height: 90px;
}

/* ============================================================
   Dropzones & File Upload Elements
   ============================================================ */
.file-dropzone {
  position: relative;
  border: 2px dashed var(--medical-sky-300);
  background: var(--medical-sky-50);
  border-radius: var(--radius-md);
  padding: 24px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.file-dropzone:hover {
  border-color: var(--medical-sky-500);
  background: #ffffff;
}

.file-dropzone input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 10;
}

.mini-dropzone {
  padding: 16px;
  min-height: 80px;
}

.camera-dropzone {
  background: #fbfdfa;
  border-color: var(--wa-green-border);
  padding: 28px 20px;
  min-height: 130px;
}

.camera-dropzone:hover {
  border-color: var(--wa-green);
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.dropzone-content svg {
  color: var(--medical-sky-600);
  margin-bottom: 8px;
}

.camera-dropzone .dropzone-content svg {
  color: var(--wa-green);
}

.dropzone-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
  word-break: break-word;
}

.dropzone-subtext {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Snap Preview Box */
.snap-preview-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 20;
  position: relative;
  width: 100%;
}

.snap-preview-box img {
  max-width: 100%;
  max-height: 240px;
  border-radius: var(--radius-md);
  border: 2px solid var(--wa-green);
  box-shadow: var(--shadow-sm);
  object-fit: contain;
}

/* ============================================================
   Buttons & Interactive Elements
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  min-height: 44px;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.82rem;
  min-height: 36px;
}

.btn-secondary {
  background: #ffffff;
  color: var(--medical-sky-700);
  border: 1.5px solid var(--medical-sky-200);
  padding: 12px 18px;
  font-size: 0.92rem;
}

.btn-secondary:hover {
  background: var(--medical-sky-50);
  border-color: var(--medical-sky-400);
}

.btn-primary {
  background: linear-gradient(135deg, var(--medical-sky-600) 0%, var(--medical-sky-700) 100%);
  color: #ffffff;
  box-shadow: var(--shadow-btn);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.35);
}

#prescriptionPanel .btn-primary,
#saveAndSendRxBtn,
#prescriptionForm .btn-primary {
  background: linear-gradient(135deg, var(--wa-green) 0%, var(--wa-green-hover) 100%);
  box-shadow: var(--shadow-wa);
}

#prescriptionPanel .btn-primary:hover,
#saveAndSendRxBtn:hover,
#prescriptionForm .btn-primary:hover {
  box-shadow: 0 6px 20px rgba(22, 163, 74, 0.35);
}

.btn-lg {
  width: 100%;
  padding: 14px 20px;
  font-size: 1rem;
  border-radius: var(--radius-md);
  margin-top: 12px;
}

.dual-actions-group {
  display: flex;
  gap: 14px;
  margin-top: 14px;
}

.flex-1 {
  flex: 1;
}

.btn-loader {
  display: flex;
  align-items: center;
  gap: 10px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   Subcards & File Explorer
   ============================================================ */
.media-subcard {
  background: var(--medical-sky-50);
  border: 1px solid var(--medical-sky-200);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 24px;
}

.subcard-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.subcard-title svg {
  color: var(--medical-sky-600);
  flex-shrink: 0;
}

.empty-files-box {
  background: #ffffff;
  border: 1px dashed var(--medical-sky-300);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
  color: var(--text-body);
  font-size: 0.9rem;
}

.empty-files-box .sub-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ============================================================
   Disease Library Grid (Tab 2)
   ============================================================ */
.disease-library-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.disease-lib-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.disease-lib-card:hover {
  border-color: var(--medical-sky-300);
  box-shadow: var(--shadow-sm);
}

.disease-lib-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.disease-lib-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
  line-height: 1;
}

.disease-lib-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.disease-lib-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.disease-lib-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.disease-lib-badges {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.file-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
}

.vid-badge {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.img-badge {
  background: #f0fdf4;
  color: #15803d;
  border-color: #bbf7d0;
}

.txt-badge {
  background: #fff7ed;
  color: #c2410c;
  border-color: #fed7aa;
}

.disease-lib-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.lib-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-body);
  background: var(--medical-sky-50);
  border: 1px solid var(--medical-sky-200);
  border-radius: var(--radius-full);
  padding: 3px 10px;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
  padding-left: 2px;
}

/* ============================================================
   Toasts & Utilities
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 1000;
  max-width: calc(100vw - 32px);
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #ffffff;
  border: 1px solid var(--border-card);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  min-width: 300px;
  color: var(--text-main);
  transform: translateX(120%);
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast.success {
  border-left: 4px solid var(--wa-green);
}

.toast.error {
  border-left: 4px solid var(--accent-danger);
}

.toast-message {
  font-size: 0.88rem;
  font-weight: 500;
  word-break: break-word;
}

@keyframes slideIn {
  to { transform: translateX(0); }
}

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

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

.mx-auto {
  margin-left: auto;
  margin-right: auto;
}

.hidden {
  display: none !important;
}

/* ============================================================
   MOBILE & TABLET RESPONSIVE DESIGN (Adaptive Mobile-First)
   ============================================================ */

/* Three lines menu button on top right styling */
.mobile-menu-toggle {
  display: none;
  background: #ffffff;
  border: 1.5px solid var(--border-card);
  border-radius: var(--radius-md);
  width: 44px;
  height: 44px;
  padding: 0;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  position: relative;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}

.mobile-menu-toggle:hover {
  background: var(--medical-sky-50);
  border-color: var(--medical-sky-300);
  color: var(--medical-sky-700);
}

/* Three lines hamburger animation to X */
.hamburger-lines {
  width: 20px;
  height: 14px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hamburger-lines span {
  display: block;
  height: 2px;
  width: 100%;
  background-color: currentColor;
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.25s ease;
  transform-origin: center;
}

.mobile-menu-toggle.is-open .hamburger-lines span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.mobile-menu-toggle.is-open .hamburger-lines span:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle.is-open .hamburger-lines span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}


/* TABLET BREAKPOINT (max-width: 1024px) */
@media (max-width: 1024px) {
  .portal-main {
    padding: 28px 24px;
  }
}

/* MOBILE & TABLET ADAPTIVE LAYOUT (max-width: 860px) */
@media (max-width: 860px) {
  .portal-container {
    flex-direction: column;
  }

  /* SHOW MOBILE TOP HEADER BAR */
  .mobile-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--mobile-header-height);
    background: #ffffff;
    border-bottom: 1px solid var(--border-card);
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
  }

  .mobile-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
  }

  .mobile-brand .logo-icon {
    width: 38px;
    height: 38px;
  }

  .mobile-brand .brand-text h2 {
    font-size: 1.15rem;
  }

  .mobile-brand .brand-sub {
    font-size: 0.7rem;
  }

  .mobile-top-right {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .mobile-doc-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--medical-sky-50);
    border: 1px solid var(--medical-sky-200);
    border-radius: var(--radius-full);
    padding: 4px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--medical-sky-800);
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-doc-chip .chip-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Three lines menu button visible on the right */
  .mobile-menu-toggle {
    display: flex;
  }


  /* SIDEBAR: TRANSFORMS INTO SLIDE-DOWN / DRAWER MENU ON MOBILE */
  .portal-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    max-width: 85vw;
    height: 100vh;
    height: -webkit-fill-available;
    z-index: 1000;
    box-shadow: -10px 0 30px rgba(15, 23, 42, 0.18);
    transform: translateX(100%);
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border-card);
    border-right: none;
    background: #ffffff;
  }

  .portal-sidebar.drawer-open {
    transform: translateX(0);
  }

  /* Sidebar header within drawer */
  .drawer-close-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-card);
  }

  .drawer-close-row .drawer-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .drawer-close-btn {
    background: var(--medical-sky-50);
    border: 1px solid var(--medical-sky-200);
    color: var(--text-main);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
  }

  .drawer-close-btn:hover {
    background: var(--medical-sky-100);
    color: var(--medical-sky-800);
  }

  .sidebar-brand {
    display: none; /* replaced by drawer-close-row on mobile */
  }

  /* WORKSPACE CONTENT SCALING */
  .portal-main {
    padding: 16px 14px 40px 14px;
    max-width: 100%;
  }

  .panel {
    padding: 24px 18px;
    border-radius: var(--radius-lg);
  }

  .panel-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    gap: 12px;
  }

  .panel-icon {
    width: 40px;
    height: 40px;
  }

  .panel-header h2 {
    font-size: 1.15rem;
  }

  .panel-header p {
    font-size: 0.82rem;
  }

  /* Dual Action Buttons Stack on Mobile */
  .dual-actions-group {
    flex-direction: column;
    gap: 12px;
  }

  .dual-actions-group .btn {
    width: 100%;
  }

  /* Disease Library Grid Responsive */
  .disease-lib-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .disease-lib-badges {
    width: 100%;
    margin-top: 2px;
  }

  .lib-file-chip {
    max-width: 100%;
  }

  /* Toasts centered on mobile */
  .toast-container {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }

  .toast {
    min-width: auto;
    width: 100%;
    padding: 12px 16px;
  }
}

/* SMALL MOBILE SCREENS (max-width: 480px) */
@media (max-width: 480px) {
  .auth-panel {
    padding: 28px 18px;
    border-radius: var(--radius-lg);
  }

  .auth-brand-title {
    font-size: 1.5rem;
  }

  .phone-input-group {
    flex-direction: row;
    gap: 8px;
  }

  .country-selector {
    padding: 0 10px;
    font-size: 0.85rem;
  }

  .country-selector .flag-icon {
    font-size: 1rem;
  }

  .country-selector .country-prefix {
    font-size: 0.85rem;
  }

  .phone-wrapper input {
    font-size: 15px;
  }

  .portal-main {
    padding: 12px 10px 32px 10px;
  }

  .panel {
    padding: 20px 14px;
  }

  .panel-header {
    flex-direction: row;
  }

  .media-subcard {
    padding: 16px 12px;
  }

  .file-dropzone {
    padding: 18px 12px;
  }

  .camera-dropzone {
    padding: 22px 14px;
  }

  .mobile-doc-chip {
    display: none; /* Hide doctor text pill on very narrow screen to keep header clean */
  }
}

/* ============================================================
   Selected Files Preview Chips (Tab 2 Multi-File Upload)
   ============================================================ */
.selected-files-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg-hover, #f8fafc);
  border: 1px dashed var(--border-card, #e2e8f0);
  border-radius: var(--radius-md, 8px);
}

.preview-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border-card, #cbd5e1);
  border-radius: var(--radius-full, 9999px);
  font-size: 0.8rem;
  color: var(--text-main, #0f172a);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  max-width: 100%;
}

.preview-file-chip .chip-name {
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.preview-file-chip .chip-size {
  font-size: 0.72rem;
  color: var(--text-muted, #64748b);
  margin-left: 2px;
}

/* ============================================================
   Disease Library File Cards (View & Delete Actions)
   ============================================================ */
.lib-file-card {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg-hover, #f8fafc);
  border: 1px solid var(--border-card, #e2e8f0);
  border-radius: var(--radius-md, 8px);
  padding: 6px 10px;
  font-size: 0.8rem;
  color: var(--text-main, #0f172a);
  transition: all 0.15s ease;
  max-width: 100%;
}

.lib-file-card:hover {
  background: #ffffff;
  border-color: var(--medical-sky-300, #7dd3fc);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
}

.lib-file-main {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  min-width: 0;
  flex: 1;
}

.lib-file-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.lib-file-title {
  font-weight: 500;
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lib-file-size {
  font-size: 0.72rem;
  color: var(--text-muted, #64748b);
  flex-shrink: 0;
}

.lib-file-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.file-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: var(--radius-sm, 6px);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.file-action-btn.view-btn {
  color: var(--medical-sky-600, #0284c7);
}

.file-action-btn.view-btn:hover {
  background: var(--medical-sky-100, #e0f2fe);
  border-color: var(--medical-sky-200, #bae6fd);
}

.file-action-btn.del-btn {
  color: #ef4444;
}

.file-action-btn.del-btn:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

/* ============================================================
   Media Preview Modal Dialog
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 2000;
  animation: fadeIn 0.15s ease-out;
}

.modal-dialog {
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border-card, #e2e8f0);
  border-radius: var(--radius-lg, 14px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  width: 100%;
  overflow: hidden;
  animation: modalSlideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.media-modal-dialog {
  max-width: 820px;
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle, #f1f5f9);
  background: var(--bg-hover, #f8fafc);
}

.modal-title-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.modal-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.modal-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main, #0f172a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 580px;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted, #64748b);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm, 6px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.modal-close-btn:hover {
  background: var(--border-card, #e2e8f0);
  color: var(--text-main, #0f172a);
}

.media-modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  max-height: calc(85vh - 140px);
  background: #0f172a;
}

.modal-preview-img {
  max-width: 100%;
  max-height: 65vh;
  object-fit: contain;
  border-radius: var(--radius-md, 8px);
}

.modal-preview-video-box {
  width: 100%;
  display: flex;
  justify-content: center;
}

.modal-preview-video {
  width: 100%;
  max-height: 65vh;
  border-radius: var(--radius-md, 8px);
  background: #000;
}

.modal-preview-textbox {
  width: 100%;
  background: #1e293b;
  border-radius: var(--radius-md, 8px);
  padding: 16px;
  max-height: 60vh;
  overflow-y: auto;
}

.modal-preview-pre {
  margin: 0;
  color: #f8fafc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-preview-pdf-box {
  width: 100%;
  height: 65vh;
}

.modal-preview-iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: var(--radius-md, 8px);
  background: #ffffff;
}

.modal-preview-fallback {
  text-align: center;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.modal-loading-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: #94a3b8;
  font-size: 0.9rem;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle, #f1f5f9);
  background: var(--bg-hover, #f8fafc);
}

.btn-danger {
  background: #ef4444;
  color: #ffffff;
  border: 1px solid #dc2626;
}

.btn-danger:hover {
  background: #dc2626;
  border-color: #b91c1c;
}

/* ============================================================
   PRESCRIPTION HISTORY (TAB 3) & RX VIEWER LIGHTBOX
   ============================================================ */
.nav-badge-pill {
  margin-left: auto;
  background: var(--medical-sky-100);
  color: var(--medical-sky-700);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.history-icon {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.history-header .header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.history-header .header-right-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-controls-card {
  background: #ffffff;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Doctor Context Banner */
.doctor-context-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--medical-sky-200);
  flex-wrap: wrap;
}

.doc-context-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.context-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--medical-sky-50);
  color: var(--medical-sky-700);
  border: 1px solid var(--medical-sky-200);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
}

.context-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: #f8fafc;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  border: 1px solid #e2e8f0;
}

.api-endpoint-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.endpoint-method {
  font-weight: 800;
  color: #15803d;
}

/* Search Bar Form */
.rx-search-bar {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.search-input-col {
  flex: 2;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.limit-select-col {
  flex: 1;
  min-width: 170px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.search-actions-col {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 1px;
}

.search-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.label-hint {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
}

.phone-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  overflow: hidden;
}

.phone-search-wrapper:focus-within {
  border-color: var(--border-focus);
  background: #ffffff;
  box-shadow: 0 0 0 3px var(--medical-sky-glow);
}

.country-prefix-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #f1f5f9;
  color: var(--text-body);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0 12px;
  height: 44px;
  border-right: 1px solid var(--border-subtle);
}

.phone-search-wrapper input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 14px;
  font-size: 0.95rem;
  color: var(--text-main);
  outline: none;
  font-family: inherit;
}

.input-clear-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.95rem;
  padding: 0 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.limit-select-wrapper select {
  width: 100%;
  height: 44px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0 12px;
  font-size: 0.9rem;
  color: var(--text-main);
  outline: none;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.limit-select-wrapper select:focus {
  border-color: var(--border-focus);
  background: #ffffff;
  box-shadow: 0 0 0 3px var(--medical-sky-glow);
}

/* Filter Active Indicator */
.rx-filter-indicator {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--medical-sky-50);
  border: 1px solid var(--medical-sky-200);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.85rem;
  animation: fadeIn 0.2s ease-out;
}

.indicator-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--medical-sky-800);
  font-weight: 500;
}

.remove-filter-btn {
  background: transparent;
  border: none;
  color: #0284c7;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
}

.remove-filter-btn:hover {
  background: rgba(2, 132, 199, 0.1);
  text-decoration: underline;
}

/* Results Meta Bar */
.results-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
}

.results-count-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.results-badge {
  background: var(--medical-sky-600);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.results-subtext {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.view-mode-toggle {
  display: flex;
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.view-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.view-mode-btn.active {
  background: var(--medical-sky-50);
  color: var(--medical-sky-700);
}

/* Rx History Cards Grid */
.rx-history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 20px;
}

.rx-card {
  background: #ffffff;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  display: flex;
  flex-direction: column;
}

.rx-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-card);
  border-color: var(--medical-sky-300);
}

.rx-card-header {
  padding: 16px 18px 12px 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #f1f5f9;
}

.patient-primary-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.patient-name-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
}

.patient-phone-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-body);
}

.phone-wa-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--wa-green);
  text-decoration: none;
  font-weight: 600;
}

.phone-wa-link:hover {
  text-decoration: underline;
  color: var(--wa-green-hover);
}

.rx-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
  white-space: nowrap;
}

/* Rx Thumbnail Box */
.rx-thumb-wrapper {
  position: relative;
  width: 100%;
  height: 180px;
  background: #f8fafc;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid #f1f5f9;
}

.rx-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.rx-card:hover .rx-thumb-img {
  transform: scale(1.04);
}

.rx-thumb-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s ease;
  backdrop-filter: blur(2px);
}

.rx-thumb-wrapper:hover .rx-thumb-overlay {
  opacity: 1;
}

.rx-thumb-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-dim);
  text-align: center;
  padding: 20px;
}

.rx-thumb-placeholder svg {
  color: var(--medical-sky-400);
}

.rx-thumb-placeholder span {
  font-size: 0.8rem;
  font-weight: 500;
}

/* Card Body */
.rx-card-body {
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.rx-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.rx-condition-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #0369a1;
  background: #e0f2fe;
  padding: 3px 9px;
  border-radius: var(--radius-full);
}

.rx-date-stamp {
  font-size: 0.76rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.rx-notes-snippet {
  background: #f8fafc;
  border-left: 3px solid var(--medical-sky-400);
  padding: 8px 12px;
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  font-size: 0.82rem;
  color: var(--text-body);
  line-height: 1.45;
}

.rx-notes-snippet strong {
  color: var(--text-main);
  font-weight: 600;
}

/* Card Footer Actions */
.rx-card-footer {
  padding: 12px 18px;
  background: #fafcff;
  border-top: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.btn-card-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.btn-card-action.primary {
  background: var(--medical-sky-600);
  color: #ffffff;
}

.btn-card-action.primary:hover {
  background: var(--medical-sky-700);
}

.btn-card-action.wa {
  background: var(--wa-green-light);
  color: var(--wa-green-hover);
  border-color: var(--wa-green-border);
}

.btn-card-action.wa:hover {
  background: #dcfce7;
}

.btn-card-action.ghost {
  background: #ffffff;
  color: var(--text-body);
  border-color: var(--border-card);
}

.btn-card-action.ghost:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

/* Rx Table View */
.rx-history-table-container {
  background: #ffffff;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

.rx-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  text-align: left;
}

.rx-history-table th {
  background: #f8fafc;
  color: var(--text-main);
  font-weight: 700;
  padding: 12px 16px;
  border-bottom: 1.5px solid var(--border-card);
  white-space: nowrap;
}

.rx-history-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.rx-history-table tr:hover {
  background: #f8fafc;
}

.table-rx-thumb {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-xs);
  object-fit: cover;
  cursor: pointer;
  border: 1px solid var(--border-card);
}

/* Empty & Loading States */
.rx-empty-state {
  text-align: center;
  padding: 48px 20px;
  background: #ffffff;
  border: 1px dashed var(--medical-sky-200);
  border-radius: var(--radius-lg);
  color: var(--text-body);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.rx-empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.rx-empty-state h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.rx-empty-state p {
  color: var(--text-muted);
  max-width: 420px;
  font-size: 0.9rem;
}

.rx-loading-state {
  text-align: center;
  padding: 50px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--text-muted);
}

.spinner-lg {
  width: 36px;
  height: 36px;
  border-width: 3px;
}

/* Dedicated Rx Lightbox Modal */
.rx-modal-dialog {
  max-width: 820px;
  width: 95%;
  background: #ffffff;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-float);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.modal-submeta {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-header-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  border: 1px solid var(--border-card);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
}

.modal-header-btn:hover {
  background: #e2e8f0;
}

.modal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0f172a;
  padding: 8px 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.image-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 5px 10px;
  border-radius: var(--radius-xs);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.modal-prescription-chips {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rx-modal-body {
  background: #090d16;
  min-height: 380px;
  max-height: 55vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  position: relative;
  padding: 20px;
}

.rx-image-canvas {
  transition: transform 0.2s ease-out;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rx-modal-img {
  max-width: 100%;
  max-height: 50vh;
  border-radius: var(--radius-xs);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  user-select: none;
}

.rx-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: #ffffff;
  border-top: 1px solid var(--border-card);
  flex-wrap: wrap;
}

.rx-modal-patient-info {
  font-size: 0.85rem;
  color: var(--text-body);
  flex: 1;
  min-width: 220px;
}

.rx-modal-cta-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-wa {
  background: var(--wa-green);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
}

.btn-wa:hover {
  background: var(--wa-green-hover);
}

/* Demo quick button on login screen */
.demo-login-box {
  margin-top: 14px;
  text-align: center;
}

.btn-demo-quick {
  width: 100%;
  background: var(--medical-sky-50);
  border: 1.5px dashed var(--medical-sky-400);
  color: var(--medical-sky-700);
  font-weight: 700;
  font-size: 0.88rem;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-demo-quick:hover {
  background: var(--medical-sky-100);
  border-color: var(--medical-sky-600);
  transform: translateY(-1px);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .rx-search-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-input-col,
  .limit-select-col,
  .search-actions-col {
    width: 100%;
  }

  .rx-history-grid {
    grid-template-columns: 1fr;
  }

  .doctor-context-banner {
    flex-direction: column;
    align-items: flex-start;
  }
}
