/* HUMO LIBRE · Panel de administración */
@font-face { font-family: 'Anton'; font-weight: 400; font-display: swap; src: url(../fonts/anton-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Bricolage Grotesque'; font-weight: 200 800; font-display: swap; src: url(../fonts/bricolage-grotesque-latin-opsz-normal.woff2) format('woff2'); }

:root {
  --bg: #EEF1EC; --panel: #FFFFFF; --line: #DCE2DA; --ink: #13201A; --muted: #5B6A61;
  --verde: #1DB653; --vidrio: #0F5A33; --brasa: #F07826; --noche: #0B120E; --danger: #B42318;
  --r: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 'Bricolage Grotesque', system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brasa); outline-offset: 2px; border-radius: 6px; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

.wordmark { font-family: 'Anton', Impact, sans-serif; font-size: 26px; letter-spacing: .01em; color: #fff; }
.wordmark b { font-weight: 400; color: var(--verde); }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px; border-radius: 999px; border: 1.5px solid transparent; background: none; font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn--primary { background: var(--vidrio); color: #fff; }
.btn--primary:hover { background: #0b4727; }
.btn--ember { background: var(--brasa); color: #160A02; }
.btn--quiet { background: #E3E8E1; }
.btn--quiet:hover { background: #D6DDD3; }
.btn--ghost { border-color: currentColor; opacity: .9; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--text { padding: 0 8px; min-height: 36px; color: var(--vidrio); }
.btn--text.is-danger { color: var(--danger); }
.btn--sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: progress; }
.icon { width: 40px; height: 40px; display: inline-grid; place-items: center; border: 0; border-radius: 50%; background: transparent; cursor: pointer; }
.icon:hover { background: #E3E8E1; }
.icon svg { width: 20px; height: 20px; }

/* Login */
.login { min-height: 100svh; display: grid; place-items: center; padding: 16px; background: var(--noche); }
.login__card { width: min(400px, 100%); background: var(--panel); border-radius: 24px; padding: 30px; display: grid; gap: 12px; }
.login__card .wordmark { color: var(--ink); font-size: 30px; }
.login__card h1 { margin: 6px 0 0; font-size: 26px; }
.login__card p { margin: 0; }
.demo-note { font-size: 13px; background: #FFF4EA; border-radius: 12px; padding: 10px 12px; color: #6b3a10; }
.err { color: var(--danger); font-weight: 600; font-size: 14px; margin: 0; }
.err:empty { display: none; }

/* Layout */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100svh; }
.side { position: sticky; top: 0; height: 100svh; background: var(--noche); color: #DDE4DF; padding: 22px 16px; display: flex; flex-direction: column; gap: 26px; }
.side__nav { display: grid; gap: 2px; }
.side__nav a { display: flex; align-items: center; justify-content: space-between; text-decoration: none; padding: 10px 12px; border-radius: 10px; font-weight: 600; color: #B9C4BD; }
.side__nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side__nav a[aria-current="page"] { background: rgba(29,182,83,.16); color: #fff; }
.pill { background: var(--brasa); color: #160A02; font-size: 12px; font-weight: 800; border-radius: 999px; padding: 1px 8px; }
.side__foot { margin-top: auto; display: grid; gap: 8px; }
.mode { font-size: 12.5px; color: #94A39A; }
.main { padding: 28px clamp(16px, 3vw, 40px) 60px; min-width: 0; outline: none; }
.banner { background: #FFF4EA; color: #6b3a10; border-radius: var(--r); padding: 12px 16px; margin-bottom: 18px; font-weight: 600; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }

.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.head h1 { margin: 0; font-family: 'Anton', Impact, sans-serif; font-weight: 400; font-size: 38px; text-transform: uppercase; letter-spacing: 0; }
.head p { margin: 4px 0 0; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.search { min-height: 42px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--panel); padding: 0 16px; min-width: 0; flex: 1 1 220px; max-width: 360px; }
.main, .list, .row > * { min-width: 0; }
.pname { all: unset; cursor: pointer; font-weight: 700; display: block; overflow-wrap: anywhere; }
.pname:hover { text-decoration: underline; }
.pname:focus-visible { outline: 2px solid var(--brasa); outline-offset: 2px; }
.select { min-height: 42px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--panel); padding: 0 14px; }

/* Tarjetas de cifras */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--panel); border-radius: var(--r); padding: 16px 18px; border: 1px solid var(--line); }
.kpi span { color: var(--muted); font-size: 14px; }
.kpi strong { display: block; font-size: 28px; line-height: 1.1; margin-top: 4px; letter-spacing: -.02em; }
.kpi small { color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; }
.box { background: var(--panel); border-radius: var(--r); border: 1px solid var(--line); padding: 18px; min-width: 0; }
.box h2 { margin: 0 0 12px; font-size: 17px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { font-size: 11px; fill: var(--muted); }
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.rank li { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 14px; }
.rank i { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: #E3E8E1; overflow: hidden; }
.rank i::after { content: ''; display: block; height: 100%; width: var(--w); background: var(--verde); }

/* Tablas / listas */
.list { background: var(--panel); border-radius: var(--r); border: 1px solid var(--line); overflow: hidden; }
.row { display: grid; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row--head { background: #F6F8F4; font-size: 13px; color: var(--muted); font-weight: 700; }
.row--order { grid-template-columns: 150px 1.2fr 1fr 110px 150px; cursor: pointer; }
.row--order:hover { background: #FAFBF8; }
.row--prod { grid-template-columns: 56px 1.6fr 1fr 90px repeat(3, 84px) 120px; }
.row--cat { grid-template-columns: 1.4fr 2fr 80px 84px 140px; }
.row img { width: 56px; height: 56px; object-fit: contain; border-radius: 10px; background: #F2F4EF; }
.row b { display: block; }
.row .sub { color: var(--muted); font-size: 13px; }
.code { font-family: 'Anton', Impact, sans-serif; letter-spacing: .02em; font-size: 16px; }
.status { min-height: 34px; border-radius: 999px; border: 1.5px solid var(--line); padding: 0 10px; font-weight: 700; font-size: 13px; background: var(--panel); }
.status[data-s="nuevo"] { background: #FFF1E6; border-color: #F7C9A5; color: #8A3D07; }
.status[data-s="confirmado"] { background: #E8F1FF; border-color: #B8D0F5; color: #1C4A8C; }
.status[data-s="enviado"] { background: #F1EBFF; border-color: #D3C4F5; color: #4B2E8F; }
.status[data-s="entregado"] { background: #E5F4EA; border-color: #A9DDB9; color: var(--vidrio); }
.status[data-s="cancelado"] { background: #F3F3F3; color: #666; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--panel); font-weight: 600; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip small { opacity: .65; margin-left: 4px; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 10px; }
.moves { display: flex; gap: 2px; }
.moves .icon { width: 34px; height: 34px; }

/* Interruptor */
.sw { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.sw input { appearance: none; width: 40px; height: 24px; border-radius: 999px; background: #CCD4CB; position: relative; cursor: pointer; transition: background .2s; margin: 0; flex: none; }
.sw input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.sw input:checked { background: var(--verde); }
.sw input:checked::after { transform: translateX(16px); }
.sw.is-warn input:checked { background: var(--danger); }
.sw.is-star input:checked { background: var(--brasa); }

/* Formularios */
.fld { display: grid; gap: 5px; font-weight: 700; font-size: 13.5px; min-width: 0; }
.fld input, .fld select, .fld textarea { width: 100%; min-height: 44px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; padding: 9px 12px; font-weight: 500; font-size: 15px; }
.fld textarea { min-height: 90px; resize: vertical; }
.fld input:focus, .fld select:focus, .fld textarea:focus { outline: none; border-color: var(--vidrio); }
.fld small { font-weight: 500; color: var(--muted); }
.fld.is-error input, .fld.is-error select { border-color: var(--danger); }
.fld .ferr { color: var(--danger); font-weight: 600; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.section { border-top: 1px solid var(--line); padding-top: 18px; margin-top: 18px; }
.section > h3 { margin: 0 0 4px; font-size: 16px; }
.section > p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.rep { display: grid; gap: 8px; margin-bottom: 10px; }
.rep__row { display: grid; gap: 8px; align-items: center; background: #F6F8F4; border-radius: 12px; padding: 8px; }
.rep__row input[type="text"], .rep__row input[type="number"] { min-height: 40px; border-radius: 10px; border: 1.5px solid var(--line); padding: 0 10px; background: #fff; min-width: 0; width: 100%; }
.rep__row--pres { grid-template-columns: 1fr 110px 40px; }
.rep__row--fl { grid-template-columns: 44px 1fr 1.3fr auto auto 40px; }
.rep__row input[type="color"] { width: 44px; height: 40px; border: 0; padding: 0; background: none; cursor: pointer; }
.rep__row label { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; white-space: nowrap; }
.img-field { display: grid; grid-template-columns: 120px 1fr; gap: 14px; align-items: center; }
.img-field img { width: 120px; height: 120px; object-fit: contain; border-radius: 14px; background: #F2F4EF; border: 1px solid var(--line); }
.img-field .stack { display: grid; gap: 8px; }
.settings { display: grid; gap: 16px; max-width: 880px; }
.settings .box h2 { margin-bottom: 4px; }
.settings .box > p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.checks { display: flex; flex-wrap: wrap; gap: 16px; }

/* Drawer */
dialog { border: 0; padding: 0; color: var(--ink); max-width: 100vw; max-height: 100svh; }
dialog::backdrop { background: rgba(11,18,14,.5); }
.drawer { margin: 0 0 0 auto; height: 100%; max-height: none; width: min(720px, 100vw); background: transparent; }
.drawer[open] .drawer__inner { animation: dIn .35s cubic-bezier(.22,1,.36,1); }
@keyframes dIn { from { transform: translateX(30px); opacity: 0; } }
.drawer__inner { height: 100svh; display: flex; flex-direction: column; background: var(--bg); }
.drawer__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 22px; background: var(--panel); border-bottom: 1px solid var(--line); }
.drawer__head h2 { margin: 0; font-size: 21px; }
.drawer__body { flex: 1; overflow-y: auto; padding: 20px 22px 30px; }
.drawer__foot { display: flex; gap: 8px; align-items: center; padding: 14px 22px max(14px, env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); }
.drawer__foot .spacer { flex: 1; }
.detail dl { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; margin: 0 0 16px; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; font-weight: 600; }
.items { list-style: none; padding: 0; margin: 0 0 16px; background: var(--panel); border-radius: var(--r); border: 1px solid var(--line); }
.items li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); }
.items li:first-child { border-top: 0; }
.items .tot { font-weight: 800; background: #F6F8F4; }
.msg { white-space: pre-wrap; background: #DCF8C6; color: #0B3B26; padding: 12px 14px; border-radius: 12px; font-size: 14px; }

.confirm { width: min(420px, calc(100vw - 32px)); border-radius: 20px; }
.confirm__inner { padding: 24px; }
.confirm h2 { margin: 0 0 8px; font-size: 20px; }
.confirm p { margin: 0 0 18px; color: var(--muted); }
.confirm__actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; z-index: 99; transition: .3s; pointer-events: none; max-width: calc(100vw - 32px); }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast.is-err { background: var(--danger); }

/* Responsive */
@media (max-width: 1100px) {
  .row--prod { grid-template-columns: 56px 1.6fr 90px repeat(3, 74px) 100px; }
  .row--prod .c-cat { display: none; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { min-width: 0; }
  .side { position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 14px; }
  .side .wordmark { font-size: 20px; }
  .side__nav { order: 3; width: 100%; display: flex; overflow-x: auto; gap: 4px; scrollbar-width: none; }
  .side__nav a { flex: none; padding: 8px 12px; }
  .side__foot { margin: 0 0 0 auto; display: flex; gap: 6px; }
  .side__foot .mode { display: none; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .row--head { display: none; }
  .row--order { grid-template-columns: 1fr auto; }
  .row--order .c-date, .row--order .c-del { display: none; }
  .row--prod { grid-template-columns: 56px 1fr auto; }
  .row--prod .c-cat, .row--prod .c-price { display: none; }
  .row--prod .c-tog { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px 16px; }
  .search { max-width: none; }
  .toolbar .select { flex: 1 1 160px; }
  .row--prod .c-tog-x { display: none; }
  .row--cat { grid-template-columns: 1fr auto; }
  .row--cat .c-sub, .row--cat .c-n { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .rep__row--fl { grid-template-columns: 44px 1fr 40px; }
  .rep__row--fl .c-notes { grid-column: 1 / -1; }
  .detail dl { grid-template-columns: 110px 1fr; }
}
@media (min-width: 861px) { .row--prod .c-tog { display: contents; } .row--prod .c-tog-m { display: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
