/* ===== Sistema de pedidos — estilos (táctil, tablet/celular primero) ===== */
:root {
  --bg: #f3f1ee; --panel: #fff; --ink: #1f2430; --muted: #6b7280; --line: #e5e1dc;
  --brand: #e85d3a; --brand-d: #c94522; --ok: #1f9d55; --warn: #d97706; --bad: #dc2626; --info: #2563eb;
  --top: #1f2430; --r: 14px; --sh: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.06);
  --tap: 52px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { font: 16px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif; color: var(--ink); background: var(--bg); }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.hidden { display: none !important; }

/* ---- Topbar ---- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; padding: 0 14px; height: 56px; background: var(--top); color: #fff; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.dot { width: 18px; height: 18px; border-radius: 50%; background: var(--brand); box-shadow: inset 0 0 0 5px #fff, inset 0 0 0 9px var(--brand); display: inline-block; }
.dot.big { width: 64px; height: 64px; box-shadow: inset 0 0 0 16px #fff, inset 0 0 0 26px var(--brand); }
.mainnav { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.mainnav a { text-decoration: none; padding: 8px 12px; border-radius: 10px; color: #cfd3dc; white-space: nowrap; }
.mainnav a.on { background: rgba(255,255,255,.12); color: #fff; }
.topright { display: flex; align-items: center; gap: 10px; }
.topright .user { text-decoration: none; color: #cfd3dc; white-space: nowrap; font-size: 14px; }
.chip { display: inline-block; padding: 4px 10px; border-radius: 99px; background: rgba(255,255,255,.12); font-size: 13px; }
.sucsel select { background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 10px; padding: 6px 8px; }
.sucsel option { color: #000; }
@media (max-width: 640px) {
  .topbar { gap: 8px; padding: 0 8px; }
  .brand span:not(.dot), .brand { font-size: 0; } .brand .dot { font-size: 16px; }
  .topright .user { font-size: 0; } .topright .user::after { content: "⏻"; font-size: 18px; }
  .mainnav a { padding: 8px 9px; font-size: 15px; }
}

/* ---- Botones ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 16px; border-radius: 12px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 600; text-decoration: none; user-select: none; touch-action: manipulation; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:disabled { background: #e7b6a8; border-color: #e7b6a8; cursor: not-allowed; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.block { width: 100%; }
.btn.lg { min-height: 60px; font-size: 19px; border-radius: 14px; }
.btn.sm { min-height: 36px; padding: 4px 10px; font-size: 14px; border-radius: 10px; }
.btn.round { width: 44px; padding: 0; border-radius: 50%; font-size: 22px; }

/* chips seleccionables */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chipbtn { min-height: var(--tap); padding: 8px 16px; border-radius: 12px; border: 2px solid var(--line); background: #fff; cursor: pointer; font-weight: 600; touch-action: manipulation; text-align: center; line-height: 1.15; }
.chipbtn small { display: block; font-weight: 500; color: var(--muted); font-size: 13px; }
.chipbtn.on { border-color: var(--brand); background: #fff1ec; color: var(--brand-d); }
.chipbtn.on small { color: var(--brand-d); }
.chipbtn:active { transform: scale(.97); }
.chipbtn.big { min-width: 96px; font-size: 18px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; background: #ece8e3; padding: 5px; border-radius: 14px; }
.seg button { min-height: 48px; border: 0; border-radius: 10px; background: transparent; font-weight: 700; font-size: 17px; cursor: pointer; }
.seg button.on { background: #fff; box-shadow: var(--sh); color: var(--brand-d); }

/* ---- Formularios ---- */
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
label > input, label > select, label > textarea { margin-top: 4px; }
input[type=text], input[type=tel], input[type=number], input[type=password], input[type=date], input[type=time], input:not([type]), select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font-size: 17px; color: var(--ink);
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }
@media (max-width: 520px) { .row, .row3 { grid-template-columns: 1fr; } }
.alert { background: #fde8e8; color: #9b1c1c; padding: 10px 12px; border-radius: 10px; margin: 8px 0; white-space: pre-line; }
.alert.info { background: #e8f0fe; color: #1e3a8a; }
.alert.okc { background: #e6f6ec; color: #14532d; }

/* ---- Login ---- */
.login-body { display: grid; place-items: center; min-height: 100vh; background: var(--top); padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: #fff; padding: 28px 24px; border-radius: 20px; text-align: center; }
.login-card h1 { margin: 10px 0 0; font-size: 24px; }
.login-card label { text-align: left; }
.login-card button { margin-top: 18px; }

/* ===== POS ===== */
.pos { display: grid; grid-template-columns: 1fr 400px; height: calc(100vh - 56px); height: calc(100dvh - 56px); }
.menu { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.rubros { display: flex; gap: 8px; padding: 10px 12px; overflow-x: auto; scrollbar-width: none; background: var(--bg); border-bottom: 1px solid var(--line); flex-shrink: 0; }
.rubros::-webkit-scrollbar { display: none; }
@media (min-width: 901px) { .rubros { flex-wrap: wrap; overflow: visible; } .rubro { min-height: 42px; padding: 6px 14px; } }
.rubro { flex-shrink: 0; min-height: 46px; padding: 8px 16px; border-radius: 99px; border: 0; background: #fff; font-weight: 700; cursor: pointer; box-shadow: var(--sh); white-space: nowrap; border-left: 6px solid var(--c, var(--brand)); }
.rubro.on { background: var(--c, var(--brand)); color: #fff; }
.search-wrap { padding: 8px 12px 0; }
.search-wrap input { min-height: 42px; font-size: 16px; }
.grid { flex: 1; overflow-y: auto; padding: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; align-content: start; -webkit-overflow-scrolling: touch; }
.prod { position: relative; display: flex; flex-direction: column; justify-content: space-between; min-height: 96px; padding: 12px; border-radius: var(--r); border: 0; background: #fff; box-shadow: var(--sh); text-align: left; cursor: pointer; border-top: 5px solid var(--c, var(--brand)); touch-action: manipulation; }
.prod:active { transform: scale(.97); }
.prod b { font-size: 16px; line-height: 1.2; }
.prod .pr { color: var(--muted); font-size: 14px; margin-top: 6px; }
.prod .qty { position: absolute; top: -6px; right: -6px; min-width: 26px; height: 26px; border-radius: 13px; background: var(--brand); color: #fff; font-weight: 700; font-size: 14px; display: grid; place-items: center; padding: 0 6px; }
.rubro-title { grid-column: 1/-1; margin: 8px 2px 0; font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.cart { display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); min-height: 0; }
.cart-head { padding: 12px; border-bottom: 1px solid var(--line); }
.cli-card { margin-top: 10px; display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: #f7f5f2; cursor: pointer; border: 2px dashed var(--line); min-height: 60px; }
.cli-card.set { border-style: solid; border-color: transparent; background: #f0f7f2; }
.cli-card .ic { font-size: 22px; }
.cli-card .t { flex: 1; min-width: 0; }
.cli-card .t b { display: block; }
.cli-card .t span { display: block; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-items { flex: 1; overflow-y: auto; padding: 6px 12px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.ci { display: flex; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ci .info { flex: 1; min-width: 0; cursor: pointer; }
.ci .info b { display: block; font-size: 15px; }
.ci .info span { display: block; font-size: 13px; color: var(--muted); }
.ci .info .nota { color: var(--warn); }
.ci .pr { font-weight: 700; white-space: nowrap; min-width: 70px; text-align: right; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: #fff; font-size: 20px; font-weight: 700; cursor: pointer; touch-action: manipulation; }
.stepper span { min-width: 22px; text-align: center; font-weight: 700; }
.extras { padding: 8px 12px; border-top: 1px solid var(--line); background: #faf9f7; }
.extras h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .05em; }
.extras .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.extras .chipbtn { min-height: 44px; padding: 6px 12px; font-size: 14px; flex-shrink: 0; white-space: nowrap; }
.totals { padding: 10px 12px; border-top: 1px solid var(--line); }
.totals .l { display: flex; justify-content: space-between; padding: 2px 0; color: var(--muted); }
.totals .l.desc { color: var(--ok); }
.totals .l.tot { color: var(--ink); font-size: 22px; font-weight: 800; padding-top: 6px; }
.totals .avisos { color: var(--warn); font-size: 14px; }
.cart-foot { padding: 0 12px 12px; display: grid; grid-template-columns: auto 1fr; gap: 8px; }
.mbar { display: none; }

@media (max-width: 900px) {
  .pos { grid-template-columns: 1fr; }
  .cart { position: fixed; inset: 56px 0 0 0; z-index: 25; transform: translateY(100%); transition: transform .25s; border-left: 0; }
  .cart.open { transform: none; }
  .cart .closecart { display: inline-flex !important; }
  .mbar { display: flex; position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 20; }
  .mbar .btn { flex: 1; justify-content: space-between; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
  .grid { padding-bottom: 90px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
@media (max-width: 380px) { .grid { grid-template-columns: 1fr 1fr; } }

/* ---- Modal ---- */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(20,22,28,.55); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .15s; }
.modal { width: 100%; max-width: 620px; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: #fff; border-radius: 20px; overflow: hidden; animation: pop .18s; }
.modal.wide { max-width: 820px; }
.modal header { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal header h3 { margin: 0; flex: 1; font-size: 20px; }
.modal .body { padding: 14px 16px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.modal footer { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.modal footer .btn.primary { flex: 1; }
.modal h4 { margin: 16px 0 8px; font-size: 15px; display: flex; gap: 8px; align-items: baseline; }
.modal h4:first-child { margin-top: 0; }
.modal h4 .req { font-size: 12px; font-weight: 600; color: var(--muted); }
.modal h4 .req.falta { color: var(--bad); }
@media (max-width: 640px) {
  .modal-bg { padding: 0; align-items: flex-end; }
  .modal { max-height: 94vh; max-height: 94dvh; border-radius: 20px 20px 0 0; }
  .modal footer { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}
@keyframes fade { from { opacity: 0 } }
@keyframes pop { from { transform: translateY(20px); opacity: 0 } }

.list-sel { display: grid; gap: 8px; }
.list-sel button { text-align: left; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: #fff; cursor: pointer; min-height: var(--tap); }
.list-sel button.on { border-color: var(--brand); background: #fff1ec; }
.list-sel button b { display: block; }
.list-sel button span { font-size: 14px; color: var(--muted); }
.big-num { font-size: 26px; letter-spacing: .04em; font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 12px; z-index: 80; font-weight: 600; animation: pop .15s; pointer-events: none; max-width: 90vw; text-align: center; }
.okbig { text-align: center; padding: 20px 0; }
.okbig .n { font-size: 64px; font-weight: 800; color: var(--brand); line-height: 1; }

/* ===== Pedidos (tablero) ===== */
.page { padding: 14px; max-width: 1400px; margin: 0 auto; }
.page-h { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.page-h h1 { margin: 0; font-size: 22px; flex: 1; min-width: 160px; }
.filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: none; }
.filters .chipbtn { min-height: 42px; padding: 6px 14px; flex-shrink: 0; }
.filters .chipbtn .n { display: inline-block; min-width: 22px; margin-left: 4px; border-radius: 11px; background: #ece8e3; font-size: 13px; padding: 0 6px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.pcard { background: #fff; border-radius: var(--r); box-shadow: var(--sh); padding: 12px; border-left: 6px solid var(--st, #999); display: flex; flex-direction: column; gap: 8px; }
.pcard .top { display: flex; align-items: center; gap: 8px; }
.pcard .num { font-size: 24px; font-weight: 800; }
.pcard .tipo { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 6px; background: #ece8e3; }
.pcard .tipo.d { background: #e0ecff; color: #1e40af; }
.pcard .t { margin-left: auto; text-align: right; font-size: 13px; color: var(--muted); }
.pcard .t b { display: block; font-size: 16px; color: var(--ink); }
.pcard .t.late b { color: var(--bad); }
.pcard .cli b { display: block; }
.pcard .cli span { font-size: 14px; color: var(--muted); display: block; }
.pcard ul { margin: 0; padding-left: 18px; font-size: 14px; }
.pcard .acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.pcard .acts .btn { flex: 1; min-width: 90px; }
.pcard .estado { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--st); }
.pcard.anulado { opacity: .55; }
.st-cocina { --st: #d97706; } .st-listo { --st: #2563eb; } .st-en_camino { --st: #7c3aed; } .st-entregado { --st: #1f9d55; } .st-anulado { --st: #9ca3af; } .st-pendiente { --st: #6b7280; }
.agente { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; padding: 6px 10px; border-radius: 99px; background: #fff; box-shadow: var(--sh); }
.agente i { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); display: inline-block; }
.agente.on i { background: var(--ok); }
.warnprint { color: var(--warn); font-size: 13px; font-weight: 600; }
pre.ticket { background: #fffef8; border: 1px dashed #ccc; padding: 12px; font: 13px/1.25 ui-monospace, Menlo, Consolas, monospace; white-space: pre; overflow-x: auto; border-radius: 8px; }

/* ===== Admin ===== */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.admin-tile { display: block; padding: 18px; background: #fff; border-radius: var(--r); box-shadow: var(--sh); text-decoration: none; }
.admin-tile b { display: block; font-size: 18px; margin-bottom: 4px; }
.admin-tile span { color: var(--muted); font-size: 14px; }
.admin-tile .ic { font-size: 26px; display: block; margin-bottom: 6px; }
.card { background: #fff; border-radius: var(--r); box-shadow: var(--sh); padding: 14px; margin-bottom: 14px; }
.card h2 { margin: 0 0 10px; font-size: 18px; }
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; padding: 8px; border-bottom: 2px solid var(--line); white-space: nowrap; }
.tbl td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr.off td { opacity: .5; }
.tbl td.num, .tbl th.num { text-align: right; white-space: nowrap; }
.tbl input, .tbl select { min-height: 40px; padding: 6px 8px; font-size: 15px; }
.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 6px; background: #ece8e3; font-weight: 600; }
.tag.g { background: #e6f6ec; color: #14532d; } .tag.r { background: #fde8e8; color: #9b1c1c; } .tag.b { background: #e0ecff; color: #1e40af; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 14px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 16px; min-height: 48px; margin: 10px 0 0; }
.check input { width: 22px; height: 22px; }
.days { display: flex; gap: 4px; flex-wrap: wrap; }
.days label { margin: 0; display: flex; align-items: center; gap: 4px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); }
.subrows .sr { display: grid; grid-template-columns: 1.2fr 1fr 2fr auto auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.subrows .sr.op { grid-template-columns: 2fr 1fr auto auto auto; }
.subrows .sr input { min-height: 44px; }
.subrows .sr .h { font-size: 12px; color: var(--muted); text-transform: uppercase; }
@media (max-width: 640px) {
  .subrows .sr, .subrows .sr.op { grid-template-columns: 1fr 1fr; padding: 8px; background: #faf9f7; border-radius: 10px; }
  .subrows .sr.hd { display: none; }
  .subrows .sr input[name$="[composicion]"] { grid-column: 1/-1; }
}
.actions-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* Dashboard */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: #fff; border-radius: var(--r); box-shadow: var(--sh); padding: 14px; }
.kpi span { display: block; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.kpi b { display: block; font-size: 28px; margin: 4px 0 2px; }
.kpi i { font-style: normal; font-size: 13px; font-weight: 600; }
.kpi i.up { color: var(--ok); } .kpi i.down { color: var(--bad); }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dash-grid .card { margin: 0; }
.dash-grid .full { grid-column: 1/-1; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }
.bar-row { display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.bar-row .rk { color: var(--muted); font-weight: 700; }
.bar-row .nm { min-width: 0; }
.bar-row .nm div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .bar { height: 6px; border-radius: 3px; background: var(--brand); margin-top: 4px; opacity: .8; }
.bar-row .v { text-align: right; white-space: nowrap; font-weight: 700; }
.bar-row .v small { display: block; font-weight: 500; color: var(--muted); }
.chart-box { position: relative; height: 280px; }
.heat { display: grid; gap: 3px; font-size: 12px; }
.heat div { padding: 6px 2px; text-align: center; border-radius: 4px; }

/* PWA */
#offline-bar { position: sticky; top: 0; z-index: 90; background: var(--bad); color: #fff; text-align: center; padding: 8px 12px; font-weight: 600; font-size: 14px; }
