/* =========================================================================
   Smart Pharma — core stylesheet  (Phase 2: warm-clinical refresh)
   Token-driven. Light + dark themes. Flat surfaces, hairline depth.
   ========================================================================= */

:root {
  /* ---- color tokens (light / warm-clinical) ---- */
  --bg-app:        oklch(98% 0.006 85);    /* main content canvas (warm)    */
  --surface:       oklch(99.5% 0.003 85);  /* cards / sheets                */
  --surface-2:     oklch(97% 0.006 83);    /* insets, hovers                */
  --surface-3:     oklch(94.5% 0.008 82);  /* chips, wells                  */

  --ink:           oklch(27% 0.012 60);    /* primary text (warm near-black)*/
  --ink-2:         oklch(46% 0.012 62);    /* secondary                     */
  --ink-3:         oklch(58% 0.010 64);    /* muted / placeholder           */
  --line:          oklch(90% 0.006 80);    /* hairline borders              */
  --line-strong:   oklch(85% 0.007 80);

  /* chrome (title bar / sidebar / top bar) — warm charcoal */
  --chrome:        oklch(27% 0.012 55);
  --chrome-2:      oklch(31% 0.014 55);
  --chrome-ink:    oklch(96% 0.004 85);
  --chrome-ink-2:  oklch(78% 0.008 75);

  /* accent — calm pharmacy teal-green (Option A: "Apteka", refined) */
  --accent:        oklch(53% 0.11 172);
  --accent-strong: oklch(46% 0.11 172);
  --accent-soft:   oklch(95% 0.035 172);
  --accent-ink:    oklch(38% 0.10 174);
  --on-accent:     oklch(99% 0.01 172);

  /* secondary — muted clinical blue */
  --blue:          oklch(58% 0.09 245);
  --blue-strong:   oklch(51% 0.10 245);
  --blue-soft:     oklch(95% 0.03 245);
  --blue-ink:      oklch(45% 0.10 250);

  /* status */
  --ok:            oklch(60% 0.13 150);
  --ok-soft:       oklch(95% 0.045 150);
  --ok-ink:        oklch(43% 0.11 150);
  --warn:          oklch(70% 0.12 70);
  --warn-soft:     oklch(95% 0.045 75);
  --warn-ink:      oklch(50% 0.10 60);
  --danger:        oklch(58% 0.17 25);
  --danger-soft:   oklch(95% 0.03 25);
  --danger-ink:    oklch(50% 0.17 25);

  /* radius + shadow scale */
  --r-sm: 8px;  --r-md: 12px;  --r-lg: 16px;  --r-xl: 22px;
  --sh-1: 0 1px 2px oklch(40% 0.02 60 / 0.06), 0 1px 3px oklch(40% 0.02 60 / 0.05);
  --sh-2: 0 2px 8px oklch(40% 0.02 60 / 0.07), 0 1px 2px oklch(40% 0.02 60 / 0.05);
  --sh-3: 0 12px 32px oklch(35% 0.02 60 / 0.14);
  --ring: 0 0 0 3px oklch(56% 0.10 168 / 0.35);

  --font: 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* legacy aliases (kept so existing rules/JS keep working) */
  --primary-color: var(--blue);
  --primary-dark: var(--blue-strong);
  --cart-color: var(--accent);
  --cart-dark: var(--accent-strong);
  --text-primary: var(--ink);
  --text-secondary: var(--ink-2);
  --bg-light: var(--bg-app);
  --bg-card: var(--surface);
  --bg-hover: var(--surface-2);
  --border-color: var(--line);
  --nav-dark-bg: var(--chrome);
}

[data-theme="dark"] {
  --bg-app:        oklch(21% 0.008 60);
  --surface:       oklch(25% 0.010 60);
  --surface-2:     oklch(28% 0.011 60);
  --surface-3:     oklch(31% 0.012 60);

  --ink:           oklch(95% 0.004 85);
  --ink-2:         oklch(76% 0.008 75);
  --ink-3:         oklch(62% 0.009 70);
  --line:          oklch(33% 0.012 60);
  --line-strong:   oklch(40% 0.013 60);

  --chrome:        oklch(13% 0.004 60);
  --chrome-2:      oklch(17% 0.006 60);
  --chrome-ink:    oklch(95% 0.004 85);
  --chrome-ink-2:  oklch(72% 0.009 72);

  --accent:        oklch(64% 0.11 168);
  --accent-strong: oklch(58% 0.11 168);
  --accent-soft:   oklch(34% 0.05 168);
  --accent-ink:    oklch(82% 0.09 168);

  --blue:          oklch(66% 0.10 245);
  --blue-strong:   oklch(60% 0.10 245);
  --blue-soft:     oklch(34% 0.05 245);
  --blue-ink:      oklch(80% 0.09 248);

  --ok-soft:  oklch(33% 0.05 158); --ok-ink: oklch(82% 0.09 158);
  --warn-soft:oklch(35% 0.06 70);  --warn-ink: oklch(85% 0.10 80);
  --danger-soft: oklch(33% 0.06 25); --danger-ink: oklch(80% 0.12 25);

  --sh-1: 0 1px 2px oklch(0% 0 0 / 0.3);
  --sh-2: 0 2px 10px oklch(0% 0 0 / 0.35);
  --sh-3: 0 12px 32px oklch(0% 0 0 / 0.5);
  --ring: 0 0 0 3px oklch(64% 0.11 168 / 0.4);
}

/* ===== Accent option B: "Clinical" blue (accent→blue, secondary→teal) ===== */
[data-accent="blue"] {
  --accent:        oklch(55% 0.12 248);
  --accent-strong: oklch(48% 0.12 248);
  --accent-soft:   oklch(95% 0.03 248);
  --accent-ink:    oklch(43% 0.12 250);
  --on-accent:     oklch(99% 0.01 248);
  /* secondary moves to teal so it stays distinct from the blue accent */
  --blue:          oklch(56% 0.09 195);
  --blue-strong:   oklch(49% 0.09 195);
  --blue-soft:     oklch(95% 0.03 195);
  --blue-ink:      oklch(41% 0.09 195);
  --ring: 0 0 0 3px oklch(55% 0.12 248 / 0.38);
}
[data-theme="dark"][data-accent="blue"] {
  --accent:        oklch(66% 0.12 248);
  --accent-strong: oklch(60% 0.12 248);
  --accent-soft:   oklch(34% 0.06 248);
  --accent-ink:    oklch(82% 0.10 248);
  --blue:          oklch(64% 0.09 195);
  --blue-strong:   oklch(58% 0.09 195);
  --blue-soft:     oklch(34% 0.05 195);
  --blue-ink:      oklch(80% 0.09 195);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: oklch(93% 0.012 80);   /* fixed light desktop — not theme-controlled, so the window always stands out */
  color: var(--ink);
  display: flex;
  justify-content: center;
  padding: 20px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

code, .mono, .code { font-family: var(--mono); font-feature-settings: 'tnum' 1; letter-spacing: -0.01em; }

/* visible keyboard focus everywhere */
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 2000;
  background: var(--accent); color: var(--on-accent); padding: 10px 16px;
  border-radius: var(--r-md); font-weight: 600; font-size: 14px; text-decoration: none;
  transform: translateY(-150%); transition: transform 0.2s ease;
}
.skip-link:focus { transform: translateY(0); }
.page-title:focus { outline: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- App shell ---------- */
.dashboard-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1800px;
  height: 95vh;
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: var(--sh-3);
  background: var(--surface);
  position: relative;
}

.title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 36px;
  background: var(--chrome);
  padding: 0 10px;
  border-bottom: 1px solid oklch(100% 0 0 / 0.06);
  flex-shrink: 0;
  user-select: none;
}
.title-bar-text { font-size: 13px; font-weight: 600; color: var(--chrome-ink-2); flex-grow: 1; text-align: center; letter-spacing: 0.02em; }
.window-controls { display: flex; gap: 4px; }
.control-btn {
  background: transparent; border: none; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border-radius: 8px; transition: background-color 0.18s ease; color: var(--chrome-ink-2);
}
.control-btn:hover { background: oklch(100% 0 0 / 0.1); }
.control-btn.close-btn:hover { background: var(--danger); color: #fff; }
.control-btn i { width: 16px; height: 16px; }

.top-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px; color: var(--chrome-ink);
  background: var(--chrome); position: relative; flex-shrink: 0;
  border-bottom: 1px solid oklch(100% 0 0 / 0.05);
}
.top-bar-left { display: flex; align-items: center; gap: 30px; }
.brand-title { display: flex; align-items: center; gap: 12px; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.brand-title i { width: 22px; height: 22px; color: var(--accent); }
.page-title {
  font-size: 20px; font-weight: 700; color: var(--chrome-ink); margin: 0;
  display: flex; align-items: center; gap: 10px; letter-spacing: -0.01em; white-space: nowrap;
  position: absolute; left: 50%; transform: translateX(-50%);
}
.page-title i { color: var(--chrome-ink); width: 20px; height: 20px; }

.header-actions { display: flex; gap: 10px; align-items: center; }
.cart-btn, .profile-btn, .icon-btn {
  padding: 11px; border-radius: var(--r-md); border: none; cursor: pointer;
  transition: background 0.18s ease, transform 0.12s ease; position: relative;
  display: flex; align-items: center; justify-content: center;
}
.cart-btn i, .profile-btn i, .icon-btn i { width: 19px; height: 19px; color: #fff; }
.cart-btn { background: var(--accent); }
.cart-btn:hover { background: var(--accent-strong); }
.cart-btn:active { transform: scale(0.96); }
.profile-btn, .icon-btn { background: oklch(100% 0 0 / 0.1); }
.profile-btn:hover, .icon-btn:hover { background: oklch(100% 0 0 / 0.18); }
.icon-btn i { color: var(--chrome-ink); }
.cart-badge {
  position: absolute; top: -5px; right: -5px; background: var(--danger); color: #fff;
  border-radius: 999px; min-width: 19px; height: 19px; padding: 0 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; border: 2px solid var(--chrome);
}

/* ---------- Auth control ---------- */
.auth-control { display: flex; align-items: center; }
.header-divider { width: 1px; height: 26px; background: oklch(100% 0 0 / 0.12); margin: 0 4px; }
.auth-identity {
  display: flex; align-items: center; gap: 6px;
  background: oklch(100% 0 0 / 0.08); border-radius: 999px; padding: 4px 4px 4px 14px;
}
.auth-username {
  color: var(--chrome-ink); font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
}
.auth-username::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex-shrink: 0;
}
.auth-btn {
  padding: 11px; border-radius: var(--r-md); border: none; cursor: pointer;
  background: oklch(100% 0 0 / 0.1); transition: background 0.18s ease, transform 0.12s ease;
  display: flex; align-items: center; justify-content: center; position: relative;
  font-family: var(--font); font-size: 14px; font-weight: 600; color: var(--chrome-ink); gap: 8px;
}
.auth-identity .auth-btn { padding: 8px; border-radius: 999px; background: transparent; }
.auth-identity .auth-btn:hover { background: oklch(100% 0 0 / 0.14); }
.auth-btn.solo { padding: 10px 16px; border-radius: var(--r-md); }
.auth-btn:hover { background: oklch(100% 0 0 / 0.18); }
.auth-btn:active { transform: scale(0.96); }
.auth-btn i { width: 19px; height: 19px; color: var(--chrome-ink); }
.auth-spinner {
  width: 19px; height: 19px; border: 2.5px solid oklch(100% 0 0 / 0.25);
  border-top-color: var(--accent); border-radius: 50%; animation: auth-spin 0.8s linear infinite; display: block;
}
@keyframes auth-spin { to { transform: rotate(360deg); } }
.auth-btn[data-tooltip]:hover::after {
  content: attr(data-tooltip); position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--chrome-2); color: var(--chrome-ink); font-size: 12.5px; font-weight: 500;
  padding: 6px 12px; border-radius: var(--r-sm); white-space: nowrap; z-index: 60; pointer-events: none;
  box-shadow: var(--sh-2);
}
.auth-dialog-overlay {
  position: fixed; inset: 0; background: oklch(20% 0.02 60 / 0.5); display: none;
  align-items: center; justify-content: center; z-index: 1200; backdrop-filter: blur(3px);
  opacity: 0; transition: opacity 0.2s ease;
}
.auth-dialog-overlay.show { display: flex; opacity: 1; }
.auth-dialog { background: var(--surface); border-radius: var(--r-xl); padding: 32px; max-width: 440px; width: 90%; text-align: center; box-shadow: var(--sh-3); }
.auth-dialog h3 { margin: 0 0 12px; font-size: 22px; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; }
.auth-dialog p { margin: 0 0 26px; font-size: 14.5px; color: var(--ink-2); }
.auth-dialog-actions { display: flex; gap: 12px; justify-content: center; align-items: center; }
.auth-dialog-btn { padding: 12px 22px; border-radius: 999px; font-size: 14.5px; font-weight: 600; border: none; cursor: pointer; transition: background 0.16s ease; font-family: var(--font); }
.auth-dialog-btn.ghost { background: none; color: var(--ink-2); }
.auth-dialog-btn.ghost:hover { background: var(--surface-2); }
.auth-dialog-btn.primary { background: var(--accent); color: var(--on-accent); }
.auth-dialog-btn.primary:hover { background: var(--accent-strong); }

/* ---------- Shared confirm dialog ---------- */
.confirm-overlay {
  position: fixed; inset: 0; background: oklch(20% 0.02 60 / 0.5); display: none;
  align-items: center; justify-content: center; z-index: 1250; backdrop-filter: blur(3px);
  opacity: 0; transition: opacity 0.2s ease;
}
.confirm-overlay.show { display: flex; opacity: 1; }
.confirm-box {
  background: var(--surface); border-radius: var(--r-xl); padding: 30px; max-width: 420px; width: 90%;
  text-align: center; box-shadow: var(--sh-3); transform: translateY(12px); transition: transform 0.2s ease;
}
.confirm-overlay.show .confirm-box { transform: translateY(0); }
.confirm-icon { width: 52px; height: 52px; border-radius: 999px; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; background: var(--warn-soft); color: var(--warn-ink); }
.confirm-icon i { width: 26px; height: 26px; }
.confirm-overlay[data-tone="danger"] .confirm-icon { background: var(--danger-soft); color: var(--danger-ink); }
.confirm-overlay[data-tone="accent"] .confirm-icon { background: var(--accent-soft); color: var(--accent-ink); }
.confirm-box h3 { margin: 0 0 10px; font-size: 21px; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; }
.confirm-box p { margin: 0 0 24px; font-size: 14.5px; color: var(--ink-2); line-height: 1.5; }
.confirm-actions { display: flex; gap: 12px; justify-content: center; }
.confirm-btn { padding: 12px 24px; border-radius: var(--r-md); font-size: 14.5px; font-weight: 600; border: none; cursor: pointer; transition: background 0.16s ease; font-family: var(--font); }
.confirm-btn.ghost { background: var(--surface-2); color: var(--ink-2); }
.confirm-btn.ghost:hover { background: var(--surface-3); }
.confirm-btn { background: var(--accent); color: var(--on-accent); }
.confirm-btn:hover { background: var(--accent-strong); }
.confirm-overlay[data-tone="danger"] #confirm-ok { background: var(--danger); color: #fff; }
.confirm-overlay[data-tone="danger"] #confirm-ok:hover { background: var(--danger-ink); }

.content-wrapper { display: flex; flex: 1; overflow: hidden; }
.side-nav {
  width: 248px; background: var(--chrome);
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative; z-index: 1; padding: 14px 0; flex-shrink: 0;
  border-right: 1px solid oklch(100% 0 0 / 0.05);
}
.side-nav .nav-item {
  display: flex; align-items: center; gap: 13px; padding: 12px 18px;
  font-size: 14.5px; font-weight: 500; color: var(--chrome-ink-2); cursor: pointer;
  border-radius: var(--r-md); transition: background 0.18s ease, color 0.18s ease;
  position: relative; margin: 2px 12px;
  font-family: inherit; border: none; background: none; width: calc(100% - 24px); text-align: left; white-space: nowrap;
}
.side-nav .nav-item:hover { background: oklch(100% 0 0 / 0.08); color: var(--chrome-ink); }
.side-nav .nav-item.active { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.side-nav .nav-item.active i { color: var(--on-accent); }
.side-nav i { width: 19px; height: 19px; stroke-width: 2; flex-shrink: 0; }

.main-content { flex: 1; display: flex; flex-direction: column; background: var(--bg-app); overflow-y: auto; }

/* text-size control (accessibility) — scales the reading surfaces + nav */
[data-font="sm"] .main-content { zoom: 0.92; }
[data-font="lg"] .main-content { zoom: 1.12; }
[data-font="xl"] .main-content { zoom: 1.25; }
[data-font="sm"] .side-nav .nav-item, [data-font="sm"] .page-title { font-size: 13px; }
[data-font="lg"] .side-nav .nav-item { font-size: 16px; }
[data-font="lg"] .page-title { font-size: 22px; }
[data-font="xl"] .side-nav .nav-item { font-size: 17px; }
[data-font="xl"] .page-title { font-size: 24px; }

/* ---------- Search ---------- */
.search-wrapper { display: flex; align-items: center; gap: 12px; margin: 22px 28px 0; }
.search-action-btn {
  padding: 13px 22px; border-radius: var(--r-md); border: none; cursor: pointer;
  background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 14.5px;
  transition: background 0.18s ease;
}
.search-action-btn:hover { background: var(--accent-strong); }
.search-bar {
  flex: 1; display: flex; align-items: center; padding: 12px 16px;
  border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.search-bar:focus-within { border-color: var(--accent); }
.search-bar input { flex: 1; border: none; font-size: 14.5px; outline: none; background: transparent; color: var(--ink); font-family: var(--font); }
.search-bar input:focus-visible { box-shadow: none; }
.search-bar input::placeholder { color: var(--ink-3); }
.search-icon { width: 19px; height: 19px; color: var(--ink-3); margin-right: 12px; stroke-width: 2; }
.scan-btn { border: none; background: var(--surface-3); color: var(--ink-2); cursor: pointer; width: 34px; height: 34px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; margin-left: 10px; transition: background 0.16s ease, color 0.16s ease; flex-shrink: 0; }
.scan-btn:hover { background: var(--accent); color: var(--on-accent); }
.scan-btn i { width: 19px; height: 19px; }

/* ---------- Filters ---------- */
.filters-container { margin: 18px 28px; background: var(--surface); border-radius: var(--r-md); border: 1px solid var(--line); overflow: hidden; }
.filters-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 22px; cursor: pointer; }
.filters-header h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--ink); }
.filters-header i { color: var(--ink-2); transition: transform 0.3s ease; }
.filters-body {
  padding: 22px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px;
  max-height: 600px; transition: max-height 0.35s ease, padding 0.35s ease, opacity 0.25s ease;
  border-top: 1px solid var(--line); opacity: 1;
}
.filters-body.collapsed { max-height: 0; padding-top: 0; padding-bottom: 0; overflow: hidden; opacity: 0; border-top-color: transparent; }
.filter-group { display: flex; flex-direction: column; gap: 11px; }
.filter-label { font-size: 12px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.05em; }
.filter-options { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-btn {
  padding: 7px 15px; font-size: 13.5px; font-weight: 500; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  cursor: pointer; transition: all 0.15s ease;
}
.filter-btn:hover { border-color: var(--accent); color: var(--ink); }
.filter-btn.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.filter-select {
  padding: 9px 12px; font-size: 13.5px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); width: 100%; max-width: 260px; font-family: var(--font);
}
.filter-select:focus-visible { border-color: var(--accent); }

/* active-filter chips bar */
.active-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 28px 4px; align-items: center; }
.active-filters:empty { display: none; }
.active-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px 5px 12px;
  background: var(--accent-soft); color: var(--accent-ink); border: 1px solid transparent;
  border-radius: 999px; font-size: 13px; font-weight: 600;
}
.active-chip button { background: none; border: none; cursor: pointer; color: inherit; display: flex; padding: 2px; border-radius: 999px; }
.active-chip button:hover { background: oklch(0% 0 0 / 0.08); }
.active-chip i { width: 14px; height: 14px; }
.active-chip.clear-all { background: transparent; color: var(--ink-2); padding: 5px 10px; cursor: pointer; text-decoration: underline; }

/* ---------- Content area ---------- */
.content-area { flex: 1; display: flex; flex-direction: column; padding: 0 18px 20px; }

/* ---------- Drug grid ---------- */
.drug-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; width: 100%; }

/* quick sections (favourites + recent searches) */
.quick-block { margin-bottom: 24px; }
.quick-head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-2); margin-bottom: 14px; }
.quick-head i { width: 16px; height: 16px; color: var(--accent); }
.recent-clear { margin-left: auto; border: none; background: none; color: var(--ink-3); font-size: 12px; font-weight: 600; cursor: pointer; text-transform: none; letter-spacing: 0; font-family: var(--font); text-decoration: underline; }
.recent-clear:hover { color: var(--ink); }
.recent-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.recent-chip { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 13.5px; font-weight: 500; cursor: pointer; font-family: var(--font); transition: border-color 0.15s ease, background 0.15s ease; }
.recent-chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.recent-chip i { width: 14px; height: 14px; color: var(--ink-3); }

/* favourite star on cards */
.fav-btn { width: 28px; height: 28px; border: none; background: transparent; border-radius: var(--r-sm); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-3); transition: color 0.15s ease, background 0.15s ease; flex-shrink: 0; }
.fav-btn:hover { background: var(--surface-2); color: oklch(74% 0.16 78); }
.fav-btn i, .fav-btn svg { width: 17px; height: 17px; }
.fav-btn.on { color: oklch(74% 0.16 78); }
.fav-btn.on svg, .fav-btn.on i { fill: currentColor; }
.tile-title-wrap { display: flex; align-items: center; gap: 4px; min-width: 0; }

/* infinite-scroll sentinel + end marker */
.scroll-sentinel { width: 100%; min-height: 4px; }
.list-end { text-align: center; color: var(--ink-3); font-size: 13px; padding: 22px 0 6px; }
.drug-tile {
  background: var(--surface); border-radius: var(--r-lg); padding: 22px;
  box-shadow: var(--sh-1); border: 1px solid var(--line);
  transition: border-color 0.18s ease, box-shadow 0.18s ease; cursor: pointer;
  display: flex; flex-direction: column; justify-content: space-between;
}
.drug-tile:hover { border-color: var(--line-strong); box-shadow: var(--sh-2); }
.drug-tile:focus-visible { border-color: var(--accent); box-shadow: var(--ring); }
.tile-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; gap: 10px; }
.tile-header-right { text-align: right; }
.tile-title { font-size: 17px; font-weight: 700; color: var(--ink); margin-bottom: 4px; letter-spacing: -0.01em; }
.tile-price { font-size: 17px; font-weight: 700; color: var(--ink); font-family: var(--mono); }
.tile-body { margin-bottom: 16px; }
.tile-text { font-size: 13.5px; color: var(--ink-2); margin-bottom: 6px; }
.tile-text strong { color: var(--ink); font-weight: 600; }
.tile-info-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.info-widget { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: var(--r-sm); }
.dosage-widget, .form-widget { background: var(--surface-3); color: var(--ink-2); }
.refund-widget { background: var(--ok-soft); color: var(--ok-ink); margin-top: 6px; display: inline-block; }
.tile-footer { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); padding-top: 14px; gap: 10px; }
.stock-info { font-size: 13.5px; color: var(--ink-2); flex: 1; text-align: center; }
.stock-info strong { color: var(--ink); font-weight: 600; }
.action-btn {
  width: 42px; height: 42px; display: flex; align-items: center; justify-content: center;
  padding: 0; border-radius: var(--r-md); color: #fff; border: none; cursor: pointer;
  transition: background 0.16s ease, transform 0.12s ease;
}
.cart-icon-btn { background: var(--accent); }
.cart-icon-btn:hover { background: var(--accent-strong); }
.cart-icon-btn:active { transform: scale(0.94); }
.order-btn { background: var(--blue); }
.order-btn:hover { background: var(--blue-strong); }
.order-btn:active { transform: scale(0.94); }
.action-btn.disabled { background: var(--surface-3); color: var(--ink-3); cursor: not-allowed; }
.action-btn i { width: 19px; height: 19px; stroke-width: 2; }

/* ---------- Status chips (shared) ---------- */
.status-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status-chip i { width: 13px; height: 13px; }
.status-chip.ok    { background: var(--ok-soft); color: var(--ok-ink); }
.status-chip.low   { background: var(--warn-soft); color: var(--warn-ink); }
.status-chip.out   { background: var(--danger-soft); color: var(--danger-ink); }

/* ---------- Skeleton loaders ---------- */
.skeleton { position: relative; overflow: hidden; background: var(--surface-3); border-radius: 6px; }
.skeleton::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, oklch(100% 0 0 / 0.35), transparent);
  transform: translateX(-100%); animation: sk 1.3s infinite;
}
[data-theme="dark"] .skeleton::after { background: linear-gradient(90deg, transparent, oklch(100% 0 0 / 0.06), transparent); }
@keyframes sk { 100% { transform: translateX(100%); } }
.sk-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px; }
.sk-line { height: 12px; margin-bottom: 10px; }

/* ---------- Empty state ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 72px 20px; color: var(--ink-3); width: 100%; }
.empty-state i { width: 52px; height: 52px; margin-bottom: 14px; opacity: 0.6; }
.empty-state .empty-title { font-size: 17px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.empty-state .empty-action {
  margin-top: 18px; padding: 11px 20px; border-radius: var(--r-md); border: none; cursor: pointer;
  background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 14px; font-family: var(--font);
}

/* ---------- Drug modal (3-column) ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: oklch(20% 0.02 60 / 0.5);
  display: none; justify-content: center; align-items: center; z-index: 1000;
  backdrop-filter: blur(4px); opacity: 0; transition: opacity 0.25s ease;
}
.modal-overlay.show { display: flex; opacity: 1; }
.modal-content {
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--sh-3);
  width: 90%; max-width: 980px; max-height: 90vh; overflow: hidden;
  display: flex; flex-direction: column; transform: translateY(16px); transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
}
.modal-overlay.show .modal-content { transform: translateY(0); }
.modal-header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 22px 28px; border-bottom: 1px solid var(--line); }
.modal-title { grid-column: 1; justify-self: start; font-size: 26px; font-weight: 700; color: var(--ink); letter-spacing: -0.02em; }
#modal-prescription-status { grid-column: 2; justify-self: center; }
.modal-close-btn { background: none; border: none; cursor: pointer; padding: 8px; border-radius: var(--r-md); transition: background 0.18s ease; color: var(--ink-2); }
.modal-close-btn:hover { background: var(--surface-2); }
.modal-close-btn i, .modal-close-btn svg { width: 22px; height: 22px; color: var(--ink-2); }
.modal-header-actions { grid-column: 3; justify-self: end; display: flex; align-items: center; gap: 4px; }
#modal-fav { width: 38px; height: 38px; }
#modal-fav i, #modal-fav svg { width: 22px; height: 22px; }
.prescription-badge { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 999px; }
.prescription-badge.required { background: var(--danger-soft); color: var(--danger-ink); }
.prescription-badge.otc { background: var(--ok-soft); color: var(--ok-ink); }
.prescription-badge i { margin-right: 6px; width: 15px; height: 15px; }

.modal-body { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; flex: 1; overflow-y: auto; padding: 24px; }
.detail-left-panel, .detail-middle-panel, .detail-right-panel { display: flex; flex-direction: column; gap: 16px; }
.tile-like-card { background: var(--surface-2); border-radius: var(--r-lg); padding: 22px; border: 1px solid var(--line); }
.card-title-lg { font-size: 16px; font-weight: 700; color: var(--ink); margin: 0 0 14px; display: flex; align-items: center; gap: 10px; }
.card-icon { width: 18px; height: 18px; color: var(--accent); }
.card-content-grid { display: grid; gap: 8px; }
.card-content-grid .info-card-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); gap: 10px; }
.card-content-grid .info-card-row:last-child { border-bottom: none; }
.info-card-label { font-size: 12px; color: var(--ink-2); font-weight: 500; white-space: nowrap; }
.info-card-value { font-size: 14px; font-weight: 600; color: var(--ink); text-align: right; }
.info-card-value.code { font-family: var(--mono); font-weight: 500; font-size: 13px; }

.action-section { background: var(--surface-2); border-radius: var(--r-lg); padding: 20px; border: 1px solid var(--line); }
.price-box { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; }
.price-label { font-size: 14px; color: var(--ink-2); }
.price-value { font-size: 26px; font-weight: 700; color: var(--ink); font-family: var(--mono); letter-spacing: -0.02em; }
.refund-info { font-size: 13px; color: var(--blue-ink); background: var(--blue-soft); padding: 10px 14px; border-radius: var(--r-md); margin-bottom: 20px; display: flex; align-items: center; }
.refund-info span { flex: 1; text-align: right; }
.refund-info i { margin-right: 8px; width: 17px; height: 17px; }
.action-button { width: 100%; padding: 13px 18px; border-radius: var(--r-md); font-size: 14px; font-weight: 600; border: none; cursor: pointer; display: flex; align-items: center; justify-content: flex-start; margin-bottom: 10px; transition: background 0.16s ease, transform 0.12s ease; font-family: var(--font); }
.action-button span { flex: 1; text-align: center; }
.action-button i { margin-right: 8px; width: 17px; height: 17px; }
.action-button.primary { background: var(--accent); color: var(--on-accent); }
.action-button.primary:hover { background: var(--accent-strong); }
.action-button.secondary { background: var(--blue); color: #fff; }
.action-button.secondary:hover { background: var(--blue-strong); }
.action-button:active { transform: scale(0.99); }

/* ---------- Toast ---------- */
.cart-notification {
  position: fixed; top: 20px; left: 50%; background: var(--accent); color: var(--on-accent);
  padding: 14px 18px; border-radius: var(--r-md); box-shadow: var(--sh-3);
  transform: translate(-50%, -150%); transition: transform 0.3s cubic-bezier(0.2,0.8,0.2,1);
  z-index: 1300; display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; max-width: 420px;
}
.cart-notification.show { transform: translate(-50%, 0); }
.cart-notification i { width: 18px; height: 18px; flex-shrink: 0; }
.cart-notification .toast-undo { margin-left: 8px; background: oklch(100% 0 0 / 0.2); border: none; color: inherit; font-weight: 700; padding: 5px 10px; border-radius: var(--r-sm); cursor: pointer; font-family: var(--font); }

/* ---------- Mobile nav ---------- */
.mobile-nav-icons, .bottom-nav { display: none; }

@media (max-width: 1024px) {
  body { padding: 0; }
  .dashboard-container { flex-direction: column; height: 100vh; width: 100%; border-radius: 0; padding-bottom: 68px; }
  .content-wrapper { flex-direction: column; }
  .title-bar { display: none; }
  .side-nav { display: none; }
  .brand-title .brand-title-text { display: none; }
  .page-title { position: static; transform: none; margin-inline: auto; flex-grow: 1; justify-content: center; }
  .header-actions .cart-btn { display: none; }
  .bottom-nav {
    display: flex; justify-content: space-around; align-items: center;
    position: fixed; bottom: 0; left: 0; width: 100%; background: var(--chrome);
    padding: 9px 0; box-shadow: 0 -2px 12px oklch(0% 0 0 / 0.25); z-index: 1000;
    border-top: 1px solid oklch(100% 0 0 / 0.06);
  }
  .bottom-nav .nav-item { display: flex; align-items: center; justify-content: center; padding: 9px; border-radius: var(--r-md); cursor: pointer; color: var(--chrome-ink-2); flex: 1; max-width: 56px; border: none; background: none; font-family: inherit; }
  .bottom-nav .nav-item.active { background: var(--accent); color: var(--on-accent); }
  .bottom-nav .nav-item i { width: 21px; height: 21px; }
  .drug-grid { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
  .modal-body { grid-template-columns: 1fr; gap: 16px; }
}

@media (max-width: 768px) {
  .top-bar { padding: 13px 18px; }
  .search-wrapper { margin: 16px 18px; flex-direction: column; gap: 10px; }
  .search-action-btn { width: 100%; }
  .filters-container { margin: 14px 18px; }
  .filters-body { grid-template-columns: 1fr; }
  .active-filters { margin-left: 18px; margin-right: 18px; }
  .content-area { padding: 0 14px 14px; }
  .drug-grid { grid-template-columns: 1fr; }
}
