:root {
  --acento: #d9480f;
  --acento-suave: color-mix(in srgb, var(--acento) 12%, white);
  --acento-osc: color-mix(in srgb, var(--acento) 80%, black);
  --fondo: #f4f3f1;
  --panel: #ffffff;
  --linea: #e4e1dc;
  --texto: #1f1d1a;
  --suave: #6f6a63;
  --ok: #2b8a3e;
  --ok-suave: #e6f4ea;
  --aviso: #c77700;
  --aviso-suave: #fff4db;
  --mal: #c92a2a;
  --mal-suave: #fdecec;
  --info: #1864ab;
  --info-suave: #e7f1fb;
  --r: 12px;
  --sombra: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--texto);
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--fondo); }
body { font-size: 15px; line-height: 1.4; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; }
a { color: var(--acento-osc); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
.num { font-variant-numeric: tabular-nums; }
.suave { color: var(--suave); }
.peq { font-size: 13px; }
.oculto { display: none !important; }

/* ---------- Barra superior ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--linea);
}
.marca { display: flex; align-items: center; gap: 8px; font-weight: 700; white-space: nowrap; min-width: 0; }
.marca img { width: 32px; height: 32px; border-radius: 8px; object-fit: cover; }
.marca .ini { width: 32px; height: 32px; border-radius: 8px; background: var(--acento); color: #fff; display: grid; place-items: center; font-weight: 800; }
.marca span { overflow: hidden; text-overflow: ellipsis; }
nav.tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs a {
  text-decoration: none; color: var(--suave); padding: 8px 12px; border-radius: 10px; white-space: nowrap; font-weight: 600; font-size: 14px;
  display: flex; align-items: center; gap: 6px;
}
nav.tabs a.activo { background: var(--acento-suave); color: var(--acento-osc); }
nav.tabs a .badge { background: var(--mal); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 6px; line-height: 18px; }
.usuario { display: flex; align-items: center; gap: 6px; white-space: nowrap; }

@media (max-width: 760px) {
  .top { flex-wrap: wrap; padding: 6px 10px 0; }
  .marca { flex: 1; }
  nav.tabs { order: 3; flex-basis: 100%; padding-bottom: 6px; }
  .usuario .nombre { display: none; }
}

main { padding: 16px; max-width: 1400px; margin: 0 auto; }
@media (max-width: 760px) { main { padding: 12px 10px 90px; } }

/* ---------- Elementos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--linea);
  background: var(--panel); font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--texto);
}
.btn:hover { border-color: #cfcac2; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.prim { background: var(--acento); border-color: var(--acento); color: #fff; }
.btn.prim:hover { background: var(--acento-osc); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.mal { color: var(--mal); }
.btn.mal-lleno { background: var(--mal); border-color: var(--mal); color: #fff; }
.btn.chico { min-height: 34px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.grande { min-height: 54px; font-size: 17px; padding: 0 22px; }
.btn.icono { width: 42px; padding: 0; }
.btn.chico.icono { width: 34px; }
.btn.fantasma { border-color: transparent; background: transparent; }
.ancho { width: 100%; }

input[type=text], input[type=number], input[type=search], input[type=tel], input[type=password], input[type=date], select, textarea {
  width: 100%; min-height: 42px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--linea); background: #fff;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--acento) 45%, transparent); outline-offset: 0; border-color: var(--acento); }
label.campo { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--suave); }
label.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
label.check input { width: 20px; height: 20px; accent-color: var(--acento); }
.fila { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.fila > .crece { flex: 1; min-width: 160px; }
.rejilla { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.pila { display: flex; flex-direction: column; gap: 12px; }
.entre { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.cab { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.cab h1 { flex: 1; min-width: 150px; }

.panel { background: var(--panel); border: 1px solid var(--linea); border-radius: var(--r); padding: 14px; box-shadow: var(--sombra); }
.panel + .panel { margin-top: 14px; }
.panel > h2 { margin-bottom: 10px; }

.seg { display: inline-flex; background: #e9e6e1; border-radius: 11px; padding: 3px; gap: 2px; overflow-x: auto; max-width: 100%; }
.seg button { border: 0; background: transparent; padding: 8px 14px; border-radius: 9px; font-weight: 600; color: var(--suave); cursor: pointer; white-space: nowrap; }
.seg button.activo { background: #fff; color: var(--texto); box-shadow: 0 1px 2px rgba(0,0,0,.1); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--linea); background: #fff; border-radius: 99px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chip.activo { background: var(--texto); color: #fff; border-color: var(--texto); }
.chips.desliza { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }

.etq { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.etq.ok { background: var(--ok-suave); color: var(--ok); }
.etq.aviso { background: var(--aviso-suave); color: var(--aviso); }
.etq.mal { background: var(--mal-suave); color: var(--mal); }
.etq.info { background: var(--info-suave); color: var(--info); }
.etq.gris { background: #eeece8; color: var(--suave); }

table.tabla { width: 100%; border-collapse: collapse; }
.tabla th { text-align: left; font-size: 12px; color: var(--suave); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; padding: 8px; border-bottom: 1px solid var(--linea); white-space: nowrap; }
.tabla td { padding: 10px 8px; border-bottom: 1px solid #f0eee9; vertical-align: middle; }
.tabla tr.clic { cursor: pointer; }
.tabla tr.clic:hover td { background: #faf9f7; }
.tabla .der { text-align: right; }
.desplaza { overflow-x: auto; }

.vacio { text-align: center; padding: 40px 10px; color: var(--suave); }
.vacio b { display: block; color: var(--texto); font-size: 16px; margin-bottom: 4px; }

.miniatura { width: 44px; height: 44px; border-radius: 9px; object-fit: cover; background: #eeece8; flex: none; display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 16px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .caja { width: min(440px, 100%); }
.login .logo { text-align: center; margin-bottom: 18px; }
.login .logo img, .login .logo .ini { width: 72px; height: 72px; border-radius: 18px; margin: 0 auto 10px; object-fit: cover; }
.login .logo .ini { background: var(--acento); color: #fff; display: grid; place-items: center; font-size: 30px; font-weight: 800; }
.usuarios { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.usuarios button { padding: 14px 8px; border-radius: 12px; border: 1px solid var(--linea); background: #fff; cursor: pointer; font-weight: 600; }
.usuarios button small { display: block; color: var(--suave); font-weight: 500; font-size: 12px; text-transform: capitalize; }
.pin-puntos { display: flex; justify-content: center; gap: 12px; margin: 14px 0; }
.pin-puntos i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--suave); }
.pin-puntos i.lleno { background: var(--texto); border-color: var(--texto); }
.teclado { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.teclado button { height: 60px; font-size: 22px; font-weight: 600; border-radius: 12px; border: 1px solid var(--linea); background: #fff; cursor: pointer; }

/* ---------- Mesas ---------- */
.area-tit { margin: 18px 0 8px; font-size: 13px; color: var(--suave); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.mesas { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.mesa {
  position: relative; min-height: 104px; border-radius: 14px; border: 2px dashed #d6d1c9; background: #fbfaf8;
  padding: 10px; cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: 2px;
}
.mesa .n { font-size: 24px; font-weight: 800; }
.mesa.ocupada { border: 2px solid var(--acento); background: #fff; box-shadow: var(--sombra); }
.mesa.ocupada .n { color: var(--acento-osc); }
.mesa .listos { position: absolute; top: 8px; right: 8px; }
.mesa.tarde { border-color: var(--mal); }

/* ---------- Tarjetas de orden ---------- */
.ordenes { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.tarjeta { background: #fff; border: 1px solid var(--linea); border-radius: var(--r); padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--sombra); }
.tarjeta:hover { border-color: #cfcac2; }

/* ---------- Editor de orden ---------- */
.editor { display: grid; grid-template-columns: 1fr 380px; gap: 14px; align-items: start; }
.editor .carta { min-width: 0; }
.cuenta { position: sticky; top: 70px; max-height: calc(100vh - 86px); display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.cuenta .cab-cuenta { padding: 12px 14px; border-bottom: 1px solid var(--linea); }
.cuenta .lineas { overflow-y: auto; flex: 1; padding: 4px 14px; }
.cuenta .pie { border-top: 1px solid var(--linea); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; background: #fcfbfa; }
.linea { display: flex; gap: 8px; padding: 9px 0; border-bottom: 1px solid #f0eee9; align-items: flex-start; }
.linea:last-child { border-bottom: 0; }
.linea .q { font-weight: 800; min-width: 26px; }
.linea .d { flex: 1; min-width: 0; }
.linea .nota { font-size: 12px; color: var(--aviso); font-weight: 600; }
.linea.cancelado .d, .linea.cancelado .p { text-decoration: line-through; color: var(--suave); }
.linea .ctl { display: flex; gap: 4px; align-items: center; }
.sep-cuenta { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--suave); font-weight: 700; padding: 10px 0 2px; }
.total { font-size: 22px; font-weight: 800; }

.platillos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.platillo {
  background: #fff; border: 1px solid var(--linea); border-radius: 12px; overflow: hidden; cursor: pointer; text-align: left; padding: 0;
  display: flex; flex-direction: column; position: relative; box-shadow: var(--sombra);
}
.platillo:active { transform: scale(.98); }
.platillo .foto { aspect-ratio: 16/10; width: 100%; object-fit: cover; background: #eeece8; }
.platillo .foto.ini { aspect-ratio: 5/2; display: grid; place-items: center; font-size: 30px; font-weight: 800; }
.platillo .info { padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.platillo .nom { font-weight: 600; font-size: 14px; line-height: 1.25; }
.platillo .pre { font-weight: 800; color: var(--acento-osc); }
.platillo.agotado { opacity: .5; }
.platillo .quedan { position: absolute; top: 6px; left: 6px; }
.platillo .en-cuenta { position: absolute; top: 6px; right: 6px; background: var(--acento); color: #fff; border-radius: 99px; min-width: 26px; height: 26px; display: grid; place-items: center; font-weight: 800; font-size: 13px; padding: 0 6px; }

.barra-movil { display: none; }
@media (max-width: 900px) {
  .editor { grid-template-columns: 1fr; }
  .editor .cuenta { display: none; }
  .editor.ver-cuenta .carta { display: none; }
  .editor.ver-cuenta .cuenta { display: flex; position: static; max-height: none; }
  .barra-movil {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; gap: 8px; padding: 10px; background: #fff; border-top: 1px solid var(--linea);
    box-shadow: 0 -4px 14px rgba(0,0,0,.06);
  }
  .barra-movil .btn { flex: 1; }
  .platillos { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}

/* ---------- Cocina ---------- */
body.modo-cocina { background: #17181b; color: #eee; }
body.modo-cocina .top { background: #1f2024; border-color: #2d2f34; }
body.modo-cocina .top .marca, body.modo-cocina .usuario { color: #eee; }
body.modo-cocina nav.tabs a { color: #9a9ca3; }
body.modo-cocina nav.tabs a.activo { background: #2d2f34; color: #fff; }
body.modo-cocina .btn { background: #2a2c31; border-color: #3a3c42; color: #eee; }
body.modo-cocina .btn.prim { background: var(--acento); border-color: var(--acento); }
body.modo-cocina .seg { background: #2a2c31; }
body.modo-cocina .seg button { color: #9a9ca3; }
body.modo-cocina .seg button.activo { background: #3a3c42; color: #fff; }
body.modo-cocina .suave { color: #9a9ca3; }
.kds { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; align-items: start; }
.comanda { background: #24262b; border-radius: 12px; overflow: hidden; border-top: 6px solid #4a8c5c; }
.comanda.medio { border-top-color: #e0a100; }
.comanda.tarde { border-top-color: #e03131; animation: latido 2s infinite; }
@keyframes latido { 50% { box-shadow: 0 0 0 3px rgba(224,49,49,.35); } }
.comanda .cab-c { padding: 10px 12px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; background: #2b2d33; }
.comanda .cab-c b { font-size: 18px; }
.comanda .tiempo { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.comanda ul { list-style: none; margin: 0; padding: 4px 0; }
.comanda li { display: flex; gap: 10px; padding: 10px 12px; cursor: pointer; border-bottom: 1px solid #2f3137; align-items: flex-start; font-size: 17px; }
.comanda li .q { font-weight: 800; color: #ffd43b; min-width: 28px; }
.comanda li .nota { display: block; font-size: 14px; color: #ff922b; font-weight: 700; }
.comanda li.hecho { opacity: .4; text-decoration: line-through; }
.comanda li .est { margin-left: auto; font-size: 11px; color: #9a9ca3; text-transform: uppercase; }
.comanda .acc { padding: 10px 12px; }

/* ---------- Gráficas simples ---------- */
.barras { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 18px; }
.barras .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; min-width: 0; }
.barras .b i { display: block; width: 100%; max-width: 46px; background: var(--acento); border-radius: 6px 6px 2px 2px; position: relative; min-height: 2px; }
.barras .b i em { position: absolute; top: -17px; left: 50%; transform: translateX(-50%); font-style: normal; font-size: 11px; color: var(--suave); white-space: nowrap; }
.barras .b span { font-size: 11px; color: var(--suave); white-space: nowrap; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.kpi { background: #fff; border: 1px solid var(--linea); border-radius: var(--r); padding: 12px 14px; }
.kpi small { color: var(--suave); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.kpi b { display: block; font-size: 22px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi.bien b { color: var(--ok); }
.kpi.malo b { color: var(--mal); }
.meter { height: 6px; background: #eeece8; border-radius: 99px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--acento); }

/* ---------- Modal ---------- */
.velo { position: fixed; inset: 0; background: rgba(20,18,15,.45); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: #fff; color: var(--texto); border-radius: 16px; width: min(520px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.ancho { width: min(760px, 100%); }
.modal header { padding: 14px 16px; border-bottom: 1px solid var(--linea); display: flex; align-items: center; gap: 10px; }
.modal header h2 { flex: 1; }
.modal .cuerpo { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal footer { padding: 12px 16px; border-top: 1px solid var(--linea); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
@media (max-width: 600px) {
  .velo { align-items: flex-end; padding: 0; }
  .modal { border-radius: 16px 16px 0 0; max-height: 92vh; width: 100%; }
}
#lector { width: 100%; border-radius: 12px; overflow: hidden; background: #000; min-height: 240px; }
#lector video { width: 100% !important; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1f1d1a; color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 80; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: calc(100% - 32px); }
.toast.error { background: var(--mal); }
@media (max-width: 900px) { .toast { bottom: 84px; } }

.foto-edit { width: 120px; height: 120px; border-radius: 14px; object-fit: cover; background: #eeece8; border: 1px dashed #cfcac2; display: grid; place-items: center; cursor: pointer; color: var(--suave); font-size: 13px; text-align: center; overflow: hidden; }
.foto-edit img { width: 100%; height: 100%; object-fit: cover; }
.alerta { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; background: var(--aviso-suave); color: #6b4300; font-weight: 600; font-size: 14px; }
.alerta.mal { background: var(--mal-suave); color: var(--mal); }
.alerta.info { background: var(--info-suave); color: var(--info); }

.pago-metodos { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.pago-metodos button { min-height: 50px; border-radius: 10px; border: 2px solid var(--linea); background: #fff; font-weight: 700; cursor: pointer; text-transform: capitalize; }
.pago-metodos button.activo { border-color: var(--acento); background: var(--acento-suave); color: var(--acento-osc); }
.cambio { font-size: 28px; font-weight: 800; color: var(--ok); }
