:root {
  --color-bg: #faf8f5;
  --color-surface: #ffffff;
  --color-text: #2c1810;
  --color-text-muted: #6b5b50;
  --color-accent: #5c3d2e;
  --color-accent-hover: #7a5240;
  --color-accent-light: #f0e6de;
  --color-border: #e0d5cc;
  --color-success: #2d7a4f;
  --color-danger: #b5342b;
  --color-badge: #d4a574;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(44, 24, 16, 0.08);
  --shadow-lg: 0 4px 20px rgba(44, 24, 16, 0.12);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px;
}

h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--color-accent);
}

.subtitle {
  color: var(--color-text-muted);
  font-size: 15px;
  margin-bottom: 24px;
}

/* Cadence Toggle */
.cadence-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 28px;
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  overflow: hidden;
  width: fit-content;
}

.cadence-btn {
  padding: 10px 24px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: all 0.2s;
}

.cadence-btn.active {
  background: var(--color-accent);
  color: #fff;
}

/* Product Grid */
.flavor-section {
  margin-bottom: 28px;
}

.flavor-name {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--color-accent-light);
}

.variant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.variant-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.variant-card.in-cart {
  border-color: var(--color-accent);
  box-shadow: var(--shadow);
}

.variant-info h3 {
  font-size: 14px;
  font-weight: 600;
}

.variant-info .meta {
  font-size: 13px;
  color: var(--color-text-muted);
}

.variant-price {
  font-weight: 700;
  font-size: 15px;
  color: var(--color-accent);
  margin-top: 4px;
}

.qty-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qty-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  color: var(--color-text);
}

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

.qty-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.qty-value {
  font-size: 16px;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

/* Cart Summary / Checkout Bar */
.checkout-bar {
  position: sticky;
  bottom: 0;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  box-shadow: 0 -4px 16px rgba(44, 24, 16, 0.1);
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
}

.checkout-bar.hidden {
  display: none;
}

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

.cart-summary strong {
  color: var(--color-text);
  font-size: 18px;
}

.checkout-btn {
  background: var(--color-accent);
  color: #fff;
  border: none;
  padding: 12px 32px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

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

.checkout-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Loading / Error States */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-muted);
  font-size: 16px;
}

.error-msg {
  background: #fef2f2;
  color: var(--color-danger);
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
}

/* Manage Page Specifics */
.email-lookup {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  max-width: 480px;
}

.email-lookup input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 15px;
  outline: none;
}

.email-lookup input:focus {
  border-color: var(--color-accent);
}

.email-lookup button {
  padding: 10px 20px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.sub-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.sub-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.sub-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.sub-badge.active {
  background: #dcfce7;
  color: var(--color-success);
}

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

.sub-badge.canceled {
  background: #fee2e2;
  color: var(--color-danger);
}

.sub-items {
  list-style: none;
  margin-bottom: 16px;
}

.sub-items li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-accent-light);
}

.sub-items li:last-child {
  border-bottom: none;
}

.item-name {
  font-weight: 600;
  font-size: 14px;
}

.item-detail {
  font-size: 13px;
  color: var(--color-text-muted);
}

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

.btn-secondary {
  padding: 8px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-light);
}

.btn-primary {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--color-accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-primary:disabled,
.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Edit mode overlay */
.edit-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(44, 24, 16, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.edit-panel {
  background: var(--color-surface);
  border-radius: 12px;
  padding: 24px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.edit-panel h2 {
  font-size: 20px;
  margin-bottom: 16px;
}

.edit-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}
