:root {
  --bg: #f7f4ee;
  --surface: #ffffff;
  --surface-alt: #efe9dd;
  --border: #e2d9c8;
  --text: #241f18;
  --text-muted: #8a8070;
  --accent: #c1631a;
  --accent-soft: #f3ddc4;
  --ok: #2f8a4e;
  --ok-soft: #dff1e4;
  --danger: #b23a2e;
  --radius: 14px;
  --sans: -apple-system, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#app.con-pie-fijo {
  padding-bottom: 190px; /* deja hueco para el pie fijo + resumen + voz, solo en Servicio de Sala */
}

.vista:not([hidden]) {
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* ---- Barra de "volver al menú principal" ---- */

.barra-vista:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.boton-volver {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.barra-vista h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Home ---- */

.vista-home {
  align-items: stretch;
  justify-content: center;
  padding: 1.5rem 1.25rem;
  gap: 1.5rem;
  min-height: 100vh;
}

.home-cabecera {
  text-align: center;
}

.home-cabecera h1 {
  margin: 0 0 0.3rem;
  font-size: 1.5rem;
  font-weight: 800;
}

.home-fecha {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: capitalize;
}

.home-botones {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.home-boton:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  border: none;
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  text-align: left;
}

.home-boton-emoji {
  font-size: 1.6rem;
  line-height: 1;
}

.home-boton-apertura {
  background: linear-gradient(135deg, #e0a72e, #c1631a);
}

.home-boton-servicio {
  background: linear-gradient(135deg, #3fa15e, #2f8a4e);
}

.home-boton-cierre {
  background: linear-gradient(135deg, #c94a3c, #b23a2e);
}

.home-boton-carta {
  background: linear-gradient(135deg, #5b5346, #241f18);
}

.home-boton-admin {
  background: linear-gradient(135deg, #6b6b6b, #33312d);
}

.banner-prueba-home {
  position: static;
  align-self: center;
  margin-top: 0.5rem;
}

/* ---- Panel de sala (mesas activas), dentro de Servicio de Sala ---- */

.panel-sala {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.panel-sala-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  background: none;
  border: none;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

.panel-sala-toggle[aria-expanded="true"] .resumen-flecha {
  transform: rotate(180deg);
}

.panel-sala-detalle:not([hidden]) {
  max-height: 40vh;
  overflow-y: auto;
  padding: 0 0.75rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.sala-fila {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  font-size: 0.84rem;
  cursor: pointer;
  text-align: left;
}

.sala-mesa {
  font-weight: 700;
}

.sala-info {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ---- Checklist (apertura / cierre) ---- */

.vista-checklist {
  padding: 1rem;
  gap: 0.75rem;
}

.checklist-fecha {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: capitalize;
}

.checklist-lista {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.checklist-fila {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
}

.checklist-fila.estado-en_proceso {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.checklist-fila.estado-finalizada {
  border-color: var(--ok);
  background: var(--ok-soft);
}

.checklist-numero {
  flex: 0 0 auto;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

.checklist-texto {
  flex: 1;
  min-width: 0;
}

.checklist-nombre-tarea {
  font-weight: 600;
  font-size: 0.92rem;
}

.checklist-estado-texto {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.checklist-boton {
  flex: 0 0 auto;
  border: none;
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.checklist-boton-proceso {
  background: var(--accent);
  color: #fff;
}

.checklist-boton-finalizar {
  background: var(--ok);
  color: #fff;
}

/* ---- Carta / Menú ---- */

.vista-carta {
  padding: 1rem;
  gap: 1rem;
}

.carta-buscador input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.92rem;
}

.carta-lista {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.carta-grupo h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.carta-fila {
  display: flex;
  justify-content: space-between;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.carta-fila:last-child {
  border-bottom: none;
}

.carta-precio {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ---- Cabecera ---- */

.cabecera {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.campo {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.campo label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

#mesa {
  font-size: 1.05rem;
  font-weight: 600;
  padding: 0.5rem 0.6rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  min-width: 5.5rem;
}

.contador-personas {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.35rem 0.5rem;
}

.contador-personas button {
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  border: none;
  background: var(--surface-alt);
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

#personas-valor {
  min-width: 1.2rem;
  text-align: center;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.banner-prueba {
  position: absolute;
  top: 0.4rem;
  right: 1rem;
  font-size: 0.65rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--danger);
  color: #fff;
  padding: 0.2rem 0.5rem;
  border-radius: 99px;
}

/* ---- Categorías ---- */

.categorias {
  display: flex;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  overflow-x: auto;
}

.categorias .tab {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.55rem 0.9rem;
  border-radius: 99px;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.categorias .tab.activa {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---- Lista de platos ---- */

.lista-platos {
  flex: 1;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.plato {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
}

.plato-fila {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.plato-info {
  min-width: 0;
}

.plato-nombre {
  font-weight: 600;
  font-size: 0.98rem;
}

.plato-precio {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex: 0 0 auto;
}

.stepper button {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}

.stepper button.mas {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.stepper .cantidad {
  min-width: 1.3rem;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.modificadores {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.chip {
  font-size: 0.76rem;
  padding: 0.28rem 0.6rem;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-muted);
  cursor: pointer;
}

.chip.activo {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.vacio {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 1rem;
  font-size: 0.9rem;
}

/* ---- Resumen ---- */

.resumen {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 128px;
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 16px rgba(0, 0, 0, 0.06);
}

.resumen-cabecera {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1rem;
  background: none;
  border: none;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

.resumen-flecha {
  transition: transform 0.15s ease;
  color: var(--text-muted);
}

.resumen-cabecera[aria-expanded="true"] .resumen-flecha {
  transform: rotate(180deg);
}

.resumen-detalle:not([hidden]) {
  max-height: 40vh;
  overflow-y: auto;
  padding: 0 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.86rem;
}

.resumen-linea {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.resumen-linea .nota {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.resumen-nota-voz {
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  color: var(--text);
}

/* ---- Voz ---- */

.voz-envoltorio:not([hidden]) {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 68px;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  pointer-events: none;
}

.boton-voz {
  pointer-events: all;
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1.4rem;
  box-shadow: 0 4px 14px rgba(193, 99, 26, 0.4);
  cursor: pointer;
}

.boton-voz.grabando {
  background: var(--danger);
  animation: pulso 1.1s infinite;
}

@keyframes pulso {
  0% {
    box-shadow: 0 0 0 0 rgba(178, 58, 46, 0.5);
  }
  70% {
    box-shadow: 0 0 0 14px rgba(178, 58, 46, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(178, 58, 46, 0);
  }
}

.voz-estado {
  margin: 0;
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--surface);
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  min-height: 1.1em;
}

/* ---- Pie ---- */

.pie {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 480px;
  display: flex;
  gap: 0.6rem;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.boton-secundario,
.boton-primario {
  flex: 1;
  padding: 0.85rem 0.5rem;
  border-radius: 12px;
  font-size: 0.92rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
}

.boton-secundario {
  background: var(--surface-alt);
  color: var(--text);
}

.boton-primario {
  background: var(--ok);
  color: #fff;
}

.boton-primario:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ---- Admin: teclado de PIN ---- */

.vista-admin-pin {
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  min-height: 100vh;
}

.pin-caja {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 20rem;
}

.pin-titulo {
  margin: 0;
  font-weight: 700;
  text-align: center;
}

.pin-puntos {
  display: flex;
  gap: 0.75rem;
}

.pin-punto {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
}

.pin-punto.lleno {
  background: var(--accent);
  border-color: var(--accent);
}

.pin-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1.2em;
}

.pin-teclado {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  width: 100%;
}

.pin-teclado button {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
}

.pin-teclado button:active {
  background: var(--surface-alt);
}

.pin-teclado .pin-vacio {
  border: none;
  background: none;
  cursor: default;
}

/* ---- Admin: panel de configuración ---- */

.vista-admin-panel {
  padding: 1rem;
  gap: 1.5rem;
}

.admin-bloque {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.admin-bloque h3 {
  margin: 0;
  font-size: 0.95rem;
}

.admin-campo {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.admin-campo input {
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.95rem;
  text-transform: none;
  letter-spacing: normal;
}

.admin-menu-lista,
.admin-checklist-lista {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.admin-fila-menu {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 0.8fr auto;
  gap: 0.4rem;
  align-items: center;
}

.admin-fila-menu input,
.admin-fila-menu select {
  padding: 0.4rem 0.4rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.8rem;
  min-width: 0;
}

.admin-fila-checklist {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.admin-fila-checklist input {
  flex: 1;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.88rem;
}

.admin-zonas-lista {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.admin-fila-zona {
  display: grid;
  grid-template-columns: 0.7fr 1.6fr 0.7fr auto;
  gap: 0.4rem;
  align-items: center;
}

.admin-fila-zona input {
  padding: 0.5rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.85rem;
  min-width: 0;
}

.admin-eliminar {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  cursor: pointer;
  font-size: 0.9rem;
}

.admin-acciones {
  display: flex;
  gap: 0.6rem;
}

.admin-acciones .boton-secundario,
.admin-acciones .boton-primario {
  flex: 1;
  padding: 0.6rem 0.5rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
}

.admin-acciones .boton-secundario {
  background: var(--surface-alt);
  color: var(--text);
}

.admin-acciones .boton-primario {
  background: var(--ok);
  color: #fff;
}

.vista-admin-panel > .boton-primario {
  padding: 0.85rem 0.5rem;
  border-radius: 12px;
  font-size: 0.92rem;
  font-weight: 700;
  border: none;
  background: var(--ok);
  color: #fff;
  cursor: pointer;
}

/* ---- Toast ---- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 200px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 0.6rem 1rem;
  border-radius: 10px;
  font-size: 0.85rem;
  max-width: 85vw;
  text-align: center;
  z-index: 20;
}
