/* ==========================================================================
   CartRank — Mobile-First Grocery Deal Tracker Design System
   Warm alabaster canvas · Crisp hairline cards · Emerald savings accents
   ========================================================================== */

:root {
  --bg-canvas: #f2f1ed;
  --bg-surface: #ffffff;
  --bg-surface-muted: #f8f7f4;
  --bg-subtle: #e7e5de;
  --bg-emerald-soft: #e3f4eb;
  --bg-amber-soft: #fdf0da;
  --bg-blue-soft: #e6f0ff;
  --bg-purple-soft: #f0e9ff;

  --ink-primary: #18231d;
  --ink-secondary: #435249;
  --ink-muted: #617067;

  --border-subtle: #e2dfd7;
  --border-strong: #c9c4b8;

  --emerald: #0e7447;
  --emerald-dark: #095634;
  --amber: #a14608;
  --amber-bright: #d97706;
  --blue: #1d4ed8;
  --purple: #6d28d9;
  --danger: #b91c1c;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 3px rgba(15, 29, 21, 0.05);
  --shadow-md: 0 6px 18px rgba(15, 29, 21, 0.08);
  --shadow-lg: 0 18px 42px rgba(15, 29, 21, 0.16);

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-code: 'DM Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --header-h: 62px;
  --bottom-nav-h: 66px;
  --card-price-bg: rgba(255, 255, 255, 0.86);
  --card-price-border: rgba(24, 35, 29, 0.09);
  --header-bg: rgba(255, 255, 255, 0.94);
  --btn-action-bg: rgba(255, 255, 255, 0.82);
  --btn-action-hover: #ffffff;
}

/* Calm, Low-Glare Dark Mode */
[data-theme='dark'] {
  --bg-canvas: #121614;
  --bg-surface: #1b211e;
  --bg-surface-muted: #212824;
  --bg-subtle: #28312c;
  --bg-emerald-soft: #143627;
  --bg-amber-soft: #3a2a14;
  --bg-blue-soft: #182a45;
  --bg-purple-soft: #2a1f47;

  --ink-primary: #edf2ef;
  --ink-secondary: #bcc8c1;
  --ink-muted: #8f9e95;

  --border-subtle: #2b342f;
  --border-strong: #3e4a44;

  --emerald: #34d399;
  --emerald-dark: #6ee7b7;
  --amber: #fbbf24;
  --danger: #f87171;

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 18px 42px rgba(0, 0, 0, 0.5);

  --card-price-bg: rgba(15, 20, 18, 0.55);
  --card-price-border: rgba(255, 255, 255, 0.08);
  --header-bg: rgba(18, 22, 20, 0.94);
  --btn-action-bg: rgba(255, 255, 255, 0.07);
  --btn-action-hover: rgba(255, 255, 255, 0.13);
}

[data-theme='dark'] .deal-card,
[data-theme='dark'] .leader-card,
[data-theme='dark'] .compare-store-cell,
[data-theme='dark'] .filter-chip.is-store-chip:not(.is-active) {
  background: var(--store-bg-dark, var(--bg-surface));
  border-color: var(--store-border-dark, var(--border-subtle));
}

[data-theme='dark'] .deal-card,
[data-theme='dark'] .leader-card,
[data-theme='dark'] .compare-store-cell {
  border-top-color: var(--store-brand, var(--emerald));
}

[data-theme='dark'] .store-list-card {
  border-color: var(--store-border-dark, var(--border-subtle));
  border-left-color: var(--store-brand, var(--emerald));
}

[data-theme='dark'] .store-list-header {
  background: var(--store-bg-dark, var(--bg-surface-muted));
  border-bottom-color: var(--store-border-dark, var(--border-subtle));
}

[data-theme='dark'] .store-pill {
  background: rgba(255, 255, 255, 0.09) !important;
  color: #f3f7f5 !important;
  border-color: rgba(255, 255, 255, 0.12);
}

[data-theme='dark'] .membership-bar {
  background: #1b2033;
  border-color: #2f3859;
}

[data-theme='dark'] .membership-bar-label {
  color: #c7d2fe;
}

[data-theme='dark'] .club-toggle-btn {
  background: #232a42;
  border-color: #3f4b75;
  color: #e0e7ff;
}

[data-theme='dark'] .club-toggle-btn.is-enabled {
  background: #4f46e5;
  border-color: #6366f1;
  color: #ffffff;
}

[data-theme='dark'] .badge-club {
  background: #282d52;
  color: #c7d2fe;
  border-color: #434c82;
}

[data-theme='dark'] .badge-emerald {
  background: #133928;
  color: #6ee7b7;
}

[data-theme='dark'] .badge-gold {
  background: #3d2f12;
  color: #fde68a;
}

[data-theme='dark'] .badge-amber {
  background: #3f2412;
  color: #fdba74;
}

[data-theme='dark'] .badge-purple {
  background: #2c1e4a;
  color: #d8b4fe;
}

[data-theme='dark'] .badge-blue {
  background: #182b4d;
  color: #93c5fd;
}

[data-theme='dark'] .badge-muted {
  background: #2a332e;
  color: #cbd5d0;
}

[data-theme='dark'] .field-input,
[data-theme='dark'] .code-textarea,
[data-theme='dark'] .config-row,
[data-theme='dark'] .request-city-box,
[data-theme='dark'] .score-preview-box,
[data-theme='dark'] .compare-group-header,
[data-theme='dark'] .qty-stepper,
[data-theme='dark'] .list-item-row.is-checked {
  background: var(--bg-surface-muted);
  color: var(--ink-primary);
}

[data-theme='dark'] .search-input:focus {
  background: var(--bg-surface-muted);
}

[data-theme='dark'] .nav-tab.is-active,
[data-theme='dark'] .filter-chip.is-active {
  background: #e6f5ee;
  border-color: #e6f5ee;
  color: #0d1f16;
}

[data-theme='dark'] .btn-primary {
  background: #10b981;
  color: #062116;
}

[data-theme='dark'] .btn-primary:hover {
  background: #34d399;
}

[data-theme='dark'] .mobile-bottom-nav {
  background: rgba(18, 22, 20, 0.96);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg-canvas);
  color: var(--ink-primary);
  line-height: 1.45;
  padding-bottom: calc(var(--bottom-nav-h) + 20px);
}

@media (min-width: 768px) {
  body {
    padding-bottom: 48px;
  }
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2.5px solid var(--emerald);
  outline-offset: 2px;
}

.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;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  background: var(--emerald);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  z-index: 1000;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

[hidden] {
  display: none !important;
}

/* ==========================================================================
   Sticky Header & Navigation
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px 10px;
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

@media (min-width: 520px) {
  .header-inner {
    padding: 10px 16px;
    gap: 12px;
  }
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  color: var(--ink-primary);
  flex-shrink: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0f7a4a, #0a5c37);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(15, 122, 74, 0.28);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.08;
}

.brand-name {
  font-size: 1.04rem;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.brand-tagline {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-muted);
  display: none;
}

@media (min-width: 480px) {
  .brand {
    gap: 10px;
  }
  .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 11px;
  }
  .brand-name {
    font-size: 1.16rem;
  }
  .brand-tagline {
    display: block;
  }
}

@media (min-width: 768px) {
  .brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 12px;
  }
  .brand-name {
    font-size: 1.3rem;
  }
  .brand-tagline {
    font-size: 0.75rem;
  }
}

.city-switcher-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 38px;
  min-width: 0;
  max-width: 100%;
  padding: 5px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-primary);
  white-space: nowrap;
  overflow: hidden;
  transition: border-color 0.15s ease, background-color 0.15s ease;
  margin-left: auto;
}

#header-city-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 520px) {
  .city-switcher-btn {
    gap: 6px;
    min-height: 42px;
    padding: 6px 12px;
    font-size: 0.875rem;
  }
}

@media (min-width: 768px) {
  .city-switcher-btn {
    margin-left: 8px;
  }
}

.city-switcher-btn:hover {
  border-color: var(--emerald);
  background: var(--bg-emerald-soft);
}

.icon-pin {
  color: var(--emerald);
  flex-shrink: 0;
}

.desktop-nav {
  display: none;
  align-items: center;
  gap: 4px;
}

@media (min-width: 768px) {
  .desktop-nav {
    display: flex;
  }
}

.nav-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  background: transparent;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--ink-secondary);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-tab:hover {
  background: var(--bg-subtle);
  color: var(--ink-primary);
}

.nav-tab.is-active {
  background: var(--ink-primary);
  color: #ffffff;
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--emerald);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.theme-toggle-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  min-width: 38px;
  padding: 6px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--ink-primary);
  font-size: 0.82rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

@media (min-width: 520px) {
  .header-actions {
    gap: 6px;
  }
  .theme-toggle-btn {
    min-height: 40px;
    min-width: 40px;
    padding: 6px 11px;
  }
}

.alerts-active-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 0 2px var(--bg-surface);
}

.alerts-status-banner {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-emerald-soft);
  color: var(--emerald-dark);
  font-size: 0.82rem;
  font-weight: 700;
}

.theme-toggle-btn:hover {
  border-color: var(--emerald);
}

.theme-toggle-label {
  display: none;
}

@media (min-width: 520px) {
  .theme-toggle-label {
    display: inline;
  }
}

.demo-notice-strip {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--amber-bright);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 18px;
  font-size: 0.82rem;
  color: var(--ink-secondary);
}

/* Mobile Fixed Bottom Navigation */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 60;
  height: var(--bottom-nav-h);
  padding: 4px 8px env(safe-area-inset-bottom, 4px);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

@media (min-width: 768px) {
  .mobile-bottom-nav {
    display: none;
  }
}

.bottom-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 48px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.bottom-nav-btn.is-active {
  color: var(--emerald);
  background: var(--bg-emerald-soft);
}

.bottom-icon-wrap {
  position: relative;
  display: inline-flex;
}

.mobile-nav-badge {
  position: absolute;
  top: -5px;
  right: -10px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--emerald);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   Main Container & Market Hero
   ========================================================================== */
.app-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 14px 28px;
}

@media (min-width: 768px) {
  .app-main {
    padding: 24px 20px 36px;
  }
}

.market-banner {
  background: linear-gradient(135deg, #132a1e 0%, #19432d 62%, #0f6b41 100%);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-md);
}

@media (min-width: 820px) {
  .market-banner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 22px 26px;
  }
}

.cycle-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.14);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin-bottom: 8px;
}

.banner-top-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.banner-top-row .cycle-pill {
  margin-bottom: 0;
}

.all-cities-quick-btn {
  min-height: 30px;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  transition: background-color 0.14s ease, border-color 0.14s ease;
}

.all-cities-quick-btn:hover,
.all-cities-quick-btn.is-active {
  background: #ffffff;
  color: #132a1e;
  border-color: #ffffff;
}

.city-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--card-price-bg);
  border: 1px solid var(--card-price-border);
  color: var(--ink-secondary);
  font-size: 0.71rem;
  font-weight: 700;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.25);
}

.market-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

@media (min-width: 768px) {
  .market-title {
    font-size: 1.65rem;
  }
}

.market-subtitle {
  margin: 6px 0 0;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.86);
  max-width: 560px;
}

.market-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.kpi-box {
  background: rgba(255, 255, 255, 0.11);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  text-align: left;
  min-width: 90px;
}

.kpi-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 500;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}

.kpi-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.78);
  margin-top: 2px;
}

/* ==========================================================================
   Top Deals Leaderboard
   ========================================================================== */
.leaderboard-section {
  margin-bottom: 22px;
}

.section-header-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.section-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.015em;
}

.section-caption {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.text-link-btn {
  background: none;
  border: none;
  padding: 6px 4px;
  min-height: 40px;
  color: var(--emerald);
  font-size: 0.83rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-link-btn:hover {
  color: var(--emerald-dark);
}

.leaderboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(265px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-snap-type: x mandatory;
}

@media (min-width: 900px) {
  .leaderboard-grid {
    grid-template-columns: repeat(3, 1fr);
    overflow-x: visible;
  }
}

.leader-card {
  scroll-snap-align: start;
  background: var(--store-bg, var(--bg-surface));
  border: 1.5px solid var(--store-border, #c5dfd2);
  border-top: 4px solid var(--store-brand, var(--emerald));
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.leader-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.rank-medal {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 0.74rem;
  font-weight: 800;
  background: #fef3c7;
  color: #92400e;
}

.rank-medal.rank-1 {
  background: #14241b;
  color: #fde68a;
}

.leader-title {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 700;
  line-height: 1.3;
}

.leader-price-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

/* ==========================================================================
   Search, Filter & Sort Controls
   ========================================================================== */
.controls-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.search-sort-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

@media (min-width: 680px) {
  .search-sort-row {
    flex-direction: row;
    align-items: center;
  }
}

.search-field-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 13px;
  color: var(--ink-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  min-height: 46px;
  padding: 10px 42px 10px 40px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-strong);
  background: var(--bg-canvas);
  font-size: 0.94rem;
  font-weight: 500;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.search-input:focus {
  background: #ffffff;
  border-color: var(--emerald);
}

.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.search-clear-btn {
  position: absolute;
  right: 4px;
  width: 38px;
  height: 38px;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-size: 1.3rem;
  border-radius: 8px;
}

.sort-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.sort-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-muted);
}

.sort-select {
  min-height: 46px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-strong);
  background: var(--bg-surface);
  font-size: 0.875rem;
  font-weight: 700;
  flex: 1;
}

.inline-compare-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--bg-emerald-soft);
  border: 1px solid #b4e0ca;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 0.84rem;
  font-weight: 600;
  color: #0b4d2f;
}

.btn-inline-emerald {
  border: none;
  background: var(--emerald);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 8px 12px;
  min-height: 38px;
  border-radius: var(--radius-pill);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

@media (min-width: 768px) {
  .filter-group {
    flex-direction: row;
    align-items: center;
    gap: 10px;
  }
}

.filter-group-label {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  min-width: 74px;
  flex-shrink: 0;
}

.chip-rail {
  display: flex;
  align-items: center;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

@media (min-width: 768px) {
  .chip-rail {
    flex-wrap: wrap;
    overflow-x: visible;
  }
}

.chip-rail::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--ink-secondary);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.14s ease;
}

.filter-chip:hover {
  border-color: var(--ink-primary);
  color: var(--ink-primary);
}

.filter-chip.is-active {
  background: var(--ink-primary);
  border-color: var(--ink-primary);
  color: #ffffff;
}

.filter-chip.is-store-chip:not(.is-active) {
  background: var(--store-bg, var(--bg-surface));
  border-color: var(--store-border, var(--border-strong));
  color: var(--ink-primary);
}

.filter-chip.is-store-chip:not(.is-active):hover {
  border-color: var(--store-brand, var(--ink-primary));
}

.store-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.results-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  margin-top: 4px;
}

.results-meta-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.results-count {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-secondary);
}

/* ==========================================================================
   Fast-Scanning Deal Cards Grid
   ========================================================================== */
.deals-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 640px) {
  .deals-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
}

@media (min-width: 1024px) {
  .deals-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
  }
}

.deal-card {
  background: var(--store-bg, var(--bg-surface));
  border: 1px solid var(--store-border, var(--border-subtle));
  border-top: 3px solid var(--store-brand, var(--emerald));
  border-radius: var(--radius-lg);
  padding: 17px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.deal-card:hover {
  border-color: var(--store-brand, #c4d7cc);
  box-shadow: var(--shadow-md);
}

.deal-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.store-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(15, 29, 21, 0.1);
  font-size: 0.77rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  max-width: 68%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 30px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  transition: transform 0.12s ease;
}

.score-pill-btn:hover {
  transform: scale(1.03);
}

.score-steal {
  background: var(--bg-emerald-soft);
  color: var(--emerald-dark);
  border-color: rgba(14, 116, 71, 0.24);
}

.score-great {
  background: var(--bg-emerald-soft);
  color: var(--emerald-dark);
  border-color: rgba(14, 116, 71, 0.16);
}

.score-solid {
  background: var(--bg-amber-soft);
  color: var(--amber);
  border-color: rgba(161, 70, 8, 0.2);
}

.score-fair {
  background: var(--bg-subtle);
  color: var(--ink-secondary);
  border-color: var(--border-subtle);
}

.badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.badge-emerald {
  background: var(--bg-emerald-soft);
  color: #0a5c37;
}

.badge-gold {
  background: #fef3c7;
  color: #92400e;
}

.badge-amber {
  background: #ffedd5;
  color: #9a3412;
}

.badge-purple {
  background: var(--bg-purple-soft);
  color: #5b21b6;
}

.badge-blue {
  background: var(--bg-blue-soft);
  color: #1e40af;
}

.badge-muted {
  background: #e5e7eb;
  color: #374151;
}

.badge-club {
  background: #e0e7ff;
  color: #312e81;
  border: 1px solid #c7d2fe;
}

/* Warehouse Club Membership Selector */
.membership-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  border-radius: var(--radius-md);
  background: #f4f6fc;
  border: 1px solid #d5ddf5;
}

@media (min-width: 768px) {
  .membership-bar {
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }
}

.membership-bar-compact {
  margin-bottom: 0;
}

.membership-bar-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 800;
  color: #312e81;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.membership-toggle-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.club-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1.5px solid #c7d2fe;
  background: #ffffff;
  color: #312e81;
  font-size: 0.8rem;
  font-weight: 700;
  transition: all 0.14s ease;
}

.club-toggle-btn:hover {
  border-color: #4338ca;
}

.club-toggle-btn.is-enabled {
  background: #312e81;
  border-color: #312e81;
  color: #ffffff;
}

.club-toggle-status {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: rgba(49, 46, 129, 0.1);
}

.club-toggle-btn.is-enabled .club-toggle-status {
  background: rgba(255, 255, 255, 0.2);
  color: #e0e7ff;
}

.official-ad-link {
  color: var(--emerald-dark);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.official-ad-link:hover {
  text-decoration: underline;
}

.compliance-footer {
  margin-top: 28px;
  padding: 16px 4px 8px;
  border-top: 1px solid var(--border-subtle);
  color: var(--ink-muted);
  font-size: 0.78rem;
  line-height: 1.55;
}

.footer-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

@media (min-width: 768px) {
  .footer-row {
    flex-direction: row;
    align-items: flex-end;
  }
}

.compliance-footer p {
  margin: 0;
  max-width: 820px;
}

.footer-admin-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-muted);
  font-size: 0.74rem;
  font-weight: 600;
  opacity: 0.72;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.footer-admin-link:hover,
.footer-admin-link.is-active {
  opacity: 1;
  color: var(--ink-primary);
  border-color: var(--border-strong);
}

/* Owner Admin Lock Gate */
.admin-lock-gate {
  display: flex;
  justify-content: center;
  padding: 24px 0 12px;
}

.admin-lock-card {
  width: 100%;
  max-width: 440px;
  padding: 26px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lock-icon-circle {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--bg-emerald-soft);
  color: var(--emerald-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.admin-unlock-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lock-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}

.lock-actions-row .btn-primary {
  flex: 1;
}

.lock-security-note {
  margin: 8px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.76rem;
  color: var(--ink-muted);
  line-height: 1.5;
}

/* Flyer Upload & Review UI */
.flyer-preview-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.flyer-thumb {
  position: relative;
  width: 96px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface-muted);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.flyer-thumb img {
  width: 100%;
  height: 78px;
  object-fit: cover;
  display: block;
}

.flyer-thumb-pdf {
  width: 100%;
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--emerald-dark);
  background: var(--bg-emerald-soft);
}

.flyer-thumb-name {
  font-size: 0.68rem;
  padding: 4px 5px;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-secondary);
}

.flyer-thumb-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(15, 29, 21, 0.78);
  color: #ffffff;
  font-size: 0.85rem;
  line-height: 1;
}

.flyer-ai-box {
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-muted);
  border: 1px solid var(--border-subtle);
}

.flyer-review-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 520px;
  overflow-y: auto;
}

.flyer-review-row {
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.flyer-review-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

@media (min-width: 560px) {
  .flyer-review-grid {
    grid-template-columns: 2fr 1fr 1fr 1fr;
  }
}

.flyer-mini-input {
  min-height: 36px;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--ink-primary);
  font-size: 0.8rem;
  width: 100%;
}

/* Manage Deals Organizer */
.manage-controls-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 640px) {
  .manage-controls-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 960px) {
  .manage-controls-grid {
    grid-template-columns: 1.5fr 1.2fr 1fr 1fr 1fr;
  }
}

.manage-deals-groups {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.manage-store-group {
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--store-brand, var(--emerald));
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-surface);
}

.manage-store-group-head {
  padding: 10px 14px;
  background: var(--bg-surface-muted);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.manage-deal-row {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.manage-deal-row:last-child {
  border-bottom: none;
}

@media (min-width: 720px) {
  .manage-deal-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.manage-deal-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.manage-deal-title-line {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.manage-deal-meta {
  font-size: 0.78rem;
  color: var(--ink-secondary);
}

.manage-deal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.manage-group-link-bar {
  padding: 10px 14px;
  background: var(--bg-canvas);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (min-width: 640px) {
  .manage-group-link-bar {
    flex-direction: row;
    align-items: center;
  }
}

.manage-group-link-bar .field-input {
  flex: 1;
  min-height: 38px;
  font-size: 0.82rem;
}

.deal-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.deal-category-line {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.deal-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.32;
  color: var(--ink-primary);
}

.deal-pkg {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-secondary);
}

.deal-pricing-box {
  background: var(--card-price-bg);
  border: 1px solid var(--card-price-border);
  border-radius: var(--radius-md);
  padding: 11px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.price-primary-stack {
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex-wrap: wrap;
}

.sale-price {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--ink-primary);
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}

.regular-price {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink-muted);
  text-decoration: line-through;
  font-variant-numeric: tabular-nums;
}

.pct-off-tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--emerald-dark);
  background: var(--bg-emerald-soft);
  padding: 2px 7px;
  border-radius: var(--radius-pill);
}

.unit-price-box {
  text-align: right;
  flex-shrink: 0;
}

.unit-price-val {
  display: block;
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--emerald-dark);
  font-variant-numeric: tabular-nums;
}

.unit-price-lbl {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--ink-muted);
  text-transform: uppercase;
}

.deal-meta-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.76rem;
  color: var(--ink-muted);
  font-weight: 600;
  flex-wrap: wrap;
}

.deal-meta-urgent {
  color: var(--amber);
  font-weight: 800;
}

.deal-actions {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}

.btn-save-deal {
  flex: 1;
  min-height: 42px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-strong);
  background: var(--btn-action-bg);
  color: var(--ink-primary);
  font-size: 0.84rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.14s ease;
}

.btn-save-deal:hover {
  background: var(--btn-action-hover);
  border-color: var(--emerald);
  color: var(--emerald-dark);
}

.btn-save-deal.is-saved {
  background: var(--bg-emerald-soft);
  border-color: var(--emerald);
  color: var(--emerald-dark);
}

.btn-compare-deal {
  min-height: 42px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--ink-secondary);
  font-size: 0.81rem;
  font-weight: 700;
  white-space: nowrap;
}

.btn-compare-deal:hover {
  background: var(--btn-action-bg);
  border-color: var(--border-strong);
  color: var(--ink-primary);
}

/* ==========================================================================
   Cross-Store Comparison View
   ========================================================================== */
.view-intro {
  margin-bottom: 16px;
}

.view-title {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.view-subtitle {
  margin: 4px 0 0;
  font-size: 0.9rem;
  color: var(--ink-secondary);
}

.compare-search-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}

.quick-picks-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.compare-results {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.compare-group-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.compare-group-header {
  padding: 14px 16px;
  background: #faf9f5;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.compare-product-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.compare-spread-pill {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--emerald-dark);
  background: var(--bg-emerald-soft);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

.compare-rows {
  display: grid;
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .compare-rows {
    grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
  }
}

.compare-store-cell {
  padding: 14px 16px;
  background: var(--store-bg, var(--bg-surface));
  border-top: 4px solid var(--store-brand, var(--border-subtle));
  border-bottom: 1px solid var(--store-border, var(--border-subtle));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.compare-store-cell .store-pill {
  max-width: calc(100% - 52px);
}

.compare-store-cell .btn-save-deal {
  flex: 0 0 auto;
  margin-top: auto;
  width: 100%;
}

@media (min-width: 768px) {
  .compare-store-cell {
    border-bottom: none;
    border-right: 1px solid var(--store-border, var(--border-subtle));
  }
  .compare-store-cell:last-child {
    border-right: none;
  }
}

.compare-store-cell.is-winner {
  box-shadow: inset 0 0 0 2px var(--emerald);
}

.compare-unit-hero {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--emerald-dark);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Personal Deal List View
   ========================================================================== */
.list-summary-banner {
  background: var(--bg-surface);
  border: 1.5px solid #c5e2d3;
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}

@media (min-width: 768px) {
  .list-summary-banner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.list-kpis {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.list-kpi-val {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.list-kpi-val.is-savings {
  color: var(--emerald);
}

.list-kpi-lbl {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--ink-muted);
  text-transform: uppercase;
}

.list-actions-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.list-store-groups {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.store-list-card {
  background: var(--bg-surface);
  border: 1.5px solid var(--store-border, var(--border-subtle));
  border-left: 5px solid var(--store-brand, var(--emerald));
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.store-list-header {
  padding: 13px 16px;
  background: var(--store-bg, #faf9f5);
  border-bottom: 1px solid var(--store-border, var(--border-subtle));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.store-list-totals {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--ink-secondary);
}

.store-list-totals strong {
  color: var(--emerald-dark);
}

.list-item-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.list-item-row:last-child {
  border-bottom: none;
}

.list-item-row.is-checked {
  opacity: 0.58;
  background: #fafaf8;
}

.list-item-row.is-checked .list-item-title {
  text-decoration: line-through;
}

.list-item-left {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.list-check {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  accent-color: var(--emerald);
  cursor: pointer;
  flex-shrink: 0;
}

.list-item-title {
  font-size: 0.92rem;
  font-weight: 700;
  margin: 0;
}

.list-item-sub {
  font-size: 0.78rem;
  color: var(--ink-muted);
  margin: 2px 0 0;
}

.list-item-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.qty-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fff;
}

.qty-btn {
  width: 34px;
  height: 36px;
  border: none;
  background: transparent;
  font-weight: 800;
  font-size: 1rem;
}

.qty-btn:hover {
  background: var(--bg-subtle);
}

.qty-val {
  min-width: 24px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
}

.list-line-price {
  text-align: right;
  min-width: 68px;
}

.list-line-sale {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 500;
}

.list-line-save {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--emerald);
}

/* ==========================================================================
   Admin & Multi-City Data Studio
   ========================================================================== */
.admin-intro-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 820px) {
  .admin-intro-row {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
  }
}

.admin-top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

@media (min-width: 720px) {
  .admin-stats-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.stat-card-val {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 500;
  color: var(--ink-primary);
}

.stat-card-lbl {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--ink-muted);
}

.admin-subtabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-bottom: 16px;
  padding-bottom: 2px;
}

.subtab-btn {
  min-height: 42px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--ink-secondary);
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

.subtab-btn.is-active {
  background: var(--emerald);
  border-color: var(--emerald);
  color: #ffffff;
}

.admin-two-col {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 900px) {
  .admin-two-col {
    grid-template-columns: 1.15fr 1fr;
    align-items: start;
  }
}

.card-surface {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.panel-heading {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 800;
}

.sub-heading {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 800;
}

.panel-desc {
  margin: 0 0 14px;
  font-size: 0.84rem;
  color: var(--ink-secondary);
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 28px 16px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-canvas);
  color: var(--ink-secondary);
  text-align: center;
  cursor: pointer;
  margin-bottom: 14px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--emerald);
  background: var(--bg-emerald-soft);
  color: var(--emerald-dark);
}

.dropzone-title {
  font-weight: 700;
  font-size: 0.9rem;
}

.dropzone-sub {
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.template-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.code-textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-strong);
  background: #faf9f5;
  font-family: var(--font-code);
  font-size: 0.78rem;
  line-height: 1.5;
  resize: vertical;
}

/* Forms & Buttons */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 520px) {
  .form-grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-span-2 {
  grid-column: 1 / -1;
}

.field-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--ink-secondary);
}

.field-input {
  min-height: 42px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  background: #fff;
  font-size: 0.88rem;
}

.color-input {
  padding: 4px;
  cursor: pointer;
}

.checkbox-fieldset {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin: 12px 0;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 6px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 600;
}

.form-footer-row {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.form-feedback {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--emerald-dark);
}

.form-feedback.is-error {
  color: var(--danger);
}

.btn-primary {
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--emerald);
  color: #ffffff;
  font-size: 0.88rem;
  font-weight: 700;
}

.btn-primary:hover {
  background: var(--emerald-dark);
}

.btn-secondary {
  min-height: 42px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--ink-primary);
  font-size: 0.84rem;
  font-weight: 700;
}

.btn-secondary:hover {
  border-color: var(--ink-primary);
}

.btn-sm {
  min-height: 38px;
  padding: 6px 12px;
  font-size: 0.78rem;
}

.btn-danger-ghost {
  min-height: 42px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid #fecaca;
  background: #fef2f2;
  color: var(--danger);
  font-size: 0.84rem;
  font-weight: 700;
}

.divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 18px 0;
}

.score-preview-box {
  background: #faf9f5;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
}

.markets-config-list,
.requests-list,
.validity-list,
.schema-diagram {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.config-row {
  padding: 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: #faf9f5;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.config-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.schema-table {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #14241b;
  color: #e6f5ee;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.schema-table strong {
  color: #6ee7b7;
  font-size: 0.84rem;
}

.toggle-inline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

/* ==========================================================================
   Empty States, Modals & Toasts
   ========================================================================== */
.empty-state {
  grid-column: 1 / -1;
  background: var(--bg-surface);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 36px 20px;
  text-align: center;
}

.empty-state h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.empty-state p {
  margin: 0 0 14px;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 25, 19, 0.56);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

@media (min-width: 600px) {
  .modal-backdrop {
    align-items: center;
    padding: 20px;
  }
}

.modal-sheet {
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-lg);
}

@media (min-width: 600px) {
  .modal-sheet {
    border-radius: 20px;
  }
}

.modal-sheet-sm {
  max-width: 440px;
}

.modal-sheet-lg {
  max-width: 680px;
}

/* Price History Chart, Toggle Switch & Storage Meter */
.btn-history-deal {
  min-height: 42px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--ink-secondary);
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.btn-history-deal:hover {
  background: var(--btn-action-bg);
  border-color: var(--border-strong);
  color: var(--ink-primary);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-muted);
  cursor: pointer;
}

.toggle-switch-input {
  width: 22px;
  height: 22px;
  accent-color: var(--emerald);
  cursor: pointer;
  flex-shrink: 0;
}

.storage-metrics-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.storage-metric-pill {
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-muted);
}

.storage-metric-pill strong {
  display: block;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.storage-metric-pill span {
  font-size: 0.7rem;
  color: var(--ink-muted);
  font-weight: 600;
}

.history-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.history-kpi-card {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-muted);
}

.history-kpi-card strong {
  display: block;
  font-size: 1.02rem;
  color: var(--ink-primary);
  font-variant-numeric: tabular-nums;
}

.history-kpi-card strong.is-low {
  color: var(--emerald-dark);
}

.history-kpi-card span {
  font-size: 0.72rem;
  color: var(--ink-muted);
  font-weight: 600;
}

.history-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.history-store-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--ink-primary);
  font-size: 0.76rem;
  font-weight: 700;
}

.history-store-toggle.is-muted {
  opacity: 0.42;
  border-style: dashed;
}

.history-chart-wrap {
  width: 100%;
  padding: 12px 10px 6px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-muted);
  overflow-x: auto;
}

.history-chart-svg {
  width: 100%;
  min-width: 420px;
  height: auto;
  display: block;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.history-table th,
.history-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.history-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}

.history-table tr:last-child td {
  border-bottom: none;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  background: var(--bg-surface);
  z-index: 2;
}

.modal-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
}

.modal-subtitle {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.modal-close-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-canvas);
  font-size: 1.4rem;
  line-height: 1;
  color: var(--ink-primary);
}

.modal-body {
  padding: 18px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mini-label {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.city-options-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.city-option-btn {
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-subtle);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
}

.city-option-btn:hover:not(:disabled) {
  border-color: var(--emerald);
}

.city-option-btn.is-selected {
  border-color: var(--emerald);
  background: var(--bg-emerald-soft);
}

.city-option-btn:disabled {
  cursor: default;
  opacity: 0.75;
  background: #faf9f5;
}

.request-city-box {
  background: #faf9f5;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
}

.score-bar-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.score-bar-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
  font-weight: 700;
}

.score-bar-track {
  height: 9px;
  background: var(--bg-subtle);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  background: var(--emerald);
  border-radius: var(--radius-pill);
}

.toast-region {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: min(92vw, 380px);
}

@media (min-width: 768px) {
  .toast-region {
    bottom: 24px;
    left: auto;
    right: 24px;
    transform: none;
  }
}

.toast-msg {
  background: #14241b;
  color: #ffffff;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
