:root {
  --bg: #f6f6f4; --fg: #1d1d1b; --muted: #6b6b66; --card: #fff; --line: #e3e3de;
  --accent: #1d1d1b; --on-accent: #fff; --wa: #1faa59; --danger: #c0392b;
  --input: #fff; --soft: #fafaf8; --noimg: #ececE8; --sold-bg: #fde8e8; --sold-fg: #b42318;
}
/* Temas del panel de administración (se eligen en la barra superior) */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121316; --fg: #ececf0; --muted: #9a9aa6; --card: #1c1d22; --line: #2e2f37;
  --accent: #e8e8ee; --on-accent: #16161a; --input: #15161a; --soft: #17181c; --noimg: #26272e;
  --danger: #ff6b5e; --sold-bg: #3a1b1b; --sold-fg: #ff9d92;
}
html[data-theme="blue"] {
  --bg: #cfe0fa; --fg: #0f1d3a; --muted: #4a5f87; --card: #eaf2ff; --line: #a9c3ee;
  --accent: #2557c8; --on-accent: #fff; --input: #f7faff; --soft: #dbe8fc; --noimg: #bcd0f2;
  --bar-line: #2557c8;
}
html[data-theme="green"] {
  --bg: #c9e8d4; --fg: #0e2b1a; --muted: #44695a; --card: #e8f6ed; --line: #a2d1b3;
  --accent: #1b7f45; --on-accent: #fff; --input: #f5fbf7; --soft: #d6eedf; --noimg: #b4dcc3;
  --bar-line: #1b7f45;
}
html[data-theme="rose"] {
  --bg: #f6d3e1; --fg: #3a1626; --muted: #84506a; --card: #fdeaf1; --line: #ebb4ca;
  --accent: #c2377a; --on-accent: #fff; --input: #fff6fa; --soft: #f9dfe9; --noimg: #eec3d4;
  --bar-line: #c2377a;
}
html[data-theme="violet"] {
  --bg: #dcd2f5; --fg: #1f1640; --muted: #62588a; --card: #efeafc; --line: #b9aae6;
  --accent: #5e3bc4; --on-accent: #fff; --input: #faf8ff; --soft: #e4dcf8; --noimg: #cfc3f0;
  --bar-line: #5e3bc4;
}
.topbar { border-top: 4px solid var(--bar-line, transparent); }
html[data-theme="midnight"] {
  color-scheme: dark;
  --bg: #0b1220; --fg: #e2e8f5; --muted: #8a97b3; --card: #131c30; --line: #24304d;
  --accent: #4f8cff; --on-accent: #fff; --input: #0f1729; --soft: #0f1729; --noimg: #1b2742;
  --danger: #ff7a70; --sold-bg: #3a1b24; --sold-fg: #ff9d92;
}
.theme-select { width: auto; padding: 6px 8px; font-size: .85rem; }
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--fg); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 1.15rem; margin: 0; }
.topbar-actions { display: flex; gap: 8px; }
.container { max-width: 1100px; margin: 0 auto; padding: 16px; }

.btn { border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent); padding: 9px 14px; border-radius: 8px;
  font: inherit; cursor: pointer; }
.btn:hover { opacity: .9; }
.btn-ghost { background: transparent; color: var(--fg); border-color: var(--line); }
.btn-wa { background: var(--wa); border-color: var(--wa); color: #fff; width: 100%; }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 5px 9px; font-size: .85rem; }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 10px;
  background: #fff; color: var(--fg); font-size: .8rem; text-align: center; }

.filters { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 16px; }
@media (min-width: 640px) { .filters { grid-template-columns: 2fr 1fr 1fr; } }
input, select, textarea { font: inherit; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--input); color: var(--fg); width: 100%; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer;
  display: flex; flex-direction: column; }
.card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.card img, .noimg { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; background: #ececE8; display: block; }
.noimg { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .85rem; }
.card-body { padding: 10px 12px 12px; }
.card-body h3 { margin: 0 0 2px; font-size: 1rem; }
.card-body .meta { font-size: .82rem; color: var(--muted); }
.price { font-weight: 700; margin-top: 6px; }

.modal { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.5); display: flex; align-items: center;
  justify-content: center; padding: 12px; }
.modal-box { position: relative; background: var(--card); border-radius: 14px; max-width: 760px; width: 100%;
  max-height: 92vh; overflow: auto; }
.modal-grid { display: grid; grid-template-columns: 1fr; }
@media (min-width: 640px) { .modal-grid { grid-template-columns: 1fr 1fr; } }
.modal-grid img, .modal-grid .noimg { aspect-ratio: 4 / 5; }
.modal-info { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.modal-info h2 { margin: 0; }
.gallery img, .gallery .noimg { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; display: block; }
.thumbs { display: flex; gap: 6px; padding: 8px; overflow-x: auto; }
.thumbs img { width: 56px; height: 70px; aspect-ratio: auto; border-radius: 6px; cursor: pointer; opacity: .6;
  border: 2px solid transparent; flex: none; }
.thumbs img.on { opacity: 1; border-color: var(--accent); }
.label { font-size: .9rem; color: var(--muted); margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--input); color: var(--fg); border-radius: 999px; padding: 6px 14px; font: inherit;
  cursor: pointer; }
.chip.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.close { position: absolute; top: 8px; right: 10px; border: 0; background: rgba(255,255,255,.9); border-radius: 50%;
  width: 34px; height: 34px; font-size: 1.4rem; cursor: pointer; z-index: 2; }
.row { display: flex; gap: 8px; align-items: center; }
.row label { font-size: .9rem; color: var(--muted); min-width: 56px; }

.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100%); background: var(--card); z-index: 50;
  display: flex; flex-direction: column; box-shadow: -4px 0 20px rgba(0,0,0,.15); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px;
  border-bottom: 1px solid var(--line); position: relative; }
.drawer-head h2 { margin: 0; font-size: 1.1rem; }
.drawer-head .close { position: static; }
.cart-items { flex: 1; overflow: auto; padding: 8px 16px; }
.cart-item { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: center; }
.cart-item img, .cart-item .noimg { width: 56px; height: 70px; border-radius: 6px; aspect-ratio: auto; }
.cart-item .t { font-weight: 600; font-size: .95rem; }
.cart-item .m { font-size: .8rem; color: var(--muted); }
.qty { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; }
.qty button { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.cart-item .rm { border: 0; background: none; color: var(--danger); cursor: pointer; font-size: .8rem; }
.drawer-foot { padding: 14px 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.total-row { display: flex; justify-content: space-between; font-size: 1.1rem; }

/* Admin */
.admin-wrap { max-width: 1000px; margin: 0 auto; padding: 16px; display: grid; gap: 20px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.panel h2 { margin-top: 0; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .full { grid-column: 1 / -1; } }
.field-label { font-size: .9rem; margin-bottom: 6px; }
.field-label.sub { margin-top: 12px; color: var(--muted); }
.num-add { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.num-add input { max-width: 140px; }
.size-summary { margin-top: 8px; font-size: .85rem; }
#numSizes .chip { padding-right: 8px; }
#numSizes .chip span { margin-left: 4px; opacity: .7; }
.variants { display: grid; gap: 12px; margin-bottom: 10px; }
.variant { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--soft); }
.variant-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.variant-head input { flex: 1; }
.imgs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.imgs .im { position: relative; }
.imgs .im img { width: 72px; height: 90px; object-fit: cover; border-radius: 6px; display: block; }
.imgs .im button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%;
  border: 0; background: var(--danger); color: #fff; cursor: pointer; line-height: 1; }
.imgs .im.new img { outline: 2px dashed var(--wa); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); font-size: .9rem; vertical-align: middle; }
td img { width: 44px; height: 55px; object-fit: cover; border-radius: 4px; }
.table-scroll { overflow-x: auto; }
.tag-off { color: var(--muted); font-style: italic; }
.tag-sold { display: inline-block; margin-top: 4px; padding: 2px 8px; border-radius: 999px; background: var(--sold-bg); color: var(--sold-fg); font-size: .75rem; font-weight: 600; }
label.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
label.check input { width: auto; margin: 0; }
.error { color: var(--danger); font-size: .9rem; }
.login-box { max-width: 340px; margin: 18vh auto; }
.login-box .panel { display: grid; gap: 10px; }
