/* =========================================================
   LaboratorioGEO - Sistema de gestion
   Lenguaje visual "bento": bloques de distinto tamano, cada
   familia con su color propio, esquinas generosas y mucha
   presencia tipografica. Tema claro y oscuro.
   ========================================================= */

:root {
  color-scheme: light;

  /* Lienzo */
  --fondo: #f1f4f6;
  --superficie: #ffffff;
  --superficie-2: #f7f9fa;
  --superficie-3: #eaeff2;

  /* Texto */
  --texto: #101d26;
  --texto-2: #566873;
  --texto-3: #8497a2;

  /* Bordes */
  --borde: #e4eaee;
  --borde-2: #cfd9df;

  /* Marca */
  --acento: #0c8478;
  --acento-fuerte: #0a6a60;
  --acento-suave: #e3f4f1;
  --acento-borde: #a8dbd3;
  --acento-contraste: #ffffff;

  /* Paleta bento: cada bloque tiene su familia */
  --bento-teal-fondo: linear-gradient(145deg, #0d8478 0%, #0a6a60 100%);
  --bento-teal-texto: #ffffff;
  --bento-violeta-fondo: linear-gradient(145deg, #6d5ae0 0%, #5342c4 100%);
  --bento-violeta-texto: #ffffff;
  --bento-ambar-fondo: linear-gradient(145deg, #e0912f 0%, #c67516 100%);
  --bento-ambar-texto: #ffffff;
  --bento-azul-fondo: linear-gradient(145deg, #2f7fd4 0%, #1d63ae 100%);
  --bento-azul-texto: #ffffff;
  --bento-rosa-fondo: linear-gradient(145deg, #d8496f 0%, #b62f55 100%);
  --bento-rosa-texto: #ffffff;
  --bento-carbon-fondo: linear-gradient(145deg, #253742 0%, #16242c 100%);
  --bento-carbon-texto: #ffffff;

  /* Semaforo */
  --ok: #0d7a53;
  --ok-suave: #e2f3eb;
  --ok-borde: #b2dcc6;
  --alerta: #b0741a;
  --alerta-suave: #fbf0da;
  --alerta-borde: #e8d2a3;
  --error: #b23529;
  --error-suave: #fbe8e6;
  --error-borde: #eec5bf;
  --info: #2264a8;
  --info-suave: #e6eff9;
  --info-borde: #bcd4ec;

  /* Grafico */
  --grafico-1: #0c8478;
  --grafico-2: #d8496f;

  /* Medidas */
  --rail: 246px;
  --radio-xl: 22px;
  --radio: 15px;
  --radio-sm: 9px;
  --radio-pill: 999px;

  /* Elevacion */
  --sombra-sm: 0 1px 2px rgba(16, 29, 38, .05);
  --sombra: 0 2px 4px rgba(16, 29, 38, .05), 0 10px 22px -10px rgba(16, 29, 38, .12);
  --sombra-lg: 0 18px 44px -14px rgba(16, 29, 38, .26), 0 6px 14px -8px rgba(16, 29, 38, .14);
  --sombra-color: 0 12px 28px -12px rgba(12, 132, 120, .55);

  --transicion: 160ms cubic-bezier(.4, 0, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) {
    color-scheme: dark;

    --fondo: #0a1115;
    --superficie: #121e25;
    --superficie-2: #17252d;
    --superficie-3: #1e2f38;

    --texto: #e9eff2;
    --texto-2: #a0b3bd;
    --texto-3: #718892;

    --borde: #223540;
    --borde-2: #2f4652;

    --acento: #2aa596;
    --acento-fuerte: #36bcac;
    --acento-suave: #0e302d;
    --acento-borde: #1b4d47;
    --acento-contraste: #04211e;

    --bento-teal-fondo: linear-gradient(145deg, #11a091 0%, #0a6f65 100%);
    --bento-violeta-fondo: linear-gradient(145deg, #7d6bf0 0%, #5946cc 100%);
    --bento-ambar-fondo: linear-gradient(145deg, #eda03c 0%, #c87c1c 100%);
    --bento-azul-fondo: linear-gradient(145deg, #3c8fe4 0%, #1f6bb8 100%);
    --bento-rosa-fondo: linear-gradient(145deg, #e2587d 0%, #bd375e 100%);
    --bento-carbon-fondo: linear-gradient(145deg, #2c414e 0%, #1a2b34 100%);

    --ok: #3cb082;
    --ok-suave: #0e2d22;
    --ok-borde: #1b4838;
    --alerta: #d59a3f;
    --alerta-suave: #312415;
    --alerta-borde: #533f1e;
    --error: #e06a5c;
    --error-suave: #341c1a;
    --error-borde: #542b26;
    --info: #5c9cdd;
    --info-suave: #13273b;
    --info-borde: #22405e;

    --grafico-1: #2aa596;
    --grafico-2: #e2587d;

    --sombra-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --sombra: 0 2px 4px rgba(0, 0, 0, .3), 0 10px 22px -10px rgba(0, 0, 0, .5);
    --sombra-lg: 0 18px 44px -14px rgba(0, 0, 0, .7), 0 6px 14px -8px rgba(0, 0, 0, .5);
    --sombra-color: 0 12px 28px -12px rgba(17, 160, 145, .5);
  }
}

:root[data-tema="oscuro"] {
  color-scheme: dark;

  --fondo: #0a1115;
  --superficie: #121e25;
  --superficie-2: #17252d;
  --superficie-3: #1e2f38;

  --texto: #e9eff2;
  --texto-2: #a0b3bd;
  --texto-3: #718892;

  --borde: #223540;
  --borde-2: #2f4652;

  --acento: #2aa596;
  --acento-fuerte: #36bcac;
  --acento-suave: #0e302d;
  --acento-borde: #1b4d47;
  --acento-contraste: #04211e;

  --bento-teal-fondo: linear-gradient(145deg, #11a091 0%, #0a6f65 100%);
  --bento-violeta-fondo: linear-gradient(145deg, #7d6bf0 0%, #5946cc 100%);
  --bento-ambar-fondo: linear-gradient(145deg, #eda03c 0%, #c87c1c 100%);
  --bento-azul-fondo: linear-gradient(145deg, #3c8fe4 0%, #1f6bb8 100%);
  --bento-rosa-fondo: linear-gradient(145deg, #e2587d 0%, #bd375e 100%);
  --bento-carbon-fondo: linear-gradient(145deg, #2c414e 0%, #1a2b34 100%);

  --ok: #3cb082;
  --ok-suave: #0e2d22;
  --ok-borde: #1b4838;
  --alerta: #d59a3f;
  --alerta-suave: #312415;
  --alerta-borde: #533f1e;
  --error: #e06a5c;
  --error-suave: #341c1a;
  --error-borde: #542b26;
  --info: #5c9cdd;
  --info-suave: #13273b;
  --info-borde: #22405e;

  --grafico-1: #2aa596;
  --grafico-2: #e2587d;

  --sombra-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --sombra: 0 2px 4px rgba(0, 0, 0, .3), 0 10px 22px -10px rgba(0, 0, 0, .5);
  --sombra-lg: 0 18px 44px -14px rgba(0, 0, 0, .7), 0 6px 14px -8px rgba(0, 0, 0, .5);
  --sombra-color: 0 12px 28px -12px rgba(17, 160, 145, .5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--fondo);
  color: var(--texto);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 { margin: 0; font-weight: 640; letter-spacing: -.022em; }
a { color: var(--acento); text-decoration: none; font-weight: 550; }
a:hover { color: var(--acento-fuerte); }

:focus-visible { outline: 2px solid var(--acento); outline-offset: 3px; border-radius: 6px; }
::selection { background: var(--acento-suave); color: var(--texto); }

* { scrollbar-width: thin; scrollbar-color: var(--borde-2) transparent; }
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--borde-2); border-radius: 7px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--texto-3); background-clip: content-box; }

/* =========================================================
   Estructura
   ========================================================= */
.app { display: flex; min-height: 100vh; padding: 10px; gap: 10px; }

.rail {
  width: var(--rail);
  flex: 0 0 var(--rail);
  background: var(--superficie);
  border-radius: var(--radio-xl);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 10px;
  height: calc(100vh - 20px);
  overflow-y: auto;
  box-shadow: var(--sombra-sm);
  z-index: 20;
}

.rail-marca {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 18px;
}

.rail-logo {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 13px;
  background: var(--bento-teal-fondo);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 750;
  font-size: 13px;
  letter-spacing: -.04em;
  box-shadow: var(--sombra-color);
}

.rail-marca-texto { min-width: 0; }

.rail-marca strong {
  display: block;
  color: var(--texto);
  font-size: 15px;
  font-weight: 680;
  letter-spacing: -.025em;
  line-height: 1.2;
}

.rail-marca span {
  display: block;
  color: var(--texto-3);
  font-size: 11.5px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rail-grupo { padding: 8px 10px 2px; }

.rail-grupo-titulo {
  color: var(--texto-3);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 10px 12px 7px;
}

.rail a.nav {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  margin: 2px 0;
  border-radius: 11px;
  color: var(--texto-2);
  font-size: 13.4px;
  font-weight: 550;
  text-decoration: none;
  position: relative;
  transition: background var(--transicion), color var(--transicion);
}

.rail a.nav::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 3px;
  background: var(--borde-2);
  transition: background var(--transicion), transform var(--transicion), border-radius var(--transicion);
}

.rail a.nav:hover { background: var(--superficie-3); color: var(--texto); }

.rail a.nav.active {
  background: var(--bento-carbon-fondo);
  color: #fff;
  font-weight: 620;
  box-shadow: var(--sombra-sm);
}

.rail a.nav.active::before {
  background: var(--acento);
  transform: rotate(45deg) scale(1.1);
  border-radius: 2px;
}

.rail-pie {
  margin-top: auto;
  padding: 16px 20px 18px;
  font-size: 10.8px;
  color: var(--texto-3);
  line-height: 1.55;
}

.contenido { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }

/* =========================================================
   Encabezado de pagina
   ========================================================= */
.barra {
  background: var(--superficie);
  border-radius: var(--radio-xl);
  padding: 20px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  box-shadow: var(--sombra-sm);
}

/* El titulo puede achicarse; la zona de acciones nunca se parte. */
.barra > div:first-child { min-width: 0; flex: 1 1 320px; }
.barra h1 { font-size: 24px; font-weight: 680; letter-spacing: -.032em; }
.barra p { margin: 4px 0 0; color: var(--texto-2); font-size: 13px; }

.barra .barra-dato {
  font-size: 12px;
  color: var(--texto-2);
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
  margin-left: auto;
}

.vista { padding: 0 0 20px; }

/* Sesion */
.sesion { display: flex; align-items: center; gap: 11px; }

.sesion-avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--bento-violeta-fondo);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  box-shadow: var(--sombra-sm);
}

.sesion-nombre { font-size: 12.8px; font-weight: 640; color: var(--texto); line-height: 1.25; }
.sesion-rol { font-size: 11px; color: var(--texto-3); line-height: 1.25; }

/* =========================================================
   Filtros y formularios
   ========================================================= */
.filtros {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  background: var(--superficie);
  border-radius: var(--radio);
  padding: 16px 18px;
  margin-bottom: 10px;
  box-shadow: var(--sombra-sm);
}

.campo { display: flex; flex-direction: column; gap: 6px; }

.campo label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--texto-3);
}

input, select, textarea {
  font-family: inherit;
  font-size: 13.4px;
  font-weight: 500;
  color: var(--texto);
  background: var(--superficie-2);
  border: 1.5px solid transparent;
  border-radius: 11px;
  padding: 9px 12px;
  min-height: 38px;
  transition: border-color var(--transicion), background var(--transicion), box-shadow var(--transicion);
}

input:hover, select:hover, textarea:hover { background: var(--superficie-3); }

input:focus, select:focus, textarea:focus {
  outline: none;
  background: var(--superficie);
  border-color: var(--acento);
  box-shadow: 0 0 0 4px var(--acento-suave);
}

input:disabled, select:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; }

input[readonly] { color: var(--texto-2); }

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

/* =========================================================
   Botones
   ========================================================= */
.boton {
  font-family: inherit;
  font-size: 13.2px;
  font-weight: 640;
  letter-spacing: -.005em;
  border: none;
  background: var(--bento-carbon-fondo);
  color: #fff;
  border-radius: 11px;
  padding: 9px 17px;
  min-height: 38px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
  box-shadow: var(--sombra-sm);
  transition: transform var(--transicion), box-shadow var(--transicion), opacity var(--transicion);
}

.boton:hover { transform: translateY(-1px); box-shadow: var(--sombra); color: #fff; }
.boton:active { transform: translateY(0); box-shadow: var(--sombra-sm); }

.boton.primario { background: var(--bento-teal-fondo); }
.boton.primario:hover { box-shadow: var(--sombra-color); }

.boton.secundario {
  background: var(--superficie-3);
  color: var(--texto);
  box-shadow: none;
}

.boton.secundario:hover { background: var(--borde); color: var(--texto); box-shadow: var(--sombra-sm); }

.boton:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }
.boton.chico { font-size: 12px; padding: 5px 12px; min-height: 30px; border-radius: 9px; }

/* Los botones de accion de una fila van juntos, en linea y sin partirse. */
tbody td:last-child { white-space: nowrap; }
tbody td > .boton + .boton { margin-left: 6px; }

/* =========================================================
   Bento: tarjetas de indicadores
   ========================================================= */
.tira {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

.kpi {
  position: relative;
  grid-column: span 3;
  background: var(--superficie);
  border-radius: var(--radio);
  padding: 18px 19px 17px;
  box-shadow: var(--sombra-sm);
  overflow: hidden;
  min-height: 118px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform var(--transicion), box-shadow var(--transicion);
}

.kpi:hover { transform: translateY(-2px); box-shadow: var(--sombra); }

.kpi .etiqueta {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--texto-3);
}

.kpi .valor {
  font-size: 29px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.038em;
  margin-top: 8px;
  line-height: 1.05;
}

.kpi .detalle { font-size: 11.5px; color: var(--texto-2); margin-top: 6px; line-height: 1.4; }

/* Mosaico sobre grilla de 12 columnas. El reparto depende de cuantas tarjetas
   haya para que cada fila cierre completa y no queden huecos al final.
   Hoy las pantallas usan 4 u 8 KPIs. */

/* Por defecto: cuatro por fila. */
.tira .kpi { grid-column: span 3; }

/* 8 tarjetas (tablero y reportes). Mosaico de tres filas llenas:
     fila 1 -> 6 + 3 + 3   (el bloque principal ocupa media grilla)
     fila 2 -> 4 + 4 + 4
     fila 3 -> 6 + 6
   Suma 12 en las tres, asi no quedan huecos. */
.tira .kpi:first-child:nth-last-child(8) { grid-column: span 6; }
.tira .kpi:first-child:nth-last-child(8) ~ .kpi:nth-child(2),
.tira .kpi:first-child:nth-last-child(8) ~ .kpi:nth-child(3) { grid-column: span 3; }
.tira .kpi:first-child:nth-last-child(8) ~ .kpi:nth-child(4),
.tira .kpi:first-child:nth-last-child(8) ~ .kpi:nth-child(5),
.tira .kpi:first-child:nth-last-child(8) ~ .kpi:nth-child(6) { grid-column: span 4; }
.tira .kpi:first-child:nth-last-child(8) ~ .kpi:nth-child(7),
.tira .kpi:first-child:nth-last-child(8) ~ .kpi:nth-child(8) { grid-column: span 6; }

/* El bloque principal respira mas y agranda la cifra. */
.tira .kpi:first-child:nth-last-child(8) {
  min-height: 152px;
  padding: 22px 24px 20px;
}

.tira .kpi:first-child:nth-last-child(8) .valor { font-size: 38px; }

/* Familias de color: cada pagina elige cuales tarjetas llevan fondo. */
.kpi-teal { background: var(--bento-teal-fondo); }
.kpi-violeta { background: var(--bento-violeta-fondo); }
/* En tema oscuro el bloque carbon se acerca al fondo: un borde tenue lo
   mantiene reconocible como bloque. */
.kpi-carbon { background: var(--bento-carbon-fondo); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .09), var(--sombra); }
.kpi-ambar { background: var(--bento-ambar-fondo); }
.kpi-azul { background: var(--bento-azul-fondo); }
.kpi-rosa { background: var(--bento-rosa-fondo); }

/* Texto sobre bloque de color. .kpi-color la aplica el componente Kpi a las
   tarjetas que llevan fondo, para no repetir selectores de posicion. */
.kpi-color { color: #fff; box-shadow: var(--sombra); }
.kpi-color .etiqueta { color: rgba(255, 255, 255, .72); }
.kpi-color .detalle { color: rgba(255, 255, 255, .8); }

/* Sobre bloque de color el semaforo se apaga: el fondo ya comunica. */
.kpi-color .valor { color: #fff !important; }

/* Brillo decorativo en los bloques con fondo */
.kpi-color::after {
  content: "";
  position: absolute;
  top: -55%;
  right: -22%;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .17) 0%, transparent 68%);
  pointer-events: none;
}

/* =========================================================
   Paneles
   ========================================================= */
.panel {
  background: var(--superficie);
  border-radius: var(--radio-xl);
  margin-bottom: 10px;
  overflow: hidden;
  box-shadow: var(--sombra-sm);
}

.panel-cabecera {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 22px 15px;
}

.panel-cabecera h2 { font-size: 16px; font-weight: 660; letter-spacing: -.025em; }
.panel-cabecera .nota { font-size: 12px; color: var(--texto-3); }
.panel-cuerpo { padding: 4px 22px 20px; }

.tabla-scroll { overflow-x: auto; max-height: 620px; }

table { width: 100%; border-collapse: collapse; font-size: 13.2px; }

thead th {
  position: sticky;
  top: 0;
  background: var(--superficie);
  text-align: left;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--texto-3);
  padding: 8px 22px 11px;
  white-space: nowrap;
  z-index: 1;
}

tbody td {
  padding: 12px 22px;
  border-top: 1px solid var(--borde);
  vertical-align: middle;
}

/* Las tablas de primer nivel no bajan de un ancho comodo; si el panel es mas
   angosto, scrollean en lugar de exprimir las columnas de texto. Las tablas
   de detalle anidadas se adaptan a su celda. */
.panel > .tabla-scroll > table { min-width: 900px; }

tbody tr { transition: background var(--transicion); }
tbody tr:hover { background: var(--superficie-2); }

tbody tr.total td {
  font-weight: 700;
  background: var(--superficie-3);
  border-top: 2px solid var(--borde-2);
}

.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.codigo {
  font-family: "SF Mono", "Cascadia Mono", Consolas, ui-monospace, monospace;
  font-size: 11.8px;
  font-weight: 550;
  color: var(--texto-2);
  white-space: nowrap;
}

.negativo { color: var(--error); }
.positivo { color: var(--ok); }
.apagado { color: var(--texto-3); }

/* =========================================================
   Etiquetas de estado
   ========================================================= */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 11px;
  border-radius: var(--radio-pill);
  font-size: 11.2px;
  font-weight: 640;
  white-space: nowrap;
  line-height: 1.65;
}

.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.pill.verde { background: var(--ok-suave); color: var(--ok); }
.pill.rojo { background: var(--error-suave); color: var(--error); }
.pill.ambar { background: var(--alerta-suave); color: var(--alerta); }
.pill.gris { background: var(--superficie-3); color: var(--texto-2); }
.pill.azul { background: var(--info-suave); color: var(--info); }

/* =========================================================
   Barras comparativas
   ========================================================= */
.barra-dato-grafico { display: flex; align-items: center; gap: 11px; }

.barra-track {
  flex: 1;
  height: 9px;
  background: var(--superficie-3);
  border-radius: var(--radio-pill);
  overflow: hidden;
  min-width: 60px;
}

.barra-fill {
  height: 100%;
  background: var(--grafico-1);
  border-radius: var(--radio-pill);
  transition: width 420ms cubic-bezier(.4, 0, .2, 1);
}

.barra-fill.egreso { background: var(--grafico-2); }

/* =========================================================
   Avisos
   ========================================================= */
.aviso {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  background: var(--ok-suave);
  color: var(--ok);
  padding: 14px 18px;
  border-radius: var(--radio);
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 520;
}

/* Circulo con borde y la letra en el mismo color: siempre legible sobre
   cualquier fondo de aviso. */
.aviso::before {
  content: "i";
  flex: none;
  width: 19px;
  height: 19px;
  margin-top: 1px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  font-size: 12px;
  font-weight: 800;
  font-style: italic;
  line-height: 16px;
  text-align: center;
}

.aviso.error { background: var(--error-suave); color: var(--error); }
.aviso.error::before { content: "!"; font-style: normal; }

.vacio { padding: 48px 22px; text-align: center; color: var(--texto-3); font-size: 13px; }

.cargando {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 40px 22px;
  color: var(--texto-2);
  font-size: 13px;
}

.cargando::before {
  content: "";
  width: 16px;
  height: 16px;
  border: 2.5px solid var(--borde-2);
  border-top-color: var(--acento);
  border-radius: 50%;
  animation: girar .7s linear infinite;
}

@keyframes girar { to { transform: rotate(360deg); } }

/* =========================================================
   Arbol del plan de cuentas
   ========================================================= */
.nivel-1 td:first-child { font-weight: 700; }
.nivel-2 td:first-child { font-weight: 620; padding-left: 40px; }
.nivel-3 td:first-child { padding-left: 62px; }
.nivel-4 td:first-child { padding-left: 84px; }

/* =========================================================
   Detalle expandible
   ========================================================= */
.detalle-fila td { background: var(--superficie-2); }
.detalle-fila table { font-size: 12.5px; }
.detalle-fila thead th { background: var(--superficie-2); }

/* =========================================================
   Formularios de alta
   ========================================================= */
.form-grilla {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 10px;
  align-items: start;
}

.campos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.campo-ancho { grid-column: span 2; }
.campo-completo { grid-column: 1 / -1; }
.campos select, .celda { max-width: 100%; text-overflow: ellipsis; }

.celda {
  width: 100%;
  min-height: 34px;
  padding: 7px 10px;
  font-size: 13px;
  border-radius: 9px;
}

.celda.num { text-align: right; font-variant-numeric: tabular-nums; }

.boton-icono {
  width: 30px;
  height: 30px;
  border: none;
  background: var(--superficie-3);
  color: var(--texto-3);
  border-radius: 9px;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background var(--transicion), color var(--transicion);
}

.boton-icono:hover { background: var(--error-suave); color: var(--error); }

.resumen { position: sticky; top: 10px; }

.resumen-lista { margin: 0; display: grid; gap: 11px; }

.resumen-lista > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.resumen-lista dt { color: var(--texto-2); font-size: 12.5px; }

.resumen-lista dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 640;
  font-size: 13.5px;
}

.resumen-total {
  margin-top: 6px;
  padding: 15px 17px;
  border-radius: var(--radio);
  background: var(--bento-carbon-fondo);
  color: #fff;
}

.resumen-total dt { font-weight: 640; color: rgba(255, 255, 255, .75) !important; font-size: 12px !important; text-transform: uppercase; letter-spacing: .07em; }
.resumen-total dd { font-size: 23px; font-weight: 720; letter-spacing: -.03em; }

.resumen-nota {
  margin-top: 14px;
  padding: 11px 14px;
  background: var(--superficie-2);
  border-radius: 11px;
  font-size: 12px;
  color: var(--texto-2);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.resumen-nota strong { font-variant-numeric: tabular-nums; }

.resumen-acciones { display: grid; gap: 9px; margin-top: 18px; }
.resumen-acciones .boton { width: 100%; }

.resumen-ayuda { margin: 12px 0 0; font-size: 11.5px; color: var(--texto-3); line-height: 1.5; }

@media (max-width: 1040px) {
  .form-grilla { grid-template-columns: minmax(0, 1fr); }
  .resumen { position: static; }
  .campo-ancho { grid-column: span 1; }
}

/* =========================================================
   Login
   ========================================================= */
.login { min-height: 100vh; display: grid; grid-template-columns: 1fr; background: var(--fondo); padding: 10px; gap: 10px; }

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 40px 24px;
}

.login-caja { width: 100%; max-width: 396px; }

.login-marca { display: flex; align-items: center; gap: 13px; margin-bottom: 28px; }
.login-marca .rail-logo { width: 46px; height: 46px; font-size: 15px; border-radius: 15px; }
.login-marca strong { display: block; font-size: 19px; font-weight: 680; letter-spacing: -.03em; }
.login-marca span { display: block; font-size: 12.5px; color: var(--texto-3); }

.login-tarjeta {
  background: var(--superficie);
  border-radius: var(--radio-xl);
  padding: 30px 30px 28px;
  box-shadow: var(--sombra-lg);
}

.login-tarjeta h1 { font-size: 22px; font-weight: 680; letter-spacing: -.03em; }
.login-tarjeta > p { margin: 6px 0 22px; color: var(--texto-2); font-size: 13.2px; }

.login-campo { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }

.login-campo label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--texto-3);
}

.login-campo input { min-height: 46px; font-size: 14.5px; border-radius: 13px; }

.login .boton { width: 100%; min-height: 46px; font-size: 14.5px; margin-top: 6px; border-radius: 13px; }

.login-pista {
  margin-top: 20px;
  padding: 13px 15px;
  background: var(--acento-suave);
  border-radius: 12px;
  font-size: 12.2px;
  color: var(--texto-2);
  line-height: 1.6;
}

.login-pista strong { color: var(--texto); font-weight: 680; }

.login-pista code {
  font-family: "SF Mono", "Cascadia Mono", Consolas, ui-monospace, monospace;
  background: var(--superficie);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 11.5px;
  font-weight: 620;
  color: var(--acento-fuerte);
}

.login-pie { margin-top: 24px; text-align: center; font-size: 11.5px; color: var(--texto-3); }

/* Panel de marca: mosaico bento sobre color */
.login-arte {
  display: none;
  position: relative;
  background: var(--bento-carbon-fondo);
  color: #fff;
  padding: 46px;
  border-radius: var(--radio-xl);
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.login-arte::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 80% 14%, rgba(17, 160, 145, .40), transparent 48%),
    radial-gradient(circle at 10% 88%, rgba(109, 90, 224, .34), transparent 46%);
  pointer-events: none;
}

.login-arte-contenido { position: relative; z-index: 1; max-width: 440px; }

.login-arte h2 {
  font-size: 33px;
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1.15;
  margin-bottom: 15px;
}

.login-arte > .login-arte-contenido > p {
  font-size: 14.5px;
  line-height: 1.65;
  color: rgba(255, 255, 255, .78);
  margin: 0 0 28px;
}

/* Mosaico de modulos */
.login-bento { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

.login-bento-item {
  background: rgba(255, 255, 255, .08);
  border-radius: 15px;
  padding: 15px 16px;
  backdrop-filter: blur(6px);
}

.login-bento-item:first-child { grid-column: span 2; }

.login-bento-item strong {
  display: block;
  font-size: 13.5px;
  font-weight: 640;
  color: #fff;
  margin-bottom: 3px;
  letter-spacing: -.015em;
}

.login-bento-item span { font-size: 12px; color: rgba(255, 255, 255, .68); line-height: 1.45; }

@media (min-width: 980px) {
  .login { grid-template-columns: 1fr 1fr; }
  .login-arte { display: flex; }
  .login-panel { padding: 40px; }
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1200px) {
  .tira .kpi { grid-column: span 4 !important; }
}

@media (max-width: 900px) {
  .app { flex-direction: column; padding: 8px; }

  .rail {
    width: 100%;
    flex: none;
    height: auto;
    position: static;
    border-radius: var(--radio);
  }

  .rail-grupo { display: inline-block; vertical-align: top; padding: 6px 10px 2px; }
  .rail-pie { display: none; }
  .barra { padding: 16px 18px; border-radius: var(--radio); }
  .barra h1 { font-size: 20px; }
  .tira { grid-template-columns: repeat(2, 1fr); }
  .tira .kpi { grid-column: span 1 !important; }
  .kpi .valor { font-size: 23px; }
  .panel { border-radius: var(--radio); }
  thead th, tbody td { padding-left: 16px; padding-right: 16px; }
}

@media (max-width: 560px) {
  .tira { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* =========================================================
   Blazor
   ========================================================= */
#blazor-error-ui {
  display: none;
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bento-carbon-fondo);
  color: #fff;
  padding: 13px 20px;
  border-radius: var(--radio);
  font-size: 13px;
  box-shadow: var(--sombra-lg);
  z-index: 1000;
}

#blazor-error-ui a { color: #fff; text-decoration: underline; }
#blazor-error-ui .dismiss { cursor: pointer; margin-left: 14px; font-weight: 700; }

.blazor-error-boundary {
  background: var(--error-suave);
  border-radius: var(--radio);
  padding: 16px;
  color: var(--error);
}
