:root {
  --rojo: #D7150F; --rojo-oscuro: #B00D08; --rojo-texto: #C40F0A; --rosado: #FDECEC;
  --texto: #222; --gris: #6B6B6B; --borde: #E8E8E8; --fondo: #F7F7F7;
  --verde: #1B7F3B; --azul: #1F5FA8; --naranja: #B26A00; --vino: #8E1B1B;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif; font-size: 15px; color: var(--texto); background: var(--fondo); }
[hidden] { display: none !important; }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 21px; margin: 0 0 4px; display: inline-block; border-bottom: 3px solid var(--rojo); padding-bottom: 2px; }
h3 { font-size: 16px; margin: 0 0 8px; color: var(--rojo-texto); }
.ayuda { color: var(--gris); margin: 4px 0 14px; line-height: 1.45; }
.pequeno { font-size: 13px; }
.error { color: var(--rojo-texto); font-weight: 600; min-height: 1em; margin: 6px 0; }

label { display: block; font-size: 13px; color: #444; margin: 0 0 10px; font-weight: 600; }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 9px 10px; font: inherit; font-weight: 400;
  border: 1px solid #D5D5D5; border-radius: 7px; background: #fff; color: var(--texto);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--rosado); border-color: var(--rojo); }
input[type=checkbox] { display: inline; width: auto; margin: 0 6px 0 0; }
textarea { min-height: 90px; resize: vertical; }
button { font: inherit; cursor: pointer; border-radius: 7px; padding: 9px 16px; border: 1px solid #D5D5D5; background: #fff; color: var(--texto); }
button:hover { border-color: var(--rojo); }
button.primario { background: var(--rojo); border-color: var(--rojo); color: #fff; font-weight: 600; }
button.primario:hover { background: var(--rojo-oscuro); }
button.peligro { color: var(--vino); border-color: #EBC1BF; }
button.enlace { border: none; background: none; padding: 4px 0; color: var(--gris); text-align: left; }
button.enlace:hover { color: var(--rojo-texto); }
button:disabled { opacity: .55; cursor: wait; }

/* Acceso */
.acceso { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; }
.tarjeta-acceso { background: #fff; width: 100%; max-width: 400px; padding: 28px; border-radius: 14px; border: 1px solid var(--borde); border-top: 4px solid var(--rojo); }
.tarjeta-acceso button.primario { width: 100%; padding: 11px; margin-top: 4px; }
.logo-acceso { width: 220px; display: block; margin: 0 auto 14px; }

/* Estructura */
.app { display: flex; min-height: 100%; }
.lateral { width: 250px; background: #fff; border-right: 1px solid var(--borde); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.marca { padding: 18px 18px 10px; } .marca img { width: 100%; }
.linea-roja { height: 3px; background: var(--rojo); }
.nombre-app { padding: 14px 20px 8px; font-size: 17px; line-height: 1.25; font-weight: 700; }
.nombre-app small { display: block; font-size: 12px; color: var(--gris); font-weight: 400; }
nav a { display: block; margin: 2px 10px; padding: 10px 14px; border-radius: 7px; color: #555; text-decoration: none; }
nav a:hover { background: #F5F5F5; color: var(--texto); }
nav a.activo { background: var(--rosado); color: var(--rojo-texto); font-weight: 700; }
.pie-lateral { margin-top: auto; padding: 14px 20px; border-top: 1px solid var(--borde); display: flex; flex-direction: column; gap: 2px; }
.usuario { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--gris); margin-bottom: 6px; text-decoration: none; }
.usuario b { color: var(--texto); display: block; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: none; background: var(--rosado); color: var(--rojo-texto);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; }
.avatar.grande { width: 112px; height: 112px; font-size: 38px; }
.persona { display: flex; gap: 10px; align-items: center; }
.punto { width: 11px; height: 11px; border-radius: 50%; display: inline-block; background: #BDBDBD; margin-right: 6px; }
.punto.si { background: #22A447; box-shadow: 0 0 0 3px #D8F3DF; }
.r-DUENO { background: #222; } .r-SEGUNDO_DUENO { background: var(--rojo); } .r-ADMINISTRADOR { background: var(--azul); } .r-OPERADOR { background: #6B6B6B; }
.foto-perfil { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.foto-perfil .botones { justify-content: flex-start; margin: 0; }
.oculto-archivo { display: none; }
.insignia { background: var(--rojo); color: #fff; border-radius: 10px; font-size: 11px; font-weight: 700; padding: 1px 7px; margin-left: 4px; }
a.boton-wa { display: inline-flex; align-items: center; gap: 8px; background: #1FA855; color: #fff; text-decoration: none; font-weight: 700;
  padding: 11px 18px; border-radius: 8px; }
a.boton-wa:hover { background: #178A45; }
.clave-temporal { font-family: Consolas, "Courier New", monospace; font-size: 26px; font-weight: 700; letter-spacing: 2px; text-align: center;
  background: #F3F3F3; border-radius: 10px; padding: 14px; margin: 10px 0; user-select: all; }
.alerta { border-left: 5px solid var(--rojo); }
.contenido { flex: 1; padding: 26px 30px; max-width: 1150px; min-width: 0; }
.barra-movil { display: none; }

/* Piezas */
.tarjeta { background: #fff; border: 1px solid var(--borde); border-radius: 12px; padding: 16px 18px; margin-bottom: 14px; }
.rejilla { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin: 12px 0 16px; }
.cifra { font-size: 30px; font-weight: 700; } .cifra-etq { color: var(--gris); font-size: 13px; }
.fila { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.fila > .crece { flex: 1; min-width: 180px; }
.columnas { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.columnas .doble { grid-column: 1 / -1; }
.tabla-env { overflow-x: auto; background: #fff; border: 1px solid var(--borde); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; background: #F3F3F3; border-bottom: 2px solid var(--rojo); padding: 9px 10px; white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid #F0F0F0; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.acciones { white-space: nowrap; text-align: right; } td.acciones button { padding: 5px 10px; font-size: 13px; }
.estado { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 9px; color: #fff; white-space: nowrap; }
.e-VIGENTE { background: var(--verde); } .e-PROGRAMADA { background: var(--azul); } .e-VENCIDA { background: var(--naranja); } .e-ANULADA { background: var(--vino); }
.placa { font-weight: 800; letter-spacing: 1px; }
.vacio { padding: 26px; text-align: center; color: var(--gris); }
.exito { border-color: #BFE3CB; border-left: 5px solid var(--verde); }
.etiqueta { display: inline-block; font-size: 12px; background: #F1F1F1; border-radius: 8px; padding: 2px 8px; color: #444; }
.aviso { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: 11px 18px; border-radius: 9px; z-index: 50; max-width: 90vw; }
dialog { border: none; border-radius: 14px; padding: 0; width: min(520px, 94vw); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog form { padding: 22px; }
.botones { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }

@media (max-width: 860px) {
  .lateral { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .lateral.abierto { transform: none; box-shadow: 0 0 30px rgba(0,0,0,.2); }
  .barra-movil { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30; background: #fff; border-bottom: 3px solid var(--rojo); padding: 8px 12px; }
  .barra-movil img { height: 32px; } .barra-movil span { font-weight: 700; font-size: 18px; }
  .icono { font-size: 20px; padding: 4px 10px; }
  .app { flex-direction: column; }
  .contenido { padding: 16px; }
  .columnas { grid-template-columns: 1fr; }
}
