/* ============================================================
   TEMA v2 · 50 · COMANDAS  ·  pantalla de cocina (KDS)
   Tablero con tickets de papel (claro u oscuro según el tema global de la app):
   número de mesa gigante, franja de estado de color, cantidades en
   cajas, notas resaltadas y botones enormes. Estados: En preparación
   (ámbar) · Lista (azul) · Entregada (verde).
   ============================================================ */
html[data-route="comandas"] .page-title h2::after { background: #e8a33a; }
/* tema OSCURO: el tablero de cocina sobre carbón (igual que antes) */
html[data-theme="dark"][data-route="comandas"] .topbar { background: color-mix(in srgb, #121110 90%, transparent); box-shadow: 0 1px 0 #2e2a25; }
html[data-theme="dark"][data-route="comandas"] .page-title { background: #1f1c18; border: 1px solid #35302b; box-shadow: none; }
html[data-theme="dark"][data-route="comandas"] .page-title::after { border-color: rgba(232, 163, 58, .1); }
html[data-theme="dark"][data-route="comandas"] .cmd-volver { color: #b6ab9d; }

.cmd-toolbar { gap: 12px; margin-bottom: 22px; }
.cmd-filtros { gap: 10px; }
.cmd-fbtn { min-height: 54px; padding: 0 24px; font-size: 16px; box-shadow: none; }
.cmd-fbtn b { font-family: var(--font-num); font-size: 24px; opacity: 1; margin-left: 4px; }
.cmd-fbtn.on b { color: inherit; }
/* tema CLARO: mismos botones, sobre fondo claro */
html:not([data-theme="dark"]) .cmd-fbtn:not(.on) { background: var(--surface); border: 1.5px solid var(--border-strong); color: var(--text-muted); }
html:not([data-theme="dark"]) .cmd-fbtn b { color: var(--text); }
html:not([data-theme="dark"]) .cmd-fbtn.on { box-shadow: 0 0 0 4px rgba(0, 0, 0, .08); }
html:not([data-theme="dark"]) .cmd-fbtn.on b { color: inherit; }
html:not([data-theme="dark"]) .cmd-fbtn.f-servido:not(.on) { border-color: #25704a; color: #1a6a3e; }
/* tema OSCURO */
html[data-theme="dark"] .cmd-fbtn:not(.on) { background: #1f1c18; border: 1.5px solid #3a342e; color: #cbbfae; }
html[data-theme="dark"] .cmd-fbtn b { color: #fff; }
html[data-theme="dark"] .cmd-fbtn.on { box-shadow: 0 0 0 4px rgba(255, 255, 255, .08); }
html[data-theme="dark"] .cmd-fbtn.f-servido:not(.on) { border-color: #25704a; color: #7cd0a0; }

.cmd-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 26px 22px; align-items: start; }

/* el ticket */
.cmd-card {
  --surface: #f7f2e7; --surface-2: #ede5d2; --text: #1c1815; --text-muted: #5a5148; --text-soft: #7a6f62; --border: #d8cfbb; --border-strong: #c9bea6;
  --state: #8a8478; --state-ink: #fff;
  position: relative; border: 0; border-radius: 14px 14px 0 0; background: var(--surface); color: var(--text);
  box-shadow: 0 14px 30px rgba(0, 0, 0, .5); overflow: visible; padding-bottom: 0;
}
.cmd-card::after {
  content: ""; display: block; height: 14px; margin-top: -1px;
  background: linear-gradient(135deg, var(--surface) 7px, transparent 0) 0 0 / 14px 14px, linear-gradient(225deg, var(--surface) 7px, transparent 0) 0 0 / 14px 14px;
  filter: drop-shadow(0 8px 6px rgba(0, 0, 0, .35));
}
.cmd-card.est-pendiente { --state: #e8a33a; --state-ink: #2a1a04; border-top: 0; }
.cmd-card.est-salio { --state: #4f8de6; --state-ink: #fff; border-top: 0; }
.cmd-card.est-servido { --state: #3fae6e; --state-ink: #04200f; border-top: 0; }

.cmd-head { background: var(--state); color: var(--state-ink); border-radius: 14px 14px 0 0; padding: 14px 18px 12px; }
.cmd-mesa { font-family: var(--font-num); font-size: 46px; font-weight: 700; letter-spacing: .02em; line-height: .95; text-transform: uppercase; color: var(--state-ink); }
.cmd-badge { background: rgba(0, 0, 0, .8); color: #fff; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; padding: 7px 13px; border-radius: 999px; }
.est-pendiente .cmd-badge, .est-salio .cmd-badge, .est-servido .cmd-badge { background: rgba(0, 0, 0, .8); color: #fff; }
.cmd-when { padding: 12px 18px; margin: 0; color: var(--text); font-size: 14px; font-weight: 700; border-bottom: 2px dashed var(--border-strong); background: var(--surface); }
.cmd-when .ico { width: 18px; height: 18px; }
.cmd-when-sec { color: var(--text-muted); font-weight: 600; }
.cmd-items { border-top: 0; padding: 14px 18px; gap: 10px; background: var(--surface); }
.cmd-item { gap: 12px; align-items: center; font-size: 19px; }
.cmd-item .ci-q { font-family: var(--font-num); font-size: 30px; min-width: 52px; text-align: center; padding: 0 6px; background: #1c1815; color: #f2c46d; border-radius: 10px; line-height: 1.25; }
.cmd-item .ci-n { font-weight: 750; line-height: 1.2; }
.cmd-item .ci-p { display: none; }
.cmd-item.anul .ci-q { background: #8a8478; color: #e7dfd0; }
.cmd-obs { margin: -4px 0 0 64px; padding: 6px 12px; background: #fff0b8; color: #5a3d00; border-left: 5px solid #e0a000; border-radius: 4px 10px 10px 4px; font-size: 14px; font-weight: 700; }
.cmd-total { background: var(--surface); border-top: 2px dashed var(--border-strong); padding: 10px 18px; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }
.cmd-total b { font-family: var(--font-num); font-size: 22px; color: var(--text-muted); }
.cmd-actions { background: var(--surface); border-top: 0; padding: 4px 16px 6px; gap: 10px; }
.cmd-actions .cmd-primary { min-height: 56px; font-size: 17px; border-radius: 14px; }
.cmd-actions .btn-ghost { color: var(--text-muted); }
.cmd-actions .btn:not(.btn-primary):not(.btn-ok):not(.btn-danger) { background: #fffdf6; border-color: #bfb49b; color: #1c1815; box-shadow: 0 3px 0 #bfb49b; }
.cmd-actions .btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.cmd-lista-ok { color: #1e7a45; font-weight: 800; }
.cmd-detalle-head { align-items: center; }

/* que el ticket nunca se salga de la pantalla (nombre de mesa + estado largo en celular) */
.cmd-grid > * { min-width: 0; }
.cmd-head { flex-wrap: wrap; gap: 8px 10px; }
.cmd-card .cmd-item .ci-n { min-width: 0; overflow-wrap: anywhere; }

/* ---------- circuito de cocina y bebidas (migración 64) ---------- */
.cmd-card.est-preparando { --state: #e07a2e; --state-ink: #2a1204; border-top: 0; }
.cmd-card.est-entregada { --state: #3fae6e; --state-ink: #04200f; border-top: 0; }
.cmd-card.tipo-bebida .cmd-head { background: #2a7fa8; --state-ink: #fff; }
.cmd-card.tipo-bebida.est-entregada .cmd-head { background: #3fae6e; --state-ink: #04200f; }
html[data-theme="dark"] .cmd-fbtn.f-preparando:not(.on) { border-color: #a4561d; color: #f0a468; }
html[data-theme="dark"] .cmd-fbtn.f-bebida:not(.on) { border-color: #2a7fa8; color: #8fcbe6; }
html:not([data-theme="dark"]) .cmd-fbtn.f-preparando:not(.on) { border-color: #a4561d; color: #a4561d; }
html:not([data-theme="dark"]) .cmd-fbtn.f-bebida:not(.on) { border-color: #2a7fa8; color: #1d6d96; }
/* el ticket de papel sobre fondo claro: sombra suave y borde */
html:not([data-theme="dark"]) .cmd-card { box-shadow: 0 10px 22px rgba(48, 32, 20, .16), 0 0 0 1px var(--border-strong); }
html:not([data-theme="dark"]) .cmd-card::after { filter: drop-shadow(0 6px 5px rgba(48, 32, 20, .16)); }
.cmd-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; position: relative; }
.cmd-menu-btn { background: rgba(0, 0, 0, .22); color: var(--state-ink); border: 0; border-radius: 10px; width: 40px; height: 40px; font-size: 22px; line-height: 1; cursor: pointer; }
.cmd-menu { position: absolute; right: 12px; top: calc(100% - 4px); z-index: 5; min-width: 220px; background: #fff; color: #1c1815; border-radius: 12px; box-shadow: 0 12px 28px rgba(0, 0, 0, .45); padding: 6px; }
.cmd-menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 12px 14px; font-size: 15px; font-weight: 700; color: #b3261e; border-radius: 8px; cursor: pointer; }
.cmd-menu button:hover { background: #f6e5e3; }
.cmd-bebida-tag { font-size: 12px; letter-spacing: .12em; font-weight: 800; opacity: .9; display: block; }
.cmd-bloqueo { margin: 6px 0 0; font-size: 13px; color: #7a6f62; }

/* ---------- avisos «Pedido listo» (se ven en cualquier pantalla) ---------- */
.avisos { position: fixed; left: 12px; right: 12px; top: 12px; z-index: 400; display: flex; flex-direction: column; gap: 10px; pointer-events: none; max-width: 520px; margin: 0 auto; }
.aviso { pointer-events: auto; display: flex; align-items: center; gap: 12px; background: #1f6f43; color: #fff; border-radius: 14px; padding: 14px 14px 14px 18px; box-shadow: 0 14px 34px rgba(0, 0, 0, .4); border: 2px solid #8fe3b3; animation: aviso-in .25s ease-out; }
.aviso-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.aviso-txt b { font-size: 16px; letter-spacing: .04em; text-transform: uppercase; }
.aviso-txt span { font-size: 15px; font-weight: 600; }
.aviso-x { background: rgba(255, 255, 255, .18); color: #fff; border: 0; border-radius: 50%; width: 34px; height: 34px; font-size: 22px; line-height: 1; cursor: pointer; }
@keyframes aviso-in { from { transform: translateY(-14px); opacity: 0; } to { transform: none; opacity: 1; } }

/* botón para cambiar la hora de salida (migración 84) */
.cmd-sacar-btn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; margin-left: 4px; border: 0; border-radius: 50%; background: transparent; color: var(--text-muted); cursor: pointer; vertical-align: middle; }
.cmd-sacar-btn:hover { background: var(--accent-soft); color: var(--accent); }
.cmd-sacar-btn .ico { width: 15px; height: 15px; }

/* Cada preparación (salsa, guarnición, verduras, ensalada, nota) en su propia línea. */
.cmd-obs { white-space: pre-line; }

/* Etapa 11: un bloque con el atributo hidden (p. ej. DESDE/HASTA de Propinas fuera de RANGO) nunca se muestra, aunque su clase defina display */
.cmd-toolbar[hidden], .toolbar[hidden], .filters[hidden] { display: none !important; }

/* Etapa 11 · Propinas: pestañas HISTORIAL / MOZOS legibles y fila de mozo con aspecto de botón de la app */
#vistas .cmd-fbtn.on { background: var(--accent-solid); border-color: var(--accent-solid); color: #fffaf2; }
#vistas .cmd-fbtn { flex: 1 1 0; justify-content: center; }
.propinas-mozo { appearance: none; -webkit-appearance: none; background: transparent; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; color: var(--text); font: inherit; padding: 14px 4px; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }
.propinas-mozo:last-child { border-bottom: 0; }
.propinas-mozo:hover { background: color-mix(in srgb, var(--accent-solid) 7%, transparent); }
.propinas-mozo:focus-visible { outline: 3px solid var(--accent-solid); outline-offset: -3px; }

/* E4: estado de impresión del último envío (no bloquea nada) */
.cmd-papel { display: inline-flex; align-items: center; gap: 6px; margin: 6px 8px 0 0; font-size: 12.5px; color: #7a6f62; }
.cmd-papel .ico { width: 14px; height: 14px; }
.cmd-papel.ok { color: #2f6b3c; }
.cmd-papel.mal { color: #a4372a; font-weight: 600; }

/* E4: anulaciones pendientes de recepción */
.anul-panel { margin-bottom: 14px; padding: 10px 12px; border: 2px solid #a4372a; border-radius: 10px; background: #fff3f1; }
.anul-tit { display: flex; align-items: center; gap: 6px; font-weight: 700; color: #a4372a; margin-bottom: 6px; }
.anul-tit .ico { width: 16px; height: 16px; }
.anul-fila { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px dashed #e3b5ae; }
.anul-lista { margin: 6px 0 0 18px; padding: 0; }

/* E5: pesadas de carne pendientes de revisión */
.cc-pend-barra { margin: 0 0 8px; }
.cc-pend-fila { padding: 8px 0; border-top: 1px dashed #d9c9ad; }
.cc-pend-chip { margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: #fdecc8; color: #8a5a00; font-size: 12px; font-weight: 600; }
.cc-pend-acc { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.cc-pend-acc input { flex: 1 1 180px; min-width: 140px; }
.cc-inac { color: #a4372a; font-weight: 600; }
.cc-rect-nota { margin-top: 8px; padding: 8px 10px; border-left: 4px solid #b07a1a; background: #fdf6e6; font-size: 13px; }
.cc-rect-nota ul, .cc-rect-datos { margin: 6px 0 0 18px; padding: 0; }
@media (max-width: 640px) { .cc-pend-acc select, .cc-pend-acc button { width: 100%; } }
.cc-rect-chip { color: #8a5a00; background: #fdecc8; padding: 1px 8px; border-radius: 999px; }

/* Sonido de avisos: el navegador del celular lo permite recién después de un toque */
.aviso-sonido { position: fixed; right: 12px; bottom: 76px; z-index: 390; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 2px solid var(--accent-solid); background: var(--surface); color: var(--accent); font-weight: 800; font-size: 14px; box-shadow: var(--shadow-md); cursor: pointer; }
.aviso-sonido[hidden] { display: none; }
.aviso-sonido.is-off { border-color: var(--border-strong); color: var(--text-muted); }
.aviso-sonido.is-pendiente { background: var(--accent-soft); }
@media (max-width: 640px) { .aviso-sonido { min-height: 48px; font-size: 15px; } }

/* Propinas manuales (administrador) */
.pm-barra { display: flex; flex-wrap: wrap; gap: 8px; }
.pm-barra .btn { min-height: 46px; }
.pm-fila.pm-anulada { opacity: .6; }
.pm-fila details summary { cursor: pointer; font-size: 13px; color: var(--text-muted); }

/* T12: entrega por producto (botón verde chico) y lista para elegir qué eliminar. */
.cmd-item .ci-entregar { margin-left: auto; padding: 2px 8px; min-height: 28px; background: var(--ok-solid, #3f7d2a); border-color: var(--ok-solid, #3f7d2a); color: #fff; }
.cmd-item .ci-entregar .ico { width: 14px; height: 14px; }
.cmd-item .ci-entregado { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: var(--ok, #3f7d2a); }
.cmd-item .ci-entregado .ico { width: 14px; height: 14px; }
.cmd-item.entregado .ci-n { text-decoration: none; color: var(--ok, #3f7d2a); }
.elim-lista { display: flex; flex-direction: column; gap: 6px; max-height: 38vh; overflow: auto; }
.elim-item { display: flex; align-items: center; gap: 8px; padding: 10px; min-height: 44px; border: 1px solid var(--border-strong, var(--border)); border-radius: 8px; cursor: pointer; }
.elim-item input { width: 20px; height: 20px; }
.elim-cant { margin-left: auto; order: 5; min-height: 36px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); font: inherit; font-size: 14px; }
