:root {
  --bg: #1f2733;
  --bg2: #283341;
  --bg3: #313e4f;
  --line: #3c4a5c;
  --text: #e7edf3;
  --muted: #93a3b5;
  --accent: #f5c518;
  --accent-ink: #1a1a1a;  /* texto sobre el color de acento (se ajusta solo: claro/oscuro) */
  --table: #6b3a2e;
  --table-border: #8a4a3a;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 16px;
  display: flex;
  flex-direction: column;
}

/* Barra superior */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 8px 14px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 18px; color: var(--accent); }
.services { display: flex; gap: 8px; align-items: center; }
.services-label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }
.service-tab {
  position: relative; padding: 7px 14px 7px 30px; border-radius: 6px; cursor: pointer;
  background: var(--bg3); color: var(--muted); border: 1px solid var(--line);
  font-size: 15px; user-select: none;
}
/* Casilla a la izquierda: muestra de un vistazo si el turno está activo. */
.service-tab::before {
  content: ''; position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; border-radius: 4px; border: 2px solid var(--muted); background: transparent;
}
.service-tab.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; border-color: var(--accent); }
.service-tab.active::before { border-color: var(--accent-ink); background: var(--accent-ink); }
.service-tab.active::after {
  content: '✓'; position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--accent); font-size: 11px; font-weight: 800; line-height: 1;
}
.counters { display: flex; gap: 14px; color: var(--muted); font-size: 15px; }
.counter span { color: var(--text); font-weight: 700; }
.datenav { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.date-wrap { position: relative; }
.date-label {
  display: block; background: var(--bg3); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 14px; font-size: 15px; white-space: nowrap; cursor: pointer;
}
/* El selector de fecha real va invisible encima de la etiqueta: al pulsar, abre el calendario. */
.date-input-overlay {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; border: 0; cursor: pointer;
}
.iconbtn {
  background: var(--bg3); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; width: 30px; height: 30px; cursor: pointer; font-size: 16px;
}
.btn-primary {
  background: var(--accent); color: var(--accent-ink); border: none; border-radius: 6px;
  padding: 7px 14px; font-weight: 600; cursor: pointer;
}
.btn-danger {
  background: #b3382f; color: #fff; border: none; border-radius: 6px;
  padding: 7px 14px; font-weight: 600; cursor: pointer;
}
.btn-secondary {
  background: var(--bg3); color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 14px; font-weight: 600; cursor: pointer;
}
.btn-secondary:hover { border-color: var(--accent); }

/* Editor de estados de reserva (Ajustes) */
.estados-list { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 10px; }
.estado-edit-row { display: flex; align-items: center; gap: 8px; }
.estado-edit-row .ee-order { display: flex; flex-direction: column; gap: 1px; }
.estado-edit-row .ee-up, .estado-edit-row .ee-down {
  background: var(--bg3); border: 1px solid var(--line); color: var(--text);
  width: 22px; height: 15px; line-height: 1; font-size: 9px; border-radius: 3px; cursor: pointer; padding: 0;
}
.estado-edit-row .ee-up:disabled, .estado-edit-row .ee-down:disabled { opacity: .3; cursor: default; }
.estado-edit-row .ee-color { width: 34px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: none; cursor: pointer; }
.estado-edit-row .ee-label {
  flex: 1; background: var(--bg3); border: 1px solid var(--line); color: var(--text);
  font-family: inherit; font-size: 13px; padding: 7px 9px; border-radius: 6px;
}
.estado-edit-row .ee-eye {
  width: 30px; height: 30px; background: none; border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; cursor: pointer; font-size: 13px;
}
.estado-edit-row .ee-eye:hover { border-color: var(--accent); }
.estado-edit-row.oculto { opacity: .5; }
.estado-edit-row.oculto .ee-label { text-decoration: line-through; }
.estado-edit-row .ee-lock { width: 30px; text-align: center; opacity: .7; }
.estado-edit-row .ee-del {
  width: 30px; height: 30px; background: none; border: 1px solid var(--line); color: #e06055;
  border-radius: 6px; cursor: pointer; font-size: 13px;
}
.estado-edit-row .ee-del:hover { border-color: #b3382f; background: rgba(179,56,47,.15); }

/* Layout principal */
.layout { flex: 1; display: flex; min-height: 0; }

/* Rail lateral izquierdo (accesos: Clientes, …) */
.railside {
  display: flex; flex-direction: column; gap: 8px;
  padding: 8px 6px; background: var(--bg2); border-right: 1px solid var(--line);
}
.rail-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px; width: 66px;
  background: var(--bg3); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 6px; cursor: pointer;
}
.rail-btn:hover { background: var(--bg); }
.rail-ico { font-size: 22px; line-height: 1; }
.rail-txt { font-size: 11px; }

/* Panel de clientes */
#custSearch {
  width: 100%; background: var(--bg3); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 10px; font-size: 16px;
}
.cust-count { color: var(--muted); font-size: 12px; margin: 8px 0; }
.cust-list {
  display: flex; flex-direction: column; max-height: 62vh; overflow: auto;
  border: 1px solid var(--line); border-radius: 8px;
}
.cust-row {
  display: grid; grid-template-columns: 1.4fr 1fr 1.4fr; gap: 8px; align-items: center;
  padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.cust-row:last-child { border-bottom: none; }
.cust-row:hover { background: var(--bg3); }
.cust-name { font-weight: 600; }
.cust-phone { color: var(--muted); }
.cust-meta { color: var(--muted); font-size: 13px; text-align: right; }
.risk { color: #e0a93b; }
.cust-stats { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.list-pane {
  width: var(--list-width, 42%); flex: 0 0 auto; min-width: 220px;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
}
/* Divisor arrastrable entre la lista de reservas y el plano. */
.pane-resizer {
  flex: 0 0 7px; position: relative; cursor: col-resize; background: transparent; touch-action: none;
}
.pane-resizer::after {
  content: ''; position: absolute; top: 50%; left: 2px; width: 3px; height: 46px;
  transform: translateY(-50%); background: var(--line); border-radius: 3px;
}
.pane-resizer:hover::after { background: var(--accent); height: 70%; }
.list-head, .list-row {
  display: grid; grid-template-columns: 78px 1fr 58px 52px 168px;
  align-items: center; gap: 8px; padding: 11px 16px;
}
.list-head { color: var(--muted); border-bottom: 1px solid var(--line); font-size: 13px; text-transform: uppercase; }
.list-body { overflow-y: auto; }
.list-row { border-bottom: 1px solid var(--line); cursor: pointer; font-size: 16px; }
.list-row .col-hora { font-weight: 700; }
.list-row .col-nombre { font-weight: 600; }
.list-row:hover { background: var(--bg2); }
/* Campana de notificaciones (reservas nuevas de web / WhatsApp) */
.noti-wrap { position: relative; }
.noti-btn { position: relative; font-size: 18px; width: auto; padding: 0 10px; }
.noti-btn.has-unread { animation: noti-ring 1.4s ease-in-out infinite; }
@keyframes noti-ring { 0%, 60%, 100% { transform: rotate(0); } 70% { transform: rotate(12deg); } 80% { transform: rotate(-10deg); } 90% { transform: rotate(6deg); } }
.noti-badge {
  position: absolute; top: -5px; right: -5px; background: #d9534f; color: #fff;
  border-radius: 10px; min-width: 18px; height: 18px; padding: 0 4px;
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.noti-badge.hidden { display: none; }
.noti-panel {
  position: absolute; top: calc(100% + 8px); right: 0; width: 330px; max-height: 64vh; overflow: auto;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 34px rgba(0,0,0,.45); z-index: 60;
}
.noti-panel.hidden { display: none; }
.noti-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 13px; border-bottom: 1px solid var(--line); font-weight: 600; }
.noti-clear { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; }
.noti-clear:hover { color: var(--text); }
.noti-list { display: flex; flex-direction: column; }
.noti-item { padding: 10px 13px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 14px; display: flex; flex-direction: column; gap: 2px; }
.noti-item:last-child { border-bottom: none; }
.noti-item:hover { background: var(--bg3); }
.noti-item.unread { border-left: 3px solid var(--accent); }
.noti-item .noti-when { color: var(--muted); font-size: 12px; }
.noti-empty { padding: 18px 13px; color: var(--muted); font-size: 13px; text-align: center; }

.col-pax { text-align: center; }
.col-mesa { text-align: center; }
.list-row .col-mesa, .list-row .col-pax { font-weight: 700; }
/* Color según el aprovechamiento de la mesa (pax frente a su capacidad). */
.col-mesa.fit-good, .col-pax.fit-good { color: #5bbf6a; }
.col-mesa.fit-ok,   .col-pax.fit-ok   { color: #e0a93b; }
.col-mesa.fit-bad,  .col-pax.fit-bad  { color: #e0625a; }
/* La columna de personas parpadea cuando el encaje es malo (rojo). */
.col-pax.fit-bad { animation: pax-blink 1s ease-in-out infinite; }
@keyframes pax-blink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.estado-bar {
  height: 22px; border-radius: 4px; display: flex; align-items: center;
  justify-content: center; font-size: 12.5px; color: #1a1a1a; font-weight: 600; padding: 0 8px;
}
.estado-bar.clickable { cursor: pointer; }
.estado-bar.clickable:hover { filter: brightness(1.08); box-shadow: 0 0 0 2px rgba(255,255,255,.15) inset; }

/* Columnas de la lista editables en línea (hora, mesa, pax) */
.col-hora.clickable, .col-mesa.clickable, .col-pax.clickable { cursor: pointer; border-radius: 4px; }
.col-hora.clickable:hover, .col-mesa.clickable:hover, .col-pax.clickable:hover {
  box-shadow: 0 0 0 2px var(--accent) inset;
}

/* Popover genérico de los editores rápidos de la lista */
.popover {
  position: fixed; z-index: 1000; max-height: 70vh; overflow-y: auto;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35); padding: 5px;
}
/* Listas verticales (estado, mesa) */
.lista-menu { display: flex; flex-direction: column; min-width: 210px; }
.estado-menu-item, .mesa-menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  background: none; border: 0; color: var(--text); font-size: 13px; font-family: inherit;
  padding: 8px 9px; border-radius: 6px; cursor: pointer;
}
.estado-menu-item:hover, .mesa-menu-item:hover { background: var(--bg3); }
.estado-menu-item.current, .mesa-menu-item.current { background: var(--bg3); font-weight: 700; }
.estado-menu-item.current::after, .mesa-menu-item.current::after { content: '✓'; margin-left: auto; color: var(--accent); }
.estado-dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; }

/* Menú de mesa */
.mesa-menu { min-width: 250px; }
.mesa-menu-zona { font-size: 11px; color: var(--accent); text-transform: uppercase; letter-spacing: .5px; padding: 6px 9px 2px; }
.mesa-menu-item .mm-code { font-weight: 700; }
.mesa-menu-item .mm-cap { font-size: 11px; opacity: .6; }
.mesa-menu-item .mm-busy { margin-left: auto; font-size: 11px; color: #e06055; font-weight: 600; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mesa-menu-item.ocupada .mm-code { color: #e06055; }

/* Menú de pax (rejilla de números) */
.pax-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; min-width: 190px; }
.pax-num, .pax-otro {
  background: var(--bg3); border: 1px solid var(--line); color: var(--text); font-family: inherit;
  font-size: 14px; font-weight: 600; padding: 9px 0; border-radius: 6px; cursor: pointer; text-align: center;
}
.pax-num:hover, .pax-otro:hover { border-color: var(--accent); }
.pax-num.current { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pax-otro { grid-column: 1 / -1; font-size: 12px; }

/* Menú de hora */
.hora-menu { min-width: 220px; max-width: 260px; }
.hora-fila { display: flex; gap: 6px; margin-bottom: 6px; }
.hora-input { flex: 1; background: var(--bg3); border: 1px solid var(--line); color: var(--text); font-family: inherit; font-size: 14px; padding: 7px 8px; border-radius: 6px; }
.hora-ok { background: var(--accent); color: var(--accent-ink); border: 0; font-weight: 700; font-family: inherit; padding: 0 14px; border-radius: 6px; cursor: pointer; }
.hora-slots { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.hora-slot { background: var(--bg3); border: 1px solid var(--line); color: var(--text); font-family: inherit; font-size: 12px; padding: 5px 7px; border-radius: 5px; cursor: pointer; }
.hora-slot:hover { border-color: var(--accent); }
.hora-slot.current { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* Plano */
.floor-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.floor {
  flex: 1; display: flex; flex-direction: column;
  gap: 12px; padding: 14px; overflow: auto; min-height: 0;
}
/* Cada fila reparte sus zonas en columnas. La de arriba ocupa más alto; la
   anclada abajo es más corta (así "las otras se acortan"). */
.floor-row {
  display: grid; gap: 12px; min-height: 160px;
  /* El ancho de cada columna lo fija el JS (grid-template-columns por zona). */
}
.floor > .floor-row { flex: 2 1 0; }
.floor > .floor-row.bottom { flex: 1 1 0; }
.zone-panel {
  position: relative;
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 8px;
}
/* Tirador para redimensionar la columna (en el borde derecho). */
.zone-resizer {
  position: absolute; top: 0; right: -7px; width: 14px; height: 100%;
  cursor: col-resize; z-index: 6; touch-action: none;
}
.zone-resizer::after {
  content: ''; position: absolute; top: 50%; left: 6px; width: 2px; height: 34px;
  transform: translateY(-50%); background: var(--line); border-radius: 2px;
}
.zone-resizer:hover::after { background: var(--accent); height: 60%; }
.zone-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 14px; font-weight: 600; font-size: 16px; color: var(--accent);
  border-bottom: 1px solid var(--line);
}
.zone-dock-btn {
  background: var(--bg3); color: var(--text); border: 1px solid var(--line);
  border-radius: 5px; font-size: 12px; padding: 2px 8px; cursor: pointer; font-weight: 600;
}
.zone-dock-btn.danger { border-color: #b3382f; color: #e9928b; }
.zone-plan { position: relative; flex: 1; min-height: 150px; }

/* Salón cerrado para el día: atenuado, con trama, y las mesas no clicables para el cliente. */
.zone-panel.zona-cerrada { border-color: #b3382f; }
.zone-panel.zona-cerrada .zone-plan {
  opacity: .5;
  background-image: repeating-linear-gradient(45deg, rgba(179,56,47,.14) 0 12px, transparent 12px 24px);
}
.zona-cerrada-badge {
  background: #b3382f; color: #fff; font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 10px; white-space: nowrap;
}

.table-box {
  position: absolute;
  width: calc(104px * var(--table-scale, 1));
  height: calc(74px * var(--table-scale, 1));
  transform: translate(-50%, -50%);
  background: var(--table); border: 2px solid var(--table-border); border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; color: #f3e7e0; text-align: center; line-height: 1.18; padding: 3px;
}
.table-box .code { font-weight: 800; font-size: calc(16px * var(--table-scale, 1)); }
.table-box .seats { font-size: calc(11px * var(--table-scale, 1)); opacity: .55; margin-top: 1px; }
.table-box .resv { font-size: calc(12px * var(--table-scale, 1)); margin-top: 2px; color: #1a1a1a; }
.table-box .resv-name {
  font-weight: 600; max-width: 100%; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; padding: 0 3px;
}
/* Pax como píldora con el color de aprovechamiento (igual criterio que la lista),
   legible sobre el fondo del estado (que puede ser de cualquier color). */
.table-box .resv-pax.pax-fit {
  display: inline-block; padding: 0 7px; border-radius: 9px; font-weight: 800;
  line-height: calc(16px * var(--table-scale, 1)); color: #1a1a1a;
}
.table-box .resv-pax.fit-ok   { background: #e0a93b; }
.table-box .resv-pax.fit-bad  { background: #e0625a; color: #fff; animation: pax-blink 1s ease-in-out infinite; }
/* Badge de nota/alergia en la mesa ocupada. */
.nota-badge {
  position: absolute; top: -7px; right: -7px; width: 19px; height: 19px;
  border-radius: 50%; background: #5b8ddf; color: #fff; font-size: 11px;
  display: flex; align-items: center; justify-content: center; cursor: help;
  border: 1px solid var(--bg2);
}
.nota-badge.alergia { background: #b3382f; }
/* Aviso de varias reservas hoy en la misma mesa (mediodía + noche). */
.multi-badge {
  position: absolute; top: -7px; left: -7px; min-width: 19px; height: 19px;
  border-radius: 10px; background: #5b8ddf; color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; cursor: help;
  border: 1px solid var(--bg2); padding: 0 4px;
}
.table-box.occupied { color: #1a1a1a; }
.table-box[draggable="true"] { cursor: grab; }
.table-box.drop-hover { outline: 2px dashed var(--accent); outline-offset: 2px; }
.list-row[draggable="true"] { cursor: grab; }

/* Modo edición del plano: recolocar mesas arrastrando. */
.floor.editing .table-box { cursor: move; touch-action: none; box-shadow: 0 0 0 2px var(--accent) inset; }
.floor.editing .zone-plan { background:
  repeating-linear-gradient(0deg, transparent 0 19px, rgba(255,255,255,.04) 19px 20px),
  repeating-linear-gradient(90deg, transparent 0 19px, rgba(255,255,255,.04) 19px 20px); }
.editbar { display: flex; align-items: center; gap: 10px; padding: 6px 14px;
  background: var(--bg2); border-bottom: 1px solid var(--line); }
.editbar .hint { color: var(--muted); font-size: 13px; }
.sizectl { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; }
.sizectl .iconbtn { width: 26px; height: 26px; font-size: 17px; line-height: 1; }
.iconbtn.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
/* Reordenar columnas de zona en modo edición. */
.floor.editing .zone-head { cursor: grab; }
.floor.editing .zone-head::before { content: '⠿ '; opacity: .6; }
.zone-panel.zone-drop { outline: 2px dashed var(--accent); outline-offset: -2px; }

/* Overlay / panel */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.overlay.hidden { display: none; }
.panel {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px;
  padding: 22px; width: 900px; max-width: 96vw; position: relative;
  max-height: 92vh; overflow-y: auto;
}
.panel-close {
  position: absolute; top: 10px; right: 12px; background: none; border: none;
  color: var(--muted); font-size: 22px; cursor: pointer;
}
.form { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.form input, .form select, .form textarea {
  background: var(--bg3); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 10px 10px; font-size: 16px;
}
/* Franjas horarias rápidas (tablet). */
.time-slots { display: flex; flex-direction: column; gap: 8px; }
.slot-group { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.slot-title { width: 100%; font-size: 13px; color: var(--accent); text-transform: uppercase; letter-spacing: .5px; }
.slot {
  background: var(--bg3); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 11px 15px; font-size: 16px; cursor: pointer; min-width: 66px;
}
.slot:hover { background: var(--bg2); }
.slot.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
/* Selección múltiple de mesas (unir mesas para grupos grandes). */
.field-hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.table-toggles { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.mesa-toggle {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  background: var(--bg3); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 7px 12px; cursor: pointer; min-width: 76px;
}
.mesa-toggle .mt-code { font-weight: 700; font-size: 15px; }
.mesa-toggle .mt-cap { font-size: 11px; opacity: .7; }
.mesa-toggle.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.mesa-toggle.active .mt-cap { opacity: .8; }
.mesa-toggle.dim { opacity: .4; } /* no encaja por aforo para este grupo */
/* Ocupada a esa hora: el camarero ve de un vistazo que ya está pillada. */
.mesa-toggle.ocupada { background: rgba(179, 56, 47, .16); border-color: #b3382f; color: var(--text); }
.mesa-toggle.ocupada .mt-code { color: #e06055; }
.mesa-toggle.ocupada .mt-busy { font-size: 11px; color: #e06055; font-weight: 600; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Si además está seleccionada (la reutilizas a sabiendas), mantiene el acento con borde rojo. */
.mesa-toggle.ocupada.active { background: var(--accent); color: var(--accent-ink); border-color: #b3382f; }
.mesa-toggle.ocupada.active .mt-code, .mesa-toggle.ocupada.active .mt-busy { color: var(--accent-ink); }
.mesa-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.mesa-group-title { width: 100%; font-size: 12px; color: var(--accent); text-transform: uppercase; letter-spacing: .5px; }
.tables-hint { font-size: 13px; color: var(--muted); margin-top: 2px; }
.tables-hint.warn { color: #e0a93b; font-weight: 600; }
/* Botón de configuración de mesa (modo editar plano). */
.table-cfg-btn {
  position: absolute; top: -7px; left: -7px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--bg3); color: var(--text);
  border: 1px solid var(--accent); font-size: 11px; padding: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.customer-hint { font-size: 13px; color: var(--muted); min-height: 16px; margin-top: -4px; }
.customer-hint.known { color: var(--accent); font-weight: 600; }
.customer-hint.risk { color: #e0a93b; font-weight: 600; }
.allergy-banner {
  background: #b3382f; color: #fff; border-radius: 6px; padding: 7px 10px;
  font-size: 13px; font-weight: 600;
}
.nota-mark { cursor: help; }
.por-staff { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 5px; }
.origen-hint { font-weight: 400; color: var(--accent); font-size: 12px; margin-top: 2px; }
.origen-hint.hidden { display: none; }
.bk-grow { flex: 1; }
.form .row { display: flex; gap: 10px; }
.form .row label { flex: 1; }
.form-actions { display: flex; justify-content: space-between; margin-top: 6px; }

/* Leyenda */
.legend {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 14px;
  background: var(--bg2); border-top: 1px solid var(--line);
}
.legend .chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted);
}
.legend .dot { width: 13px; height: 13px; border-radius: 3px; display: inline-block; }
.hidden { display: none !important; }

/* Pantalla de acceso (login) */
.login-overlay {
  position: fixed; inset: 0; background: var(--bg); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.login-card {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 12px;
  padding: 28px; width: 340px; max-width: 94vw;
  display: flex; flex-direction: column; gap: 12px; text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.login-card h2 { margin: 0; color: var(--accent); font-size: 24px; }
.login-card p { margin: 0 0 6px; color: var(--muted); font-size: 14px; }
.login-card input {
  background: var(--bg3); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 12px 14px; font-size: 17px;
}
.login-card .btn-primary { padding: 12px; font-size: 16px; }
.login-error { color: #e9928b; font-size: 13px; min-height: 16px; }

/* Ajustes */
.settings-section { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 6px; }
.settings-section h4 { margin: 0 0 6px; font-size: 15px; color: var(--text); }
.settings-msg { font-size: 13px; min-height: 18px; margin: 2px 0; }
.settings-msg.ok { color: #5bbf6a; }
.settings-msg.err { color: #e9928b; }
.color-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0; }
.color-row input[type="color"] {
  width: 46px; height: 34px; padding: 0; border: 1px solid var(--line);
  border-radius: 8px; background: var(--bg3); cursor: pointer;
}
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line);
  cursor: pointer; padding: 0;
}
.swatch.sel { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg2), 0 0 0 4px currentColor; }
.web-preview {
  width: 100%; height: 420px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; margin-top: 8px;
}
.set-inline { display: flex; gap: 8px; align-items: flex-end; }
.set-inline label { flex: 1; }
.lock-check { display: flex; flex-direction: row; align-items: center; gap: 8px; font-size: 14px; color: var(--text); cursor: pointer; }
.lock-check input { width: 18px; height: 18px; cursor: pointer; }
/* Checkbox "Notificar al cliente por WhatsApp" del formulario de reserva.
   Destacado en verde WhatsApp: box grande y texto en la MISMA línea.
   (Con .form delante para ganar a la regla genérica ".form label", que pone columna.) */
.form label.notify-check {
  display: flex; flex-direction: row; align-items: center; gap: 12px;
  background: rgba(37, 211, 102, .10); border: 1px solid rgba(37, 211, 102, .45);
  border-radius: 8px; padding: 10px 12px; cursor: pointer; margin: 2px 0;
}
.form label.notify-check:hover { background: rgba(37, 211, 102, .16); border-color: #25d366; }
.form .notify-check input {
  width: 26px; height: 26px; flex: 0 0 auto; cursor: pointer; accent-color: #25d366; margin: 0;
}
.notify-check .notify-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.notify-check .notify-title { font-size: 15px; font-weight: 700; color: var(--text); }
.notify-check .notify-sub { font-size: 12.5px; color: #6fdc95; }
.logo-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 6px 0; }
.logo-preview {
  width: 140px; height: 70px; border: 1px dashed var(--line); border-radius: 8px;
  display: flex; align-items: center; justify-content: center; color: var(--muted);
  font-size: 13px; background: var(--bg3); overflow: hidden; flex: 0 0 auto;
}
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.brand-logo { height: 26px; width: auto; max-width: 130px; object-fit: contain; border-radius: 4px; }
.brand-logo.hidden { display: none; }
.brand { display: flex; align-items: center; gap: 8px; }

/* ===========================================================================
   Móvil / tablet: apilar lista y plano, plano deslizable por salones.
   =========================================================================== */
@media (max-width: 860px) {
  body { font-size: 15px; }

  /* Barra superior: que envuelva en varias líneas. */
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 8px 10px; }
  .datenav { margin-left: 0; }
  .services { flex-wrap: wrap; }

  /* Lista arriba, plano abajo (en vez de lado a lado). */
  .layout { flex-direction: column; }
  .railside { flex-direction: row; align-items: center; border-right: none; border-bottom: 1px solid var(--line); padding: 6px 10px; }
  .rail-btn { flex-direction: row; width: auto; gap: 8px; padding: 8px 12px; }

  /* Barra de "Editar plano": que envuelva y no se amontonen los botones. */
  .editbar { flex-wrap: wrap; gap: 6px 8px; padding: 6px 8px; }
  #editTools { display: inline-flex; flex-wrap: wrap; gap: 6px; }
  .sizectl { font-size: 12px; }
  .editbar .hint { flex: 1 1 100%; order: 10; font-size: 12px; margin: 0; }

  /* La página entera hace scroll (no ventanitas internas): cada salón a tamaño
     completo y la leyenda al final. */
  html, body { height: auto; }
  body { min-height: 100%; }
  .list-pane { width: 100%; min-width: 0; border-right: none; border-bottom: 1px solid var(--line); max-height: none; }
  .pane-resizer { display: none; }
  .list-body { overflow: visible; }
  .floor-pane { min-height: 0; }
  .floor { display: block; overflow: visible; padding: 10px; }
  .floor-row { display: block; }
  .floor > .floor-row, .floor > .floor-row.bottom { flex: none; }
  .zone-panel { width: 100%; min-width: 0; margin-bottom: 12px; }
  .zone-plan { min-height: 260px; overflow: hidden; }
  .zone-resizer { display: none; } /* en móvil los salones van apilados */

  /* Paneles (reserva, mesa, clientes) a casi todo el ancho. */
  .panel { width: 96vw; padding: 16px; }

  /* Leyenda en una sola línea que se desliza (ocupa poco). */
  .legend { flex-wrap: nowrap; overflow-x: auto; padding: 6px 10px; }
  .legend .chip { flex: 0 0 auto; font-size: 12px; }
}

@media (max-width: 520px) {
  .brand { font-size: 16px; }
  .counters { font-size: 13px; gap: 10px; }
  .list-head, .list-row { grid-template-columns: 52px 1fr 44px 36px 96px; gap: 6px; padding: 9px 10px; font-size: 14px; }
  .estado-bar { font-size: 11px; height: auto; min-height: 20px; line-height: 1.15; white-space: normal; padding: 3px 6px; }
  .form .row { flex-wrap: wrap; }            /* campos de formulario en una columna */
  .form .row label { flex: 1 1 100%; }
  .btn-primary, .btn-danger { padding: 9px 12px; }
}
