:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efede8;
  --ink: #1d1c1a;
  --ink-2: #5d5a54;
  --ink-3: #8f8b83;
  --line: #e2dfd8;
  --accent: #0f6e5c;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1ed;
  --sale: #c2410c;
  --sale-soft: #fdeee5;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn-soft: #fff5d6;
  --shadow: 0 1px 2px rgba(20, 18, 14, .06), 0 4px 16px rgba(20, 18, 14, .06);
  --shadow-lg: 0 10px 40px rgba(20, 18, 14, .18);
  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 22px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Tienda: fondos de secciones y tonos para las tarjetas de categoría */
  --hero-bg: #e8f2ee;
  --hero-ink: #0b3d33;
  --warn: #a15c00;
  --tint-1: #e9f1ec; --tint-2: #f6ebe3; --tint-3: #ebeaf5; --tint-4: #f3eedd; --tint-5: #e6eef4; --tint-6: #f5e6ec;
  /* Escala de espacios (rejilla de 4/8 px) */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141412;
    --surface: #1d1d1a;
    --surface-2: #272723;
    --ink: #f1efea;
    --ink-2: #b9b5ad;
    --ink-3: #85817a;
    --line: #34332e;
    --accent: #3cc3a5;
    --accent-ink: #08261f;
    --accent-soft: #173a32;
    --sale: #fb923c;
    --sale-soft: #3b2417;
    --danger: #f97066;
    --danger-soft: #3d1d1a;
    --warn-soft: #3a3115;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, .5);
    --hero-bg: #16302a;
    --hero-ink: #e3f4ee;
    --warn: #f5b649;
    --tint-1: #1e2a25; --tint-2: #2b231e; --tint-3: #23222e; --tint-4: #2a271c; --tint-5: #1e2731; --tint-6: #2d2026;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  text-decoration: none; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.icon { width: 40px; padding: 0; }
.btn svg { width: 18px; height: 18px; flex: none; }

.input, .select, textarea.input {
  height: 40px; padding: 0 12px; width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.field { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: var(--surface-2); color: var(--ink-2);
}
.badge.sale { background: var(--sale); color: #fff; }
.badge.ok { background: var(--accent-soft); color: var(--accent); }
.badge.off { background: var(--danger-soft); color: var(--danger); }

/* Diálogos */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15, 14, 12, .5); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: fade .15s ease;
}
.dialog {
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg);
  width: min(980px, 100%); max-height: calc(100dvh - 32px); overflow: auto; position: relative;
  animation: pop .18s ease;
}
.dialog-close { position: absolute; top: 12px; right: 12px; z-index: 2; }
@keyframes fade { from { opacity: 0 } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.99) } }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80;
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-weight: 600; font-size: 14px; box-shadow: var(--shadow-lg);
  animation: pop .18s ease; max-width: calc(100% - 32px); text-align: center;
}
.toast.err { background: var(--danger); color: #fff; }

.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite; margin: 60px auto;
}
@keyframes spin { to { transform: rotate(360deg) } }
