:root {
  --ink: #311714;
  --muted: #76584f;
  --red: #aa151b;
  --red-dark: #741315;
  --orange: #ef6a22;
  --gold: #f2b629;
  --cream: #fff8e9;
  --paper: #fffdf8;
  --line: #ead8c5;
  --shadow: 0 22px 70px rgba(79, 29, 20, .14);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0, rgba(255, 220, 74, .24), transparent 24rem),
    linear-gradient(180deg, #fffdf8, #fff7e8);
  font-family: "DM Sans", sans-serif;
}
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  min-height: 82px;
  padding: 10px clamp(18px, 4vw, 62px);
  border-bottom: 1px solid rgba(115, 49, 36, .12);
  background: rgba(255, 253, 248, .93);
  backdrop-filter: blur(16px);
}
.brand img { display: block; width: 138px; height: auto; }
.topbar-center { min-width: 0; display: flex; justify-content: center; }
.topbar nav { display: flex; justify-content: center; gap: 8px; }
.topbar nav a, .support {
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 700;
}
.topbar nav a[aria-current="page"] { background: #f8e5c4; color: var(--red-dark); }
.support { border: 1px solid var(--line); }
.topbar-account {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 7px 18px;
  border: 1px solid #ead4af;
  border-radius: 14px;
  background: #fff8e9;
  line-height: 1.15;
}
.topbar-account span {
  color: var(--red);
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.topbar-account strong {
  max-width: min(42vw, 520px);
  overflow: hidden;
  color: var(--ink);
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-account small { color: var(--muted); font-size: .78rem; font-weight: 700; }
body.merchant-authenticated .topbar-center nav { display: none; }

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, .92fr) minmax(520px, 1.08fr);
  gap: clamp(30px, 5vw, 78px);
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: clamp(48px, 7vw, 96px) 0;
  align-items: start;
}
.portal-intro { position: sticky; top: 130px; padding: 30px 0; }
.eyebrow {
  margin: 0 0 10px;
  color: var(--red);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.portal-intro h1, .merchant-header h1, .catalog-heading h2, .auth-card h2, .cart-head h2 {
  margin: 0;
  font-family: "Fraunces", serif;
  line-height: .98;
}
.portal-intro h1 { font-size: clamp(3.5rem, 7vw, 6.4rem); }
.portal-intro h1 em { color: var(--red); font-style: normal; }
.portal-intro > p:not(.eyebrow) { max-width: 580px; color: var(--muted); font-size: 1.08rem; line-height: 1.7; }
.portal-intro ul { display: grid; gap: 12px; padding: 0; margin: 30px 0; list-style: none; }
.portal-intro li { display: flex; gap: 10px; line-height: 1.5; }
.portal-intro li::before { content: "✓"; color: #2e7c45; font-weight: 900; }
.trust-card {
  display: flex;
  gap: 14px;
  max-width: 480px;
  padding: 18px;
  border: 1px solid #ead4af;
  border-radius: 18px;
  background: rgba(255, 255, 255, .68);
}
.trust-card > span { display: grid; place-items: center; flex: 0 0 38px; height: 38px; border-radius: 50%; background: #e4f4e7; color: #27703d; font-weight: 900; }
.trust-card p { margin: 0; color: var(--muted); line-height: 1.5; }

.auth-card {
  padding: clamp(26px, 5vw, 48px);
  border: 1px solid rgba(145, 82, 54, .16);
  border-radius: 30px;
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow);
}
.auth-card h2 { font-size: clamp(2.2rem, 4vw, 3.4rem); }
.helper { margin: 12px 0 28px; color: var(--muted); line-height: 1.55; }
form { display: grid; gap: 18px; }
fieldset { display: grid; gap: 16px; padding: 0; border: 0; margin: 0; }
fieldset + fieldset { padding-top: 22px; border-top: 1px solid var(--line); }
legend { margin-bottom: 16px; font-weight: 800; font-size: 1.05rem; }
label { display: grid; gap: 7px; color: #4f2b24; font-size: .9rem; font-weight: 700; }
input, textarea, select {
  width: 100%;
  border: 1px solid #d9c6b6;
  border-radius: 13px;
  background: #fffefa;
  color: var(--ink);
  padding: 13px 14px;
  font-size: 1rem;
  outline: none;
  transition: .2s ease;
}
input:focus, textarea:focus, select:focus { border-color: var(--orange); box-shadow: 0 0 0 4px rgba(239, 106, 34, .12); }
label small { color: var(--muted); font-weight: 500; }
.optional-label { display: inline-flex; width: max-content; margin-left: 6px; padding: 3px 7px; border-radius: 999px; background: #f4eadf; color: var(--muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; }
.file-field input[type="file"] { padding: 9px; background: #fffaf1; color: var(--muted); }
.file-field input[type="file"]::file-selector-button { min-height: 38px; margin-right: 10px; padding: 0 13px; border: 0; border-radius: 10px; background: var(--ink); color: #fff; font-weight: 800; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.check-row { display: grid; grid-template-columns: 22px 1fr; align-items: start; gap: 10px; line-height: 1.45; }
.check-row input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--red); }
.check-row.compact { font-size: .82rem; font-weight: 600; }
.primary-button, .secondary-button, .back-button, .pay-button, .cart-toggle, .logout-button, .add-button {
  border: 0;
  cursor: pointer;
  font-weight: 800;
}
.primary-button, .secondary-button { min-height: 51px; border-radius: 999px; }
.primary-button, .pay-button { background: linear-gradient(135deg, var(--red), var(--orange)); color: white; box-shadow: 0 12px 26px rgba(151, 36, 28, .22); }
.secondary-button { width: 100%; border: 1px solid #dac3b0; background: #fff; color: var(--ink); }
.back-button { padding: 8px 0; margin: 0 0 24px; background: transparent; color: var(--red); }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 26px 0 16px; color: var(--muted); font-size: .82rem; }
.auth-divider::before, .auth-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.form-error { margin: 0; padding: 12px 14px; border-radius: 12px; background: #fff0ef; color: #9c2025; font-size: .9rem; font-weight: 700; }
.status-panel { text-align: center; padding: 38px 0; }
.status-icon { display: grid; place-items: center; width: 70px; height: 70px; margin: 0 auto 20px; border-radius: 50%; background: #e5f5e9; color: #27703d; font-size: 2rem; font-weight: 900; }
.status-panel p:not(.eyebrow) { margin: 16px auto 28px; max-width: 390px; color: var(--muted); line-height: 1.6; }
.eligibility-warning, .registration-warning { padding: 17px 18px; border: 1px solid #e7c36c; border-radius: 16px; background: #fff2bf; }
.eligibility-warning { max-width: 480px; margin-top: 18px; }
.eligibility-warning p, .registration-warning p { margin: 6px 0 0; color: var(--muted); line-height: 1.5; }
.registration-warning { font-size: .9rem; }

.shop { min-height: calc(100vh - 82px); }
.merchant-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 42px max(24px, calc((100vw - 1320px) / 2));
  color: #fff;
  background:
    radial-gradient(circle at 80% 10%, rgba(255, 206, 58, .35), transparent 24rem),
    linear-gradient(135deg, #4e1514, #8b1b18 54%, #c64020);
}
.merchant-header .eyebrow { color: #ffd668; }
.merchant-header h1 { font-size: clamp(2.4rem, 5vw, 4.8rem); }
.merchant-header p:last-child { margin: 8px 0 0; color: #f7ddd7; }
.merchant-actions { display: flex; gap: 10px; }
.cart-toggle, .logout-button { min-height: 46px; padding: 0 17px; border-radius: 999px; }
.cart-toggle { background: #ffd551; color: #3b1a12; }
.cart-toggle b { display: inline-grid; place-items: center; min-width: 23px; height: 23px; margin-left: 6px; border-radius: 99px; background: #fff; }
.logout-button { border: 1px solid rgba(255,255,255,.34); background: rgba(255,255,255,.08); color: #fff; }
.merchant-main { display: grid; grid-template-columns: minmax(0, 1fr) 410px; gap: 30px; width: min(1320px, calc(100% - 36px)); margin: 0 auto; padding: 48px 0 72px; align-items: start; }
.catalog-heading { display: flex; justify-content: space-between; gap: 24px; align-items: end; margin-bottom: 22px; }
.catalog-heading h2 { font-size: clamp(2.4rem, 4vw, 4rem); }
.catalog-heading > p { max-width: 390px; margin: 0; color: var(--muted); line-height: 1.5; }
.merchant-notice { display: flex; justify-content: space-between; gap: 16px; padding: 16px 18px; margin-bottom: 22px; border: 1px solid #efd393; border-radius: 16px; background: #fff3cb; }
.merchant-notice span { color: var(--muted); }
.product-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.product-card { overflow: hidden; border: 1px solid var(--line); border-radius: 22px; background: #fff; box-shadow: 0 12px 35px rgba(83, 39, 26, .08); }
.product-image { position: relative; min-height: 210px; background: linear-gradient(145deg, #fff4c7, #f4d58b); }
.product-image img { width: 100%; height: 220px; object-fit: cover; display: block; mix-blend-mode: multiply; }
.product-badge { position: absolute; top: 14px; left: 14px; padding: 7px 10px; border-radius: 99px; background: #fff; color: var(--red); font-size: .76rem; font-weight: 800; }
.product-info { padding: 18px; }
.product-info h3 { margin: 0; font-family: "Fraunces", serif; font-size: 1.55rem; }
.product-info p { min-height: 42px; margin: 8px 0 18px; color: var(--muted); }
.product-buy { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.product-price { color: var(--red-dark); font-size: 1.35rem; font-weight: 900; }
.add-button { padding: 11px 15px; border-radius: 999px; background: var(--ink); color: #fff; }

.cart-panel { position: sticky; top: 104px; padding: 24px; border: 1px solid var(--line); border-radius: 24px; background: #fff; box-shadow: var(--shadow); }
.cart-head { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.cart-head h2 { font-size: 2.3rem; }
.cart-head button { display: none; width: 40px; height: 40px; border: 0; border-radius: 50%; background: #f8ede3; color: var(--ink); font-size: 1.7rem; }
.cart-empty { display: grid; place-items: center; padding: 46px 10px; text-align: center; }
.cart-empty > span { font-size: 2.6rem; }
.cart-empty strong { margin-top: 14px; }
.cart-empty p { margin: 6px 0 0; color: var(--muted); }
.cart-items { display: grid; gap: 10px; margin: 24px 0; }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 13px 0; border-bottom: 1px solid #eee0d4; }
.cart-line small { display: block; margin-top: 4px; color: var(--muted); }
.quantity-control { display: grid; grid-template-columns: 32px 28px 32px; align-items: center; text-align: center; }
.quantity-control button { width: 32px; height: 32px; border: 0; border-radius: 50%; background: #f4e8dc; color: var(--ink); font-size: 1.2rem; }
.checkout-form { gap: 16px; }
.choice-card { display: grid; grid-template-columns: 20px 1fr; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; }
.choice-card input { width: 18px; height: 18px; accent-color: var(--red); }
.choice-card small { display: block; margin-top: 3px; }
.billing-summary { display: grid; gap: 4px; padding: 13px; border-radius: 13px; background: #fff6de; font-size: .83rem; line-height: 1.45; }
.billing-summary span { color: var(--muted); }
.totals { display: grid; gap: 9px; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.totals > div { display: flex; justify-content: space-between; gap: 16px; }
.grand-total { padding-top: 7px; font-size: 1.25rem; }
.pay-button { display: flex; justify-content: space-between; gap: 14px; width: 100%; min-height: 54px; padding: 0 18px; border-radius: 16px; }
.pay-button:disabled { opacity: .62; cursor: wait; }
.secure-note { margin: -5px 0 0; color: var(--muted); font-size: .76rem; line-height: 1.5; text-align: center; }
.cart-backdrop { position: fixed; inset: 0; z-index: 49; background: rgba(37, 16, 14, .45); }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 80; transform: translate(-50%, 120px); padding: 12px 18px; border-radius: 999px; background: var(--ink); color: #fff; opacity: 0; transition: .25s ease; }
.toast.is-visible { transform: translate(-50%, 0); opacity: 1; }
footer { display: flex; justify-content: space-between; gap: 20px; padding: 26px clamp(18px, 4vw, 62px); border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; }
footer a { color: inherit; }

@media (max-width: 1080px) {
  .auth-shell { grid-template-columns: 1fr; max-width: 760px; }
  .portal-intro { position: static; padding-bottom: 0; }
  .merchant-main { grid-template-columns: 1fr; }
  .cart-panel { position: fixed; z-index: 50; top: 0; right: 0; width: min(430px, 94vw); height: 100vh; overflow-y: auto; border-radius: 0; transform: translateX(105%); transition: transform .25s ease; }
  .cart-panel.is-open { transform: translateX(0); }
  .cart-head button { display: block; }
}

@media (max-width: 760px) {
  .topbar { grid-template-columns: 1fr auto; min-height: 72px; gap: 10px; padding: 9px 14px; }
  .brand img { width: 112px; }
  body:not(.merchant-authenticated) .topbar-center { display: none; }
  .topbar nav { display: none; }
  .support { font-size: .75rem; padding: 9px 11px; }
  body.merchant-authenticated .topbar { grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; }
  body.merchant-authenticated .brand img { width: 74px; }
  body.merchant-authenticated .topbar-account { width: 100%; padding: 7px 8px; border-radius: 12px; }
  body.merchant-authenticated .topbar-account span { font-size: .53rem; }
  body.merchant-authenticated .topbar-account strong { max-width: 47vw; font-size: .84rem; }
  body.merchant-authenticated .topbar-account small { font-size: .68rem; }
  body.merchant-authenticated .support {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    overflow: hidden;
    padding: 0;
    font-size: 0;
  }
  body.merchant-authenticated .support::after { content: "Ayuda"; font-size: .62rem; }
  input, textarea, select { font-size: 16px; }
  .auth-shell { width: min(100% - 22px, 650px); padding: 34px 0 48px; }
  .portal-intro { padding: 10px 5px; }
  .portal-intro h1 { font-size: clamp(3.3rem, 16vw, 5rem); }
  .auth-card { border-radius: 22px; padding: 24px 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .merchant-header { align-items: flex-start; padding: 28px 18px; }
  .merchant-header h1 { font-size: 2.5rem; }
  .merchant-actions { flex-direction: column; }
  .merchant-main { width: min(100% - 22px, 720px); padding: 32px 0 56px; }
  .catalog-heading { display: grid; align-items: start; }
  .merchant-notice { display: grid; }
  .product-grid { grid-template-columns: 1fr; }
  footer { display: grid; }
}
