:root {
  --bg: #ffffff;
  --bg-alt: #f6f6f4;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e5e4;
  --brand: #136f63;
  --brand-ink: #0d4f46;
  --warn: #b91c1c;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: none; }

.container { max-width: 1280px; margin: 0 auto; padding: 0 1rem; }

/* Layout de 3 zonas */
.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  padding: 1.25rem 0 3rem;
}
@media (min-width: 1024px) {
  .layout { grid-template-columns: 250px minmax(0, 1fr); }
}
.aside-left { display: none; }
@media (min-width: 1024px) { .aside-left { display: block; } }
.content { min-width: 0; }

/* Header */
.header {
  background: var(--ink);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 40;
}
.header-inner {
  display: grid;
  gap: 0.6rem;
  padding: 0.7rem 0;
}
@media (min-width: 1024px) {
  .header-inner { grid-template-columns: auto 1fr auto auto; align-items: center; }
}
.brand { font-weight: 800; font-size: 1.25rem; letter-spacing: 0.02em; color: #fff; }
.search-form { display: flex; gap: 0.4rem; }
.search-form input[type=search] {
  flex: 1;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.95rem;
}
.btn {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--brand-ink); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.header-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

.locale-switch { display: flex; gap: 0.15rem; font-size: 0.85rem; }
.locale-switch a {
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  color: #d6d3d1;
}
.locale-switch a.active { background: #fff; color: var(--ink); font-weight: 700; }

.context-form { display: flex; gap: 0.35rem; align-items: center; }
.context-form select { padding: 0.4rem; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.context-form label { font-size: 0.75rem; color: #d6d3d1; }

/* Cards */
.cards {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.card:hover { box-shadow: 0 6px 18px rgba(0,0,0,0.09); transform: translateY(-2px); }
.card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--bg-alt); }
.card-body { padding: 0.6rem 0.75rem 0.8rem; display: flex; flex-direction: column; gap: 0.25rem; }
.card-title { font-weight: 600; font-size: 0.95rem; line-height: 1.25; min-height: 2.4em; }
.card-meta { color: var(--muted); font-size: 0.75rem; }
.card-price { font-weight: 800; color: var(--brand-ink); font-size: 1rem; margin-top: auto; }

/* Sidebar derecha (off-canvas) */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 60;
  display: none;
}
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(92vw, 400px);
  background: #fff;
  z-index: 70;
  transform: translateX(100%);
  transition: transform 0.2s ease;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 24px rgba(0,0,0,0.15);
}
.drawer.open { transform: translateX(0); }
.drawer-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}
.drawer-body { flex: 1; overflow-y: auto; padding: 1rem 1.1rem; }

/* Menú lateral */
.menu { list-style: none; margin: 0; padding: 0; }
.menu li { margin: 0.15rem 0; }
.menu a { display: block; padding: 0.45rem 0.6rem; border-radius: 8px; }
.menu a:hover { background: var(--bg-alt); }
.menu .sub { list-style: none; padding-left: 1rem; }

/* Vista de producto */
.product-grid { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
@media (min-width: 900px) { .product-grid { grid-template-columns: 1fr 1fr; } }
.product-gallery img { width: 100%; border-radius: 12px; }
.thumbnails { display: flex; gap: 0.5rem; margin-top: 0.5rem; overflow-x: auto; }
.thumbnails img { width: 72px; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.price-lg { font-size: 1.6rem; font-weight: 800; color: var(--brand-ink); }
.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.badge.parent { background: #eef2ff; color: #3730a3; }
.badge.orphan { background: #ecfdf5; color: #065f46; }

/* Listados comerciales */
.section-title { font-size: 1.2rem; font-weight: 800; margin: 1.25rem 0 0.75rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.toolbar select { padding: 0.45rem; border-radius: 8px; border: 1px solid var(--line); }

.pagination { display: flex; gap: 0.35rem; justify-content: center; margin-top: 2rem; flex-wrap: wrap; }
.pagination a, .pagination span {
  min-width: 2.2rem; text-align: center; padding: 0.45rem 0.2rem;
  border-radius: 8px; border: 1px solid var(--line);
}
.pagination .current { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Footer */
.footer { border-top: 1px solid var(--line); background: var(--bg-alt); padding: 2rem 0; margin-top: 2rem; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; color: var(--muted); font-size: 0.85rem; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }
.grid-collapsible { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.grid-collapsible summary { cursor: pointer; padding: 0.7rem 1rem; font-weight: 700; background: var(--bg-alt); }

table.spec { width: 100%; border-collapse: collapse; }
table.spec th, table.spec td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); }
table.spec th { color: var(--muted); font-weight: 600; width: 40%; }

.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }

/* Carrito */
.cart-lines { display: flex; flex-direction: column; gap: 0.9rem; }
.cart-line { border: 1px solid var(--line); border-radius: 10px; padding: 0.6rem 0.75rem; display: flex; flex-direction: column; gap: 0.35rem; }
.cart-line-name { font-weight: 600; }
.cart-line-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.cart-line-subtotal { color: var(--muted); font-size: 0.85rem; }
.cart-line-remove { align-self: flex-end; }
.cart-delay { font-size: 0.8rem; font-weight: 700; color: var(--brand-ink); background: #ecfdf5; padding: 0.1rem 0.5rem; border-radius: 999px; }
.qty-input { width: 4.5rem; padding: 0.45rem; border-radius: 8px; border: 1px solid var(--line); }
.badge.warn { background: #fef2f2; color: var(--warn); }
.card-add { padding: 0 0.75rem 0.75rem; }
.card-add .btn { width: 100%; justify-content: center; }

/* Checkout */
.checkout-fields { display: grid; gap: 0.7rem; grid-template-columns: 1fr; padding: 0.8rem 1rem; }
@media (min-width: 640px) { .checkout-fields { grid-template-columns: 1fr 1fr; } }
.checkout-fields label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; font-weight: 600; }
.checkout-fields input { padding: 0.5rem 0.7rem; border-radius: 8px; border: 1px solid var(--line); }
.checkout-payments { padding: 0.8rem 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.payment-option { display: flex; gap: 0.5rem; align-items: center; border: 1px solid var(--line); padding: 0.6rem 0.8rem; border-radius: 8px; cursor: pointer; }
.checkout-form .btn { margin-top: 0.75rem; }

.header-user { color: #d6d3d1; font-size: 0.85rem; }
.login-form { max-width: 22rem; display: flex; flex-direction: column; gap: 0.7rem; margin-top: 0.5rem; }
.login-form label { display: flex; flex-direction: column; gap: 0.25rem; font-weight: 600; font-size: 0.9rem; }
.login-form input { padding: 0.5rem 0.7rem; border-radius: 8px; border: 1px solid var(--line); }
.badge.ok { background: #ecfdf5; color: #065f46; }

.banner { background: #eef2ff; border: 1px solid #c7d2fe; border-radius: 10px; padding: 0.7rem 1rem; margin: 1rem 0; }
.banner-footer { background: transparent; border: none; padding: 0; margin: 1rem 0 0; color: var(--muted); font-size: 0.85rem; }
.blocked-page { max-width: 34rem; margin-top: 4rem; text-align: center; }
.blocked-page h1 { color: var(--warn); }
