:root {
  --bg: #f4f7f9;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --primary: #0f766e;
  --primary-dark: #0d5c56;
  --primary-soft: #e6f7f5;
  --accent: #0284c7;
  --wa: #25D366;
  --wa-dark: #1da851;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --warn: #d97706;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 18px 48px rgba(15, 23, 42, 0.14);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 800;
  font-size: 1.12rem;
}
.brand-badge {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), #14b8a6);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.28);
}
.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.58rem 1.05rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.16s var(--ease), background 0.18s ease, box-shadow 0.18s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 14px rgba(15, 118, 110, 0.28); }
.btn-soft { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-soft:hover { background: var(--surface-soft); border-color: #cbd5e1; }
.btn-wa { background: var(--wa); color: #fff; }
.btn-wa:hover { background: var(--wa-dark); box-shadow: 0 6px 18px rgba(37, 211, 102, 0.32); }
.btn-danger { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 0.42rem 0.78rem; font-size: 0.81rem; border-radius: 8px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Container & Hero */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.25rem;
}
.hero {
  background: linear-gradient(135deg, #0f766e 0%, #0d5c56 55%, #0f172a 100%);
  color: #fff;
  border-radius: 20px;
  padding: 2rem 1.85rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  right: -60px;
  top: -60px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(20, 184, 166, 0.35), transparent 70%);
  pointer-events: none;
}
.hero h1 { margin: 0 0 0.4rem; font-size: clamp(1.4rem, 3vw, 2rem); letter-spacing: -0.02em; }
.hero p { margin: 0 0 1.2rem; opacity: 0.9; max-width: 680px; font-size: 0.95rem; }

.search-row {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.search-box {
  flex: 1 1 320px;
  position: relative;
}
.search-box input {
  width: 100%;
  padding: 0.85rem 1rem 0.85rem 2.75rem;
  border-radius: 12px;
  border: 2px solid transparent;
  font-size: 0.98rem;
  background: #fff;
  color: var(--text);
  outline: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.search-box input:focus { border-color: #14b8a6; }
.search-icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.stats-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.1rem;
  font-size: 0.82rem;
}
.stat-pill {
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(6px);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
}

/* Filter bar */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  box-shadow: var(--shadow);
}
.filter-bar select {
  padding: 0.52rem 0.75rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 0.85rem;
  max-width: 210px;
  outline: none;
}
.filter-bar select:focus { border-color: var(--primary); }
.chip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.78rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: all 0.18s ease;
}
.chip-toggle.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-dark);
}
.result-meta {
  margin-left: auto;
  font-size: 0.83rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Medicine Grid */
.med-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(265px, 1fr));
  gap: 1rem;
}
.med-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform 0.22s var(--ease), box-shadow 0.22s var(--ease), border-color 0.2s ease;
}
.med-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: #99f6e4;
}
.med-img-wrap {
  position: relative;
  height: 162px;
  background: #f0fdfa;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.med-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s var(--ease);
}
.med-card:hover .med-img-wrap img { transform: scale(1.04); }
.med-badges {
  position: absolute;
  top: 0.55rem;
  left: 0.55rem;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.badge-teal { background: rgba(15, 118, 110, 0.92); color: #fff; }
.badge-who { background: #0284c7; color: #fff; }
.badge-neml { background: #16a34a; color: #fff; }
.badge-soft { background: #e2e8f0; color: #334155; }

.med-body {
  padding: 0.9rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  flex: 1;
}
.med-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem;
}
.med-name {
  font-weight: 800;
  font-size: 1.02rem;
  color: var(--text);
  margin: 0;
}
.med-strength {
  font-size: 0.78rem;
  color: var(--primary);
  font-weight: 700;
  white-space: nowrap;
}
.med-generic {
  font-size: 0.85rem;
  color: #334155;
  font-weight: 600;
}
.med-mfr {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.med-footer {
  margin-top: auto;
  padding-top: 0.65rem;
  border-top: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
}
.price-tag { font-weight: 800; color: var(--primary-dark); }

/* Skeletons */
.skeleton {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 10px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
  margin: 1.75rem 0 2.5rem;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 23, 42, 0.56);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal-card {
  width: 100%;
  max-width: 920px;
  max-height: 92vh;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(18px) scale(0.98);
  transition: transform 0.26s var(--ease);
}
.modal-backdrop.open .modal-card { transform: translateY(0) scale(1); }
.modal-sm { max-width: 520px; }
.modal-header {
  padding: 1rem 1.35rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.modal-body {
  padding: 1.25rem 1.35rem;
  overflow-y: auto;
}
.close-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  cursor: pointer;
  font-size: 1.15rem;
  display: grid;
  place-items: center;
}
.close-btn:hover { background: #e2e8f0; }

/* Detail Hero */
.detail-hero {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.25rem;
  margin-bottom: 1.2rem;
}
@media (max-width: 720px) {
  .detail-hero { grid-template-columns: 1fr; }
}
.detail-photo-box {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #f0fdfa;
  height: 200px;
  cursor: zoom-in;
}
.detail-photo-box img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.65rem;
  margin-top: 0.85rem;
}
.meta-box {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
}
.meta-box small { display: block; color: var(--text-muted); font-size: 0.73rem; }
.meta-box strong { font-size: 0.88rem; }

/* Tabs */
.tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.65rem;
  margin-bottom: 1rem;
}
.tab-btn {
  padding: 0.42rem 0.82rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.tab-btn.active {
  background: var(--primary);
  color: #fff;
}
.clinical-block {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.15rem;
  margin-bottom: 0.85rem;
}
.clinical-block h4 { margin: 0 0 0.45rem; color: var(--primary-dark); font-size: 0.92rem; }
.clinical-block p { margin: 0; font-size: 0.89rem; white-space: pre-line; color: #1e293b; }

/* WhatsApp Cards */
.wa-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.85rem;
}
.wa-contact-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  flex-wrap: wrap;
}
.code-box {
  background: #0f172a;
  color: #e2e8f0;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.8rem;
  overflow-x: auto;
  white-space: pre;
}

/* Forms & Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.15rem;
}
.form-group { margin-bottom: 0.9rem; }
.form-group label { display: block; font-size: 0.83rem; font-weight: 700; margin-bottom: 0.3rem; color: #334155; }
.form-control {
  width: 100%;
  padding: 0.62rem 0.8rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  outline: none;
  background: #fff;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12); }

.alert {
  padding: 0.75rem 0.95rem;
  border-radius: 10px;
  font-size: 0.86rem;
  margin-bottom: 0.9rem;
}
.alert-err { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-ok { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
th, td { text-align: left; padding: 0.68rem 0.75rem; border-bottom: 1px solid var(--border); }
th { background: var(--surface-soft); color: var(--text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }

.progress-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), #14b8a6);
  transition: width 0.35s ease;
}

/* Floating WhatsApp Button for quick API key contact */
.fab-wa {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 35;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.72rem 1.15rem;
  border-radius: 999px;
  background: var(--wa);
  color: #fff;
  font-weight: 700;
  font-size: 0.88rem;
  border: none;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(37, 211, 102, 0.38);
  transition: transform 0.2s var(--ease);
}
.fab-wa:hover { transform: translateY(-3px); background: var(--wa-dark); }
