* { box-sizing: border-box; }
body { font-family: system-ui, sans-serif; margin: 0; background: #f4f4f5; color: #1a1a1a; }
#login { max-width: 320px; margin: 80px auto; display: flex; flex-direction: column; gap: 12px; padding: 24px; background: #fff; border-radius: 12px; box-shadow: 0 2px 12px rgba(0,0,0,.08); }
#login input, #login button { padding: 12px; border-radius: 8px; border: 1px solid #ccc; font-size: 16px; }
#login button { background: var(--brand-700); color: #fff; border: none; cursor: pointer; }
.keep-session { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #555; justify-content: center; }
#login .keep-session input { width: auto; padding: 0; border: none; }
.error { color: #c0271a; min-height: 18px; margin: 0; }
header { display: flex; align-items: center; gap: 16px; padding: 12px 16px; background: var(--brand-700); color: #fff; flex-wrap: wrap; }
header h1 { font-size: 20px; margin: 0; }
nav { display: flex; gap: 8px; flex-wrap: wrap; }
nav button { padding: 8px 12px; border-radius: 8px; border: none; background: rgba(255,255,255,.15); color: #fff; cursor: pointer; }
nav button.active { background: #fff; color: var(--brand-700); font-weight: 600; }
.catalog-bar { padding: 12px 16px; display: flex; gap: 8px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 16px 12px; align-items: center; }
.inline-form input, .inline-form select { padding: 8px; border-radius: 8px; border: 1px solid #ccc; }
.btn-start { background: var(--brand-700); color: #fff; border: none; padding: 8px 12px; border-radius: var(--r-sm); cursor: pointer; }
.btn-ready { background: var(--brand-700); color: #fff; border: none; padding: 8px 12px; border-radius: var(--r-sm); cursor: pointer; }
.btn-ghost { background: #eee; border: 1px solid #ccc; padding: 8px 12px; border-radius: 8px; cursor: pointer; }
.btn-danger { background: #fff; color: #c0271a; border: 1px solid #e3b7b3; padding: 6px 10px; border-radius: 8px; cursor: pointer; }
#catalog-list { padding: 0 16px 40px; }
.cat-group { background: #fff; border: 1px solid #e6e6e6; border-radius: 12px; margin-bottom: 14px; padding: 12px; }
.cat-grp-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.cat-grp-head input.cat-name { flex: 1 1 180px; padding: 6px; border-radius: 8px; border: 1px solid #ccc; font-weight: 600; }
.cat-grp-head select { padding: 6px; border-radius: 8px; border: 1px solid #ccc; }
.cat-group.inactive { opacity: .55; }
.prod-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 6px 0; border-top: 1px dashed #eee; }
.prod-row input.prod-name { flex: 1 1 160px; padding: 6px; border-radius: 8px; border: 1px solid #ccc; }
.variants { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.variant { display: flex; gap: 4px; align-items: center; background: #f7f7f7; border: 1px solid #e0e0e0; border-radius: 8px; padding: 4px 6px; }
.variant input.v-name { width: 80px; padding: 4px; border-radius: 6px; border: 1px solid #ccc; }
.variant input.v-price { width: 70px; padding: 4px; border-radius: 6px; border: 1px solid #ccc; text-align: right; }
.empty { color: #888; font-style: italic; padding: 6px 0; }
.muted { color: #666; font-size: 13px; }

/* --- KDS (Cocina / Barra) — sistema azul + glanceability --- */
.kds-bar { padding: var(--s-3) var(--s-4); display: flex; gap: var(--s-4); align-items: center; flex-wrap: wrap; }
.kds-served { display: flex; gap: 6px; align-items: center; font-size: 15px; }
.kds-status { color: var(--muted); font-size: 13px; }
.kds-board { padding: 0 var(--s-4) 40px; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--s-4); }

.kds-ticket { background: var(--surface); border: 1px solid var(--border); border-left: 6px solid var(--border); border-radius: var(--r-lg); padding: 0 0 var(--s-3); overflow: hidden; box-shadow: var(--shadow-card); }
.kds-ticket-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); padding: var(--s-3); background: var(--bg); border-bottom: 1px solid var(--border); }
.kds-mesa-big { font-size: 2rem; font-weight: 800; color: var(--text); line-height: 1; }

/* Cronómetro de antigüedad (canal independiente del estado) */
.kds-age { font-size: 14px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.kds-age--warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.kds-age--danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }

.kds-prog { font-size: .9rem; color: var(--muted); margin: var(--s-2) var(--s-3) 0; }
.kds-prog.full { color: var(--ok); font-weight: 700; }

.kds-items { list-style: none; margin: var(--s-2) 0 0; padding: 0 var(--s-3); display: flex; flex-direction: column; gap: 6px; }
.kds-item { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; padding: 8px; border-radius: var(--r-sm); background: var(--bg); }
.kds-item.done { opacity: .5; text-decoration: line-through; }
.kds-qty { font-weight: 700; min-width: 28px; font-size: 1.05rem; }
.kds-name { flex: 1 1 auto; }
.kds-variant { color: var(--muted); font-weight: 400; }
.kds-notes { color: var(--danger); font-size: 13px; width: 100%; }
.kds-toggle { margin-left: auto; }
.kds-anulado { color: var(--danger); font-weight: 800; margin-left: 6px; }
.kds-item-anulado .kds-name { text-decoration: line-through; opacity: .7; }

.kds-actions { display: flex; gap: var(--s-2); margin: var(--s-3) var(--s-3) 0; flex-wrap: wrap; }
.kds-actions .btn-primary, .kds-actions .btn-ok, .kds-actions .btn-danger { flex: 1 1 auto; min-height: var(--tap); }
.k-done { color: var(--ok); font-weight: 700; align-self: center; }

/* Banda + acento de estado (canal de estado del ticket) */
.kds-ticket.ks-en_preparacion { border-left-color: var(--warn); }
.kds-ticket.ks-en_preparacion .kds-ticket-head { background: var(--warn-bg); border-bottom-color: var(--warn-border); }
.kds-ticket.ks-lista { border-left-color: var(--ok); }
.kds-ticket.ks-lista .kds-ticket-head { background: var(--ok-bg); border-bottom-color: var(--ok-border); }
.kds-ticket.barra.bar-ready { border-left-color: var(--ok); opacity: .75; }
.kds-ticket.barra.bar-ready .kds-ticket-head { background: var(--ok-bg); border-bottom-color: var(--ok-border); }

/* --- Caja --- */
.caja-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.caja-open { display: flex; flex-direction: column; gap: 6px; }
.caja-sales p { margin: 4px 0; }
.caja-tot { font-size: 1.1rem; }
.caja-clo { display: flex; gap: 16px; padding: 4px 0; border-bottom: 1px solid #eee; }
.ap-flag { font-size: .8rem; font-weight: normal; margin-left: .75rem; }

/* (estilos KDS unificados arriba en el bloque azul) */

/* ---- Caja: cuentas expandidas (Bloque 3) ---- */
.caja-acct { display: block; border: 1px solid #d8d8d8; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; background: #fff; }
.ca-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.ca-head .ca-mesa { font-weight: 700; font-size: 1.05rem; }
.ca-head .ca-rounds-count { color: #666; font-size: .85rem; }
.ca-head .ca-total { margin-left: auto; font-weight: 700; }
.ca-head .ca-wai { color: #555; font-size: .85rem; }
.ca-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.ca-rounds-box { display: flex; flex-direction: column; gap: 8px; }
.ca-round { border-left: 3px solid var(--brand-700); padding: 4px 0 4px 10px; }
.ca-round.cancelled { border-left-color: #b33; opacity: .6; }
.ca-round-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.ca-round-items { list-style: none; margin: 4px 0 0; padding: 0; }
.ca-item { display: grid; grid-template-columns: 2.2em 1fr auto auto 1.2em auto; gap: 8px; align-items: baseline; padding: 1px 0; }
.ca-item.done { color: var(--ok); }
.ca-item .ci-qty { color: #444; }
.ca-item .ci-price { font-variant-numeric: tabular-nums; }
.ronda-anulada { color: #b33; font-style: italic; }
.ca-anulado { color: var(--danger); text-decoration: line-through; opacity: .85; }
.ca-anulado .ci-price { text-decoration: none; font-weight: 700; }
.ca-cancel-item { font-size: .8rem; padding: 2px 6px; }
.anular-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.anular-name { font-weight: 700; }
.ca-item .ci-station, .ca-item .ci-state { text-align: center; }

/* --- Camareros --- */
.cam-row { border: 1px solid #ddd; border-radius: 8px; padding: 10px 12px; margin: 8px 0; }
.cam-head { display: flex; align-items: center; gap: 8px; }
.cam-name { font-weight: 600; }
.cam-badge { font-size: 12px; padding: 1px 8px; border-radius: 10px; }
.cam-on { background: var(--ok-bg); color: var(--ok); }
.cam-off { background: #f1f1f1; color: #888; }
.cam-off-btn { margin-left: auto; }
.cam-clave { margin: 4px 0; font-size: 0.9rem; }
.cam-clave-edit { margin-left: 8px; }
.cam-clave-input { width: 140px; }

/* Ranking de rondas de hoy (s27) */
#cam-ranking { margin: 8px 0 16px; }
.cam-rk-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.cam-rk-head h3 { margin: 0; }
.cam-rk-sum { color: var(--muted); font-size: 14px; font-weight: 600; }
.cam-rk-empty { color: var(--muted); }
.cam-rk-list { display: flex; flex-direction: column; gap: 6px; }
.cam-rk-row {
  display: grid;
  grid-template-columns: 24px 14px minmax(80px, 1fr) 84px 1.5fr 1.5fr;
  align-items: center; gap: 8px;
  padding: 6px 10px; border: 1px solid var(--border);
  border-radius: var(--r-sm); background: var(--surface);
}
.cam-rk-pos { font-weight: 700; color: var(--muted); text-align: center; }
.cam-rk-dot { width: 12px; height: 12px; border-radius: 999px; display: inline-block; }
.cam-rk-name { font-weight: 600; }
.cam-rk-count { font-weight: 700; color: var(--brand-700); white-space: nowrap; }
.cam-rk-track { background: var(--bg); border-radius: 999px; height: 10px; overflow: hidden; }
.cam-rk-bar { display: block; height: 100%; border-radius: 999px; }
.cam-rk-sec { font-size: 13px; color: var(--muted); }
.cam-rk--0 { background: var(--wc-0); }
.cam-rk--1 { background: var(--wc-1); }
.cam-rk--2 { background: var(--wc-2); }
.cam-rk--3 { background: var(--wc-3); }
.cam-rk--4 { background: var(--wc-4); }
.cam-rk--5 { background: var(--wc-5); }
.cam-rk--6 { background: var(--wc-6); }
.cam-rk--7 { background: var(--wc-7); }

/* ---- Modal de comanda (Bloque 3) ---- */
.cm-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-start; justify-content: center; padding: 24px 12px; overflow-y: auto; z-index: 50; }
.cm-overlay[hidden] { display: none; }
.cm-dialog { background: #fff; border-radius: 12px; width: min(680px, 100%); padding: 16px; box-shadow: 0 8px 30px rgba(0,0,0,.3); }
.cm-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cm-head h3 { margin: 0; }
.cm-code-bar { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; background: var(--brand-100); border-radius: var(--r-sm); padding: 8px 12px; margin-bottom: 10px; }
.cm-code-label { font-weight: 600; color: var(--brand-900); }
.cm-code-val { font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: 1px; color: var(--brand-900); }
.cm-code-hint { color: var(--muted); font-size: .82rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip:not(.chip--sel):hover { background: #e8e8e8; }
.add-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; padding: 8px; background: #f7f7f7; border-radius: 8px; }
.add-form .add-label { font-weight: 600; }
.cm-cart { margin-top: 10px; border-top: 1px solid #e3e3e3; padding-top: 8px; }
.cm-cart h4 { margin: 0 0 6px; }
#cm-cart-list { list-style: none; margin: 0; padding: 0; }
.cart-line { display: grid; grid-template-columns: 2.2em 1fr auto auto; gap: 8px; align-items: baseline; padding: 2px 0; }
.cart-line .cl-notes { grid-column: 2 / 3; color: #777; font-size: .82rem; }
.cm-cart-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.cm-note { color: #888; font-size: .8rem; margin: 6px 0 0; }

/* ---- Picker de mesa para Nueva comanda (Bloque 3) ---- */
.cm-tables-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; margin-top: 8px; }
.tile .t-num { font-weight: 700; font-size: 1.1rem; }

/* ---------- Pestaña Ventas (analítica) ---------- */
.ventas-controls { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-bottom: 1rem; }
.period-btns button { margin-right: .25rem; }
.period-btns button.active { background: var(--brand-700); color: #fff; }
.period-range { display: flex; gap: .35rem; align-items: center; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); padding: .8rem 1rem; text-align: center; }
.kpi.hero { background: var(--brand-700); color: #fff; }
.kpi-num { font-size: 1.6rem; font-weight: 700; }
.kpi-lbl { font-size: .8rem; opacity: .8; }
.ventas-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.panel-block { background: #fff; border: 1px solid #e2e2e2; border-radius: 8px; padding: .75rem 1rem; }
.panel-block h3 { margin: 0 0 .6rem; font-size: 1rem; }
.bar-row { display: grid; grid-template-columns: 7rem 1fr auto; gap: .5rem; align-items: center; margin: .25rem 0; font-size: .85rem; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--bg); border-radius: 4px; height: 14px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--brand-500); }
.bar-val { white-space: nowrap; font-variant-numeric: tabular-nums; }
.bar-val small { color: #888; }
table.rank { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.rank th, table.rank td { text-align: left; padding: .2rem .4rem; border-bottom: 1px solid #eee; }
table.rank td:nth-child(2), table.rank td:nth-child(3),
table.rank th:nth-child(2), table.rank th:nth-child(3) { text-align: right; font-variant-numeric: tabular-nums; }
.histo { display: flex; align-items: flex-end; gap: 2px; height: 90px; }
.histo .h { flex: 1; background: var(--brand-300); border-radius: 2px 2px 0 0; }
.histo .h.peak { background: var(--brand-700); }
.histo-x { display: flex; justify-content: space-between; font-size: .7rem; color: #888; margin-top: .25rem; }
.histo-cap { font-size: .8rem; margin: .4rem 0 0; }
.histo-cap.empty { color: #888; }
.tile .t-state { font-size: .78rem; color: #555; }
nav button.locked::after { content: ' 🔒'; opacity: .8; }
#owner-gate { max-width: 320px; margin: 16px auto; display: flex; flex-direction: column; gap: 10px; padding: 16px; background: #fff; border: 1px solid var(--brand-100, #dbe3ff); border-radius: 12px; }
#owner-gate input { padding: 12px; border-radius: 8px; border: 1px solid #ccc; font-size: 16px; }
.accesos-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.accesos-hint { color: #666; font-size: 14px; margin: 4px 0 16px; }
.accesos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.cartel { background: #fff; border: 1px solid var(--brand-100, #dbe3ff); border-radius: 16px;
          padding: 20px; text-align: center; }
.cartel-qr { width: 180px; height: 180px; image-rendering: pixelated; }
.cartel-titulo { font-size: 18px; font-weight: 700; color: var(--brand-700, #1d4ed8); margin-top: 12px; }
.cartel-sub { font-size: 13px; color: #555; margin-top: 6px; }
.cartel-url { font-size: 11px; color: #999; margin-top: 8px; word-break: break-all; }

.cm-libre-form { display: flex; flex-direction: column; gap: 8px; }

@media print {
  body * { visibility: hidden; }
  #accesos-view, #accesos-view * { visibility: visible; }
  #accesos-view { position: absolute; inset: 0; }
  .accesos-head, .accesos-hint { display: none; }
  .accesos-grid { display: block; }
  .cartel { page-break-after: always; border: none; height: 100vh; box-sizing: border-box;
            display: flex; flex-direction: column; align-items: center; justify-content: center; }
  .cartel-qr { width: 60vw; height: 60vw; max-width: 480px; max-height: 480px; }
  .cartel-titulo { font-size: 32px; margin-top: 24px; }
  .cartel-sub { font-size: 18px; }
  .cartel-url { font-size: 14px; }
}

/* Pie legal RGPD (s33) */
.legal-footer { text-align: center; padding: 14px 8px; font-size: .82rem; }
.legal-footer a { color: var(--muted); text-decoration: none; }
.legal-footer a:hover { text-decoration: underline; }
