/* ═══════════════════════════════════════════════════
   MEDMINDER — Complete Style Sheet
   ═══════════════════════════════════════════════════ */

:root {
  --brand:      #1a504c;
  --brand-dark: #133d3a;
  --brand-mid:  #22665f;
  --brand-soft: #e8f5f3;
  --bg:         #f4faf9;
  --line:       #d8e5e3;
  --text:       #0f172a;
  --muted:      #64748b;
  --danger:     #dc2626;
  --success:    #059669;
  --shadow-sm:  0 4px 12px rgba(15,23,42,0.06);
  --shadow-md:  0 12px 28px rgba(15,23,42,0.09);
  --shadow-lg:  0 20px 50px rgba(15,23,42,0.10);
  --radius-sm:  0.75rem;
  --radius-md:  1rem;
  --radius-lg:  1.25rem;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Geologica', sans-serif !important;
  background: linear-gradient(160deg, #f0faf8 0%, #f5f9f8 50%, #eff6f5 100%) !important;
  color: var(--text) !important;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  overflow-x: hidden; /* Ensure body never allows horizontal scroll */
}

input, select, textarea { text-transform: uppercase; letter-spacing: 0.02em; }
input::placeholder, textarea::placeholder { text-transform: uppercase; opacity: 0.6; }

.font-cinzel, .font-header {
  font-family: 'Cinzel', serif !important;
  text-transform: uppercase;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}


/* ═══════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════ */
header {
  background: linear-gradient(135deg, #133d3a 0%, #1a504c 100%) !important;
  box-shadow: 0 8px 24px rgba(15,23,42,0.18) !important;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.nav-link {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  border-radius: 0.6rem;
  color: rgba(255,255,255,0.75);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-decoration: none;
  transition: all 150ms ease;
}
.nav-link:hover, .nav-link--active {
  color: #fff;
  background: rgba(255,255,255,0.10);
}
.nav-link i { font-size: 0.85rem; }

.export-btn {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: 0.6rem;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.85);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 150ms ease;
}
.export-btn:hover {
  background: rgba(255,255,255,0.18);
  color: #fff;
}
.export-btn i { color: #f87171; font-size: 0.9rem; }


/* ═══════════════════════════════════════════════════
   STATS SECTION
   ═══════════════════════════════════════════════════ */
.stats-section {
  background: rgba(255,255,255,0.55);
  border-bottom: 1px solid rgba(218,227,226,0.8);
  backdrop-filter: blur(8px);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: rgba(255,255,255,0.9);
  border: 1px solid rgba(218,227,226,0.85);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow-sm);
  transition: transform 150ms ease, box-shadow 150ms ease;
}
.stat-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }

.stat-icon {
  width: 2.6rem; height: 2.6rem; flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 0.7rem;
  font-size: 1rem;
}
.stat-icon--teal  { background: rgba(26,80,76,0.10); color: var(--brand); border: 1px solid rgba(26,80,76,0.14); }
.stat-icon--blue  { background: rgba(14,165,233,0.10); color: #0284c7; border: 1px solid rgba(14,165,233,0.18); }
.stat-icon--amber { background: rgba(245,158,11,0.10); color: #b45309; border: 1px solid rgba(245,158,11,0.18); }
.stat-icon--red   { background: rgba(239,68,68,0.10); color: #b91c1c; border: 1px solid rgba(239,68,68,0.18); }

.stat-body { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }

.stat-value {
  font-size: 1.6rem; font-weight: 900; color: var(--text);
  line-height: 1; letter-spacing: -0.02em;
}
.stat-value--sm { font-size: 1.05rem; }

.stat-label {
  font-size: 0.6rem; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  white-space: normal; /* Fixed: allows wrapping on small screens */
  line-height: 1.2;
}

#alert-banner {
  margin-top: 0.6rem;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.68rem;
  font-weight: 800;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
#alert-banner.has-alerts {
  background: rgba(254,226,226,0.9);
  border: 1px solid rgba(254,202,202,1);
  color: #991b1b;
}
#alert-banner.is-ok {
  background: rgba(220,252,231,0.9);
  border: 1px solid rgba(187,247,208,1);
  color: #166534;
}


/* ═══════════════════════════════════════════════════
   MAIN LAYOUT
   ═══════════════════════════════════════════════════ */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 1.8fr;
  gap: 1.25rem;
  align-items: start;
  padding-top: 1.25rem;
}

.form-panel, .list-panel {
  background: rgba(255,255,255,0.88);
  border: 1px solid rgba(218,227,226,0.9);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(218,227,226,0.7);
  background: rgba(248,252,251,0.8);
  flex-wrap: wrap; /* Fixed: prevents horizontal overflow */
}

.step-badge {
  font-size: 0.62rem; font-weight: 900;
  padding: 0.3rem 0.65rem; border-radius: 999px;
  background: rgba(26,80,76,0.08);
  color: var(--brand);
  border: 1px solid rgba(26,80,76,0.14);
}

.count-badge {
  font-size: 0.62rem; font-weight: 900;
  padding: 0.3rem 0.65rem; border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid rgba(226,232,240,1);
}


/* ═══════════════════════════════════════════════════
   SUCCESS OVERLAY
   ═══════════════════════════════════════════════════ */
.success-overlay {
  position: absolute; inset: 0; z-index: 60;
  background: linear-gradient(135deg, #133d3a 0%, #1a504c 100%);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 350ms ease;
  border-radius: var(--radius-lg);
}
.success-overlay.is-visible { opacity: 1; pointer-events: auto; }
.success-inner { text-align: center; }
.success-anim {
  width: 5rem; height: 5rem; margin: 0 auto;
  display: grid; place-items: center;
  background: rgba(255,255,255,0.12);
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.25);
  font-size: 2.5rem; color: #6ee7b7;
  animation: successPulse 0.5s ease;
}
@keyframes successPulse {
  0% { transform: scale(0.5); opacity: 0; }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}


/* ═══════════════════════════════════════════════════
   WIZARD PROGRESS
   ═══════════════════════════════════════════════════ */
.wizard-progress {
  display: flex;
  align-items: center;
  padding: 1rem 1.5rem 0;
}

.wiz-step {
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
  flex: 0 0 auto;
}

.wiz-dot {
  width: 2rem; height: 2rem;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 0.7rem; font-weight: 900;
  background: #e2e8f0; color: #94a3b8;
  border: 2px solid #e2e8f0;
  transition: all 250ms ease;
}

.wiz-step > span {
  font-size: 0.58rem; font-weight: 800;
  color: #94a3b8; letter-spacing: 0.06em;
  transition: color 250ms ease;
}

.wiz-step.is-active .wiz-dot {
  background: var(--brand); color: #fff;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(26,80,76,0.14);
}
.wiz-step.is-active > span { color: var(--brand); }

.wiz-step.is-done .wiz-dot {
  background: #dcfce7; color: #16a34a;
  border-color: #bbf7d0;
}
.wiz-step.is-done > span { color: #16a34a; }
.wiz-step.is-done .wiz-dot::after { content: '✓'; font-size: 0.75rem; }
.wiz-step.is-done .wiz-dot { font-size: 0; }

.wiz-connector {
  flex: 1;
  height: 2px;
  background: #e2e8f0;
  margin: 0 0.5rem;
  margin-bottom: 1.2rem;
  border-radius: 2px;
  min-width: 10px; /* Fixed: allows shrinking on mobile */
  transition: background 300ms ease;
}
.wiz-connector.is-done { background: #bbf7d0; }


/* ═══════════════════════════════════════════════════
   STEP PANELS + TRANSITIONS
   ═══════════════════════════════════════════════════ */
.steps-viewport {
  padding: 1rem 1.25rem 0;
  min-height: 300px;
}

.step-panel { display: none; }
.step-panel.is-active {
  display: block; animation: stepEnterRight 0.22s ease;
}
.step-panel.slide-from-left {
  animation: stepEnterLeft 0.22s ease !important;
}

@keyframes stepEnterRight {
  from { opacity: 0; transform: translateX(18px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes stepEnterLeft {
  from { opacity: 0; transform: translateX(-18px); }
  to   { opacity: 1; transform: translateX(0); }
}

.step-hint {
  font-size: 0.68rem; font-weight: 700;
  color: var(--muted); letter-spacing: 0.03em;
  margin-bottom: 1rem;
}

.field-group { margin-bottom: 0; }
.field-label {
  display: block; font-size: 0.62rem; font-weight: 900;
  color: #475569; letter-spacing: 0.08em; margin-bottom: 0.5rem;
}


/* ═══════════════════════════════════════════════════
   SEARCH INPUT
   ═══════════════════════════════════════════════════ */
.search-wrap {
  position: relative;
  display: flex; align-items: center;
}
.search-icon {
  position: absolute; left: 0.9rem; z-index: 1;
  font-size: 0.8rem; color: var(--muted); pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 0.8rem 2.5rem 0.8rem 2.4rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.95);
  font-size: 0.78rem; font-weight: 700;
  color: var(--text);
  font-family: 'Geologica', sans-serif;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}
.search-input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(26,80,76,0.10);
  transform: translateY(-1px);
}
.search-spinner {
  position: absolute; right: 0.9rem;
  color: var(--brand); font-size: 0.8rem;
}


/* ═══════════════════════════════════════════════════
   UNIT PILLS
   ═══════════════════════════════════════════════════ */
.unit-pills {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
}
.unit-pill {
  display: inline-flex; align-items: center; gap: 0.38rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: #f8fafc; border: 1.5px solid #e2e8f0;
  color: #64748b; font-size: 0.62rem; font-weight: 900;
  font-family: 'Geologica', sans-serif; letter-spacing: 0.06em;
  cursor: pointer; transition: all 150ms ease;
}
.unit-pill i { font-size: 0.7rem; }
.unit-pill:hover {
  border-color: rgba(26,80,76,0.35); color: var(--brand);
  background: rgba(26,80,76,0.04); transform: translateY(-1px);
}
.unit-pill.is-active {
  background: var(--brand); border-color: var(--brand); color: #fff;
  box-shadow: 0 6px 16px rgba(26,80,76,0.22);
}


/* ═══════════════════════════════════════════════════
   FREQUENCY CARDS (Step 2)
   ═══════════════════════════════════════════════════ */
.freq-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
}

.freq-card {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.25rem; padding: 0.75rem 0.4rem;
  background: rgba(255,255,255,0.9);
  border: 1.5px solid var(--line); border-radius: var(--radius-md);
  cursor: pointer; transition: all 160ms ease;
  font-family: 'Geologica', sans-serif;
  box-shadow: 0 4px 10px rgba(15,23,42,0.04);
}
.freq-card:hover {
  transform: translateY(-2px); border-color: rgba(26,80,76,0.35);
  box-shadow: 0 8px 20px rgba(15,23,42,0.08);
}
.freq-card.is-active {
  background: linear-gradient(135deg, rgba(26,80,76,0.10), rgba(26,80,76,0.05));
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26,80,76,0.12), 0 8px 20px rgba(26,80,76,0.10);
}

.freq-card__emoji { font-size: 1.4rem; line-height: 1; }
.freq-card__label {
  font-size: 0.6rem; font-weight: 900;
  color: #334155; letter-spacing: 0.04em; text-align: center;
}
.freq-card__sub {
  font-size: 0.54rem; font-weight: 700; color: var(--muted); text-align: center;
}
.freq-card.is-active .freq-card__label { color: var(--brand); }


/* ═══════════════════════════════════════════════════
   ADVANCED OPTIONS CONTAINER
   ═══════════════════════════════════════════════════ */
.adv-container {
  margin-top: 1rem;
  background: linear-gradient(180deg, rgba(247,250,250,0.98), rgba(240,248,246,0.98));
  border: 1px solid rgba(208,222,220,0.85);
  border-radius: var(--radius-md); padding: 0.85rem;
}
.adv-header {
  display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 0.75rem; font-size: 0.62rem; letter-spacing: 0.08em;
}
.adv-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem;
}
.adv-card {
  display: block; background: #fff;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 0.65rem; cursor: pointer; transition: all 150ms ease;
}
.adv-card:hover { border-color: rgba(26,80,76,0.3); }
.adv-card.is-selected {
  border-color: var(--brand);
  background: linear-gradient(135deg, rgba(26,80,76,0.08), rgba(26,80,76,0.04));
}

.adv-card__top { display: flex; align-items: center; gap: 0.4rem; }
.adv-emoji { font-size: 0.9rem; }
.adv-card__name { font-size: 0.62rem; font-weight: 900; color: #334155; flex: 1; }
.adv-check {
  width: 1.1rem; height: 1.1rem; border-radius: 50%;
  background: #e2e8f0; display: grid; place-items: center;
  font-size: 0.5rem; color: transparent; transition: all 150ms ease;
}
.adv-card.is-selected .adv-check { background: var(--brand); color: #fff; }

.expandable {
  margin-top: 0.6rem; padding-top: 0.6rem;
  border-top: 1px dashed rgba(148,163,184,0.3);
}
.adv-row {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.62rem; font-weight: 800; color: #64748b;
}

.adv-num {
  width: 3rem; height: 1.8rem;
  border: 1px solid var(--line); border-radius: 0.5rem;
  background: #fff; text-align: center;
  font-size: 0.75rem; font-weight: 900;
  color: var(--text); padding: 0 0.25rem;
  font-family: 'Geologica', sans-serif;
}
.adv-num:focus { outline: none; border-color: var(--brand); }

.day-picker { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.day-btn {
  flex: 1; min-width: 1.8rem; text-align: center; padding: 0.3rem;
  background: #fff; border: 1.5px solid var(--line); border-radius: 0.4rem;
  cursor: pointer; font-size: 0.6rem; font-weight: 900;
  color: #64748b; transition: all 120ms ease;
  font-family: 'Geologica', sans-serif; display: grid; place-items: center;
}
.day-btn:has(.day-chk:checked) {
  background: var(--brand); border-color: var(--brand); color: #fff;
}


/* ═══════════════════════════════════════════════════
   STEP 3 — SCHEDULE CONFIG
   ═══════════════════════════════════════════════════ */
.date-input {
  width: 100%; padding: 0.75rem 1rem;
  border: 1.5px solid var(--line); border-radius: var(--radius-md);
  background: rgba(255,255,255,0.95);
  font-size: 0.78rem; font-weight: 800;
  color: var(--brand); cursor: pointer;
  font-family: 'Geologica', sans-serif;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.date-input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(26,80,76,0.10);
}

.schedule-chip {
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(216,229,227,0.95);
  border-radius: var(--radius-md); padding: 0.85rem;
  box-shadow: 0 6px 14px rgba(15,23,42,0.04);
}
.schedule-chip__head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  margin-bottom: 0.65rem;
}
.schedule-chip__head h5 {
  font-size: 0.68rem; font-weight: 900; color: var(--text); margin: 0;
}
.schedule-chip__tag {
  font-size: 0.6rem; font-weight: 900;
  padding: 0.22rem 0.5rem; border-radius: 999px;
  color: var(--brand); background: rgba(26,80,76,0.08);
  border: 1px solid rgba(26,80,76,0.14);
}

.schedule-chip__row {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.45rem 0; border-top: 1px solid rgba(226,232,240,0.7);
  font-size: 0.68rem; font-weight: 900; color: #475569;
}
.schedule-chip__row:first-of-type { border-top: 0; }

.schedule-chip__row input {
  border: 1px solid var(--line); border-radius: 0.65rem;
  padding: 0.35rem 0.6rem; background: #fff;
  font-size: 0.72rem; font-weight: 800; color: var(--text); text-align: right;
  font-family: 'Geologica', sans-serif;
}
.schedule-chip__row input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26,80,76,0.08);
}

.dose-wrap {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.25rem 0.6rem; background: rgba(248,250,252,0.95);
  border-radius: 0.65rem; border: 1px solid rgba(226,232,240,0.95);
}
.dose-wrap .dynamic-unit-label {
  font-size: 0.62rem; font-weight: 900; color: var(--muted);
}


/* ═══════════════════════════════════════════════════
   ON DEMAND CONFIG
   ═══════════════════════════════════════════════════ */
.ondemand-box {
  background: linear-gradient(135deg, rgba(26,80,76,0.05), rgba(26,80,76,0.02));
  border: 1px solid rgba(26,80,76,0.14);
  border-radius: var(--radius-md); padding: 1rem;
}
.ondemand-box__header {
  display: flex; align-items: center; gap: 0.5rem;
  color: var(--brand); margin-bottom: 0.5rem;
}
.ondemand-box__header h4 { font-size: 0.78rem; font-weight: 900; }

.toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.65rem 0;
  border-top: 1px solid rgba(26,80,76,0.10); border-bottom: 1px solid rgba(26,80,76,0.10);
}

.tgl-switch { cursor: pointer; position: relative; display: inline-block; }
.tgl-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.tgl-track {
  display: block; width: 2.6rem; height: 1.4rem; background: #cbd5e1;
  border-radius: 999px; position: relative; transition: background 200ms ease;
}
.tgl-switch input:checked + .tgl-track { background: var(--brand); }
.tgl-thumb {
  position: absolute; top: 0.2rem; left: 0.2rem; width: 1rem; height: 1rem;
  background: #fff; border-radius: 50%; box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  transition: transform 200ms ease;
}
.tgl-switch input:checked + .tgl-track .tgl-thumb { transform: translateX(1.2rem); }

.inv-row {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,0.85); border: 1px solid rgba(218,227,226,0.8);
  border-radius: var(--radius-sm); padding: 0.65rem 0.85rem;
  font-size: 0.68rem; font-weight: 800; color: #475569;
}
.inv-input-wrap { display: flex; align-items: center; gap: 0.4rem; }
.inv-input-wrap input {
  width: 4rem; text-align: right; border: none; background: transparent;
  font-size: 0.78rem; font-weight: 900; color: var(--brand); outline: none;
  font-family: 'Geologica', sans-serif;
}
.inv-input-wrap .dynamic-unit-label { font-size: 0.62rem; font-weight: 900; color: var(--muted); }


/* ═══════════════════════════════════════════════════
   WIZARD NAVIGATION
   ═══════════════════════════════════════════════════ */
.wiz-nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; padding: 1rem 1.25rem;
  border-top: 1px solid rgba(218,227,226,0.65); margin-top: 1rem;
}

.step-dots { display: flex; gap: 0.4rem; }
.step-dot {
  width: 0.5rem; height: 0.5rem; border-radius: 50%;
  background: #e2e8f0; transition: all 200ms ease;
}
.step-dot.is-active { background: var(--brand); width: 1.25rem; border-radius: 4px; }
.step-dot.is-done { background: #bbf7d0; }

.wiz-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.65rem 1.25rem; border-radius: 999px;
  font-size: 0.68rem; font-weight: 900; letter-spacing: 0.06em;
  cursor: pointer; border: none; font-family: 'Geologica', sans-serif;
  transition: all 150ms ease;
}

.wiz-btn--primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff;
  box-shadow: 0 8px 20px rgba(26,80,76,0.22);
}
.wiz-btn--primary:hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(26,80,76,0.28); }

.wiz-btn--success {
  background: linear-gradient(135deg, #059669, #047857); color: #fff;
  box-shadow: 0 8px 20px rgba(5,150,105,0.22);
}
.wiz-btn--success:hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(5,150,105,0.28); }

.wiz-btn--ghost {
  background: transparent; color: #64748b; border: 1px solid #e2e8f0;
}
.wiz-btn--ghost:hover { background: #f8fafc; color: #334155; }


/* ═══════════════════════════════════════════════════
   SUGGESTIONS DROPDOWN
   ═══════════════════════════════════════════════════ */
#med-suggestions {
  position: absolute; top: calc(100% + 0.4rem); left: 0; right: 0;
  background: rgba(255,255,255,0.99); border: 1px solid rgba(208,222,220,0.95);
  border-radius: var(--radius-md); box-shadow: 0 24px 48px rgba(15,23,42,0.16);
  max-height: 14rem; overflow-y: auto; z-index: 100;
  list-style: none; margin: 0; padding: 0;
}

.suggestion {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.75rem 1rem; border-bottom: 1px solid rgba(241,245,249,0.9);
  cursor: pointer; transition: background 100ms ease; background: #fff;
}
.suggestion:last-child { border-bottom: none; }
.suggestion:hover, .suggestion.is-focused { background: rgba(26,80,76,0.05); }
.suggestion--loading, .suggestion--empty {
  cursor: default; color: #64748b; justify-content: flex-start; gap: 0.5rem;
  font-size: 0.72rem; font-weight: 800;
}
.suggestion__main { display: flex; flex-direction: column; gap: 0.1rem; }
.suggestion__main strong { font-size: 0.78rem; color: var(--text); word-break: break-word;}
.suggestion__main span { font-size: 0.64rem; color: #64748b; }
.suggestion__source {
  font-size: 0.58rem; font-weight: 900; padding: 0.2rem 0.45rem; border-radius: 999px;
  color: var(--brand); background: rgba(26,80,76,0.08); white-space: nowrap;
}


/* ═══════════════════════════════════════════════════
   MEDICINE LIST PANEL
   ═══════════════════════════════════════════════════ */
.list-panel { min-height: 24rem; }
.list-panel .panel-header { padding: 1rem 1.25rem; }
.list-panel > div:last-child { padding: 0.5rem 1rem 1rem; }

.empty-state {
  min-height: 16rem; display: grid; place-items: center;
  text-align: center; padding: 2rem 1rem;
  border: 1.5px dashed rgba(148,163,184,0.45); border-radius: var(--radius-md);
  background: rgba(255,255,255,0.5); margin: 0.5rem 0;
}
.empty-state i { font-size: 3rem; color: rgba(26,80,76,0.18); display: block; margin-bottom: 0.75rem; }
.empty-state p { font-size: 0.72rem; font-weight: 900; color: #94a3b8; }


/* ═══════════════════════════════════════════════════
   MEDICINE CARDS
   ═══════════════════════════════════════════════════ */
.med-card {
  background: rgba(255,255,255,0.92); border: 1px solid rgba(216,229,227,0.9);
  border-radius: var(--radius-md); padding: 0.95rem 1rem;
  box-shadow: 0 6px 16px rgba(15,23,42,0.05);
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}
.med-card:hover {
  transform: translateY(-1px); box-shadow: 0 12px 24px rgba(15,23,42,0.08);
  border-color: rgba(26,80,76,0.18);
}
.med-card--done { opacity: 0.78; }

.med-card__top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem;
  margin-bottom: 0.6rem;
}
.med-card__name-row { display: flex; align-items: center; gap: 0.65rem; min-width: 0; }
.med-icon {
  width: 2.4rem; height: 2.4rem; flex: 0 0 auto; display: grid; place-items: center;
  border-radius: 0.65rem; background: rgba(26,80,76,0.08); color: var(--brand);
  border: 1px solid rgba(26,80,76,0.12); font-size: 0.85rem;
}
.med-card__title {
  font-size: 0.92rem; font-weight: 900; color: var(--text);
  line-height: 1.2; word-break: break-word;
}
.med-pill {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.28rem 0.55rem; border-radius: 999px;
  font-size: 0.6rem; font-weight: 900; color: var(--brand);
  background: rgba(26,80,76,0.08); border: 1px solid rgba(26,80,76,0.14);
  white-space: nowrap; flex-shrink: 0;
}

.med-meta { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.75rem; }
.info-chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.3rem 0.55rem; border-radius: 999px; background: rgba(248,250,252,0.95);
  border: 1px solid rgba(226,232,240,0.9); color: #475569; font-size: 0.6rem; font-weight: 900;
}
.info-chip i { color: var(--brand); font-size: 0.6rem; }

.med-detail {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.55rem 0.7rem; border-radius: 0.65rem; background: rgba(248,250,252,0.95);
  border: 1px solid rgba(226,232,240,0.9); color: #475569; font-size: 0.65rem; font-weight: 800;
  margin-bottom: 0.6rem;
}
.med-detail i { color: var(--brand); }

.med-card__actions {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  border-top: 1px solid rgba(226,232,240,0.6); padding-top: 0.7rem; margin-top: 0.2rem;
}

.action-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  padding: 0.5rem 0.85rem; border-radius: 999px; font-size: 0.62rem; font-weight: 900;
  font-family: 'Geologica', sans-serif; letter-spacing: 0.05em; cursor: pointer; border: none;
  transition: all 140ms ease;
  white-space: nowrap; /* Button content shouldn't wrap itself, but buttons can wrap */
}
.action-btn--take {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff; flex: 1;
  box-shadow: 0 6px 14px rgba(26,80,76,0.18);
}
.action-btn--take:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(26,80,76,0.26); }
.action-btn--take:disabled { background: linear-gradient(135deg, #059669, #047857); cursor: default; box-shadow: none; }

.action-btn--edit { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.action-btn--edit:hover { background: #e2e8f0; }

.action-btn--delete { background: rgba(254,226,226,0.8); color: #b91c1c; border: 1px solid rgba(254,202,202,0.9); }
.action-btn--delete:hover { background: rgba(254,202,202,0.9); }


/* ═══════════════════════════════════════════════════
   CUSTOM TIME PICKER POP-OVER
   ═══════════════════════════════════════════════════ */
.time-trigger {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.35rem 0.6rem; background: #fff; border: 1px solid var(--line); border-radius: 0.65rem;
  font-size: 0.72rem; font-weight: 800; color: var(--text);
  cursor: pointer; transition: border-color 150ms ease, box-shadow 150ms ease; min-width: 6.5rem;
}
.time-trigger:hover { border-color: var(--brand); }

.time-picker-popover {
  position: absolute; z-index: 9999; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; width: 11rem; font-family: 'Geologica', sans-serif;
}
.time-picker-popover.hidden { display: none; }
.tp-cols { display: flex; height: 14rem; }
.tp-col {
  flex: 1; overflow-y: auto; scrollbar-width: none; border-right: 1px solid var(--line);
  scroll-behavior: smooth;
}
.tp-col::-webkit-scrollbar { display: none; }
.tp-col:last-child { border-right: none; }
.tp-item {
  padding: 0.6rem; text-align: center; font-size: 0.85rem; font-weight: 800; color: #475569;
  cursor: pointer; transition: background 150ms ease, color 150ms ease;
}
.tp-item:hover { background: #f8fafc; }
.tp-item.is-active { background: var(--brand); color: #fff; }
.tp-actions { padding: 0.5rem; border-top: 1px solid var(--line); background: #f8fafc; display: flex; justify-content: center; }
.tp-actions .wiz-btn { width: 100%; justify-content: center; padding: 0.4rem; font-size: 0.65rem;}


/* ═══════════════════════════════════════════════════
   SCROLLBAR
   ═══════════════════════════════════════════════════ */
.scrollbar-thin { scrollbar-width: thin; scrollbar-color: rgba(100,116,139,0.45) transparent; }


/* ═══════════════════════════════════════════════════
   RESPONSIVE (The Mobile Fixes)
   ═══════════════════════════════════════════════════ */

/* Large Tablets */
@media (max-width: 1024px) {
  .main-grid { grid-template-columns: 1fr; gap: 1.5rem; }
  .list-panel { min-height: auto; }
}

/* Tablets and small screens */
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
  
  /* Strictly hide text on navbar buttons to save space */
  .nav-text, .export-btn span { display: none !important; } 
  
  /* Remove extra margins from icons since the text is gone */
  .nav-link i { margin: 0 !important; }
  #nav-user-name { margin: 0 !important; }
  
  /* Tighter padding to prevent the buttons from pushing off-screen */
  .nav-link { padding: 0.5rem 0.65rem !important; }
  .export-btn { padding: 0.5rem 0.75rem; }
}

/* Very Small Mobile Phones (iPhone SE, etc.) */
@media (max-width: 380px) {
  /* Shrink the logo slightly so buttons have room to breathe */
  header img { height: 2.2rem !important; }
  .nav-link { padding: 0.4rem 0.5rem !important; }
}

/* Standard Mobile Phones */
@media (max-width: 640px) {
  /* Fix Grid Crushing */
  .freq-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .adv-grid { grid-template-columns: 1fr; gap: 0.5rem; }
  .unit-pills { gap: 0.35rem; }
  .unit-pill { padding: 0.4rem 0.6rem; font-size: 0.58rem; }
  
  /* Fix Stats Overflow */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
  .stat-card { 
    flex-direction: column; 
    text-align: center; 
    padding: 0.8rem 0.5rem; 
    gap: 0.5rem; 
  }
  .stat-body { align-items: center; }
  .stat-label { font-size: 0.55rem; white-space: normal; line-height: 1.2; }
  .stat-value { font-size: 1.4rem; }

  /* Fix Form Padding and Nav Overflow */
  .panel-header { padding: 1rem; }
  .steps-viewport { padding: 1rem 1rem 0; min-height: 260px; }
  
  .wiz-nav { padding: 1rem; flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
  .step-dots { width: 100%; justify-content: center; order: -1; margin-bottom: 0.5rem; }
  .wiz-btn { flex: 1; justify-content: center; }

  /* Fix Medicine Cards squishing */
  .med-card__top { flex-direction: column; align-items: flex-start; gap: 0.6rem; }
  .med-card__name-row { width: 100%; }
  .med-pill { align-self: flex-start; }
  .med-card__actions { justify-content: stretch; }
  .med-card__actions .action-btn { flex: 1; justify-content: center; }
}

/* Very Small Mobile Phones */
@media (max-width: 480px) {
  /* Fix Progress Bar Overflow */
  .wizard-progress { padding: 1rem 1rem 0; gap: 0.25rem; }
  .wiz-step > span { display: none; } /* Hide text, keep numbered dots */
  .wiz-connector { margin-bottom: 0; } /* Re-align line when text drops */

  .panel-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .step-badge, .count-badge { align-self: flex-start; margin-top: 0.25rem; }
  
  /* Fix On-Demand Layout squish */
  .inv-row { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .inv-input-wrap { width: 100%; justify-content: space-between; }
  .schedule-chip__row input { width: 4rem; }
  
  /* Tiny Stats */
  .stats-grid { gap: 0.5rem; }
  .stat-card { padding: 0.6rem 0.5rem; gap: 0.5rem; }
  .stat-icon { width: 2rem; height: 2rem; font-size: 0.8rem; }
  .stat-value { font-size: 1.25rem; }
}

/* ═══════════════════════════════════════════════════
   EXPORT IMAGE MODE (Hides buttons during screenshot)
   ═══════════════════════════════════════════════════ */
.exporting .med-card__actions { display: none !important; }
.exporting .empty-state { border: none !important; background: transparent !important; }

/* ═══════════════════════════════════════════════════
   AUTHENTICATION FIELD FIXES
   ═══════════════════════════════════════════════════ */
#login-id, #login-password, #reg-email, #reg-password, #reg-confirm,
#recover-identifier, #recover-password {
  text-transform: none !important;
  letter-spacing: normal !important;
}

#login-id::placeholder, #login-password::placeholder, #reg-email::placeholder, 
#reg-password::placeholder, #reg-confirm::placeholder, 
#recover-identifier::placeholder, #recover-password::placeholder {
  text-transform: none !important;
}