/* ============================================================
   MedLens Design System
   Clean, readable healthcare UI.
   Light + Dark themes. Mobile-first.
   ============================================================ */

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-page:    #F2F5F3;
  --bg-card:    #FFFFFF;
  --bg-raised:  #FAFCFB;
  --bg-muted:   #EBF1EE;

  /* Text */
  --txt-main:   #111B18;
  --txt-muted:  #4D6860;
  --txt-soft:   #7D9590;
  --txt-inv:    #FFFFFF;

  /* Brand */
  --green-900:  #0B3328;
  --green-700:  #0F5540;
  --green-600:  #157A58;
  --green-500:  #1A9E72;
  --green-400:  #3DC494;
  --green-100:  #D1FAE5;
  --green-50:   #F0FDF4;
  --glow:       rgba(26, 158, 114, 0.18);

  /* Status colours */
  --red:        #DC2626;
  --red-bg:     #FEF2F2;
  --amber:      #D97706;
  --amber-bg:   #FFFBEB;
  --blue:       #2563EB;
  --blue-bg:    #EFF6FF;

  /* Gold */
  --gold:       #D97706;
  --gold-bg:    #FEF3C7;

  /* Borders */
  --border:     #DDE6E2;
  --border-sub: #EDF2EF;

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-pill: 9999px;

  /* Shadows */
  --sh-sm:  0 1px 3px rgba(11,35,29,.04), 0 1px 2px rgba(11,35,29,.02);
  --sh-md:  0 4px 16px -2px rgba(11,35,29,.07), 0 2px 6px -1px rgba(11,35,29,.03);
  --sh-lg:  0 12px 32px -4px rgba(11,35,29,.09), 0 4px 12px -2px rgba(11,35,29,.03);

  /* Type */
  --font:   'Inter', system-ui, -apple-system, sans-serif;
  --mono:   'JetBrains Mono', 'Courier New', monospace;
}

/* ── Professional Health-Tech Dark Theme ─────────────────────────────── */
[data-theme="dark"] {
  --bg-page:    #090D16; /* Deep obsidian navy canvas */
  --bg-card:    #0F172A; /* Rich clinical slate card background */
  --bg-raised:  #1A2234; /* Elevated components & interactive inputs */
  --bg-muted:   #1E293B; /* Subtle slot containers & pill tags */

  --txt-main:   #F8FAFC; /* Crisp ultra-clean white text */
  --txt-muted:  #94A3B8; /* Slate-400 secondary text */
  --txt-soft:   #64748B; /* Slate-500 subtle captions */
  --txt-inv:    #090D16;

  --green-900:  #10B981;
  --green-700:  #34D399;
  --green-600:  #10B981;
  --green-500:  #10B981;
  --green-400:  #34D399;
  --green-100:  rgba(16, 185, 129, 0.16);
  --green-50:   rgba(16, 185, 129, 0.08);
  --glow:       rgba(16, 185, 129, 0.25);

  --red:        #F87171;
  --red-bg:     rgba(239, 68, 68, 0.16);
  --amber:      #FBBF24;
  --amber-bg:   rgba(245, 158, 11, 0.16);
  --blue:       #38BDF8;
  --blue-bg:    rgba(56, 189, 248, 0.14);

  --gold:       #F59E0B;
  --gold-bg:    rgba(245, 158, 11, 0.14);

  --border:     rgba(255, 255, 255, 0.09);
  --border-sub: rgba(255, 255, 255, 0.05);

  --sh-sm:  0 1px 3px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
  --sh-md:  0 6px 20px -2px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.06);
  --sh-lg:  0 16px 40px -4px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--txt-main);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; }
a { text-decoration: none; color: inherit; }

/* ── Header ─────────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

[data-theme="dark"] .app-header {
  background: rgba(15, 23, 42, 0.88);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--green-900), var(--green-500));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-name {
  font-size: 17px;
  font-weight: 800;
  color: var(--green-900);
  letter-spacing: -.3px;
}

[data-theme="dark"] .brand-name { color: var(--green-400); }

.brand-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  background: var(--green-100);
  color: var(--green-600);
  padding: 2px 8px;
  border-radius: var(--r-pill);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Language selector */
.lang-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 12px;
  cursor: pointer;
}

.lang-select {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--txt-main);
  outline: none;
}

/* ── Hero band ──────────────────────────────────────────────── */
.hero-band {
  background: linear-gradient(180deg, var(--bg-muted) 0%, var(--bg-page) 100%);
  border-bottom: 1px solid var(--border-sub);
  padding: 40px 24px 32px;
}

.hero-inner {
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
}

.hero-pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--green-600);
  background: var(--green-50);
  border: 1px solid var(--green-100);
  padding: 4px 14px;
  border-radius: var(--r-pill);
  margin-bottom: 16px;
}

.hero-headline {
  font-size: clamp(24px, 4vw, 36px);
  font-weight: 800;
  color: var(--txt-main);
  letter-spacing: -.5px;
  line-height: 1.2;
  margin-bottom: 12px;
}

.hero-sub {
  font-size: 15px;
  color: var(--txt-muted);
  line-height: 1.65;
}

/* ── Main layout ────────────────────────────────────────────── */
.app-main {
  max-width: 1020px;
  margin: 0 auto;
  padding: 32px 24px 80px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-sm);
}

/* ── Scanner card ───────────────────────────────────────────── */
.scanner-card {
  padding: 24px;
}

/* Tabs */
.scanner-tabs {
  display: inline-flex;
  gap: 4px;
  background: var(--bg-muted);
  padding: 4px;
  border-radius: var(--r-pill);
  margin-bottom: 22px;
}

.tab {
  background: transparent;
  border: none;
  padding: 8px 18px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
  color: var(--txt-muted);
  transition: background .18s, color .18s, box-shadow .18s;
}

.tab.active {
  background: var(--bg-card);
  color: var(--green-700);
  box-shadow: var(--sh-sm);
}

[data-theme="dark"] .tab.active { color: var(--green-400); }

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--r-lg);
  padding: 44px 24px;
  text-align: center;
  background: var(--bg-raised);
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .15s;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--green-500);
  background: var(--green-50);
  transform: translateY(-1px);
}

.dropzone-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--green-100);
  color: var(--green-600);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.dropzone-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 6px;
}

.dropzone-hint {
  font-size: 13px;
  color: var(--txt-muted);
  margin-bottom: 22px;
}

.dropzone-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.or-text {
  font-size: 13px;
  color: var(--txt-soft);
}

/* Preview bar */
.preview-bar {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-muted);
  border-radius: var(--r-md);
  flex-wrap: wrap;
}

.preview-thumb {
  width: 52px;
  height: 52px;
  border-radius: var(--r-sm);
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.preview-info { flex: 1; min-width: 0; }

.preview-name {
  display: block;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-size {
  display: block;
  font-size: 12px;
  color: var(--txt-muted);
  margin-top: 2px;
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Text mode */
.text-mode {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.text-mode-hint {
  font-size: 13.5px;
  color: var(--txt-muted);
}

.rx-textarea {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.65;
  resize: vertical;
  outline: none;
  background: var(--bg-raised);
  color: var(--txt-main);
  transition: border-color .2s, box-shadow .2s;
}

.rx-textarea:focus {
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px var(--glow);
  background: var(--bg-card);
}

.text-mode-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Status message */
.status-msg {
  margin-top: 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--txt-muted);
  min-height: 20px;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 18px;
  transition: background .15s, color .15s, transform .12s, box-shadow .15s;
  white-space: nowrap;
}

.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--green-700);
  color: #fff;
}
.btn-primary:hover { background: var(--green-600); transform: translateY(-1px); }

.btn-outline-sm {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--txt-main);
  padding: 7px 14px;
  font-size: 13px;
}
.btn-outline-sm:hover { background: var(--bg-muted); }

.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--txt-main);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--r-pill);
}
.btn-icon:hover { border-color: var(--green-500); }

.btn-cta {
  background: var(--green-700);
  color: #fff;
  padding: 8px 16px;
  font-size: 13px;
  border-radius: var(--r-pill);
}
.btn-cta:hover { background: var(--green-600); }

.btn-ghost {
  background: transparent;
  color: var(--green-600);
  border: none;
  padding: 8px 12px;
}
.btn-ghost:hover { background: var(--green-50); }

.btn-ghost-sm {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--txt-muted);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: var(--r-sm);
}
.btn-ghost-sm:hover { color: var(--txt-main); }

.btn-ghost-dim {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.55);
  font-size: 13px;
  padding: 7px 12px;
}
.btn-ghost-dim:hover { color: #fff; }

.btn-white-sm {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  color: #fff;
  font-size: 13px;
  padding: 7px 14px;
  border-radius: var(--r-sm);
}
.btn-white-sm:hover { background: rgba(255,255,255,.2); }

.btn-close {
  background: transparent;
  border: none;
  font-size: 16px;
  color: var(--txt-soft);
  padding: 6px;
  line-height: 1;
  border-radius: var(--r-sm);
}
.btn-close:hover { color: var(--txt-main); background: var(--bg-muted); }

/* Spinner */
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}

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

/* ── Savings card ───────────────────────────────────────────── */
.savings-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #072219 0%, #0D3828 55%, #145240 100%);
  border: 1px solid rgba(61,196,148,.2);
  box-shadow: 0 12px 28px -6px rgba(7,34,25,.5);
}

.savings-backdrop {
  position: absolute;
  top: -40%;
  right: -15%;
  width: 380px;
  height: 380px;
  background: radial-gradient(circle, rgba(61,196,148,.28) 0%, transparent 70%);
  pointer-events: none;
}

.savings-body {
  position: relative;
  padding: 28px 30px;
}

.savings-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.savings-eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #6EE7B7;
  margin-bottom: 4px;
}

.savings-headline {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.3px;
}

.savings-pct-pill {
  background: var(--green-600);
  color: #ECFDF5;
  font-size: 13px;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: var(--r-pill);
  flex-shrink: 0;
  align-self: flex-start;
}

.savings-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  padding: 20px 0;
  border-top: 1px solid rgba(255,255,255,.08);
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.savings-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-lbl {
  font-size: 12px;
  font-weight: 500;
  color: #A7F3D0;
}

.stat-num {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
}

.stat-num.emerald { color: #34D399; }
.stat-num.cyan    { color: #38BDF8; }
.stat-num.gold    { color: #FBBF24; }

.stat-note {
  font-size: 11.5px;
  color: rgba(255,255,255,.4);
}

.cost-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
}

.cost-old { color: #F87171; text-decoration: line-through; opacity: .8; font-size: 18px; }
.cost-arrow { color: #6B7280; font-size: 14px; }
.cost-new { color: #34D399; font-size: 24px; }

.savings-actions {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.actions-left {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Section header shared style ────────────────────────────── */
.section-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.section-icon {
  font-size: 22px;
  background: var(--bg-muted);
  padding: 8px 10px;
  border-radius: var(--r-md);
  flex-shrink: 0;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--txt-main);
}

.section-sub {
  font-size: 13px;
  color: var(--txt-muted);
  margin-top: 2px;
}

/* ── Timetable ───────────────────────────────────────────────── */
.timetable-card {
  padding: 22px 24px;
}

.timetable-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.time-slot-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .2s, transform .15s;
}

.time-slot-card:hover {
  border-color: var(--green-500);
  transform: translateY(-2px);
  box-shadow: var(--sh-sm);
}

.time-slot-header {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-sub);
}

.time-slot-title {
  font-weight: 700;
  font-size: 13.5px;
  margin-bottom: 2px;
}

.time-slot-time {
  font-size: 11px;
  color: var(--txt-soft);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.time-slot-meds {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slot-pill-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 10px;
}

.slot-pill-name {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 2px;
}

.slot-pill-dose {
  font-size: 11.5px;
  color: var(--txt-muted);
}

.slot-empty {
  font-size: 12px;
  color: var(--txt-soft);
  font-style: italic;
}

/* ── Synergy card ───────────────────────────────────────────── */
.synergy-card {
  padding: 22px 24px;
  background: var(--green-50);
  border-color: var(--green-100);
}

[data-theme="dark"] .synergy-card {
  background: rgba(26,158,114,.07);
  border-color: rgba(26,158,114,.18);
}

.synergy-body {
  font-size: 14px;
  color: var(--txt-muted);
  line-height: 1.65;
}

/* ── Interactions ───────────────────────────────────────────── */
.interaction-card {
  padding: 22px 24px;
}

.interaction-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.interaction-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  text-transform: uppercase;
  letter-spacing: .5px;
  flex-shrink: 0;
}

.badge-red    { background: var(--red-bg);   color: var(--red);   border: 1px solid #FECACA; }
.badge-amber  { background: var(--amber-bg); color: var(--amber); border: 1px solid #FDE68A; }
.badge-green  { background: var(--green-50); color: var(--green-600); border: 1px solid var(--green-100); }

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

.interaction-item {
  padding: 13px 16px;
  border-radius: var(--r-md);
  border-left: 4px solid transparent;
  font-size: 13.5px;
  line-height: 1.55;
}

.item-red   { background: var(--red-bg);   border-left-color: var(--red);   }
.item-amber { background: var(--amber-bg); border-left-color: var(--amber); }
.item-green { background: var(--green-50); border-left-color: var(--green-500); }

.interaction-item-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.interaction-item-action {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--txt-muted);
}

/* ── Medicines section ──────────────────────────────────────── */
.medicines-section { /* no card wrapper, contains individual med-cards */ }

.med-section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 16px;
}

.med-count {
  font-size: 13px;
  font-weight: 700;
  background: var(--bg-muted);
  color: var(--txt-muted);
  padding: 4px 12px;
  border-radius: var(--r-pill);
  flex-shrink: 0;
}

.medicines-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Medicine card */
.med-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  display: grid;
  grid-template-columns: 1fr 310px;
  gap: 0;
  overflow: hidden;
  transition: box-shadow .2s, border-color .2s;
}

.med-card:hover {
  box-shadow: var(--sh-md);
  border-color: #C4D4CC;
}

.med-main-info {
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  border-right: 1px solid var(--border);
}

.med-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.med-brand-name {
  font-size: 17px;
  font-weight: 800;
  color: var(--green-900);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

[data-theme="dark"] .med-brand-name { color: var(--green-400); }

.med-strength-tag {
  font-size: 11.5px;
  font-weight: 700;
  background: var(--bg-muted);
  color: var(--txt-muted);
  padding: 2px 8px;
  border-radius: 4px;
}

.med-condition-pill {
  font-size: 11.5px;
  font-weight: 600;
  background: var(--blue-bg);
  color: var(--blue);
  padding: 3px 10px;
  border-radius: var(--r-pill);
  white-space: nowrap;
}

.med-salt-line {
  font-size: 12.5px;
  color: var(--txt-muted);
  font-family: var(--mono);
}

.med-dosage-block {
  background: var(--bg-raised);
  border-radius: var(--r-sm);
  border-left: 3px solid var(--green-500);
  padding: 9px 13px;
  font-size: 13px;
  line-height: 1.6;
}

.med-timing-label { font-weight: 700; }

/* Why to take */
.med-why-box {
  background: var(--green-50);
  border-left: 3px solid var(--green-500);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  padding: 10px 13px;
}

[data-theme="dark"] .med-why-box {
  background: rgba(26,158,114,.07);
}

.med-why-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--green-700);
  margin-bottom: 3px;
}

.med-why-desc {
  font-size: 13px;
  color: var(--txt-muted);
  line-height: 1.5;
}

/* Meal guidance */
.med-meal-box {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.med-meal-timing-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.med-meal-timing-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  background: var(--blue-bg);
  color: var(--blue);
  padding: 3px 9px;
  border-radius: var(--r-pill);
}

.meal-guidance-line {
  font-size: 12.5px;
  color: var(--txt-muted);
  line-height: 1.5;
}

.meal-avoid-line {
  font-size: 12px;
  background: var(--gold-bg);
  color: #92400E;
  padding: 5px 9px;
  border-radius: var(--r-sm);
  border-left: 3px solid var(--amber);
  line-height: 1.45;
}

[data-theme="dark"] .meal-avoid-line {
  background: rgba(217,119,6,.12);
  color: #FCD34D;
}

/* Precautions list */
.med-precautions-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 4px;
}

.med-precautions-list li {
  font-size: 12.5px;
  color: var(--txt-muted);
  position: relative;
  padding-left: 18px;
  line-height: 1.5;
}

.med-precautions-list li::before {
  content: "·";
  color: var(--green-500);
  font-size: 20px;
  position: absolute;
  left: 4px;
  top: -4px;
}

/* Generic alt box */
.med-alt-box {
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(to bottom, #F8FBF9, #F2F7F4);
}

[data-theme="dark"] .med-alt-box {
  background: linear-gradient(to bottom, rgba(26,158,114,.06), rgba(26,158,114,.03));
}

.alt-eyebrow {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--green-600);
  margin-bottom: 5px;
}

.alt-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--green-900);
}

[data-theme="dark"] .alt-name { color: var(--green-400); }

.alt-manufacturer {
  font-size: 12px;
  color: var(--txt-soft);
  margin-bottom: 10px;
}

.alt-price-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.alt-price-val {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 800;
  color: var(--green-600);
}

.alt-save-badge {
  font-size: 11.5px;
  font-weight: 700;
  background: var(--green-100);
  color: var(--green-700);
  padding: 3px 8px;
  border-radius: var(--r-pill);
}

.alt-actions-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Unverified card variant */
.med-card.unverified .med-main-info {
  border-right: none;
}

/* ── Footer ─────────────────────────────────────────────────── */
.app-footer {
  background: var(--bg-muted);
  border-top: 1px solid var(--border);
  padding: 24px;
}

.footer-inner {
  max-width: 1020px;
  margin: 0 auto;
  text-align: center;
}

.footer-disclaimer {
  font-size: 12.5px;
  color: var(--txt-muted);
  line-height: 1.6;
  margin-bottom: 8px;
}

.footer-copy {
  font-size: 12px;
  color: var(--txt-soft);
}

/* ── FAB ─────────────────────────────────────────────────────── */
.copilot-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--green-900), var(--green-600));
  color: #fff;
  border: 1px solid rgba(61,196,148,.3);
  padding: 12px 20px;
  border-radius: var(--r-pill);
  font-size: 13.5px;
  font-weight: 700;
  box-shadow: 0 8px 20px -4px rgba(7,34,25,.45), 0 4px 8px rgba(0,0,0,.15);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}

.copilot-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px -4px rgba(7,34,25,.55);
}

.fab-pulse {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  background: #34D399;
  border-radius: 50%;
  border: 2px solid var(--bg-page);
}

.fab-icon { font-size: 16px; }
.fab-label { display: inline; }

/* ── Copilot drawer ─────────────────────────────────────────── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  justify-content: flex-end;
}

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

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7,34,25,.45);
  backdrop-filter: blur(3px);
}

.drawer-panel {
  position: relative;
  width: 380px;
  max-width: 100vw;
  height: 100%;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.16,1,.3,1);
  box-shadow: var(--sh-lg);
}

.drawer-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: var(--bg-card);
}

.drawer-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--green-900);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

[data-theme="dark"] .chat-avatar { background: var(--green-600); }

.drawer-title {
  font-size: 14.5px;
  font-weight: 700;
}

.drawer-status {
  font-size: 11.5px;
  color: var(--green-600);
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green-500);
  flex-shrink: 0;
}

.drawer-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Emergency banner */
.emergency-banner {
  background: var(--red);
  color: #fff;
  padding: 10px 16px;
  font-size: 12.5px;
  font-weight: 600;
  animation: pulseRed 2s infinite;
  flex-shrink: 0;
}

@keyframes pulseRed {
  0%, 100% { background: #DC2626; }
  50%       { background: #B91C1C; }
}

/* Suggestions */
.suggestions-bar {
  padding: 10px 14px;
  display: flex;
  gap: 7px;
  overflow-x: auto;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border-sub);
  scrollbar-width: none;
  flex-shrink: 0;
}
.suggestions-bar::-webkit-scrollbar { display: none; }

.chip {
  white-space: nowrap;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--txt-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}

.chip:hover {
  background: var(--green-50);
  color: var(--green-600);
  border-color: var(--green-400);
}

/* Chat messages */
.chat-messages {
  flex: 1;
  padding: 18px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bg-raised);
}

.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 90%;
}

.chat-msg.bot  { align-self: flex-start; }
.chat-msg.user { align-self: flex-end; }

.msg-bubble {
  padding: 11px 14px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  line-height: 1.6;
}

.chat-msg.bot  .msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--txt-main);
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  border-bottom-left-radius: 4px;
}

.chat-msg.bot  .msg-bubble strong { color: var(--green-700); }
[data-theme="dark"] .chat-msg.bot .msg-bubble strong { color: var(--green-400); }

.chat-msg.user .msg-bubble {
  background: var(--green-900);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-meta {
  font-size: 11px;
  color: var(--txt-soft);
  margin-top: 3px;
  padding: 0 2px;
}

.chat-msg.user .msg-meta { text-align: right; }

/* Chat form */
.chat-form {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  padding: 9px 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
  background: var(--bg-raised);
  color: var(--txt-main);
  transition: border-color .2s, box-shadow .2s;
}

.chat-input:focus {
  border-color: var(--green-500);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px var(--glow);
}

.btn-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--green-600);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s, transform .12s;
  flex-shrink: 0;
}

.btn-send:hover { background: var(--green-700); transform: scale(1.06); }

.chat-disclaimer {
  padding: 8px 16px;
  font-size: 10.5px;
  color: var(--txt-soft);
  text-align: center;
  background: var(--bg-raised);
  border-top: 1px solid var(--border-sub);
  flex-shrink: 0;
}

/* ── Modal ───────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(7,34,25,.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal[hidden] { display: none !important; }

.modal-box {
  background: var(--bg-card);
  border-radius: var(--r-xl);
  max-width: 560px;
  width: 100%;
  box-shadow: 0 20px 48px rgba(0,0,0,.25);
  overflow: hidden;
  animation: modalIn .2s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(.96) translateY(6px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}

.modal-top {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--green-600);
  margin-bottom: 3px;
}

.modal-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--txt-main);
}

.modal-content {
  padding: 20px 22px;
  max-height: 60vh;
  overflow-y: auto;
}

.modal-desc {
  font-size: 13.5px;
  color: var(--txt-muted);
  margin-bottom: 14px;
}

.slip-box {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--green-900);
  white-space: pre-wrap;
  word-break: break-word;
}

[data-theme="dark"] .slip-box { color: var(--green-400); }

.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--bg-raised);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .savings-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 700px) {
  .header-inner { padding: 0 16px; }
  .header-nav .brand-badge { display: none; }
  .hero-band { padding: 28px 16px 24px; }
  .app-main { padding: 20px 16px 80px; }

  .savings-grid { grid-template-columns: 1fr 1fr; gap: 16px; }
  .savings-body { padding: 20px 18px; }

  .med-card {
    grid-template-columns: 1fr;
  }

  .med-main-info {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .timetable-grid {
    grid-template-columns: 1fr 1fr;
  }

  .copilot-fab { bottom: 16px; right: 16px; padding: 11px 16px; }
  .fab-label { display: none; }

  .drawer-panel { width: 100vw; }
}

@media (max-width: 480px) {
  .savings-grid { grid-template-columns: 1fr; }
  .savings-top { flex-direction: column; align-items: flex-start; }
  .timetable-grid { grid-template-columns: 1fr; }
  .scanner-tabs { width: 100%; justify-content: stretch; }
  .tab { flex: 1; text-align: center; font-size: 12px; padding: 7px 10px; }
}

/* ── Small utility button variants for medicine cards ─────── */
.btn-sm {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: var(--r-sm);
}

.btn-outline-med {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--txt-muted);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: var(--r-sm);
}

.btn-outline-med:hover { border-color: var(--green-500); color: var(--green-700); }

/* ── Print styles ────────────────────────────────────────────── */
@media print {
  .app-header, .copilot-fab, .drawer-overlay, .hero-band, .savings-actions,
  .tab, .dropzone, .preview-bar, .text-mode, #uploadSection { display: none !important; }
  .app-main { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ============================================================
   Professional Health-Tech Dark Theme Component Styling
   ============================================================ */
[data-theme="dark"] .card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .dropzone {
  background: #0F172A;
  border-color: rgba(255, 255, 255, 0.14);
}

[data-theme="dark"] .dropzone:hover,
[data-theme="dark"] .dropzone.dragover {
  border-color: var(--green-400);
  background: rgba(16, 185, 129, 0.08);
}

[data-theme="dark"] .rx-textarea {
  background: #0B0F19;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #F8FAFC;
}

[data-theme="dark"] .rx-textarea:focus {
  border-color: var(--green-400);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

[data-theme="dark"] .preview-bar {
  background: #1A2234;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .med-card {
  background: #0F172A;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 16px -2px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .med-main-info {
  background: #0F172A;
}

[data-theme="dark"] .med-brand-name {
  color: #F8FAFC;
}

[data-theme="dark"] .med-why-box {
  background: rgba(16, 185, 129, 0.07);
  border-left: 3px solid var(--green-400);
}

[data-theme="dark"] .med-why-title {
  color: var(--green-400);
}

[data-theme="dark"] .med-why-desc {
  color: #CBD5E1;
}

[data-theme="dark"] .med-meal-box {
  background: #141E30;
  border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .med-meal-timing-pill {
  background: rgba(56, 189, 248, 0.14);
  color: #38BDF8;
}

[data-theme="dark"] .meal-avoid-line {
  background: rgba(245, 158, 11, 0.12);
  color: #FCD34D;
  border-left-color: #F59E0B;
}

[data-theme="dark"] .med-alt-box {
  background: linear-gradient(180deg, #131E30 0%, #0F172A 100%);
  border: 1px solid rgba(16, 185, 129, 0.18);
}

[data-theme="dark"] .alt-name {
  color: var(--green-400);
}

[data-theme="dark"] .alt-eyebrow {
  color: var(--green-400);
}

[data-theme="dark"] .synergy-card {
  background: rgba(16, 185, 129, 0.06);
  border-color: rgba(16, 185, 129, 0.18);
}

[data-theme="dark"] .synergy-card .card-head h2 {
  color: var(--green-400);
}

[data-theme="dark"] .synergy-body {
  color: #CBD5E1;
}

[data-theme="dark"] .timetable-slot {
  background: #131E30;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .slot-pill-card {
  background: #1A2234;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .slot-pill-name {
  color: #F8FAFC;
}

[data-theme="dark"] .interaction-item.high {
  background: rgba(239, 68, 68, 0.1);
  border-left-color: #F87171;
  color: #FECACA;
}

[data-theme="dark"] .interaction-item.moderate {
  background: rgba(245, 158, 11, 0.1);
  border-left-color: #FBBF24;
  color: #FDE68A;
}

[data-theme="dark"] .interaction-item.synergy {
  background: rgba(16, 185, 129, 0.1);
  border-left-color: #34D399;
  color: #A7F3D0;
}

[data-theme="dark"] .badge-red {
  background: rgba(239, 68, 68, 0.15);
  color: #F87171;
  border-color: rgba(239, 68, 68, 0.3);
}

[data-theme="dark"] .badge-amber {
  background: rgba(245, 158, 11, 0.15);
  color: #FBBF24;
  border-color: rgba(245, 158, 11, 0.3);
}

[data-theme="dark"] .badge-green {
  background: rgba(16, 185, 129, 0.15);
  color: #34D399;
  border-color: rgba(16, 185, 129, 0.3);
}

[data-theme="dark"] .drawer-panel {
  background: #0F172A;
  border-left: 1px solid rgba(255, 255, 255, 0.09);
}

[data-theme="dark"] .drawer-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: #131E30;
}

[data-theme="dark"] .drawer-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: #0F172A;
}

[data-theme="dark"] .chat-input {
  background: #0B0F19;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #F8FAFC;
}

[data-theme="dark"] .chat-input:focus {
  border-color: var(--green-400);
}

[data-theme="dark"] .chat-msg.bot .msg-bubble {
  background: #1E293B;
  color: #F8FAFC;
  border: 1px solid rgba(255, 255, 255, 0.07);
}

[data-theme="dark"] .chat-msg.user .msg-bubble {
  background: linear-gradient(135deg, #10B981, #059669);
  color: #FFFFFF;
}

[data-theme="dark"] .modal-content {
  background: #0F172A;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 48px -8px rgba(0, 0, 0, 0.8);
}

[data-theme="dark"] .slip-box {
  background: #0B0F19;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #F8FAFC;
}

[data-theme="dark"] .hero-band {
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.06) 0%, transparent 100%);
}
