:root {
  --fondo: #f4f5f7;
  --superficie: #ffffff;
  --borde: #dfe2e7;
  --texto: #1d2330;
  --suave: #5f6878;
  --primario: #1f5fbf;
  --primario-oscuro: #174a96;
  --verde: #1e8e4e;
  --wa: #128c4b;
  --rojo: #c0392b;
  --ambar: #b7791f;
  --gris: #7a8494;
  --radio: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fondo);
  color: var(--texto);
  font-size: 15px;
}
a { color: var(--primario); text-decoration: none; }
a:hover { text-decoration: underline; }

.barra {
  display: flex; align-items: center; gap: 20px;
  background: var(--texto); color: #fff; padding: 0 20px; height: 54px;
}
.barra .marca { font-weight: 700; font-size: 17px; color: #fff; }
.barra nav { display: flex; gap: 4px; flex: 1; }
.barra nav a { color: #c9d0dc; padding: 8px 12px; border-radius: 6px; }
.barra nav a:hover, .barra nav a.activo { background: #ffffff1a; color: #fff; text-decoration: none; }
.barra .usuario { color: #c9d0dc; font-size: 14px; display: flex; gap: 12px; align-items: center; }
.barra .usuario button { background: none; border: 0; color: #c9d0dc; cursor: pointer; font: inherit; text-decoration: underline; }

main { max-width: 1280px; margin: 0 auto; padding: 24px 20px 60px; }
h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }

.mensajes { list-style: none; padding: 0; margin: 0 0 16px; }
.mensajes li { padding: 10px 14px; border-radius: 8px; margin-bottom: 6px; background: #e8f0fd; }
.mensajes li.success { background: #e3f4ea; color: #145c33; }
.mensajes li.error { background: #fbe7e5; color: #8a2419; }

.tarjeta { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); padding: 18px; }
.columnas { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.columnas-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.pila > * + * { margin-top: 20px; }
@media (max-width: 960px) { .columnas, .columnas-2 { grid-template-columns: 1fr; } }

/* Resumen y filtros */
.filtros { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--borde);
  background: var(--superficie); color: var(--texto); font-size: 14px;
}
.chip.activo { background: var(--texto); color: #fff; border-color: var(--texto); }
.chip b { margin-left: 4px; }

/* Grilla de habitaciones */
.grilla { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.hab {
  display: block; background: var(--superficie); border: 1px solid var(--borde);
  border-left: 5px solid var(--gris); border-radius: var(--radio); padding: 12px 14px;
  color: var(--texto); min-height: 96px; position: relative;
}
.hab:hover { text-decoration: none; border-color: var(--primario); }
.hab .num { font-size: 22px; font-weight: 700; }
.hab .est { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--suave); }
.hab .nombre { font-size: 13px; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hab .alarma { position: absolute; top: 10px; right: 12px; font-size: 13px; }
.hab.libre { border-left-color: var(--verde); }
.hab.ocupada { border-left-color: var(--primario); }
.hab.limpieza { border-left-color: var(--ambar); }
.hab.fuera { border-left-color: var(--rojo); opacity: .75; }

.etiqueta { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef0f3; }
.etiqueta.libre { background: #e3f4ea; color: #145c33; }
.etiqueta.ocupada { background: #e4ecfa; color: var(--primario-oscuro); }
.etiqueta.limpieza { background: #fbf0dc; color: #7a4f0f; }
.etiqueta.fuera { background: #fbe7e5; color: #8a2419; }
.etiqueta.sonando { background: var(--rojo); color: #fff; }

/* Listas */
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { padding: 9px 0; border-bottom: 1px solid var(--borde); display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.lista li:last-child { border-bottom: 0; }
.vacio { color: var(--suave); font-size: 14px; margin: 0; }
.suave { color: var(--suave); font-size: 13px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--borde); }
th { color: var(--suave); font-weight: 600; font-size: 13px; }

/* Formularios y botones */
form.fila { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--suave); }
input[type=text], input[type=password], input[type=date], input[type=datetime-local], input[type=tel], select, textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--borde); border-radius: 8px; font: inherit; background: #fff;
}
.campo { margin-bottom: 12px; }
.campo .ayuda { font-size: 12px; color: var(--suave); margin-top: 3px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600;
  cursor: pointer; background: var(--primario); color: #fff; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--primario-oscuro); text-decoration: none; }
.btn.wa { background: var(--wa); }
.btn.wa:hover { background: #0d6e3a; }
.btn.peligro { background: var(--rojo); }
.btn.sec { background: #fff; color: var(--texto); border-color: var(--borde); }
.btn.sec:hover { background: #f0f2f5; }
.btn.chico { padding: 5px 10px; font-size: 13px; }
.btn.ancho { width: 100%; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; }

.mensajes-wa { display: grid; gap: 8px; }
.mensajes-wa button { text-align: left; background: #f3faf6; border: 1px solid #cde8d8; border-radius: 8px; padding: 10px 12px; cursor: pointer; font: inherit; width: 100%; }
.mensajes-wa button:hover { background: #e3f4ea; }
.mensajes-wa b { display: block; font-size: 14px; }
.mensajes-wa span { font-size: 13px; color: var(--suave); }

.qr-mini { width: 140px; height: 140px; border: 1px solid var(--borde); border-radius: 8px; background: #fff; }
.encabezado { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.encabezado h1 { margin: 0; }

/* Avisos (despertadores y llamadas) */
#sonido-aviso { background: #fbf0dc; color: #7a4f0f; padding: 8px 20px; text-align: center; font-size: 14px; }
#sonido-aviso button { margin-left: 8px; }
#alarmas { position: fixed; inset: 0; background: #0f1520b3; display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
#alarmas.visible { display: flex; }
#alarmas .caja { background: #fff; border-radius: 14px; max-width: 520px; width: 100%; padding: 22px; box-shadow: 0 20px 60px #0006; max-height: 90vh; overflow: auto; }
#alarmas h2 { font-size: 22px; color: var(--rojo); }
.alarma-item { border: 1px solid var(--borde); border-radius: 10px; padding: 14px; margin-top: 12px; }
.alarma-item .titulo { font-size: 18px; font-weight: 700; }
.alarma-item .acciones { margin-top: 10px; }

#toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 40; }
.toast { background: var(--texto); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 8px 24px #0004; font-size: 14px; max-width: 320px; }

/* Login */
.login { max-width: 360px; margin: 80px auto; }
