/* =========================================================================
   nodra.css — identidad visual del Control de Equipos TI
   -------------------------------------------------------------------------
   Organización del archivo:
     1. Tokens (variables de color, tipografía y espacio)
     2. Base y accesibilidad
     3. Barra lateral y navegación
     4. Lienzo, encabezados y avisos
     5. Tarjetas de métricas
     6. Tablas
     7. Formularios
     8. Botones, distintivos y utilidades
     9. Gráficas y piezas del tablero
    10. Pantalla de acceso
    11. Responsivo e impresión
   ========================================================================= */

/* ============================== 1. TOKENS =============================== */
:root {
  /* Paleta de marca */
  --tinta:        #15253c;   /* azul profundo: navegación y texto principal */
  --indigo:       #240690;   /* azul índigo vívido: acciones y dato clave   */
  --gris-azul:    #495563;   /* azul apagado: texto secundario              */
  --linea:        #dce2e8;   /* azul claro: bordes y separadores            */
  --papel:        #f7f9fb;   /* blanco de fondo                             */
  --blanco:       #ffffff;

  /* Derivados funcionales (mismo origen, distinta luminosidad) */
  --tinta-85:     #233550;
  --tinta-suave:  rgba(21, 37, 60, .06);
  --indigo-velo:  #eeebfa;
  --indigo-borde: #c9c0ee;
  --ok:           #0f6b4f;
  --ok-velo:      #e5f3ee;
  --alerta:       #96590a;
  --alerta-velo:  #fbf0dd;
  --alto:         #9c2a2a;
  --alto-velo:    #f8e8e8;

  /* Tipografía */
  --fuente-ui:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --fuente-display: 'Sora', 'Inter', -apple-system, 'Segoe UI', sans-serif;

  /* Espaciado y forma */
  --r-chico: 6px;
  --r:       10px;
  --r-grande:14px;
  --ancho-nav: 236px;
  --sombra: 0 1px 2px rgba(21, 37, 60, .05);
}

/* ============================ 2. BASE =================================== */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--papel);
  color: var(--tinta);
  font-family: var(--fuente-ui);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--fuente-display); font-weight: 600; margin: 0; line-height: 1.25; }
h1 { font-size: 1.65rem; letter-spacing: .035em; font-weight: 300; }
h2 { font-size: 1.05rem; letter-spacing: .02em; }
h3 { font-size: .95rem; letter-spacing: .015em; }
p  { margin: 0; }

a { color: var(--indigo); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 2px;
  border-radius: 3px;
}

.salto-contenido {
  position: absolute; left: -999px; top: 0; z-index: 99;
  background: var(--tinta); color: #fff; padding: 10px 16px;
}
.salto-contenido:focus { left: 8px; top: 8px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ========================= 3. BARRA LATERAL ============================= */
.barra-lateral {
  position: fixed; inset: 0 auto 0 0;
  width: var(--ancho-nav);
  background: var(--tinta);
  color: #cfd8e4;
  display: flex; flex-direction: column;
  padding: 22px 0 16px;
  z-index: 40;
  overflow: hidden;
}

/* Marca de agua: el isotipo recortado, apenas visible, como textura */
.barra-lateral::after {
  content: '';
  position: absolute; right: -110px; bottom: 120px;
  width: 300px; height: 300px;
  background: url('../img/nodra-isotipo-blanco.png') no-repeat center / contain;
  opacity: .04;
  pointer-events: none;
}

.marca { display: flex; align-items: center; gap: 11px; padding: 0 20px 24px; }
.marca-iso { width: 34px; height: auto; display: block; }
.marca-texto { display: flex; flex-direction: column; line-height: 1.15; }
.marca-nombre {
  font-family: var(--fuente-display); font-weight: 400;
  letter-spacing: .34em; font-size: .92rem; color: #fff;
}
.marca-sub { font-size: .72rem; color: #7e8ea4; letter-spacing: .06em; margin-top: 2px; }

.menu { display: flex; flex-direction: column; gap: 1px; padding: 0 12px; flex: 1; }
.menu-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--r-chico);
  color: #b4c0d1; font-size: .9rem; text-decoration: none;
  transition: background .12s ease, color .12s ease;
}
.menu-item:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.menu-item.es-activo { background: var(--indigo); color: #fff; }
.menu-item .icono { width: 17px; height: 17px; flex: none; opacity: .9; }

.barra-pie { padding: 14px 16px 0; border-top: 1px solid rgba(255,255,255,.09); margin: 0 12px; }
.perfil { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.perfil-inicial {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  background: rgba(255,255,255,.1); color: #fff;
  display: grid; place-items: center;
  font-family: var(--fuente-display); font-size: .85rem;
}
.perfil-datos { display: flex; flex-direction: column; min-width: 0; }
.perfil-nombre {
  color: #e7edf5; font-size: .83rem; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px;
}
.perfil-rol { font-size: .72rem; color: #7e8ea4; }
.barra-acciones { display: flex; flex-direction: column; gap: 2px; }
.barra-acciones a {
  display: flex; align-items: center; gap: 8px;
  color: #94a3b8; font-size: .8rem; padding: 5px 0; text-decoration: none;
}
.barra-acciones a:hover { color: #fff; text-decoration: none; }
.barra-acciones .icono { width: 14px; height: 14px; }

.abrir-menu { display: none; }

/* ===================== 4. LIENZO Y ENCABEZADOS ========================== */
.lienzo {
  margin-left: var(--ancho-nav);
  padding: 30px 34px 24px;
  min-height: 100vh;
  display: flex; flex-direction: column;
}
body.sin-nav .lienzo { margin-left: 0; padding: 0; }

.encabezado {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
  padding-bottom: 18px; margin-bottom: 22px;
  border-bottom: 1px solid var(--linea);
}
.encabezado-texto p { color: var(--gris-azul); font-size: .88rem; margin-top: 5px; max-width: 68ch; }
.encabezado-acciones { display: flex; gap: 9px; flex-wrap: wrap; }

.aviso {
  border: 1px solid var(--linea); border-left-width: 3px;
  background: var(--blanco); border-radius: var(--r-chico);
  padding: 11px 15px; margin-bottom: 16px; font-size: .88rem;
}
.aviso-ok     { border-left-color: var(--ok);     background: var(--ok-velo); }
.aviso-error  { border-left-color: var(--alto);   background: var(--alto-velo); }
.aviso-aviso  { border-left-color: var(--alerta); background: var(--alerta-velo); }
.aviso-info   { border-left-color: var(--indigo); background: var(--indigo-velo); }

.pie-marca {
  margin-top: auto; padding-top: 26px;
  display: flex; align-items: center; gap: 9px;
  color: var(--gris-azul); font-size: .78rem;
}
.pie-marca img { width: 17px; height: auto; opacity: .85; }
.pie-marca strong { font-family: var(--fuente-display); font-weight: 400; letter-spacing: .22em; color: var(--tinta); }
.pie-version { margin-left: auto; color: #8995a5; }

/* ======================== 5. TARJETAS DE MÉTRICAS ====================== */
.panel {
  background: var(--blanco);
  border: 1px solid var(--linea);
  border-radius: var(--r);
  box-shadow: var(--sombra);
}
.panel-cabeza {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; padding: 15px 18px 12px; border-bottom: 1px solid var(--linea);
}
.panel-cabeza p { font-size: .8rem; color: var(--gris-azul); }
.panel-cuerpo { padding: 16px 18px; }
.panel-cuerpo.sin-aire { padding: 0; }

.rejilla { display: grid; gap: 16px; }
.rejilla-4 { grid-template-columns: repeat(4, 1fr); }
.rejilla-3 { grid-template-columns: repeat(3, 1fr); }
.rejilla-2 { grid-template-columns: repeat(2, 1fr); }
.rejilla-7-5 { grid-template-columns: 7fr 5fr; }
.rejilla + .rejilla { margin-top: 16px; }

.kpi {
  background: var(--blanco); border: 1px solid var(--linea);
  border-radius: var(--r); padding: 16px 18px 17px;
  display: flex; flex-direction: column; gap: 4px;
  box-shadow: var(--sombra);
}
.kpi-rotulo { font-size: .78rem; color: var(--gris-azul); }
.kpi-cifra {
  font-family: var(--fuente-display); font-weight: 300;
  font-size: 2rem; letter-spacing: -.012em; line-height: 1.1;
  font-variant-numeric: tabular-nums; color: var(--tinta);
}
.kpi-nota { font-size: .76rem; color: #8995a5; }

/* El KPI principal: única pieza que usa el índigo a bloque */
.kpi-destacado {
  background: var(--tinta); border-color: var(--tinta); color: #e7edf5;
  position: relative; overflow: hidden;
}
.kpi-destacado::after {
  content: ''; position: absolute; right: -60px; top: -40px;
  width: 190px; height: 190px;
  background: url('../img/nodra-isotipo-blanco.png') no-repeat center / contain;
  opacity: .05;
}
.kpi-destacado .kpi-rotulo { color: #9fb0c6; }
.kpi-destacado .kpi-cifra  { color: #fff; font-size: 2.3rem; }
.kpi-destacado .kpi-nota   { color: #8ea0b8; }

/* ============================= 6. TABLAS =============================== */
.tabla-marco { overflow-x: auto; }
table.tabla { width: 100%; border-collapse: collapse; font-size: .87rem; }
.tabla thead th {
  text-align: left; font-weight: 500; font-size: .76rem;
  color: var(--gris-azul); padding: 10px 14px;
  border-bottom: 1px solid var(--linea); white-space: nowrap;
  background: #fcfdfe;
}
.tabla tbody td { padding: 11px 14px; border-bottom: 1px solid #edf1f5; vertical-align: middle; }
.tabla tbody tr:last-child td { border-bottom: 0; }
.tabla tbody tr:hover { background: #fafbfd; }
.tabla .num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--fuente-display); font-weight: 400; }
.tabla .folio-id {
  font-family: var(--fuente-display); font-size: .82rem;
  letter-spacing: .04em; color: var(--tinta); font-weight: 400;
}
.tabla .apagado { color: var(--gris-azul); }
.tabla .acciones { text-align: right; white-space: nowrap; }

.vacio { padding: 44px 20px; text-align: center; color: var(--gris-azul); }
.vacio strong { display: block; font-family: var(--fuente-display); font-weight: 400; font-size: 1rem; color: var(--tinta); margin-bottom: 5px; }

/* =========================== 7. FORMULARIOS ============================ */
.forma { display: grid; gap: 16px; }
.forma-rejilla { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.campo { display: flex; flex-direction: column; gap: 6px; }
.campo-ancho { grid-column: 1 / -1; }

label { font-size: .82rem; color: var(--tinta); font-weight: 500; }
label .opcional { color: #8995a5; font-weight: 400; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], select, textarea {
  font-family: var(--fuente-ui); font-size: .9rem; color: var(--tinta);
  background: var(--blanco);
  border: 1px solid var(--linea); border-radius: var(--r-chico);
  padding: 9px 11px; width: 100%;
  transition: border-color .12s ease, box-shadow .12s ease;
}
input:hover, select:hover, textarea:hover { border-color: #c3cdd9; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(36, 6, 144, .1);
}
input[type=file] { font-size: .85rem; padding: 7px; }
textarea { resize: vertical; min-height: 84px; }
select { appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23495563' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; padding-right: 32px;
}
.ayuda { font-size: .76rem; color: var(--gris-azul); }
.error-campo { font-size: .78rem; color: var(--alto); }
input.con-error, select.con-error { border-color: var(--alto); }

.calculo {
  font-size: .8rem; color: var(--gris-azul);
  background: var(--indigo-velo); border: 1px solid var(--indigo-borde);
  border-radius: var(--r-chico); padding: 8px 11px;
}
.calculo strong { font-family: var(--fuente-display); color: var(--indigo); font-weight: 600; }

fieldset { border: 0; padding: 0; margin: 0; }
.forma-seccion { border-top: 1px solid var(--linea); padding-top: 18px; margin-top: 2px; }
.forma-seccion > h3 { margin-bottom: 14px; }
.forma-pie { display: flex; gap: 10px; align-items: center; padding-top: 4px; }
.forma-pie .izquierda { margin-right: auto; }

/* ====================== 8. BOTONES Y DISTINTIVOS ======================= */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--fuente-ui); font-size: .85rem; font-weight: 500;
  padding: 9px 15px; border-radius: var(--r-chico);
  border: 1px solid var(--linea); background: var(--blanco); color: var(--tinta);
  cursor: pointer; text-decoration: none;
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover { background: #f2f5f8; text-decoration: none; }
.btn-primario { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.btn-primario:hover { background: #1c0474; border-color: #1c0474; }
.btn-tinta { background: var(--tinta); border-color: var(--tinta); color: #fff; }
.btn-tinta:hover { background: var(--tinta-85); }
.btn-peligro { color: var(--alto); border-color: #e3c9c9; background: #fff; }
.btn-peligro:hover { background: var(--alto-velo); }
.btn-chico { padding: 5px 10px; font-size: .78rem; }
.btn[disabled], .btn[aria-disabled=true] { opacity: .5; pointer-events: none; }
.btn .icono { width: 15px; height: 15px; }

.marca-estado {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .75rem; padding: 2px 8px; border-radius: 20px;
  border: 1px solid var(--linea); background: #fff; color: var(--gris-azul);
  white-space: nowrap;
}
.marca-estado::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.e-ok     { color: var(--ok);     border-color: #bedfd2; background: var(--ok-velo); }
.e-medio  { color: var(--alerta); border-color: #ecd9b4; background: var(--alerta-velo); }
.e-alto   { color: var(--alto);   border-color: #e7c4c4; background: var(--alto-velo); }
.e-indigo { color: var(--indigo); border-color: var(--indigo-borde); background: var(--indigo-velo); }
.e-neutro { color: var(--gris-azul); }
.marca-estado.sin-punto::before { display: none; }

.cinta-filtros {
  display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
  background: var(--blanco); border: 1px solid var(--linea);
  border-radius: var(--r); padding: 13px 16px; margin-bottom: 18px;
}
.cinta-filtros .campo { gap: 4px; }
.cinta-filtros label { font-size: .75rem; color: var(--gris-azul); font-weight: 400; }
.cinta-filtros input, .cinta-filtros select { padding: 7px 10px; font-size: .85rem; }
.atajos { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.atajo {
  font-size: .78rem; padding: 6px 11px; border-radius: 20px;
  border: 1px solid var(--linea); color: var(--gris-azul); background: #fff; text-decoration: none;
}
.atajo:hover { border-color: #c3cdd9; text-decoration: none; }
.atajo.es-activo { background: var(--tinta); border-color: var(--tinta); color: #fff; }

/* ==================== 9. GRÁFICAS Y PIEZAS DEL TABLERO ================= */
.lienzo-grafica { position: relative; }
.lienzo-grafica.alta { height: 290px; }

.barras { display: flex; flex-direction: column; gap: 13px; }
.barra-fila { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.barra-nombre { font-size: .85rem; }
.barra-valor { font-family: var(--fuente-display); font-size: .85rem; font-variant-numeric: tabular-nums; }
.barra-riel { grid-column: 1 / -1; height: 6px; background: #eef1f5; border-radius: 3px; overflow: hidden; }
.barra-relleno { height: 100%; background: var(--indigo); border-radius: 3px; }
.barra-relleno.tono-2 { background: #4a3bb0; }
.barra-relleno.tono-3 { background: var(--tinta); }

.lista-pareja { display: flex; flex-direction: column; }
.lista-pareja > div {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 9px 0; border-bottom: 1px solid #edf1f5; font-size: .86rem;
}
.lista-pareja > div:last-child { border-bottom: 0; }
.lista-pareja dt, .lista-pareja .et { color: var(--gris-azul); }
.lista-pareja dd, .lista-pareja .va {
  margin: 0; font-family: var(--fuente-display); font-weight: 400;
  font-variant-numeric: tabular-nums; text-align: right;
}

.ficha { display: grid; grid-template-columns: 170px 1fr; gap: 10px 18px; font-size: .88rem; }
.ficha dt { color: var(--gris-azul); }
.ficha dd { margin: 0; }

/* ======================= 10. PANTALLA DE ACCESO ======================== */
.acceso { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100vh; }
.acceso-arte {
  background: var(--tinta); color: #e7edf5;
  padding: 52px 54px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.acceso-arte::after {
  content: ''; position: absolute; left: 42%; top: 50%;
  width: 118%; height: 118%; transform: translateY(-50%);
  background: url('../img/nodra-isotipo-blanco.png') no-repeat center / contain;
  opacity: .07;
}
.acceso-arte > * { position: relative; z-index: 1; }
.acceso-logo { width: 148px; height: auto; }
.acceso-arte h2 {
  font-size: 1.85rem; font-weight: 300; letter-spacing: .02em;
  line-height: 1.35; max-width: 17ch; color: #fff;
}
.acceso-arte p { color: #9fb0c6; font-size: .88rem; max-width: 42ch; margin-top: 12px; }
.acceso-pie { font-size: .75rem; color: #7e8ea4; display: flex; align-items: center; gap: 8px; }
.acceso-pie strong { font-family: var(--fuente-display); font-weight: 400; letter-spacing: .2em; color: #cfd8e4; }

.acceso-forma { display: grid; place-items: center; padding: 40px 28px; background: var(--papel); }
.acceso-caja { width: 100%; max-width: 352px; }
.acceso-caja h1 { font-size: 1.4rem; margin-bottom: 6px; }
.acceso-caja > p { color: var(--gris-azul); font-size: .87rem; margin-bottom: 24px; }
.acceso-caja .btn { width: 100%; justify-content: center; margin-top: 4px; }
.acceso-nota {
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--linea);
  font-size: .78rem; color: var(--gris-azul);
}

/* ================== 11. RESPONSIVO E IMPRESIÓN ========================= */
@media (max-width: 1180px) {
  .rejilla-4 { grid-template-columns: repeat(2, 1fr); }
  .rejilla-7-5 { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .acceso { grid-template-columns: 1fr; }
  .acceso-arte { padding: 32px 28px; }
  .acceso-arte h2 { font-size: 1.4rem; }
  .rejilla-3, .rejilla-2 { grid-template-columns: 1fr; }
  .ficha { grid-template-columns: 1fr; gap: 2px 0; }
  .ficha dd { margin-bottom: 10px; }
}

@media (max-width: 780px) {
  .barra-lateral {
    transform: translateX(-100%);
    transition: transform .2s ease;
    width: 250px; box-shadow: 0 0 40px rgba(0,0,0,.25);
  }
  body.menu-abierto .barra-lateral { transform: translateX(0); }
  .lienzo { margin-left: 0; padding: 70px 18px 20px; }

  .abrir-menu {
    display: inline-flex; align-items: center; gap: 9px;
    position: fixed; top: 12px; left: 12px; z-index: 50;
    background: var(--blanco); border: 1px solid var(--linea);
    border-radius: var(--r-chico); padding: 9px 13px; cursor: pointer;
    font-family: var(--fuente-ui); font-size: .82rem; color: var(--tinta);
  }
  .abrir-menu span { display: block; width: 15px; height: 1.5px; background: var(--tinta); }
  .abrir-menu span + span { margin-top: -3px; }
  .abrir-menu em { font-style: normal; margin-left: 2px; }

  .forma-rejilla { grid-template-columns: 1fr; }
  .rejilla-4 { grid-template-columns: 1fr; }
  .encabezado { align-items: flex-start; flex-direction: column; }
  .atajos { margin-left: 0; }
}

@media print {
  .barra-lateral, .abrir-menu, .encabezado-acciones, .cinta-filtros { display: none !important; }
  .lienzo { margin: 0; padding: 0; }
  .panel, .kpi { break-inside: avoid; box-shadow: none; }
  body { font-size: 11px; }
}

/* ============ 12. GRÁFICAS SVG ============ */
.gsvg { width: 100%; height: auto; display: block; overflow: visible; }
.gsvg-dona { max-width: 240px; margin: 4px auto 0; }
.gsvg text { font-family: var(--fuente-ui); }
.gsvg rect, .gsvg circle, .gsvg path { transition: opacity .12s ease; }
.gsvg rect:hover, .gsvg path:hover { opacity: .82; cursor: default; }

.leyenda {
  display: flex; gap: 18px; justify-content: center;
  margin-top: 10px; font-size: .78rem; color: var(--gris-azul);
}
.leyenda span { display: inline-flex; align-items: center; gap: 6px; }
.leyenda i { width: 10px; height: 10px; border-radius: 2px; display: block; }
.leyenda i.punto { border-radius: 50%; width: 8px; height: 8px; }
