/* =====================================================================
   EXPOLUZ ACCESS MANAGER — Hoja de estilos
   ---------------------------------------------------------------------
   Identidad tomada del logo de Expoluz: fondo claro, tipografía en el
   negro del isotipo y el rojo de la marca reservado para lo que importa
   (acción principal, sección activa, alertas). Los valores de rojo, gris
   y negro salen de muestrear el archivo del logo, no son aproximados.

   Layout por dispositivo:
     · ≥ 1000px  sidebar completo a la izquierda
     · 640–999px sidebar reducido a barra de íconos
     · < 640px   barra inferior fija + tablas convertidas en tarjetas
   ===================================================================== */

:root {
    /* --- Marca --- */
    --rojo:         #d6261e;   /* rojo del isotipo */
    --rojo-oscuro:  #ab1c15;   /* hover y textos sobre claro */
    --rojo-suave:   #fdeceb;   /* fondos teñidos */
    --gris-marca:   #969593;   /* gris de "luz" */
    --negro-marca:  #1f1a17;   /* negro de "expo" */

    /* --- Superficies --- */
    --bg-base:   #f4f2f1;      /* neutro cálido, no gris de fábrica */
    --bg-panel:  #ffffff;
    --bg-hover:  #ece8e6;
    --bg-sutil:  #faf9f8;
    --border:    #e0dad7;
    --border-fuerte: #cdc5c1;

    /* --- Texto --- */
    --text-main: #1f1a17;
    --text-sec:  #6f6763;

    /* --- Semánticos (independientes del rojo de marca) --- */
    --exito:   #0e7a45;
    --alerta:  #a86407;
    --peligro: #d6261e;

    /* --- Sombras --- */
    --sombra-1: 0 1px 2px rgba(31,26,23,0.06), 0 1px 3px rgba(31,26,23,0.04);
    --sombra-2: 0 2px 6px rgba(31,26,23,0.07), 0 8px 20px rgba(31,26,23,0.06);
    --sombra-3: 0 12px 40px rgba(31,26,23,0.18);

    /* --- Alias de compatibilidad ---
       Estos nombres quedaron de la maqueta original y siguen usándose en
       estilos en línea del HTML. Se mantienen apuntando a la paleta nueva
       para no tener que tocarlos uno por uno. */
    --accent-blue: var(--rojo);
    --accent-red:  var(--peligro);
    --success:     var(--exito);
    --warning:     var(--alerta);

    --sidebar-ancho: 260px;
    --radio: 12px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; }

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--rojo); outline-offset: 2px; }

/* =====================================================================
   ÍCONOS
   Un solo set de trazo, sin relleno, en currentColor: heredan el color
   del contexto (menú activo, botón de peligro, texto secundario) sin
   tener que declarar variantes.
   ===================================================================== */
.ico, .nav-ico, .foto-ico {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}
.ico { width: 1.05em; height: 1.05em; vertical-align: -0.18em; }
.nav-ico { width: 19px; height: 19px; }
.foto-ico { width: 26px; height: 26px; stroke-width: 1.4; }
.ico.rotado { transform: rotate(45deg); }   /* el "+" pasa a ser una X */

/* Los botones separan el ícono del texto sin depender de espacios */
.btn { display: inline-flex; align-items: center; gap: 7px; justify-content: center; }
.btn .ico { width: 15px; height: 15px; vertical-align: 0; }

/* Punto de estado: reemplaza al carácter ● , que cambia de tamaño según
   la tipografía instalada */
.punto { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; margin-right: 6px; flex-shrink: 0; }
.sin-leer { color: var(--rojo); display: inline-flex; align-items: center; }

/* Varias clases de acá abajo declaran display:flex, que le gana a la regla
   [hidden]{display:none} del navegador. Sin esto, el chip de filtro, la
   campanita en cero y el botón de instalar quedarían siempre visibles. */
[hidden] { display: none !important; }

/* --------------------------------------------------------------- LOGIN */
#login-screen { position: fixed; inset: 0; background: var(--bg-base); display: flex; justify-content: center; align-items: center; z-index: 1000; padding: 20px; }
.login-box { background: var(--bg-panel); padding: 40px 36px; border-radius: 16px; border: 1px solid var(--border); box-shadow: var(--sombra-2); width: 100%; max-width: 410px; text-align: center; }
.logo-login { width: 100%; max-width: 240px; height: auto; margin: 0 auto 18px; display: block; }
.login-box .sub { color: var(--text-sec); margin-bottom: 26px; font-size: 13.5px; }
.login-box input { width: 100%; padding: 12px 14px; margin-bottom: 14px; border-radius: 9px; border: 1px solid var(--border-fuerte); background: var(--bg-sutil); color: var(--text-main); outline: none; font-size: 16px; transition: 0.15s; }
.login-box input:focus { border-color: var(--rojo); background: #fff; box-shadow: 0 0 0 3px rgba(214,38,30,0.12); }
.login-box button { width: 100%; padding: 13px; background: var(--rojo); color: #fff; border: none; border-radius: 9px; font-weight: 700; cursor: pointer; transition: 0.15s; font-size: 15px; }
.login-box button:hover:not(:disabled) { background: var(--rojo-oscuro); }
.login-box button:disabled { opacity: 0.55; cursor: not-allowed; }
.login-error { color: var(--rojo-oscuro); font-size: 13px; margin-bottom: 12px; min-height: 18px; }

/* ------------------------------------------------------------- SIDEBAR */
.sidebar { width: var(--sidebar-ancho); background: var(--bg-panel); border-right: 1px solid var(--border); display: none; flex-direction: column; padding: 22px 16px; flex-shrink: 0; }
.sidebar.visible { display: flex; }

.logo-container { display: flex; flex-direction: column; gap: 8px; margin-bottom: 32px; padding: 0 4px; }
.logo-sidebar { width: 150px; height: auto; }
.logo-isotipo { width: 38px; height: auto; display: none; }   /* solo en modo compacto */
.logo-badge { background: var(--negro-marca); color: #fff; padding: 4px 9px; border-radius: 5px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.4px; width: fit-content; text-transform: uppercase; }
.user-email { font-size: 11.5px; color: var(--text-sec); word-break: break-all; }

.nav-menu { list-style: none; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item { padding: 11px 13px; border-radius: 9px; cursor: pointer; color: var(--text-sec); font-weight: 500; font-size: 14px; transition: 0.15s; display: flex; align-items: center; gap: 11px; position: relative; user-select: none; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-main); }
.nav-item.active { background: var(--rojo-suave); color: var(--rojo-oscuro); font-weight: 600; box-shadow: inset 3px 0 0 var(--rojo); }
/* El botón de NFC late mientras la lectura está abierta */
.btn-nfc.leyendo { background: var(--rojo); animation: latido 1.4s ease-in-out infinite; }
@keyframes latido { 0%,100% { opacity: 1; } 50% { opacity: 0.62; } }
.nav-salir { margin-top: auto; color: var(--rojo-oscuro); }
.nav-instalar { color: var(--exito); }
#nav-superadmin { color: var(--negro-marca); }

.badge-contador { margin-left: auto; background: var(--rojo); color: #fff; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }

/* -------------------------------------------------------- ÁREA CENTRAL */
.main-content { flex: 1; display: none; flex-direction: column; overflow-y: auto; padding: 30px 34px; }
.main-content.visible { display: flex; }

.view-section { display: none; animation: fadeIn 0.25s ease; }
.view-section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; flex-wrap: wrap; gap: 15px; }
.titulo-vista { font-size: 23px; letter-spacing: -0.3px; }
.subtitulo-vista { color: var(--text-sec); font-size: 13.5px; margin-top: 3px; }
.titulo-seccion { font-size: 15px; }
.building-selector, select.input { background: var(--bg-panel); border: 1px solid var(--border-fuerte); color: var(--text-main); padding: 10px 12px; border-radius: 9px; outline: none; font-size: 14px; max-width: 100%; box-shadow: var(--sombra-1); }
.building-selector:focus, select.input:focus { border-color: var(--rojo); }

/* ------------------------------------------------ TARJETAS DE MÉTRICAS */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 18px; margin-bottom: 20px; }
.card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radio); padding: 20px; box-shadow: var(--sombra-1); }
.card h3 { color: var(--text-sec); font-size: 12.5px; font-weight: 600; letter-spacing: 0.2px; }
.card .value { font-size: 30px; font-weight: 700; margin-top: 8px; font-variant-numeric: tabular-nums; }

.card-filtro { text-align: left; cursor: pointer; color: var(--text-main); font: inherit; transition: 0.15s; display: flex; flex-direction: column; }
.card-filtro:hover { box-shadow: var(--sombra-2); transform: translateY(-2px); }
.card-filtro[aria-pressed="true"] { box-shadow: inset 0 0 0 2px currentColor, var(--sombra-1); background: var(--bg-sutil); }
.card-hint { font-size: 11px; color: var(--text-sec); margin-top: 8px; }
.card-filtro[aria-pressed="true"] .card-hint::after { content: " · activo"; color: var(--rojo); font-weight: 700; }

.filtro-activo { display: flex; align-items: center; gap: 10px; background: var(--rojo-suave); border: 1px solid rgba(214,38,30,0.28); color: var(--rojo-oscuro); padding: 8px 14px; border-radius: 20px; font-size: 13px; font-weight: 500; width: fit-content; margin-bottom: 18px; }
.filtro-activo button { background: none; border: none; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; }

/* ---------------------------------------------------------- TABLAS */
.tabla-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; background: var(--bg-panel); border-radius: var(--radio); overflow: hidden; border: 1px solid var(--border); font-size: 14px; box-shadow: var(--sombra-1); }
.data-table th, .data-table td { padding: 13px 15px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table th { background: var(--bg-sutil); color: var(--text-sec); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; }
.data-table tbody tr { transition: background 0.12s; }
.data-table tbody tr:hover { background: var(--bg-sutil); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .empty { text-align: center; color: var(--text-sec); padding: 34px; }

.tag-badge { background: var(--bg-hover); color: var(--negro-marca); padding: 4px 9px; border-radius: 5px; font-family: 'Consolas', monospace; border: 1px solid var(--border-fuerte); white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; }
.tag-badge.lost { background: var(--rojo-suave); color: var(--rojo-oscuro); border-color: rgba(214,38,30,0.3); text-decoration: line-through; }

.estado-activo  { color: var(--exito);   font-weight: 700; }
.estado-perdido { color: var(--peligro); font-weight: 700; }

/* ---------------------------------------------------------- BOTONES */
.btn { background: var(--rojo); color: #fff; border: none; padding: 9px 16px; border-radius: 8px; cursor: pointer; font-weight: 600; transition: 0.15s; font-size: 13px; white-space: nowrap; box-shadow: var(--sombra-1); }
.btn:hover:not(:disabled) { background: var(--rojo-oscuro); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn-danger { background: #fff; border: 1px solid rgba(214,38,30,0.45); color: var(--rojo-oscuro); }
.btn-danger:hover:not(:disabled) { background: var(--rojo-suave); }
.btn-warning { background: #fff; border: 1px solid rgba(168,100,7,0.45); color: var(--alerta); }
.btn-warning:hover:not(:disabled) { background: #fdf5e7; }
.btn-success { background: #fff; border: 1px solid rgba(14,122,69,0.45); color: var(--exito); }
.btn-success:hover:not(:disabled) { background: #e7f5ee; }
.btn-pdf { background: #fff; border: 1px solid var(--border-fuerte); color: var(--negro-marca); }
.btn-pdf:hover:not(:disabled) { background: var(--bg-hover); }
.btn-nfc { background: var(--exito); }
.btn-nfc:hover:not(:disabled) { background: #0a5f36; }
.btn-ghost { background: #fff; border: 1px solid var(--border-fuerte); color: var(--text-sec); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-main); }
.btn-chico { padding: 6px 11px; font-size: 12px; }
.btn-ancho { width: 100%; }

.acciones-col { display: flex; gap: 6px; flex-wrap: wrap; }
.acciones-barra { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.section-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; gap: 12px; flex-wrap: wrap; }
.search-input { background: var(--bg-panel); border: 1px solid var(--border-fuerte); color: var(--text-main); padding: 9px 13px; border-radius: 9px; outline: none; min-width: 240px; flex: 1 1 240px; font-size: 14px; box-shadow: var(--sombra-1); }
.search-input:focus { border-color: var(--rojo); }
.search-input::placeholder { color: #a49c98; }

/* --------------------------------------------------------- FORMULARIOS */
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 6px; color: var(--text-sec); font-size: 13px; font-weight: 500; }
.form-group input, .form-group select {
    width: 100%; padding: 11px 13px; border-radius: 9px; border: 1px solid var(--border-fuerte);
    background: var(--bg-sutil); color: var(--text-main); outline: none;
    font-size: 16px;   /* 16px evita el zoom automático de iOS al enfocar */
    transition: 0.15s;
}
.form-group input:focus, .form-group select:focus { border-color: var(--rojo); background: #fff; box-shadow: 0 0 0 3px rgba(214,38,30,0.1); }
.form-group input:invalid:not(:placeholder-shown) { border-color: var(--peligro); }
/* Campos autocompletados desde un propietario ya existente */
.form-group input[readonly] { background: var(--bg-hover); color: var(--text-sec); cursor: default; }
.form-group input[readonly]:focus { box-shadow: none; border-color: var(--border-fuerte); background: var(--bg-hover); }

.panel { background: var(--bg-panel); padding: 26px; border-radius: var(--radio); border: 1px solid var(--border); box-shadow: var(--sombra-1); }
.panel + .panel { margin-top: 22px; }
.panel h3 { font-size: 15px; margin-bottom: 18px; display: flex; align-items: center; gap: 8px; }
.panel h3 .ico, .sub-panel h4 .ico { width: 17px; height: 17px; color: var(--text-sec); }
.sub-panel h4 { display: flex; align-items: center; gap: 7px; }
.panel-form { max-width: 520px; }
.hint { color: var(--text-sec); font-size: 12px; margin-top: 6px; line-height: 1.55; }
.separador { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; align-items: end; }
.form-grid .form-group { margin-bottom: 0; }
.mt-15 { margin-top: 15px; } .mt-20 { margin-top: 20px; } .mb-10 { margin-bottom: 10px; }

.aviso-propietario { background: var(--rojo-suave); border: 1px solid rgba(214,38,30,0.25); border-radius: 9px; padding: 12px 14px; font-size: 13px; line-height: 1.6; margin-bottom: 15px; color: var(--text-main); }
.aviso-propietario strong { color: var(--rojo-oscuro); }
.aviso-propietario .lista-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; align-items: center; }

.check-seguir { display: flex; align-items: center; gap: 9px; color: var(--text-sec); font-size: 13px; cursor: pointer; margin: 8px 0 4px; }
.check-seguir input { width: 17px; height: 17px; accent-color: var(--rojo); cursor: pointer; flex-shrink: 0; }

.fila-botones { display: flex; gap: 10px; margin-top: 14px; }
.fila-botones .btn-ancho { flex: 1; }
.fila-nfc { display: flex; gap: 10px; }
.fila-nfc input { font-family: 'Consolas', monospace; font-weight: 700; letter-spacing: 1px; font-variant-numeric: tabular-nums; }

.etiqueta-opcional { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; background: var(--bg-hover); border: 1px solid var(--border); color: var(--text-sec); padding: 2px 7px; border-radius: 10px; margin-left: 6px; font-weight: 600; }

/* ---- Carga de foto para acceso facial ---- */
.zona-foto { border: 1px dashed var(--border-fuerte); border-radius: 10px; background: var(--bg-sutil); transition: 0.15s; }
.zona-foto:hover, .zona-foto.arrastrando { border-color: var(--rojo); background: var(--rojo-suave); }
.foto-vacia { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 26px 16px; cursor: pointer; text-align: center; color: var(--text-sec); font-size: 13px; }
.foto-vacia .foto-ico { font-size: 26px; }
.foto-vacia .hint { margin: 0; }
.foto-cargada { display: flex; gap: 16px; padding: 16px; align-items: center; }
.foto-cargada img { width: 92px; height: 116px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-panel); }
.foto-datos { display: flex; flex-direction: column; gap: 7px; align-items: flex-start; min-width: 0; }
.foto-datos strong { font-size: 13px; word-break: break-all; }
.foto-datos .hint { margin: 0; }

/* ---- Período de vigencia ---- */
.fila-fechas { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0 4px; }
.fila-fechas label { display: block; margin-bottom: 5px; color: var(--text-sec); font-size: 13px; }
.fila-fechas input { width: 100%; padding: 11px; border-radius: 9px; border: 1px solid var(--border-fuerte); background: var(--bg-sutil); color: var(--text-main); outline: none; font-size: 15px; }
.fila-fechas input:focus { border-color: var(--rojo); background: #fff; }

/* ---- Credenciales en el directorio ---- */
.credenciales { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.avatar-facial { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; border: 2px solid var(--bg-panel); box-shadow: 0 0 0 1px var(--border-fuerte); flex-shrink: 0; }
.pill-facial { background: #e7f5ee; color: var(--exito); border: 1px solid rgba(14,122,69,0.28); padding: 4px 9px; border-radius: 5px; font-size: 11.5px; font-weight: 700; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.pill-facial .ico { width: 13px; height: 13px; }
.sin-credencial { color: var(--text-sec); font-style: italic; font-size: 12.5px; }
.vigencia { font-size: 11px; color: var(--text-sec); display: flex; align-items: center; gap: 4px; margin-top: 5px; font-variant-numeric: tabular-nums; }
.vigencia .ico { width: 13px; height: 13px; }
.vigencia.vencida { color: var(--peligro); font-weight: 600; }
.foto-modal { width: 84px; height: 106px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }

/* Bloque de dispositivos dentro del alta de edificio */
.sub-panel { border: 1px dashed var(--border-fuerte); border-radius: 10px; padding: 16px; margin-top: 20px; background: var(--bg-sutil); }
.sub-panel-cab { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.sub-panel h4 { font-size: 13px; color: var(--text-main); }
.fila-dispositivo { display: grid; grid-template-columns: 1.2fr 1.2fr 1fr auto; gap: 10px; margin-bottom: 10px; align-items: center; }
.fila-dispositivo input { padding: 10px; border-radius: 8px; border: 1px solid var(--border-fuerte); background: #fff; color: var(--text-main); outline: none; font-size: 14px; width: 100%; }
.fila-dispositivo input:focus { border-color: var(--rojo); }
.fila-dispositivo .quitar { background: #fff; border: 1px solid rgba(214,38,30,0.45); color: var(--rojo-oscuro); border-radius: 8px; cursor: pointer; padding: 9px 11px; display: flex; align-items: center; }
.fila-dispositivo .quitar .ico { width: 15px; height: 15px; }
.fila-dispositivo .quitar:hover { background: var(--rojo-suave); }

/* --------------------------------------------------- FICHAS DE EDIFICIO */
.grid-edificios { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 18px; }
.ficha-edificio { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radio); padding: 20px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--sombra-1); transition: 0.15s; }
.ficha-edificio:hover { box-shadow: var(--sombra-2); }
.ficha-edificio h3 { font-size: 16px; }
.ficha-edificio .direccion { color: var(--text-sec); font-size: 13px; }
.ficha-cifras { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; }
.ficha-cifras span { display: flex; align-items: center; gap: 4px; }
.ficha-cifras .ico { width: 15px; height: 15px; }
.ficha-acciones { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }
.lista-equipos { list-style: none; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--border); padding-top: 13px; }
.lista-equipos li { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 12.5px; }
.lista-equipos .sn { font-family: 'Consolas', monospace; color: var(--text-sec); font-size: 11.5px; }
.lista-equipos .vacio { color: var(--text-sec); font-style: italic; }

.role-pill { font-size: 10.5px; padding: 3px 9px; border-radius: 20px; text-transform: uppercase; font-weight: 700; white-space: nowrap; }
.role-pill.superadmin { background: var(--rojo-suave); color: var(--rojo-oscuro); border: 1px solid rgba(214,38,30,0.3); }
.role-pill.cliente { background: var(--bg-hover); color: var(--text-sec); border: 1px solid var(--border-fuerte); }

/* ------------------------------------------------------- NOTIFICACIONES */
.lista-notif { display: flex; flex-direction: column; gap: 10px; }
.notif { background: var(--bg-panel); border: 1px solid var(--border); border-left: 4px solid var(--border-fuerte); border-radius: 10px; padding: 14px 18px; display: flex; gap: 14px; align-items: flex-start; box-shadow: var(--sombra-1); }
.notif.no-leida { border-left-color: var(--rojo); background: #fffdfd; }
.notif .icono { color: var(--text-sec); display: flex; padding-top: 1px; }
.notif .icono .ico { width: 18px; height: 18px; }
.notif.no-leida .icono { color: var(--rojo); }
.notif .cuerpo { flex: 1; min-width: 0; }
.notif .texto { font-size: 14px; line-height: 1.5; }
.notif .meta { font-size: 11.5px; color: var(--text-sec); margin-top: 6px; display: flex; gap: 10px; flex-wrap: wrap; }
.notif .meta strong { color: var(--text-main); font-weight: 600; }
.notif-vacia { color: var(--text-sec); text-align: center; padding: 44px 20px; }

/* --------------------------------------------------------------- TOASTS */
#toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 2000; max-width: min(340px, calc(100vw - 32px)); }
.toast { background: var(--bg-panel); border: 1px solid var(--border); border-left: 4px solid var(--rojo); padding: 14px 18px; border-radius: 9px; font-size: 13.5px; line-height: 1.5; box-shadow: var(--sombra-3); animation: slideIn 0.25s ease; }
.toast.ok { border-left-color: var(--exito); }
.toast.error { border-left-color: var(--peligro); }
.toast.warn { border-left-color: var(--alerta); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* --------------------------------------------------------------- MODALES */
.modal-fondo { position: fixed; inset: 0; background: rgba(31,26,23,0.45); backdrop-filter: blur(2px); z-index: 1500; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-caja { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px; width: 100%; max-width: 560px; max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--sombra-3); }
.modal-cab { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-cab h3 { font-size: 16px; margin: 0; }
.modal-cerrar { background: none; border: none; color: var(--text-sec); font-size: 22px; cursor: pointer; line-height: 1; padding: 0 4px; }
.modal-cerrar:hover { color: var(--rojo); }
.modal-cuerpo { padding: 22px; overflow-y: auto; }
.modal-pie { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; background: var(--bg-sutil); }

.loading { color: var(--text-sec); font-size: 13px; }
.print-header { display: none; }

/* =====================================================================
   TABLET — el sidebar se reduce a una barra de íconos
   ===================================================================== */
@media (max-width: 999px) and (min-width: 640px) {
    .sidebar.visible { width: 76px; padding: 18px 10px; align-items: center; }
    .sidebar .nav-txt, .sidebar .user-email, .sidebar .logo-badge, .logo-sidebar { display: none; }
    .logo-isotipo { display: block; width: 34px; }
    .logo-container { margin-bottom: 26px; align-items: center; }
    .nav-item { justify-content: center; padding: 13px 8px; }
    .nav-item.active { box-shadow: inset 0 -3px 0 var(--rojo); }
    .nav-ico { width: 22px; height: 22px; }
    .badge-contador { position: absolute; top: 4px; right: 10px; margin: 0; }
    .main-content { padding: 24px; }
}

/* =====================================================================
   CELULAR — barra inferior fija y tablas convertidas en tarjetas
   ===================================================================== */
@media (max-width: 639px) {
    body { flex-direction: column; overflow: auto; }

    .sidebar.visible {
        order: 2; position: fixed; bottom: 0; left: 0; right: 0; width: 100%;
        flex-direction: row; padding: 6px 4px calc(6px + var(--safe-bottom));
        border-right: none; border-top: 1px solid var(--border);
        box-shadow: 0 -2px 12px rgba(31,26,23,0.07); z-index: 500;
    }
    .sidebar .logo-container { display: none; }
    .nav-menu { flex-direction: row; gap: 2px; width: 100%; justify-content: space-around; }
    .nav-item { flex-direction: column; gap: 3px; padding: 8px 4px; font-size: 10px; flex: 1; justify-content: center; text-align: center; min-width: 0; }
    .nav-item.active { box-shadow: none; }
    .nav-ico { width: 21px; height: 21px; }
    .nav-txt { font-size: 9.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
    .nav-salir { margin-top: 0; }
    .badge-contador { position: absolute; top: 2px; right: 50%; transform: translateX(22px); margin: 0; min-width: 17px; height: 17px; font-size: 10px; }

    .main-content { padding: 16px 14px calc(78px + var(--safe-bottom)); }
    .header { margin-bottom: 20px; }
    .titulo-vista { font-size: 19px; }
    .building-selector { width: 100%; }
    .card-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .card { padding: 15px; }
    .card .value { font-size: 25px; margin-top: 6px; }
    .card-filtro:last-child { grid-column: 1 / -1; }
    .search-input { min-width: 0; width: 100%; flex: 1 1 100%; }
    .acciones-barra .btn { flex: 1; }
    .panel { padding: 18px; }
    .form-grid, .fila-fechas { grid-template-columns: 1fr; }
    .fila-botones { flex-direction: column; }
    .foto-cargada { flex-direction: column; align-items: flex-start; }
    .grid-edificios { grid-template-columns: 1fr; }
    .fila-dispositivo { grid-template-columns: 1fr 1fr; }
    .fila-dispositivo .quitar { grid-column: 2; justify-self: end; }
    #toast-container { left: 14px; right: 14px; bottom: calc(84px + var(--safe-bottom)); max-width: none; }
    .modal-caja { max-height: 92vh; }

    /* Cada fila pasa a ser una tarjeta con las etiquetas al costado */
    .tabla-responsive, .tabla-responsive thead, .tabla-responsive tbody,
    .tabla-responsive tr, .tabla-responsive td { display: block; width: 100%; }
    .tabla-responsive { border: none; background: none; box-shadow: none; }
    .tabla-responsive thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .tabla-responsive tr { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 11px; margin-bottom: 12px; padding: 6px 4px; box-shadow: var(--sombra-1); }
    .tabla-responsive tr:hover { background: var(--bg-panel); }
    .tabla-responsive td { border: none; display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 9px 14px; text-align: right; }
    .tabla-responsive td::before {
        content: attr(data-label);
        color: var(--text-sec); font-size: 10.5px; text-transform: uppercase;
        font-weight: 700; letter-spacing: 0.4px; text-align: left; flex-shrink: 0;
    }
    /* Los botones de acción entran en una sola línea */
    .tabla-responsive td.acciones-col { justify-content: flex-end; padding-top: 4px; flex-wrap: nowrap; gap: 6px; }
    .tabla-responsive td.acciones-col::before { display: none; }
    .tabla-responsive td.acciones-col .btn { padding: 8px 10px; font-size: 12px; }
    .tabla-responsive .empty { display: block; text-align: center; }
    .tabla-responsive .empty::before { content: ""; }
}

/* =====================================================================
   EXPORTAR A PDF — hoja corporativa con el logo (Ctrl+P > Guardar como PDF)
   ===================================================================== */
@media print {
    @page { margin: 14mm; size: A4; }

    body { background: #fff; color: #000; height: auto; overflow: visible; display: block; }
    .sidebar, .card-grid, .btn, .header select, .search-input, .section-bar,
    .filtro-activo, #login-screen, #toast-container, #modal-container,
    .acciones-col, .no-print { display: none !important; }

    .main-content { display: block !important; padding: 0; overflow: visible; }
    .view-section { display: none !important; }
    .view-section#view-dashboard { display: block !important; }
    .header { display: none; }

    .print-header { display: block; margin-bottom: 18px; border-bottom: 2px solid var(--rojo); padding-bottom: 12px; }
    .print-logo { width: 168px; height: auto; margin-bottom: 12px; }
    .print-header h1 { font-size: 21px; color: #000; margin-bottom: 6px; }
    .print-header .meta { font-size: 11.5px; color: #444; line-height: 1.65; }
    .print-header .meta strong { color: #000; }

    .data-table { border: 1px solid #ddd; border-radius: 0; box-shadow: none; font-size: 11px; width: 100%;
                  background: #fff !important; color: #000 !important; }
    .data-table tr, .data-table tbody { background: #fff !important; }
    .data-table th { background: #f2f2f2 !important; color: #222 !important; border-bottom: 2px solid #aaa; }
    .data-table td { border-bottom: 1px solid #eee; color: #000 !important; background: #fff !important; }
    .data-table td strong { color: #000 !important; }
    .data-table td::before { content: none !important; }
    .data-table tr { page-break-inside: avoid; }
    thead { display: table-header-group; }

    /* La especificidad tiene que superar a `.data-table td` */
    .data-table td.estado-activo  { color: #0a6b3c !important; }
    .data-table td.estado-perdido { color: #b3140e !important; }

    .tag-badge { border: none !important; background: none !important; color: #000 !important; padding: 0; font-weight: 700; }
    .tag-badge.lost { text-decoration: line-through; color: #b3140e !important; }
    .avatar-facial { box-shadow: none; border: 1px solid #ccc; }
    .pill-facial { background: none !important; border: 1px solid #aaa; color: #000 !important; }
}
