:root {
  --bg: #FAF6F0;
  --panel: #FFFFFF;
  --text: #2B1B12;
  --muted: #7A6656;
  --accent: #6F4E37;
  --accent-dark: #4E3524;
  --accent-light: #C19A6B;
  --border: #E7DACB;
  --danger: #B33A3A;
  --success: #3A7D44;
  --warn: #B8860B;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

.container { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; width: 100%; }

.site-footer {
  text-align: center; padding: 20px 16px 28px; font-size: 0.82rem; color: var(--muted);
}

.topbar {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  background: var(--accent-dark);
  color: #fff;
  padding: 10px 16px;
}
.topbar .brand { color: #fff; font-weight: 700; font-size: 1.1rem; text-decoration: none; margin-right: auto; }

.menu-toggle {
  background: none; border: none; color: #fff; font-size: 1.3rem; line-height: 1;
  cursor: pointer; padding: 8px 12px; border-radius: 6px;
}
.menu-toggle:hover { background: rgba(255,255,255,0.12); }

.topbar nav {
  display: none;
  position: absolute; top: calc(100% + 6px); right: 16px;
  flex-direction: column; gap: 2px;
  background: var(--accent-dark);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  padding: 8px;
  min-width: 230px;
  max-width: calc(100vw - 32px);
  z-index: 100;
}
.topbar nav.open { display: flex; }
.topbar nav a { color: #F1E4D5; text-decoration: none; font-size: 0.92rem; padding: 10px 12px; border-radius: 6px; }
.topbar nav a:hover, .topbar nav a:active { color: #fff; background: rgba(255,255,255,0.12); }
.topbar .nav-who {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 0.85rem; color: #E7DACB;
  margin-top: 6px; padding: 10px 12px 4px; border-top: 1px solid rgba(255,255,255,0.15);
}
.topbar .logout { color: #F1E4D5; text-decoration: underline; }

h1 { color: var(--accent-dark); font-size: 1.5rem; margin: 0 0 16px; }
h2 { color: var(--accent-dark); font-size: 1.15rem; margin: 24px 0 10px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 18px;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.login-wrap { max-width: 380px; margin: 80px auto; }
.login-wrap .card { text-align: center; }
.login-wrap .brand { font-size: 1.6rem; font-weight: 700; color: var(--accent-dark); margin-bottom: 4px; }
.login-wrap .tagline { color: var(--muted); font-size: 0.85rem; margin-bottom: 22px; }

label { display: block; font-size: 0.85rem; color: var(--muted); margin: 12px 0 4px; text-align: left; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 0.95rem; background: #fff; color: var(--text);
}
textarea { resize: vertical; min-height: 70px; }

button, .btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  margin-top: 10px;
}
button:hover, .btn:hover { background: var(--accent-dark); }
.btn-secondary { background: #fff; color: var(--accent); border: 1px solid var(--accent); }
.btn-secondary:hover { background: var(--bg); color: var(--accent-dark); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 7px 12px; font-size: 0.82rem; margin: 2px; min-height: 34px; }
.action-cell { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.action-cell form { margin: 0; }

.error { color: var(--danger); font-size: 0.88rem; margin-top: 8px; }
.success-box { background: #EAF5EC; border: 1px solid var(--success); color: #1F4D27; padding: 14px 16px; border-radius: 8px; }

/* ── Storefront ─────────────────────────────────────────────────── */
.hero {
  background: var(--accent-dark);
  color: #F1E4D5;
  margin: -24px -16px 28px;
  padding: 44px 20px 40px;
  text-align: center;
}
.hero-text { max-width: 560px; margin: 0 auto; }
.hero h1 { color: #fff; font-size: 1.7rem; margin: 0 0 14px; text-wrap: balance; }
.hero-sub { color: #D9C7B4; font-size: 0.95rem; margin: 0; }

.series-section { margin-bottom: 28px; }
.series-title { margin: 0 0 12px; }
.series-scroller {
  display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory;
  padding-bottom: 6px; -webkit-overflow-scrolling: touch;
  margin: 0 -16px; padding-left: 16px; padding-right: 16px;
}
.series-card {
  flex: 0 0 auto; scroll-snap-align: start;
  width: 240px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; text-decoration: none; color: var(--text); display: flex; flex-direction: column;
}
.series-card-body { padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.series-card-label { color: var(--accent); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; margin: 0; font-weight: 700; }
.series-card-hook { font-size: 0.85rem; margin: 0; line-height: 1.4; font-style: italic; }
.series-card-cta { color: var(--accent-dark); font-size: 0.78rem; font-weight: 600; margin-top: 4px; }

.category-tabs {
  display: flex; gap: 8px; overflow-x: auto; margin: 0 0 20px; padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}
.category-tab {
  flex: 0 0 auto; padding: 8px 16px; border-radius: 999px; font-size: 0.85rem;
  text-decoration: none; color: var(--accent-dark); background: var(--panel);
  border: 1px solid var(--border); white-space: nowrap;
}
.category-tab.active { background: var(--accent-dark); color: #fff; border-color: var(--accent-dark); }
.category-tab:hover:not(.active) { border-color: var(--accent); }

.cart-bar {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 24px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--accent-dark); color: #fff;
  box-shadow: 0 -6px 16px rgba(0,0,0,0.18);
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.cart-bar-hidden { transform: translateY(110%); opacity: 0; pointer-events: none; }
.cart-bar-info { font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.cart-bar-info span#cart-bar-count { font-weight: 700; }
.cart-bar-actions { display: flex; gap: 8px; flex-shrink: 0; }
.cart-bar .btn, .cart-bar .btn-secondary { margin: 0; }

.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.product-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; display: flex; flex-direction: column;
}
.product-image-btn {
  display: block; width: 100%; height: 320px; padding: 0; margin: 0; border: none;
  background: var(--bg); cursor: zoom-in;
}
.product-image-btn img { width: 100%; height: 100%; object-fit: contain; display: block; }
.product-card-body { padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.product-card-body h2 { margin: 0; font-size: 1.02rem; }
.product-desc { color: var(--muted); font-size: 0.85rem; margin: 0 0 4px; }
.product-price { color: var(--accent-dark); font-weight: 700; font-size: 1.05rem; margin: 0 0 6px; }
.empty-shop { color: var(--muted); grid-column: 1 / -1; text-align: center; padding: 40px 0; }

.product-actions { display: flex; flex-direction: column; gap: 8px; }
.add-to-cart-form { display: flex; flex-wrap: wrap; gap: 8px; }
.add-to-cart-form .btn { flex: 1; margin-top: 0; white-space: nowrap; min-width: 120px; }
.variant-select { flex: 1 1 100%; width: auto; padding: 9px 8px; }
.qty-input { width: 56px; flex: 0 0 auto; padding: 9px 8px; text-align: center; }
.buy-now-link { text-align: center; font-size: 0.82rem; color: var(--accent); text-decoration: none; }
.buy-now-link:hover { text-decoration: underline; }

.lightbox-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.88);
  align-items: center; justify-content: center; padding: 24px;
}
.lightbox-overlay.open { display: flex; }
.lightbox-overlay img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.lightbox-close {
  position: absolute; top: 16px; right: 16px; z-index: 201;
  background: rgba(255,255,255,0.12); color: #fff; border: none; border-radius: 999px;
  width: 40px; height: 40px; font-size: 1.1rem; cursor: pointer;
}
.lightbox-close:hover { background: rgba(255,255,255,0.22); }

@media (max-width: 480px) {
  .product-image-btn { height: 260px; }
}

.shop-topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin: -24px -16px 20px; padding: 12px 16px;
  background: var(--accent-dark);
}
.shop-topbar-brand { color: #fff; font-weight: 700; text-decoration: none; }
.shop-topbar-actions { display: flex; align-items: center; gap: 14px; }
.lang-toggle {
  color: #F1E4D5; text-decoration: none; font-size: 0.82rem; font-weight: 700;
  border: 1px solid rgba(255,255,255,0.35); border-radius: 5px; padding: 3px 7px;
}
.lang-toggle:hover { background: rgba(255,255,255,0.12); }
.shop-topbar-cart { color: #F1E4D5; text-decoration: none; font-size: 0.9rem; position: relative; }
.cart-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 4px; margin-left: 4px;
  background: var(--accent-light); color: var(--accent-dark); font-weight: 700; font-size: 0.72rem;
  border-radius: 999px; vertical-align: middle;
}

.cart-lines { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.cart-line {
  display: grid; grid-template-columns: 56px 1fr auto auto auto; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
}
.cart-line img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; }
.cart-line-body { min-width: 0; }
.cart-line-name { margin: 0; font-size: 0.92rem; font-weight: 600; }
.cart-line-price { margin: 2px 0 0; font-size: 0.78rem; color: var(--muted); }
.cart-line-qty { margin: 0; }
.cart-line-qty .qty-input { width: 52px; margin: 0; }
.cart-line-subtotal { font-weight: 700; color: var(--accent-dark); font-size: 0.9rem; white-space: nowrap; }
.cart-line-remove { margin: 0; }
.btn-remove {
  background: none; border: none; color: var(--muted); font-size: 1rem; cursor: pointer;
  padding: 4px 8px; margin: 0;
}
.btn-remove:hover { color: var(--danger); }
.cart-total-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 1.15rem; font-weight: 700; color: var(--accent-dark);
  padding: 14px 0; border-top: 1px solid var(--border); margin-bottom: 14px;
}

.checkout-cart-summary { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 18px; }
.checkout-cart-line { display: flex; justify-content: space-between; font-size: 0.9rem; padding: 4px 0; }
.checkout-cart-total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; font-weight: 700; color: var(--accent-dark); }

@media (max-width: 480px) {
  .cart-line {
    grid-template-columns: 44px 1fr auto;
    grid-template-areas: "img name remove" "img qty subtotal";
    row-gap: 6px;
  }
  .cart-line img { grid-area: img; width: 44px; height: 44px; }
  .cart-line-body { grid-area: name; }
  .cart-line-qty { grid-area: qty; }
  .cart-line-subtotal { grid-area: subtotal; justify-self: end; }
  .cart-line-remove { grid-area: remove; justify-self: end; }
}

.back-link { display: inline-block; color: var(--accent); text-decoration: none; font-size: 0.88rem; margin-bottom: 16px; }
.back-link:hover { text-decoration: underline; }

.checkout-wrap { max-width: 520px; margin: 0 auto; }
.checkout-form { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; }
.operator-choice { display: flex; gap: 12px; margin-top: 6px; }
.operator-option { display: flex; align-items: center; gap: 6px; font-size: 0.9rem; color: var(--text); margin: 0; }
.operator-option input { width: auto; }
.btn-block { display: block; width: 100%; text-align: center; }
.checkout-note { color: var(--muted); font-size: 0.8rem; text-align: center; margin: 10px 0 0; }
.form-error { background: #FBEAEA; border: 1px solid var(--danger); color: var(--danger); padding: 10px 14px; border-radius: 8px; font-size: 0.88rem; }

.status-wrap { max-width: 480px; margin: 0 auto; text-align: center; }
.status-eyebrow { color: var(--muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
.status-amount { color: var(--accent-dark); font-weight: 700; font-size: 1.3rem; margin: 0 0 18px; }
.status-box { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 26px 22px; margin-bottom: 18px; }
.status-box.status-paid { border-color: var(--success); }
.status-box.status-failed { border-color: var(--danger); }
.spinner {
  width: 30px; height: 30px; border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; margin: 0 auto 14px; animation: spin 0.8s linear infinite;
}
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

table { width: 100%; min-width: 480px; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:hover td { background: rgba(0,0,0,0.02); }
td a { color: var(--accent); text-decoration: none; font-weight: 600; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters .field { min-width: 140px; }
.filters label { margin: 0 0 3px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 0.76rem; font-weight: 600; }
.badge-PENDING { background: #FFF3D6; color: var(--warn); }
.badge-PAID { background: #E1F5E4; color: var(--success); }
.badge-PROCESSING { background: #E1EEFB; color: #1F5FA8; }
.badge-SHIPPED { background: #E6E0FB; color: #5A3FA8; }
.badge-DONE { background: #E1F5E4; color: var(--success); }
.badge-FAILED { background: #FBE1E1; color: var(--danger); }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.status-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }

.product-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }

@media (max-width: 700px) {
  .detail-grid { grid-template-columns: 1fr; }
  .topbar nav { right: 8px; left: 8px; min-width: 0; max-width: none; }
  .container { padding: 16px 12px 48px; }
  h1 { font-size: 1.25rem; }
  h2 { font-size: 1.05rem; }
  .card { padding: 14px; }
  .status-row input[type="text"] { min-width: 100%; }
  button, .btn { width: 100%; text-align: center; }
  .action-cell button, .action-cell .btn, form.action-cell, .btn-sm { width: auto; }
  .filters button[type="submit"] { width: auto; }
}
