:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --ink: #1d1c1a;
  --muted: #6b6761;
  --line: #e4e1db;
  --brand: #e8590c;
  --brand-ink: #ffffff;
  --brand-soft: #fff1e8;
  --ok: #2b8a3e;
  --ok-soft: #e9f7ec;
  --warn: #9c6500;
  --warn-soft: #fff6df;
  --err: #c92a2a;
  --err-soft: #fdecec;
  --wa: #1f9d55;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 6px 20px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151412; --surface: #1f1e1b; --ink: #f1efea; --muted: #a39e96; --line: #34322e;
    --brand: #ff7a33; --brand-soft: #3a2518; --ok-soft: #1d3324; --warn-soft: #3a2f14; --err-soft: #3d1d1d;
    --ok: #5fd07a; --warn: #f0b64a; --err: #ff7b7b; --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
h1 { font-size: clamp(1.5rem, 3vw, 2.1rem); line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 .7rem; }
.wrap { width: min(1180px, 100% - 2rem); margin-inline: auto; }
.main { flex: 1; padding: 1.5rem 0 3rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.warn { color: var(--warn); font-weight: 600; }
.danger-text { color: var(--err) !important; }
code { background: var(--brand-soft); padding: .05rem .35rem; border-radius: 6px; font-size: .9em; }

/* header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .55rem; color: var(--ink); font-size: 1.35rem; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand b { color: var(--brand); }
.brand-mark { width: 30px; height: 30px; color: var(--brand); }
.nav { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.nav a { color: var(--ink); font-weight: 500; }
.inline { display: inline; margin: 0; }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; font-weight: 500; }
.nav .link-btn { color: var(--muted); }
.site-footer { border-top: 1px solid var(--line); padding: 1.4rem 0; color: var(--muted); font-size: .9rem; background: var(--surface); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; background: var(--brand); color: var(--brand-ink); border: 1px solid var(--brand); border-radius: 10px; padding: .62rem 1.1rem; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.danger { background: transparent; color: var(--err); border-color: var(--err); }
.btn.small { padding: .38rem .75rem; font-size: .88rem; }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn.buy { background: var(--wa); border-color: var(--wa); font-size: 1.1rem; padding: .85rem 1.4rem; width: 100%; max-width: 420px; }
.btn.buy svg { width: 22px; height: 22px; }

/* catálogo */
.hero { padding: 1rem 0 1.5rem; }
.hero p { color: var(--muted); margin: 0 0 1rem; }
.search { display: flex; gap: .5rem; max-width: 560px; }
.search input { flex: 1; }
.chips { display: flex; gap: .45rem; flex-wrap: wrap; margin-top: 1rem; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: .3rem .8rem; border-radius: 999px; font-size: .88rem; }
.chip.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.chip.static { display: inline-block; margin-bottom: .6rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.1rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--ink); box-shadow: var(--shadow); transition: transform .15s ease; display: flex; flex-direction: column; }
.card:hover { transform: translateY(-2px); text-decoration: none; }
.card-img { aspect-ratio: 1; background: var(--bg); }
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: .8rem .95rem 1rem; }
.card-body h2 { font-size: 1rem; margin: 0 0 .25rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.price { font-weight: 700; color: var(--brand); margin: .3rem 0 0; font-size: 1.1rem; }
.price.big { font-size: 1.9rem; margin: .2rem 0 1rem; }
.noimg { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: .9rem; min-height: 160px; }
.noimg.big { min-height: 360px; }
.empty { text-align: center; color: var(--muted); padding: 3rem 0; }
.pager { display: flex; justify-content: center; align-items: center; gap: 1rem; margin-top: 2rem; }

/* producto */
.back { display: inline-block; margin-bottom: 1rem; font-size: .92rem; }
.product { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 2rem; align-items: start; }
.gallery-main { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; aspect-ratio: 1; }
.gallery-main img { width: 100%; height: 100%; object-fit: contain; }
.thumbs { display: flex; gap: .5rem; margin-top: .6rem; overflow-x: auto; padding-bottom: .3rem; }
.thumb { border: 2px solid transparent; border-radius: 10px; padding: 0; background: var(--surface); cursor: pointer; flex: 0 0 72px; height: 72px; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.active { border-color: var(--brand); }
.specs { margin: 1.4rem 0; display: grid; gap: .7rem; }
.specs div { display: grid; grid-template-columns: 110px 1fr; gap: .5rem; }
.specs dt { color: var(--muted); }
.specs dd { margin: 0; }
.swatches { display: flex; gap: .5rem; flex-wrap: wrap; }
.swatch { display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--line); border-radius: 999px; padding: .15rem .6rem .15rem .3rem; font-size: .85rem; }
.dot { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0,0,0,.2); background: var(--line); display: inline-block; }
.description { border-top: 1px solid var(--line); padding-top: 1rem; overflow-wrap: anywhere; }
.description p:first-child { margin-top: 0; }
.description a:not([href]) { color: inherit; text-decoration: none; cursor: text; }

/* formularios */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem 1.4rem; box-shadow: var(--shadow); margin-bottom: 1.2rem; }
.panel h2:first-child, .panel h1:first-child { margin-top: 0; }
.panel.narrow { max-width: 420px; margin: 2rem auto; }
.form { display: grid; gap: .9rem; }
.form label { display: grid; gap: .3rem; font-size: .9rem; font-weight: 500; }
.form label.check { display: flex; align-items: center; gap: .5rem; }
input, textarea, select { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: .55rem .7rem; width: 100%; min-width: 0; }
input[type=checkbox] { width: auto; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
textarea { resize: vertical; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .9rem; align-items: end; }
.span-2 { grid-column: span 2; }
.hint { color: var(--muted); font-size: .85rem; padding-bottom: .65rem; }
.upload { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--line); }

/* avisos */
.flash { border-radius: 10px; padding: .75rem 1rem; margin-bottom: 1rem; border: 1px solid transparent; }
.flash ul { margin: .3rem 0 0; padding-left: 1.2rem; }
.flash-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.flash-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.flash-error { background: var(--err-soft); color: var(--err); border-color: color-mix(in srgb, var(--err) 30%, transparent); }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--line); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }

/* admin */
.toolbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar-actions { display: flex; gap: .5rem; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .7rem .8rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.table tr:last-child td { border-bottom: 0; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.thumb-cell { width: 64px; }
.thumb-cell img { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; }
.edit-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1.2rem; align-items: start; }
.breakdown { width: 100%; border-collapse: collapse; font-size: .92rem; }
.breakdown td { padding: .3rem 0; border-bottom: 1px dashed var(--line); }
.breakdown tr.sum td { font-weight: 700; border-bottom: 1px solid var(--line); }
.files { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .6rem; }
.files li { display: grid; gap: .15rem; overflow-wrap: anywhere; }
.row-actions { display: flex; gap: .7rem; align-items: center; }
.row-actions form { margin: 0; }
.img-admin { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .8rem; }
.img-admin figure { margin: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg); }
.img-admin img { aspect-ratio: 1; object-fit: cover; width: 100%; }
.img-admin figcaption { padding: .4rem .5rem; display: flex; justify-content: space-between; align-items: center; gap: .3rem; flex-wrap: wrap; }
/* pedidos */
.single-layout { max-width: 760px; }
.lines { display: grid; gap: .6rem; }
.line { display: grid; grid-template-columns: minmax(0, 1fr) 120px auto; gap: .7rem; align-items: end; }
.line .link-btn { padding-bottom: .7rem; }
.line + .line .lbl { display: none; }
.add-line { justify-self: start; }
.orders-search { margin: 1rem 0; }
.nowrap { white-space: nowrap; }
.order-product { display: flex; gap: .8rem; align-items: center; }
.order-product img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; flex: none; }
.comments { list-style: none; padding: 0; margin: 1.2rem 0 0; display: grid; gap: .7rem; }
.comment { border: 1px solid var(--line); border-radius: 10px; padding: .6rem .8rem; background: var(--bg); }
.comment.system { background: transparent; border-style: dashed; color: var(--muted); font-size: .9rem; }
.comment-meta { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.comment-meta form { margin: 0; }
.comment-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: .2rem; }
.table tfoot td { border-top: 1px solid var(--line); border-bottom: 0; }
.badge.st-nuevo { background: var(--brand-soft); color: var(--brand); }
.badge.st-imprimiendo { background: var(--warn-soft); color: var(--warn); }
.badge.st-listo { background: var(--ok-soft); color: var(--ok); }
.badge.st-entregado { background: var(--line); color: var(--muted); }
.badge.st-cancelado { background: var(--err-soft); color: var(--err); }
.product-picker { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: .5rem; }
.product-picker legend { font-size: .9rem; font-weight: 500; padding: 0; margin-bottom: .3rem; }
.pick-list { display: grid; gap: .4rem; max-height: 340px; overflow-y: auto; padding: .15rem; position: relative; }
.pick { display: block; cursor: pointer; }
.pick[hidden] { display: none; }
.pick input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.pick-body { display: flex; align-items: center; gap: .75rem; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.pick:hover .pick-body { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
.pick input:checked + .pick-body { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.pick input:focus-visible + .pick-body { outline: 2px solid var(--brand); outline-offset: 1px; }
.pick-img { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; flex: none; background: var(--surface); }
.pick-none { display: grid; place-items: center; color: var(--muted); border: 1px dashed var(--line); font-size: 1.2rem; }
.pick-text { display: grid; min-width: 0; line-height: 1.3; }
.pick-text b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.original .description { max-height: 260px; overflow-y: auto; font-size: .85rem; margin: .5rem 0; }
details summary { cursor: pointer; color: var(--muted); }

.formula pre { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; overflow-x: auto; font-size: .85rem; }
.error-page { text-align: center; padding: 4rem 0; }
.error-code { font-size: 4rem; font-weight: 800; color: var(--brand); margin: 0; }

.product > *, .edit-layout > * { min-width: 0; }
@media (max-width: 860px) {
  .product, .edit-layout { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .card-body { padding: .6rem .7rem .8rem; }
  .line { grid-template-columns: minmax(0, 1fr) 90px auto; }
  .table .hide-sm { display: none; }
}
