:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-subtle: #f4f4f5;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-secondary: #52525b;
  --text-muted: #71717a;
  --accent: #18181b;
  --accent-hover: #27272a;
  --emerald-bg: #ecfdf5;
  --emerald-border: #a7f3d0;
  --emerald-text: #065f46;
  --amber-bg: #fffbeb;
  --amber-border: #fde68a;
  --amber-text: #92400e;
  --rose-bg: #fff1f2;
  --rose-border: #fecdd3;
  --rose-text: #9f1239;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.tabular-nums {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.w-full {
  width: 100%;
}

/* Auth Screen */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 390px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px;
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 14px;
  font-family: var(--font-mono);
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: #10b981;
  display: inline-block;
}

.auth-title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-subtitle {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Topbar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.brand-name {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
}

.meta-chip {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 4px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ext-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: var(--font-sans);
}

.ext-pill-ok {
  background: var(--emerald-bg);
  border-color: var(--emerald-border);
  color: var(--emerald-text);
}

.ext-pill-ok .ext-dot {
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  background: #10b981;
}

.ext-pill-warn {
  background: var(--amber-bg);
  border-color: var(--amber-border);
  color: var(--amber-text);
}

.ext-pill-warn .ext-dot {
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  background: #f59e0b;
}

.saved-lists-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Inputs & Buttons */
.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.input-field,
.select-compact {
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  font-family: var(--font-sans);
}

.select-compact {
  padding: 5px 8px;
  font-size: 12px;
}

.mono-input {
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
}

.input-field:focus,
.items-textarea:focus,
.select-compact:focus {
  outline: 2px solid #18181b;
  outline-offset: -1px;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-sans);
}

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

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-lg {
  padding: 11px 18px;
  font-size: 14px;
}

.btn-secondary-sm,
.btn-ghost-sm {
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
}

.btn-secondary-sm {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-secondary-sm:hover {
  background: var(--surface-subtle);
}

.btn-ghost-sm {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}

.btn-ghost-sm:hover {
  background: var(--surface-subtle);
  color: var(--text);
}

/* Main Layout */
.main-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* Composer */
.composer-panel {
  padding: 18px 20px;
}

.composer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.page-title {
  margin: 0 0 3px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.composer-quick-actions {
  display: flex;
  gap: 8px;
}

.composer-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 16px;
}

@media (max-width: 900px) {
  .composer-grid {
    grid-template-columns: 1fr;
  }
}

.items-textarea {
  width: 100%;
  height: 100%;
  min-height: 146px;
  resize: vertical;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  background: #fcfcfd;
}

.composer-controls {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}

.control-block {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.control-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.control-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px;
  gap: 3px;
}

.seg-btn {
  border: none;
  background: transparent;
  padding: 7px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-sans);
}

.seg-btn.active {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.search-cta {
  width: 100%;
  padding: 11px 16px;
}

.form-error {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--rose-bg);
  border: 1px solid var(--rose-border);
  color: var(--rose-text);
  font-size: 12px;
  font-weight: 600;
}

.form-ok {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--emerald-bg);
  border: 1px solid var(--emerald-border);
  color: var(--emerald-text);
  font-size: 12px;
  font-weight: 600;
}

/* Asymmetric Hero Summary */
.summary-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

@media (max-width: 960px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }
}

.hero-summary-card,
.secondary-summary-card {
  padding: 18px 20px;
}

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: uppercase;
}

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

.status-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.status-emerald {
  background: var(--emerald-bg);
  border-color: var(--emerald-border);
  color: var(--emerald-text);
}

.hero-main-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.hero-store-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.hero-price-line {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.hero-price {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.savings-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--emerald-text);
  background: var(--emerald-bg);
  border: 1px solid var(--emerald-border);
  padding: 2px 8px;
  border-radius: 4px;
}

.hero-meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.hero-cta-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.hero-note {
  font-size: 11px;
  color: var(--text-muted);
}

.secondary-metric {
  font-size: 24px;
  font-weight: 700;
  margin: 6px 0 4px;
}

.secondary-desc {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.divider-line {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

.yaguar-status-text {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* 3-Column Comparison Grid */
.carts-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

@media (max-width: 1160px) {
  .carts-grid {
    grid-template-columns: 1fr;
  }
}

.cart-column {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cart-column.is-winner {
  border-color: #10b981;
}

.cart-col-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: #fcfcfd;
}

.cart-store-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.cart-store-name {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.cart-branch {
  font-size: 12px;
  color: var(--text-muted);
}

.rank-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.rank-pill.winner {
  background: var(--emerald-bg);
  border: 1px solid var(--emerald-border);
  color: var(--emerald-text);
}

.rank-pill.diff {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.cart-totals-box {
  margin-top: 12px;
}

.cart-total {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.cart-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.cart-common {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.store-notice {
  margin: 12px 12px 0;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12px;
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  color: var(--amber-text);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.cart-items-list {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-card.is-excluded {
  opacity: 0.55;
  background: var(--surface-subtle);
}

.item-card.is-missing {
  border-color: var(--rose-border);
  background: var(--rose-bg);
}

.item-query-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 1px solid #f4f4f5;
  padding-bottom: 5px;
}

.item-query-label {
  font-weight: 600;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-toggle-btn {
  background: transparent;
  border: none;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
}

.item-toggle-btn:hover {
  color: var(--text);
}

.item-main {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.item-thumb {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #ffffff;
  flex-shrink: 0;
}

.item-info {
  min-width: 0;
  flex: 1;
}

.item-title {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  line-height: 1.35;
}

.item-title:hover {
  text-decoration: underline;
}

.item-submeta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.promo-tag {
  display: inline-block;
  margin-top: 4px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--emerald-bg);
  color: var(--emerald-text);
  border: 1px solid var(--emerald-border);
}

.item-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.pres-select,
.alt-select {
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 11.5px;
  background: var(--surface);
  color: var(--text);
  max-width: 100%;
  font-family: var(--font-sans);
}

.alt-select {
  width: 100%;
  color: var(--text-secondary);
}

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

.qty-btn {
  width: 24px;
  height: 24px;
  border: none;
  background: var(--surface-subtle);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

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

.qty-val {
  min-width: 28px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  padding: 0 4px;
}

.item-pricing-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px dashed #e4e4e7;
}

.unit-price-text {
  font-size: 11.5px;
  color: var(--text-secondary);
}

.line-subtotal {
  font-size: 14px;
  font-weight: 700;
}

.cart-col-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: #fcfcfd;
}

.btn-store-cta {
  width: 100%;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--accent);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
}

.btn-store-cta:hover {
  background: var(--surface-subtle);
}

.cart-column.is-winner .btn-store-cta {
  background: var(--accent);
  color: #ffffff;
}

.cart-column.is-winner .btn-store-cta:hover {
  background: var(--accent-hover);
}

.btn-store-cta:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(24, 24, 27, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 60;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.modal-sm {
  max-width: 400px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

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

.modal-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.steps-list {
  margin: 4px 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.steps-list code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface-subtle);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.modal-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 6px;
  flex-wrap: wrap;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-fill {
  width: 10%;
  height: 100%;
  background: #10b981;
  transition: width 180ms ease;
}
