:root {
  --bg: #f5f8fb;
  --surface: #ffffff;
  --surface-soft: #f0fdfa;
  --primary: #0ea5a4;
  --primary-dark: #0f766e;
  --accent: #2563eb;
  --text: #102033;
  --muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 14px 38px rgba(15, 23, 42, 0.08);
  --radius: 22px;
}

[data-theme="dark"] {
  --bg: #07111f;
  --surface: #101b2d;
  --surface-soft: #102b35;
  --primary: #2dd4bf;
  --primary-dark: #14b8a6;
  --accent: #60a5fa;
  --text: #f8fafc;
  --muted: #94a3b8;
  --border: #22324a;
  --shadow: 0 14px 38px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, rgba(14, 165, 164, 0.14), transparent 34%), var(--bg);
  color: var(--text);
  line-height: 1.5;
}
button, input, select { font: inherit; }
a { color: inherit; }
.page { width: min(1180px, 100%); margin: 0 auto; padding: 12px; }
.app-shell { display: grid; grid-template-columns: 390px 1fr; gap: 18px; min-height: calc(100vh - 24px); }
.search-panel, .results-panel {
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(226, 232, 240, 0.82);
  border-radius: 30px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
[data-theme="dark"] .search-panel, [data-theme="dark"] .results-panel {
  background: rgba(16, 27, 45, 0.84);
  border-color: rgba(34, 50, 74, 0.9);
}
.search-panel { position: sticky; top: 12px; align-self: start; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 18px 18px 10px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; margin-right: auto; }
.brand-icon {
  width: 42px; height: 42px; border-radius: 15px; display: grid; place-items: center;
  color: #fff; background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 12px 24px rgba(14, 165, 164, 0.24); flex: 0 0 auto; font-size: 21px;
}
.brand-title { font-weight: 850; letter-spacing: -0.03em; line-height: 1.1; }
.brand-subtitle { color: var(--muted); font-size: 12px; margin-top: 2px; }
.theme-toggle, .admin-link {
  border: 1px solid var(--border); color: var(--text); background: var(--surface);
  min-width: 42px; height: 42px; border-radius: 999px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 12px; font-size: 13px; font-weight: 800;
}
.hero-copy { padding: 4px 18px 14px; }
.hero-copy h1 { font-size: clamp(25px, 4vw, 38px); line-height: 1.05; letter-spacing: -0.055em; margin-bottom: 10px; }
.hero-copy p { color: var(--muted); font-size: 14px; }
.search-card {
  margin: 0 12px 12px; padding: 12px; border-radius: 24px;
  background: var(--surface); border: 1px solid var(--border);
}
.main-search { display: flex; align-items: center; gap: 10px; background: var(--bg); border: 1px solid transparent; border-radius: 18px; padding: 0 12px; transition: .2s ease; }
.main-search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(14, 165, 164, .12); }
.main-search span { color: var(--muted); font-size: 20px; }
.main-search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); padding: 15px 0; font-size: 15px; }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 10px; }
.btn {
  border: 0; border-radius: 16px; padding: 13px 12px; font-weight: 800; cursor: pointer;
  transition: transform .18s ease, background .18s ease; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; gap: 7px; text-align: center;
}
.btn:active { transform: scale(.98); }
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--primary), var(--accent)); }
.btn-soft { color: var(--primary-dark); background: var(--surface-soft); }
[data-theme="dark"] .btn-soft { color: var(--primary); }
.mini-form { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 10px; }
.field { width: 100%; border: 1px solid var(--border); color: var(--text); background: var(--surface); border-radius: 16px; padding: 12px; outline: 0; }
.field:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(14, 165, 164, .10); }
.notice { margin: 0 12px 14px; border-radius: 20px; padding: 12px; background: var(--surface-soft); color: var(--muted); display: flex; gap: 10px; font-size: 13px; }
.history-box { padding: 0 12px 16px; }
.box-title { display: flex; justify-content: space-between; align-items: center; margin: 0 4px 9px; color: var(--muted); font-size: 13px; font-weight: 700; }
.chip-list { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 8px 11px; font-size: 13px; cursor: pointer; }
.results-panel { padding: 18px; }
.results-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.results-header h2 { font-size: clamp(22px, 3vw, 32px); letter-spacing: -0.04em; line-height: 1.08; }
.updated { color: var(--muted); font-size: 13px; white-space: nowrap; margin-top: 6px; }
.status-row { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 16px; }
.status-pill { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; color: var(--muted); padding: 8px 11px; font-size: 13px; font-weight: 700; }
.pharmacy-grid { display: grid; gap: 13px; }
.pharmacy-card { background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: 15px; transition: .18s ease; }
.pharmacy-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.pharmacy-name { font-size: 18px; font-weight: 900; letter-spacing: -0.025em; }
.district { color: var(--primary-dark); font-size: 13px; font-weight: 800; margin-top: 2px; }
[data-theme="dark"] .district { color: var(--primary); }
.favorite { width: 38px; height: 38px; border-radius: 14px; border: 1px solid var(--border); background: var(--bg); cursor: pointer; font-size: 17px; flex: 0 0 auto; }
.address { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.card-meta span { background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 7px 10px; color: var(--muted); font-size: 13px; font-weight: 700; }
.card-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.action { border-radius: 14px; text-decoration: none; padding: 10px 8px; text-align: center; font-size: 13px; font-weight: 850; background: var(--bg); border: 1px solid var(--border); color: var(--text); }
.action.call { color: #fff; border-color: transparent; background: var(--primary); }
.empty-state, .loading { background: var(--surface); border: 1px dashed var(--border); border-radius: 24px; text-align: center; padding: 28px 18px; color: var(--muted); }
.empty-state { display: none; }
.bottom-tabs { display: none; }

@media (max-width: 820px) {
  body { background: var(--bg); }
  .page { padding: 0; }
  .app-shell { display: block; min-height: 100vh; }
  .search-panel, .results-panel { border: 0; border-radius: 0; box-shadow: none; background: var(--bg); backdrop-filter: none; }
  .search-panel { position: static; }
  .topbar { padding: 12px 14px 6px; }
  .brand-icon { width: 36px; height: 36px; border-radius: 13px; font-size: 18px; }
  .brand-title { font-size: 15px; }
  .brand-subtitle, .admin-link { display: none; }
  .theme-toggle { width: 38px; height: 38px; }
  .hero-copy { display: none; }
  .search-card { position: sticky; top: 0; z-index: 20; margin: 0; border-radius: 0 0 24px 24px; border-width: 0 0 1px; padding: 10px 12px 12px; box-shadow: 0 10px 26px rgba(15, 23, 42, .07); }
  .main-search { border-radius: 16px; background: var(--bg); }
  .main-search input { padding: 13px 0; font-size: 14px; }
  .quick-actions { grid-template-columns: 1fr; }
  .btn { padding: 12px; border-radius: 15px; font-size: 14px; }
  .mini-form { grid-template-columns: 1fr 1fr; gap: 8px; }
  .field { padding: 11px 10px; font-size: 13px; border-radius: 14px; }
  .notice, .history-box { display: none; }
  .results-panel { padding: 14px 12px 82px; }
  .results-header { align-items: center; margin-top: 4px; }
  .results-header h2 { font-size: 20px; }
  .updated { font-size: 12px; }
  .status-row { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; margin-bottom: 12px; scrollbar-width: none; }
  .status-row::-webkit-scrollbar { display: none; }
  .status-pill { white-space: nowrap; font-size: 12px; padding: 7px 10px; }
  .pharmacy-card { border-radius: 20px; padding: 13px; }
  .pharmacy-card:hover { transform: none; box-shadow: none; }
  .pharmacy-name { font-size: 17px; }
  .address { font-size: 13px; }
  .card-meta { gap: 6px; }
  .card-meta span { font-size: 12px; padding: 6px 9px; }
  .card-actions { grid-template-columns: 1.1fr 1fr 1fr; }
  .action { padding: 9px 6px; font-size: 12px; }
  .bottom-tabs {
    position: fixed; left: 10px; right: 10px; bottom: 10px; z-index: 30; display: grid;
    grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 8px; border: 1px solid var(--border);
    border-radius: 24px; background: rgba(255, 255, 255, .9); backdrop-filter: blur(18px);
    box-shadow: 0 12px 34px rgba(15, 23, 42, .16);
  }
  [data-theme="dark"] .bottom-tabs { background: rgba(16, 27, 45, .9); }
  .tab { border-radius: 16px; text-align: center; padding: 8px 6px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 800; }
  .tab span { display: block; font-size: 18px; line-height: 1; margin-bottom: 3px; }
  .tab.active { background: var(--surface-soft); color: var(--primary-dark); }
  [data-theme="dark"] .tab.active { color: var(--primary); }
}
@media (max-width: 370px) {
  .mini-form { grid-template-columns: 1fr; }
  .card-actions { grid-template-columns: 1fr; }
}

.action.muted { opacity: .55; cursor: not-allowed; }
.card-meta:empty { display:none; }
.card-head > div:empty { display:none; }

.brand-logo {
  width: var(--header-logo-width, 42px);
  height: var(--header-logo-height, 42px);
  object-fit: contain;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 4px;
  flex: 0 0 auto;
}
.site-footer {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  margin: 16px 0 0;
  padding: 16px 18px;
  color: var(--muted);
  font-size: 13px;
}
.site-footer a {
  color: var(--primary-dark);
  font-weight: 900;
  text-decoration: none;
}
@media (max-width: 820px) {
  .brand-logo {
  width: var(--header-logo-width, 42px);
  height: var(--header-logo-height, 42px);
  object-fit: contain;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 4px;
  flex: 0 0 auto;
}
  .site-footer {
    display:block;
    padding: 12px 12px 92px;
    text-align:center;
    background: var(--bg);
  }
  .site-footer a { display:inline-block; margin-top:6px; }
}

.brand-logo-square {
  border-radius: 15px;
}
.brand-logo-rectangle {
  border-radius: 13px;
}
.brand-logo-circle {
  border-radius: 999px;
}
.brand-copy {
  min-width: 0;
}
@media (max-width: 820px) {
  .brand-logo {
  width: var(--header-logo-width, 42px);
  height: var(--header-logo-height, 42px);
  object-fit: contain;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 4px;
  flex: 0 0 auto;
}
  .brand-logo-square, .brand-logo-circle {
  border-radius: 999px;
}
  .brand-logo-circle {
  border-radius: 999px;
}
  .brand-logo-rectangle {
  border-radius: 13px;
}
}

.brand-logo-original {
  border-radius: 10px;
  padding: 0;
  border: 0;
  background: transparent;
}

@media (max-width: 820px) {
  .brand-logo {
    width: min(var(--header-logo-width, 42px), 120px);
    height: min(var(--header-logo-height, 42px), 44px);
  }
}
