/* Comanda · panel de pizzería. Barra lateral oscura en PC, barra inferior en celular. */
:root {
  --bg: #F4F3F1;
  --surface: #FFFFFF;
  --surface-2: #FAF9F7;
  --ink: #1F1B17;
  --muted: #6E675F;
  --line: #E4E0DA;
  --accent: #D2382B;
  --accent-ink: #FFFFFF;
  --accent-soft: #FBE7E4;
  --basil: #2E7D4F;
  --side: #1F1B17;
  --side-ink: #EDE8E2;
  --side-muted: #A39A90;
  --good: #23784A; --good-bg: #E2F3E8;
  --warn: #A25E00; --warn-bg: #FCEFD7;
  --bad: #B52B22; --bad-bg: #FBE3E0;
  --info: #2C5DA8; --info-bg: #E3ECFA;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(31,27,23,.06), 0 4px 14px rgba(31,27,23,.06);
  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-body: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121110; --surface: #1C1A18; --surface-2: #22201D; --ink: #F1ECE6; --muted: #A99F95; --line: #322E2A;
    --accent: #F0584A; --accent-ink: #1A0D0B; --accent-soft: #3A1C18; --basil: #5CC38A;
    --side: #0C0B0A; --side-ink: #EDE8E2; --side-muted: #8E857C;
    --good: #66D196; --good-bg: #15301F; --warn: #F2B14E; --warn-bg: #382A10; --bad: #F48A80; --bad-bg: #3B1A17; --info: #8DB4F5; --info-bg: #1B2740;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121110; --surface: #1C1A18; --surface-2: #22201D; --ink: #F1ECE6; --muted: #A99F95; --line: #322E2A;
  --accent: #F0584A; --accent-ink: #1A0D0B; --accent-soft: #3A1C18; --basil: #5CC38A;
  --side: #0C0B0A; --side-ink: #EDE8E2; --side-muted: #8E857C;
  --good: #66D196; --good-bg: #15301F; --warn: #F2B14E; --warn-bg: #382A10; --bad: #F48A80; --bad-bg: #3B1A17; --info: #8DB4F5; --info-bg: #1B2740;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--f-body); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }
h1, h2, h3 { font-family: var(--f-display); margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: 26px; line-height: 1.15; }
h2 { font-size: 18px; }
h3 { font-size: 15.5px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Estructura ---------- */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100%; }
.side { background: var(--side); color: var(--side-ink); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 10px 16px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; flex: none; }
.brand b { display: block; font-family: var(--f-display); font-size: 16px; line-height: 1.1; }
.brand span { font-size: 12px; color: var(--side-muted); }
.navbtn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 9px; background: transparent; color: var(--side-ink); cursor: pointer; text-align: left; font-weight: 600; font-size: 14.5px; }
.navbtn:hover { background: rgba(255,255,255,.07); }
.navbtn[aria-current="page"] { background: rgba(255,255,255,.12); }
.navbtn[aria-current="page"] svg { color: var(--accent); }
.navbtn .count { margin-left: auto; background: var(--accent); color: #fff; font-size: 11.5px; padding: 0 7px; border-radius: 999px; }
.side .sep { height: 1px; background: rgba(255,255,255,.08); margin: 8px 6px; }
.side .grow { flex: 1; }
.syncchip { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--side-muted); padding: 8px 10px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--side-muted); flex: none; }
.dot[data-s="ok"] { background: #4CC37F; } .dot[data-s="error"] { background: #F07A6E; } .dot[data-s="syncing"] { background: #F2B14E; }
main.content { padding: 24px 28px 48px; min-width: 0; }
.page { display: grid; gap: 18px; max-width: 1280px; margin: 0 auto; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.pagehead p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.bottomnav { display: none; }
.topbar { display: none; }

/* ---------- Componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; align-content: start; }
.card.flush { padding: 0; overflow: hidden; }
.cardhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px; position: relative; overflow: hidden; }
.kpi .l { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi .v { font-family: var(--f-display); font-size: 27px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi .s { font-size: 12.5px; color: var(--muted); }
.kpi[data-s]::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--line); }
.kpi[data-s="good"]::before { background: var(--good); } .kpi[data-s="warn"]::before { background: var(--warn); } .kpi[data-s="bad"]::before { background: var(--bad); } .kpi[data-s="accent"]::before { background: var(--accent); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 9px; padding: 8px 13px; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.wa { background: #1E8E4E; border-color: #1E8E4E; color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 9px; font-size: 13px; border-radius: 7px; }
.btn.lg { padding: 12px 18px; font-size: 15.5px; border-radius: 11px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.iconbtn { width: 34px; height: 34px; padding: 0; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill[data-s="good"] { background: var(--good-bg); color: var(--good); }
.pill[data-s="warn"] { background: var(--warn-bg); color: var(--warn); }
.pill[data-s="bad"] { background: var(--bad-bg); color: var(--bad); }
.pill[data-s="info"] { background: var(--info-bg); color: var(--info); }
.pill[data-s="accent"] { background: var(--accent-soft); color: var(--accent); }

.field { display: grid; gap: 5px; min-width: 0; }
.field > label, .lbl { font-size: 13px; font-weight: 600; color: var(--muted); }
.input, input[type="text"], input[type="number"], input[type="tel"], input[type="email"], input[type="password"], input[type="date"], input[type="time"], input[type="datetime-local"], input[type="url"], input[type="search"], select, textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; font-size: 14.5px; min-width: 0;
}
textarea { resize: vertical; min-height: 70px; }
input[type="number"] { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .field { flex: 1 1 160px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 11px; border-radius: 7px; font-weight: 600; font-size: 13.5px; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; font-weight: 600; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.check input.switch { width: 40px; height: 23px; }
.switch { appearance: none; width: 40px; height: 23px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; transition: background .15s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch:checked { background: var(--basil); }
.switch:checked::after { transform: translateX(17px); }

table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
.t th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t .r { text-align: right; }
.t tr.click { cursor: pointer; }
.t tr.click:hover td { background: var(--surface-2); }
.tablewrap { overflow-x: auto; }

.empty { text-align: center; color: var(--muted); padding: 26px 12px; font-size: 14px; }
.list { display: grid; gap: 8px; }
.li { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.li .grow { flex: 1; min-width: 0; }
.li .t1 { font-weight: 700; }
.li .t2 { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; color: #fff; flex: none; font-family: var(--f-display); }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.alert[data-s="bad"] { background: var(--bad-bg); color: var(--bad); }
.alert[data-s="warn"] { background: var(--warn-bg); color: var(--warn); }
.alert[data-s="good"] { background: var(--good-bg); color: var(--good); }
.alert[data-s="info"] { background: var(--info-bg); color: var(--info); }
.alert b { white-space: nowrap; }

/* ---------- Tablero de pedidos ---------- */
.board { display: grid; grid-template-columns: repeat(4, minmax(230px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; display: grid; gap: 10px; align-content: start; min-height: 220px; }
.colhead { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px; }
.colhead h3 { font-size: 14.5px; display: flex; gap: 8px; align-items: center; }
.colhead .bar { width: 10px; height: 10px; border-radius: 3px; }
.ocard { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 11px; display: grid; gap: 8px; box-shadow: var(--shadow); }
.ocard.late { border-color: var(--bad); }
.ocard .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.ocard .no { font-family: var(--f-display); font-weight: 700; font-size: 16px; }
.ocard .items { font-size: 13.5px; color: var(--ink); display: grid; gap: 1px; }
.ocard .meta { display: flex; gap: 6px; flex-wrap: wrap; }
.ocard .foot { display: flex; gap: 6px; flex-wrap: wrap; }
.ocard .note { font-size: 12.5px; background: var(--warn-bg); color: var(--warn); padding: 4px 8px; border-radius: 6px; }

/* ---------- Nuevo pedido ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 18px; align-items: start; }
.menugrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.mitem { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 8px; }
.mitem .head { display: flex; gap: 10px; align-items: center; }
.mitem .sw { width: 34px; height: 34px; border-radius: 9px; flex: none; display: grid; place-items: center; color: #fff; font-weight: 800; font-family: var(--f-display); }
.mitem h3 { font-size: 15px; line-height: 1.2; }
.sizes { display: flex; gap: 6px; flex-wrap: wrap; }
.sizebtn { flex: 1 1 auto; border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 6px 8px; cursor: pointer; text-align: center; font-size: 12.5px; font-weight: 600; line-height: 1.2; }
.sizebtn b { display: block; font-size: 14px; font-variant-numeric: tabular-nums; }
.sizebtn:hover { border-color: var(--accent); background: var(--accent-soft); }
.ticket { position: sticky; top: 16px; }
.tline { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.qty { display: inline-flex; align-items: center; gap: 4px; }
.qty button { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 800; }
.qty span { min-width: 20px; text-align: center; font-weight: 700; }
.totals { display: grid; gap: 4px; font-size: 14.5px; }
.totals div { display: flex; justify-content: space-between; }
.totals .grand { font-family: var(--f-display); font-size: 22px; font-weight: 700; padding-top: 6px; border-top: 1px solid var(--line); }

.mobiletotal { display: none; }
@media (max-width: 1100px) { .mobiletotal { display: flex; position: sticky; bottom: -18px; margin: 0 -18px -18px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); justify-content: space-between; align-items: center; gap: 10px; z-index: 2; } }
.prodgrid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 620px), 1fr)); }

/* ---------- Gráficas ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--f-body); }
.chart .grid line { stroke: var(--line); }
.chart .bar { fill: var(--accent); }
.chart .bar.dim { fill: var(--line); }
.chart .val { fill: var(--ink); font-weight: 700; }
.hbar { display: grid; grid-template-columns: minmax(110px, 1.2fr) 2fr auto; gap: 10px; align-items: center; font-size: 13.5px; }
.hbar .track { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.hbar .track span { display: block; height: 100%; background: var(--accent); border-radius: 5px; }

/* ---------- Horarios ---------- */
.sched { display: grid; grid-template-columns: 130px repeat(7, minmax(84px, 1fr)) 90px; gap: 6px; align-items: center; min-width: 900px; }
.sched .h { font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; }
.slot { border: 1px solid var(--line); border-radius: 8px; padding: 5px; display: grid; gap: 3px; background: var(--surface); font-size: 12px; }
.slot.off { background: var(--surface-2); opacity: .7; }
.slot input[type="time"] { padding: 3px 4px; font-size: 12px; border-radius: 6px; }

/* ---------- Diálogos y avisos ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15,12,10,.5); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--bg); border-radius: 16px; width: min(720px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; display: grid; gap: 14px; padding: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { width: min(1080px, 100%); }
.modalhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; position: sticky; top: -18px; background: var(--bg); padding: 6px 0; z-index: 1; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); font-weight: 600; font-size: 14px; max-width: 360px; }
.preview { white-space: pre-wrap; background: var(--surface); border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
code { background: var(--surface-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 5px; font-size: 13px; }

/* ---------- Celular ---------- */
@media (max-width: 1100px) {
  .pos { grid-template-columns: 1fr; }
  .ticket { position: static; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .topbar { display: flex; position: sticky; top: 0; z-index: 20; background: var(--side); color: var(--side-ink); padding: calc(10px + env(safe-area-inset-top)) 14px 10px; align-items: center; gap: 10px; }
  .topbar .brand-mark { width: 30px; height: 30px; border-radius: 8px; }
  .topbar b { font-family: var(--f-display); font-size: 16px; flex: 1; }
  main.content { padding: 16px 14px calc(92px + env(safe-area-inset-bottom)); }
  .bottomnav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottomnav button { border: 0; background: transparent; display: grid; justify-items: center; gap: 2px; font-size: 11px; font-weight: 700; color: var(--muted); padding: 4px 0; cursor: pointer; position: relative; }
  .bottomnav button[aria-current="page"] { color: var(--accent); }
  .bottomnav .plus { width: 46px; height: 46px; border-radius: 14px; background: var(--accent); color: #fff; display: grid; place-items: center; margin-top: -18px; box-shadow: 0 6px 16px rgba(210,56,43,.35); }
  .bottomnav .badge { position: absolute; top: 0; right: calc(50% - 20px); background: var(--accent); color: #fff; font-size: 10px; padding: 0 5px; border-radius: 999px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  h1 { font-size: 22px; }
  .board { grid-template-columns: repeat(4, 82vw); scroll-snap-type: x mandatory; }
  .col { scroll-snap-align: start; }
  .modal { border-radius: 16px 16px 0 0; align-self: end; max-height: 94vh; }
  .overlay { padding: 0; place-items: end stretch; }
  .toasts { left: 12px; right: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); }
}
@media (max-width: 420px) { .g4 { grid-template-columns: 1fr 1fr; } .kpi .v { font-size: 22px; } }
@media (prefers-reduced-motion: no-preference) {
  .modal { animation: pop .16s ease-out; }
  @keyframes pop { from { transform: translateY(8px); opacity: .6; } to { transform: none; opacity: 1; } }
}
@media print {
  .side, .bottomnav, .topbar, .actions, .btn { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
}
