:root {
  --bg: #F5F4EF;
  --surface: #FFFFFF;
  --ink: #16201B;
  --muted: #6E7771;
  --faint: #9AA29C;
  --brand: #0F3D2E;
  --brand-light: #26543F;
  --brand-700: #14503C;
  --brand-300: #3E6B5A;
  --accent: #C99A3B;
  --accent-soft: #F3E7CC;
  --pos: #2F7D5B;
  --pos-soft: #E4F0EA;
  --neg: #B4472E;
  --neg-soft: #F6E6E0;
  --line: #E7E5DD;
  --line-strong: #DAD7CD;
  --shadow: 0 1px 2px rgba(22,32,27,.04), 0 8px 24px -12px rgba(22,32,27,.12);
  --radius: 14px;
}

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

html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
}

.serif {
  font-family: 'Fraunces', Georgia, serif;
}

/* Header / Navbar */
.header {
  background: var(--brand);
  color: #D7E3DC;
  padding: 16px 32px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 4px 20px rgba(15, 61, 46, 0.15);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(150deg, var(--accent), #E0BE74);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px -4px rgba(201,154,59,.7);
}

.header-logo svg {
  width: 18px;
  height: 18px;
}

.header-name {
  font-family: 'Fraunces';
  font-weight: 600;
  font-size: 18px;
  color: #fff;
}

.header-name span {
  color: var(--accent);
}

.header-nav {
  display: flex;
  gap: 24px;
  align-items: center;
}

.header-nav a {
  font-size: 14px;
  font-weight: 500;
  color: #B9CCC2;
}

.header-nav a:hover, .header-nav a.active {
  color: #fff;
}

.header-nav .cart-link {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s;
}

.header-nav .cart-link:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.2);
}

.header-nav .cart-link .count {
  background: var(--accent);
  color: #2A2008;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
}

/* Layout container */
.container {
  max-width: 1200px;
  width: 100%;
  margin: 32px auto;
  padding: 0 24px;
  flex: 1;
}

/* Alerts */
.alert {
  padding: 14px 20px;
  border-radius: var(--radius);
  margin-bottom: 24px;
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}

.alert-success {
  background: var(--pos-soft);
  color: var(--pos);
  border: 1px solid rgba(47, 125, 91, 0.15);
}

.alert-error {
  background: var(--neg-soft);
  color: var(--neg);
  border: 1px solid rgba(180, 71, 46, 0.15);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-brand {
  background: var(--brand);
  color: #fff;
}

.btn-brand:hover {
  background: var(--brand-700);
}

.btn-accent {
  background: var(--accent);
  color: #2A2008;
}

.btn-accent:hover {
  background: #E0BE74;
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-secondary:hover {
  border-color: var(--line-strong);
  background: #FAF9F5;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12.5px;
  border-radius: 8px;
}

.btn-full {
  width: 100%;
}

/* Forms */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 11px 14px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  border-color: var(--brand-300);
  box-shadow: 0 0 0 3px rgba(15, 61, 46, 0.08);
}

/* Catalog page */
.catalog-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 32px;
}

.filters-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  height: fit-content;
  position: sticky;
  top: 100px;
}

.filters-title {
  font-family: 'Fraunces';
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.filter-section {
  margin-bottom: 20px;
}

.filter-section h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 10px;
}

.filter-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-item {
  font-size: 13.5px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.products-title h1 {
  font-family: 'Fraunces';
  font-size: 24px;
  font-weight: 600;
}

.products-title p {
  font-size: 13px;
  color: var(--muted);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: 10px;
  width: 320px;
  box-shadow: var(--shadow);
}

.search-box input {
  border: none;
  background: none;
  outline: none;
  width: 100%;
  font-size: 13.5px;
  color: var(--ink);
}

.search-box svg {
  width: 16px;
  height: 16px;
  color: var(--faint);
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.product-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: var(--shadow);
  transition: transform 0.2s, border-color 0.2s;
}

.product-card:hover {
  transform: translateY(-4px);
  border-color: var(--line-strong);
}

.product-image {
  aspect-ratio: 4/3;
  width: 100%;
  background: #F8F8F5;
  border-radius: 10px;
  margin-bottom: 12px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.product-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
}

.product-image .placeholder {
  color: var(--faint);
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 11px;
}

.product-image .placeholder svg {
  width: 24px;
  height: 24px;
  margin-bottom: 4px;
}

.product-brand {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 4px;
}

.product-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
  min-height: 44px;
}

.product-stock {
  font-size: 11.5px;
  margin-bottom: 12px;
  font-weight: 500;
}

.product-stock.ok {
  color: var(--pos);
}

.product-stock.low {
  color: var(--neg);
}

.product-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: auto;
}

.product-price-box {
  display: flex;
  flex-direction: column;
}

.product-price-label {
  font-size: 9.5px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.product-price {
  font-family: 'Fraunces';
  font-size: 18px;
  font-weight: 600;
  color: var(--brand);
}

.product-price span {
  font-size: 13px;
  font-weight: 500;
  margin-right: 2px;
}

.product-tier-badge {
  font-size: 9px;
  background: var(--pos-soft);
  color: var(--pos);
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
  display: inline-block;
  margin-top: 2px;
  width: fit-content;
}

.product-badge-mayorista {
  background: var(--accent-soft);
  color: #9A7521;
}

/* Detail page */
.detail-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 48px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}

.detail-img-box {
  background: #F8F8F5;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  aspect-ratio: 4/3;
  width: 100%;
  overflow: hidden;
}

.detail-img-box img {
  max-width: 100%;
  max-height: 100%;
}

.detail-info {
  display: flex;
  flex-direction: column;
}

.detail-brand {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
}

.detail-name {
  font-family: 'Fraunces';
  font-size: 32px;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 8px;
}

.detail-sku {
  font-family: 'JetBrains Mono';
  font-size: 12px;
  color: var(--faint);
  margin-bottom: 16px;
}

.detail-price-card {
  background: #FBFBF8;
  border: 1px solid var(--line);
  padding: 16px 20px;
  border-radius: 10px;
  margin-bottom: 24px;
}

.detail-desc {
  font-size: 14.5px;
  color: var(--muted);
  margin-bottom: 24px;
  line-height: 1.6;
}

/* Cart Page */
.cart-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 32px;
}

.cart-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.cart-table {
  width: 100%;
  border-collapse: collapse;
}

.cart-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.cart-table td {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.cart-table tr:last-child td {
  border-bottom: none;
}

.cart-product {
  display: flex;
  align-items: center;
  gap: 14px;
}

.cart-product img {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  object-fit: cover;
  background: #F8F8F5;
}

.cart-product-info h3 {
  font-size: 14.5px;
  font-weight: 600;
}

.cart-product-info span {
  font-family: 'JetBrains Mono';
  font-size: 11.5px;
  color: var(--faint);
}

.cart-qty-form {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cart-qty-form input {
  width: 50px;
  padding: 6px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  height: fit-content;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  color: var(--muted);
  margin-bottom: 12px;
}

.summary-row.total {
  font-family: 'Fraunces';
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 14px;
}

/* Authentication layout */
.auth-box {
  max-width: 440px;
  width: 100%;
  margin: 60px auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.auth-title {
  font-family: 'Fraunces';
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 8px;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 24px;
}

/* Checkout Page */
.checkout-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 32px;
}

.qr-section {
  display: none;
  background: #FBFBF8;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 20px;
  margin-top: 16px;
  text-align: center;
}

.qr-image {
  width: 160px;
  height: 160px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 12px auto;
  display: grid;
  place-items: center;
}

/* Customer account portal */
.account-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 32px;
}

.account-sidebar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  height: fit-content;
}

.account-profile-box {
  text-align: center;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 20px;
}

.account-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--brand-light);
  color: #fff;
  font-size: 20px;
  font-weight: 600;
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
}

.account-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.account-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
}

.account-menu-item:hover, .account-menu-item.active {
  background: var(--bg);
  color: var(--brand);
}

.account-main {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

/* Tables in customer account */
.account-table {
  width: 100%;
  border-collapse: collapse;
}

.account-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.account-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}

.account-table tr:hover td {
  background: #FBFBF8;
}

/* Chip/Badge components in account */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
}

.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.badge-pendiente { background: #EFEDE6; color: var(--muted); }
.badge-preparacion { background: var(--accent-soft); color: #9A7521; }
.badge-despachado { background: #E5ECEA; color: var(--brand); }
.badge-entregado { background: var(--pos-soft); color: var(--pos); }
.badge-cancelado { background: var(--neg-soft); color: var(--neg); }

/* Footer */
.footer {
  background: var(--brand);
  color: #7FA193;
  text-align: center;
  padding: 24px;
  font-size: 12.5px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: auto;
}

/* Pagination links styling */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
}

.pagination-link {
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
}

.pagination-link.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.pagination-link.disabled {
  color: var(--faint);
  pointer-events: none;
}

/* Detail specs table */
.specs-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}

.specs-table td {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.specs-table td:first-child {
  font-weight: 600;
  color: var(--muted);
  width: 140px;
}

.specs-table tr:last-child td {
  border-bottom: none;
}

/* Responsiveness */
@media (max-width: 900px) {
  .catalog-grid, .cart-grid, .checkout-grid, .account-grid, .detail-grid {
    grid-template-columns: 1fr;
  }
  .filters-card {
    position: static;
  }
}

@media (max-width: 600px) {
  .header {
    padding: 16px;
  }
  .header-nav {
    gap: 12px;
  }
  .header-nav a:not(.cart-link) {
    display: none;
  }
  .container {
    padding: 0 16px;
    margin: 16px auto;
  }
}
