:root {
  --bg: #f7f8f7;
  --surface: #ffffff;
  --text: #17211b;
  --muted: #657168;
  --border: #dfe5e0;
  --accent: #167447;
  --accent-hover: #0f6039;
  --danger: #b42318;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

.site-header {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand { font-size: 1.45rem; font-weight: 800; letter-spacing: -0.04em; color: var(--accent); }
.nav { display: flex; align-items: center; gap: 22px; color: var(--muted); }
.nav a:hover { color: var(--text); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 22px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
.button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button-secondary { background: transparent; color: var(--accent); }
.button-small { min-height: 38px; padding: 0 16px; }
.button:disabled { opacity: .55; cursor: not-allowed; }

.hero {
  width: min(1180px, calc(100% - 32px));
  margin: 42px auto 78px;
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  align-items: center;
  gap: 64px;
  min-height: 520px;
}
.hero h1 { margin: 0; max-width: 720px; font-size: clamp(3rem, 7vw, 6.4rem); line-height: .95; letter-spacing: -0.065em; }
.hero-copy > p { max-width: 650px; margin: 28px 0; font-size: 1.2rem; line-height: 1.65; color: var(--muted); }
.actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-panel { padding: 34px; border: 1px solid var(--border); border-radius: 28px; background: var(--surface); box-shadow: 0 22px 70px rgba(18, 44, 28, .08); }
.hero-panel strong { font-size: 1.3rem; }
.hero-panel p { margin-bottom: 0; line-height: 1.6; color: var(--muted); }

.section { width: min(1180px, calc(100% - 32px)); margin: 0 auto 72px; }
.section h2 { margin: 0 0 28px; font-size: clamp(2rem, 4vw, 3.4rem); letter-spacing: -0.04em; }
.section-copy { max-width: 780px; color: var(--muted); font-size: 1.1rem; line-height: 1.7; }
.section-muted { padding: 48px; border-radius: 28px; background: #eef3ef; }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.feature-grid article { padding: 26px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.feature-grid h3 { margin-top: 0; }
.feature-grid p { margin-bottom: 0; color: var(--muted); line-height: 1.55; }
.footer { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 44px; color: var(--muted); border-top: 1px solid var(--border); }

.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-aside { padding: 52px; background: #173d2a; color: white; display: flex; flex-direction: column; justify-content: space-between; }
.auth-aside .brand { color: white; }
.auth-aside h1 { max-width: 620px; margin: auto 0 24px; font-size: clamp(2.6rem, 6vw, 5.5rem); line-height: .98; letter-spacing: -0.055em; }
.auth-aside p { max-width: 520px; color: rgba(255,255,255,.72); line-height: 1.6; }
.auth-main { padding: 42px 24px; display: grid; place-items: center; background: var(--surface); }
.form-card { width: min(520px, 100%); }
.form-card h2 { margin: 0 0 8px; font-size: 2rem; letter-spacing: -0.035em; }
.form-card > p { margin: 0 0 30px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field.full { grid-column: 1 / -1; }
.field label { font-weight: 650; font-size: .92rem; }
.field input {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  outline: none;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(22,116,71,.12); }
.checkbox { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0 20px; color: var(--muted); line-height: 1.45; }
.form-actions { display: grid; gap: 12px; }
.form-actions .button { width: 100%; }
.form-links { display: flex; justify-content: space-between; gap: 16px; margin-top: 18px; font-size: .92rem; color: var(--accent); }
.notice { display: none; margin: 0 0 18px; padding: 12px 14px; border-radius: 10px; background: #eef7f1; color: #145c38; line-height: 1.45; }
.notice.error { background: #fff0ef; color: var(--danger); }
.notice.visible { display: block; }

/* Native dashboard/search migration */
.dashboard-header { border-bottom: 1px solid var(--border); }
.dashboard-nav { font-size: .92rem; }
.cart-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
}
.cart-indicator strong {
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: .78rem;
}

.search-page { width: min(1320px, calc(100% - 32px)); margin: 0 auto 72px; }
.search-hero {
  margin-top: 28px;
  padding: clamp(28px, 5vw, 54px);
  border: 1px solid #d7e4da;
  border-radius: 28px;
  background: linear-gradient(135deg, #eef7f1 0%, #f8fbf9 62%, #e6f1ea 100%);
}
.search-hero-copy { max-width: 780px; }
.search-hero h1 { margin: 0; font-size: clamp(2.5rem, 5vw, 4.5rem); line-height: 1; letter-spacing: -.055em; }
.search-hero-copy p { max-width: 660px; margin: 18px 0 0; color: var(--muted); font-size: 1.08rem; line-height: 1.6; }
.connection-warning {
  display: flex;
  gap: 8px 18px;
  align-items: center;
  flex-wrap: wrap;
  margin: 24px 0 0;
  padding: 14px 16px;
  border-radius: 14px;
  background: #173d2a;
  color: white;
}
.connection-warning span { color: rgba(255,255,255,.74); }

.search-form {
  display: grid;
  grid-template-columns: minmax(170px, .25fr) minmax(280px, 1fr) auto;
  align-items: end;
  gap: 12px;
  margin-top: 30px;
}
.search-mode-field, .search-input-field { display: grid; gap: 7px; }
.search-mode-field > span, .search-input-field > span { font-size: .8rem; font-weight: 750; color: #435047; }
.search-mode-field select, .search-input-field input {
  width: 100%;
  min-height: 52px;
  border: 1px solid #cbd8ce;
  border-radius: 12px;
  background: white;
  padding: 0 14px;
  outline: none;
  color: var(--text);
}
.search-mode-field select:focus, .search-input-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(22,116,71,.12); }
.search-submit { min-height: 52px; }
.search-steps { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; color: var(--muted); font-size: .85rem; }
.search-steps span { padding: 8px 11px; border-radius: 999px; background: rgba(255,255,255,.72); border: 1px solid rgba(188,204,193,.65); }

.search-content { padding-top: 42px; }
.search-content-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.eyebrow { display: block; margin-bottom: 5px; color: var(--accent); font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .11em; }
.search-content h2 { margin: 0; font-size: clamp(1.8rem, 4vw, 2.8rem); letter-spacing: -.04em; }
.search-status { margin: 0; color: var(--muted); text-align: right; }
.search-status[data-tone="success"] { color: var(--accent); }
.search-status[data-tone="error"] { color: var(--danger); }
.search-results { min-height: 250px; }
.loading-state, .empty-state {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 250px;
  padding: 32px;
  border: 1px dashed #c9d5cc;
  border-radius: 20px;
  background: rgba(255,255,255,.55);
  text-align: center;
  color: var(--muted);
}
.empty-state strong { color: var(--text); font-size: 1.15rem; }
.empty-state p { margin: 8px 0 0; }
.empty-state.error { border-color: #efc7c3; background: #fff5f4; color: var(--danger); }

.drugstore-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.drugstore-column, .product-group {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(21,52,33,.055);
}
.drugstore-column-head, .product-group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  min-height: 82px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.drugstore-column-head h3, .product-group-head h3 { margin: 0; font-size: 1.05rem; letter-spacing: -.02em; }
.drugstore-column-head > span { color: var(--muted); font-size: .82rem; }
.listing-stack { display: grid; max-height: 560px; overflow: auto; }
.listing-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 16px 18px;
  border-bottom: 1px solid #edf0ed;
}
.listing-row:last-child { border-bottom: 0; }
.listing-row:hover { background: #fafcfb; }
.listing-main { min-width: 0; }
.listing-title-row { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.listing-title-row strong { min-width: 0; font-size: .9rem; line-height: 1.35; text-transform: uppercase; }
.listing-main p { margin: 6px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.4; }
.source-pill {
  flex: none;
  padding: 3px 7px;
  border-radius: 999px;
  background: #eef4ef;
  color: #39634a;
  font-size: .68rem;
  font-weight: 750;
}
.listing-price { display: grid; justify-items: end; gap: 8px; min-width: 125px; }
.listing-price > strong { font-size: 1rem; }
.listing-price label { display: grid; gap: 4px; color: var(--muted); font-size: .68rem; text-align: right; }
.qty-input {
  width: 92px;
  height: 36px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  color: var(--text);
  text-align: right;
}
.qty-input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(22,116,71,.1); }
.unlinked { color: var(--danger); font-size: .72rem; font-weight: 700; }
.drugstore-column-foot, .product-group-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: #fbfcfb;
  color: var(--muted);
  font-size: .8rem;
}

.product-results { display: grid; gap: 16px; }
.product-group-head { min-height: 100px; }
.product-group-head > div { min-width: 0; }
.product-group-head p { margin: 7px 0 0; color: var(--muted); font-size: .82rem; }
.product-group-head img { width: 72px; height: 72px; object-fit: contain; border-radius: 10px; background: white; }
.product-group .listing-stack { max-height: none; }

@media (max-width: 980px) {
  .search-form { grid-template-columns: 1fr 2fr; }
  .search-submit { grid-column: 1 / -1; width: 100%; }
  .drugstore-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .nav a:not(.button) { display: none; }
  .hero { grid-template-columns: 1fr; gap: 28px; min-height: auto; margin-top: 44px; }
  .feature-grid { grid-template-columns: 1fr; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-aside { min-height: 260px; padding: 28px 24px; }
  .auth-aside h1 { margin-top: 44px; font-size: 2.6rem; }
  .auth-main { padding: 40px 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .dashboard-header { align-items: flex-start; padding: 18px 0; }
  .dashboard-nav { gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
  .dashboard-nav > span:first-child { width: 100%; text-align: right; }
  .search-content-head { align-items: flex-start; flex-direction: column; }
  .search-status { text-align: left; }
}

@media (max-width: 640px) {
  .search-page { width: min(100% - 20px, 1320px); }
  .search-hero { margin-top: 10px; padding: 24px 18px; border-radius: 20px; }
  .search-form { grid-template-columns: 1fr; }
  .search-submit { grid-column: auto; }
  .listing-row { grid-template-columns: 1fr; gap: 10px; }
  .listing-price { grid-template-columns: 1fr auto; align-items: end; justify-items: start; min-width: 0; }
  .listing-price label { justify-items: end; }
  .drugstore-column-foot, .product-group-foot { align-items: stretch; flex-direction: column; }
  .drugstore-column-foot .button, .product-group-foot .button { width: 100%; }
  .cart-indicator { display: none; }
}
