/* QRS Team Service — CSS propio, mobile-first, sin frameworks */
:root {
  --naranja: #E8A028;
  --naranja-osc: #D09840;
  --gris: #8B8D90;
  --gris-osc: #3A3A3A;
  --gris-claro: #F4F4F5;
  --blanco: #FFFFFF;
  --rojo: #C0392B;
  --verde: #27AE60;
  --amarillo: #E67E22;
  --sombra: 0 1px 4px rgba(0,0,0,.12);
  --radio: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--gris-osc);
  background: var(--gris-claro);
  min-height: 100vh;
  font-size: clamp(15px, 1.6vw, 16px);
}
a { color: var(--naranja-osc); }
h1 { font-size: clamp(1.25rem, 3vw, 1.6rem); margin: .4em 0 .6em; }
h2 { font-size: clamp(1.05rem, 2.4vw, 1.25rem); margin: 1em 0 .5em; }

/* ---------------- topbar ---------------- */
.topbar {
  background: var(--blanco);
  box-shadow: var(--sombra);
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .5rem .9rem;
  position: sticky;
  top: 0;
  z-index: 50;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--gris); }
.brand img { height: 30px; width: auto; }
.brand span { color: var(--naranja); font-size: 1.1rem; }
.menu-toggle { display: none; }
.menu-btn {
  margin-left: auto;
  font-size: 1.5rem;
  cursor: pointer;
  padding: .2rem .6rem;
  border-radius: 6px;
  user-select: none;
}
.nav { display: none; width: 100%; flex-direction: column; gap: .1rem; }
.menu-toggle:checked ~ .nav { display: flex; }
.nav a, .nav .btn-link {
  padding: .65rem .6rem;
  text-decoration: none;
  color: var(--gris-osc);
  border-radius: 6px;
  font-size: .95rem;
}
.nav a:hover { background: var(--gris-claro); }
.inline-form { display: inline; }
.btn-link {
  background: none; border: none; cursor: pointer;
  color: var(--gris); font-size: .95rem; text-align: left; width: 100%;
}
@media (min-width: 900px) {
  .menu-btn { display: none; }
  .nav { display: flex !important; flex-direction: row; width: auto; margin-left: auto; flex-wrap: wrap; }
  .btn-link { width: auto; }
}

/* ---------------- layout ---------------- */
.contenido { padding: 1rem; max-width: 1300px; margin: 0 auto; }
.flashes { margin-bottom: 1rem; }
.flash {
  background: #FDF3E3; border-left: 4px solid var(--naranja);
  padding: .6rem .9rem; border-radius: 6px; margin-bottom: .4rem;
}
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: .9rem;
  margin: 1rem 0;
}
.card {
  background: var(--blanco); border-radius: var(--radio);
  box-shadow: var(--sombra); padding: 1rem; min-width: 0;
}
.card .num { font-size: 2rem; font-weight: 700; color: var(--naranja); }
.card .etq { color: var(--gris); font-size: .9rem; }

/* ---------------- tablas ---------------- */
.tabla-wrap { overflow-x: auto; background: var(--blanco); border-radius: var(--radio); box-shadow: var(--sombra); }
table { border-collapse: collapse; width: 100%; min-width: 560px; }
th, td { padding: .55rem .7rem; text-align: left; border-bottom: 1px solid #ECECEC; font-size: .92rem; }
th {
  background: var(--naranja); color: var(--blanco);
  position: sticky; top: 0; white-space: nowrap;
}
tr:hover td { background: #FBF6EC; }
.tabla-wrap.compacta table { min-width: 0; }

/* ---------------- formularios ---------------- */
form.panel-form, .form-card {
  background: var(--blanco); border-radius: var(--radio); box-shadow: var(--sombra);
  padding: 1rem; margin: 1rem 0; display: flex; flex-wrap: wrap; gap: .7rem; align-items: flex-end;
}
label.campo { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--gris); flex: 1 1 180px; min-width: 0; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], select, textarea {
  padding: .55rem .6rem; border: 1px solid #D5D5D8; border-radius: 6px;
  font-size: 1rem; width: 100%; background: var(--blanco);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--naranja); border-color: var(--naranja); }
.boton, button.boton {
  background: var(--naranja); color: var(--blanco); border: none; cursor: pointer;
  padding: .6rem 1.1rem; border-radius: 6px; font-size: 1rem; font-weight: 600;
  min-height: 44px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
.boton:hover { background: var(--naranja-osc); }
.boton.secundario { background: var(--gris); }
.boton.peligro { background: var(--rojo); }
.boton.mini { padding: .3rem .6rem; min-height: 34px; font-size: .85rem; }
.acciones { display: flex; gap: .4rem; flex-wrap: wrap; }

/* cards clicables y detalles de confirmación */
a.card { text-decoration: none; color: inherit; display: block; transition: box-shadow .15s; }
a.card:hover { box-shadow: 0 3px 12px rgba(0,0,0,.18); }
details.acc-detalle { display: inline-block; vertical-align: top; }
details.acc-detalle summary { list-style: none; cursor: pointer; }
details.acc-detalle summary::-webkit-details-marker { display: none; }
details.acc-detalle[open] {
  background: var(--blanco); border: 1px solid var(--naranja); border-radius: var(--radio);
  padding: .6rem; box-shadow: var(--sombra); max-width: 280px;
}
details.acc-detalle form { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .4rem; }
details.acc-detalle input[type=text] { width: 9.5rem; }

/* ---------------- badges / semáforo ---------------- */
.badge { padding: .15rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.badge.ok { background: #E8F8EF; color: var(--verde); }
.badge.warn { background: #FDF3E3; color: var(--amarillo); }
.badge.ko { background: #FDECEA; color: var(--rojo); }
.badge.off { background: var(--gris-claro); color: var(--gris); }

/* ---------------- login / totp ---------------- */
.auth-wrap { max-width: 400px; margin: 8vh auto; padding: 0 1rem; }
.auth-card {
  background: var(--blanco); border-radius: var(--radio);
  box-shadow: 0 4px 24px rgba(0,0,0,.10); padding: 2rem 1.8rem;
  border-top: 4px solid var(--naranja);
}
.auth-card .brand { justify-content: center; margin-bottom: .8rem; }
.auth-card h1 { text-align: center; font-size: 1.3rem; margin: .2rem 0 1.2rem; }
.auth-card p { text-align: center; color: var(--gris); font-size: .92rem; }
.auth-card img.qr-totp { display: block; margin: .8rem auto; width: min(220px, 70vw); }
.auth-card form { display: flex; flex-direction: column; gap: 1rem; }
.auth-card form .campo { flex: none; }  /* sin esto, el flex-basis de .campo se vuelve ALTO en columna */
.auth-card .boton { width: 100%; margin-top: .3rem; }

/* ---------------- vista pública ---------------- */
.pub-body { background: var(--gris-claro); }
.pub-cab {
  background: var(--blanco); padding: 1rem; text-align: center;
  border-bottom: 4px solid var(--naranja);
}
.pub-cab img { height: 36px; }
.pub-cab h1 { margin: .3rem 0 0; font-size: 1.15rem; }
.pub-cab .fecha { color: var(--gris); font-size: .9rem; }
.pub-lista { padding: .8rem; max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: .7rem; }
.pub-bano {
  background: var(--blanco); border-radius: var(--radio); box-shadow: var(--sombra);
  padding: .9rem 1rem; display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
}
.pub-bano .nombre { font-weight: 700; flex: 1 1 40%; min-width: 0; }
.pub-bano .estado { text-align: right; flex: 1 1 50%; min-width: 0; }
.pub-bano .hora { font-size: 1.05rem; font-weight: 700; color: var(--naranja-osc); }
.pub-bano .detalle { color: var(--gris); font-size: .82rem; }
.pub-sin { color: var(--gris); font-style: italic; }
.pub-acciones { display: flex; gap: .7rem; padding: .4rem .8rem 1.4rem; max-width: 640px; margin: 0 auto; flex-wrap: wrap; }
.pub-acciones .boton { flex: 1 1 180px; }
.pub-form { background: var(--blanco); border-radius: var(--radio); box-shadow: var(--sombra); padding: 1rem; margin: .5rem .8rem; max-width: 640px; }
.pub-form h2 { margin-top: 0; }
.oculto { display: none !important; }
.caritas { display: flex; gap: .5rem; justify-content: center; margin: .6rem 0; flex-wrap: wrap; }
.caritas button {
  font-size: 2rem; background: var(--gris-claro); border: 2px solid transparent;
  border-radius: 12px; padding: .35rem .6rem; cursor: pointer; min-width: 54px; min-height: 54px;
}
.caritas button:hover, .caritas button.sel { border-color: var(--gris-osc); }
.caritas button { display: flex; flex-direction: column; align-items: center; gap: .15rem; }
.caritas .cnum { font-size: .85rem; font-weight: 700; color: rgba(0,0,0,.65); }
/* fondo de rojo (1) a verde (5) */
.caritas .cv1, .val-chip.cv1 { background: #F5B7B1; }
.caritas .cv2, .val-chip.cv2 { background: #F8CBA6; }
.caritas .cv3, .val-chip.cv3 { background: #F9E79F; }
.caritas .cv4, .val-chip.cv4 { background: #C8E6A0; }
.caritas .cv5, .val-chip.cv5 { background: #A9DFBF; }
.caritas button.sel { outline: 3px solid var(--gris-osc); }
.val-chip { padding: .1rem .5rem; border-radius: 999px; font-weight: 700; white-space: nowrap; }
.pub-historial { background: var(--blanco); border-radius: var(--radio); box-shadow: var(--sombra); padding: .9rem 1rem; }
.pub-historial h2 { margin: 0 0 .5rem; font-size: 1rem; color: var(--gris); }
.pub-historial ul { list-style: none; margin: 0; padding: 0; }
.pub-historial li { padding: .35rem 0; border-bottom: 1px solid #ECECEC; font-size: .95rem; }
.pub-historial li:last-child { border-bottom: none; }
.pub-historial .hh { font-weight: 700; color: var(--naranja-osc); }
/* botón de avisos push del panel */
.push-zona { display: flex; align-items: center; gap: .6rem; margin: .4rem 0 1rem; flex-wrap: wrap; }
.push-zona .estado { font-size: .9rem; color: var(--gris); }
.honeypot { position: absolute; left: -9999px; opacity: 0; height: 0; overflow: hidden; }

/* ---------------- app limpiadora ---------------- */
.app-wrap { max-width: 480px; margin: 0 auto; padding: 1rem; text-align: center; }
.app-wrap h1 { color: var(--gris); }
.pin-display {
  font-size: 2rem; letter-spacing: .6rem; background: var(--blanco);
  border-radius: var(--radio); padding: .6rem; margin: .8rem 0; min-height: 3.4rem;
  box-shadow: var(--sombra); font-weight: 700;
}
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.pin-pad button {
  font-size: 1.5rem; padding: .9rem; border: none; border-radius: var(--radio);
  background: var(--blanco); box-shadow: var(--sombra); cursor: pointer; min-height: 60px;
}
.pin-pad button:active { background: #FDF3E3; }
.pin-pad .pad-ok { background: var(--naranja); color: var(--blanco); font-weight: 700; }
.pin-pad .pad-borrar { color: var(--rojo); }
.msg-grande { font-size: 1.2rem; padding: 1rem; border-radius: var(--radio); margin: 1rem 0; }
.msg-grande.ok { background: #E8F8EF; color: var(--verde); }
.msg-grande.error { background: #FDECEA; color: var(--rojo); }
.msg-grande.aviso { background: #FDF3E3; color: var(--amarillo); }
#visor-scanner, #visor-tarjeta { width: 100%; max-height: 65vh; border-radius: var(--radio); background: #000; margin-top: .6rem; }
.badge-offline {
  position: fixed; bottom: .8rem; left: 50%; transform: translateX(-50%);
  background: var(--gris-osc); color: var(--blanco); padding: .4rem .9rem;
  border-radius: 999px; font-size: .85rem; z-index: 60;
}

/* ---------------- impresión QRs ---------------- */
.hoja-qr {
  background: var(--blanco); border: 2px solid var(--gris); border-radius: var(--radio);
  padding: 1.2rem; margin: 1rem auto; max-width: 420px; text-align: center;
  page-break-after: always;
}
.hoja-qr img { width: min(300px, 80vw); height: auto; }
.hoja-qr .titulo { font-size: 1.3rem; font-weight: 700; }
.hoja-qr .sub { color: var(--gris); }
.hoja-qr.privado { border-color: var(--naranja); }
@media print {
  .topbar, .no-print, .flashes { display: none !important; }
  body { background: #fff; }
  .hoja-qr { box-shadow: none; margin: 0 auto 1cm; }
}

/* ---------------- BI ---------------- */
.bi-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 900px) { .bi-grid { grid-template-columns: 1fr 1fr; } }
.bi-card {
  background: var(--blanco); border-radius: var(--radio); box-shadow: var(--sombra);
  padding: 1rem 1.2rem; min-width: 0; border-top: 3px solid var(--naranja);
}
.bi-card canvas { max-width: 100%; cursor: zoom-in; }
.bi-cab { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.bi-cab h2 { margin: .2rem 0 .6rem; }
.bi-expand {
  background: var(--gris-claro); border: none; cursor: pointer; color: var(--gris-osc);
  font-size: 1.05rem; border-radius: 6px; padding: .2rem .55rem; min-height: 34px;
}
.bi-expand:hover { background: var(--naranja); color: var(--blanco); }
.filtros { display: flex; gap: .7rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.filtros label.campo { flex: 0 1 200px; }
.filtros-card {
  background: var(--blanco); border-radius: var(--radio); box-shadow: var(--sombra);
  padding: 1rem 1.2rem; border-top: 3px solid var(--naranja);
}
.bi-rango-txt { color: var(--gris); margin: .4rem 0 0; }

/* modal de gráfica ampliada */
.bi-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.bi-modal-caja {
  background: var(--blanco); border-radius: var(--radio);
  width: min(1200px, 96vw); height: min(88vh, 820px);
  display: flex; flex-direction: column; padding: 1rem 1.4rem;
  box-shadow: 0 8px 40px rgba(0,0,0,.35);
}
.bi-modal-filtros {
  margin: .5rem 0 0; padding: .6rem .8rem; background: var(--gris-claro);
  border-radius: var(--radio);
}
.bi-modal-filtros label.campo { flex: 1 1 140px; font-size: .8rem; }
.bi-modal-filtros select, .bi-modal-filtros input { padding: .4rem .5rem; font-size: .9rem; }
.bi-modal-cab { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.bi-modal-cab h2 { margin: 0; }
.bi-modal-cuerpo { flex: 1; min-height: 0; position: relative; margin-top: .6rem; }
.bi-modal-cuerpo canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }

/* acciones de tablas más ordenadas */
td .acciones, td.acciones { align-items: center; }
.acciones select { max-width: 190px; }
.acciones-col { display: flex; flex-direction: column; gap: .5rem; min-width: 300px; }
.fila-acc { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.fila-acc select { max-width: 200px; flex: 1 1 150px; }
.qr-mini { text-align: center; color: var(--gris); }
.qr-mini img { display: block; margin: 0 auto .2rem; border: 1px solid #ECECEC; border-radius: 6px; padding: 3px; background: #fff; }
td { vertical-align: middle; }

/* ---------------- error ---------------- */
.error-wrap { text-align: center; margin: 12vh auto; max-width: 420px; padding: 1rem; }
.error-wrap .cod { font-size: 3.2rem; font-weight: 700; color: var(--gris); }

/* código generado (se muestra una vez) */
.codigo-once {
  background: #FDF3E3; border: 2px dashed var(--naranja); border-radius: var(--radio);
  padding: 1rem; margin: 1rem 0; text-align: center;
}
.codigo-once .cod { font-size: 2rem; letter-spacing: .4rem; font-weight: 700; color: var(--naranja-osc); }
