/* Portal CLIMIA · Powered by GLACI·AC. Misma imagen que el portal de konIA (tokens de brand.rs). */
@font-face { font-family: "Space Grotesk"; src: url(fuentes/SpaceGrotesk-Medium.ttf); font-weight: 500; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url(fuentes/SpaceGrotesk-Bold.ttf); font-weight: 700; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url(fuentes/IBMPlexSans-Regular.ttf); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url(fuentes/IBMPlexSans-Medium.ttf); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url(fuentes/IBMPlexSans-SemiBold.ttf); font-weight: 600; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url(fuentes/IBMPlexMono-Regular.ttf); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url(fuentes/IBMPlexMono-SemiBold.ttf); font-weight: 600; font-display: swap; }

:root {
  color-scheme: light;
  --paper: #F5F4F1; --surface: #FFFFFF; --surface-alt: #EFEEEA;
  --ink: #14161C; --dim: #4A4E5A; --mute: #767A86;
  --line: #E4E2DD; --line2: #D2CFC8;
  --accent: #5B4EF5; --accent-soft: #EFEDFE; --accent-ink: #4336D9;
  --ok: #12A594; --warn: #E8A33D; --high: #E07B39; --crit: #E5484D;
  --ok-soft: #E3F5F2; --warn-soft: #FCF1E1; --high-soft: #FBEAE0; --crit-soft: #FCE6E7;
  --band: rgba(18, 165, 148, .09);
  /* Series de temperatura: slots 1–3 de la paleta validada (todas las parejas, claro y oscuro). */
  --s-suministro: #2a78d6; --s-retorno: #eb6834; --s-ambiente: #1baf7a;
  --f-display: "Space Grotesk", "IBM Plex Sans", system-ui, sans-serif;
  --f-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #121317; --surface: #1c1d22; --surface-alt: #25262c;
    --ink: #F2F2F4; --dim: #B9BBC4; --mute: #8A8D98;
    --line: #2E3037; --line2: #3A3C44;
    --accent: #8A80FF; --accent-soft: #26244A; --accent-ink: #B3ACFF;
    --ok-soft: #10302C; --warn-soft: #3A2C14; --high-soft: #3A2416; --crit-soft: #3D1A1C;
    --band: rgba(18, 165, 148, .14);
    --s-suministro: #3987e5; --s-retorno: #d95926; --s-ambiente: #199e70;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #121317; --surface: #1c1d22; --surface-alt: #25262c;
  --ink: #F2F2F4; --dim: #B9BBC4; --mute: #8A8D98;
  --line: #2E3037; --line2: #3A3C44;
  --accent: #8A80FF; --accent-soft: #26244A; --accent-ink: #B3ACFF;
  --ok-soft: #10302C; --warn-soft: #3A2C14; --high-soft: #3A2416; --crit-soft: #3D1A1C;
  --band: rgba(18, 165, 148, .14);
  --s-suministro: #3987e5; --s-retorno: #d95926; --s-ambiente: #199e70;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 15px/1.5 var(--f-sans); -webkit-font-smoothing: antialiased; }
button, select, input { font: inherit; color: inherit; }
/* Un estilo con display (p. ej. .boton-sec) no debe poder mostrar algo marcado como oculto. */
[hidden] { display: none !important; }
/* La lista que despliega un <select> la dibuja el navegador: sin fondo y color propios, en Windows queda texto
   claro sobre fondo blanco. */
select { background-color: var(--surface); color: var(--ink); }
select option { background-color: var(--surface); color: var(--ink); }
.num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- marca */
.marca { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.marca .icono { width: 36px; height: 36px; position: relative; flex: none; }
.marca .icono::before { content: ""; position: absolute; left: 0; bottom: 0; width: 28px; height: 28px; border-radius: 7px; background: var(--ink); }
.marca .icono::after { content: ""; position: absolute; right: 0; top: 0; width: 11px; height: 11px; border-radius: 3px; background: var(--accent); }
.marca .wm { font-family: var(--f-display); font-weight: 700; font-size: 26px; letter-spacing: -.02em; line-height: 1; }
.marca .wm b { color: var(--accent); font-weight: 700; }
.marca .pw { display: block; font-family: var(--f-mono); font-size: 11.5px; color: var(--mute); margin-top: 3px; letter-spacing: .02em; }

/* ---------------------------------------------------------------- cabecera y pestañas */
header.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top .fila { max-width: 1200px; margin: 0 auto; padding: 14px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.top .centro { flex: 1; min-width: 200px; display: flex; justify-content: center; }
.top .derecha { text-align: right; font-size: 13px; color: var(--mute); }
.top .derecha .cliente { color: var(--ink); font-family: var(--f-mono); font-weight: 600; }
.selector { font-family: var(--f-display); font-weight: 500; font-size: 19px; color: var(--ink);
  background-color: var(--surface); border: 1px solid var(--line2); border-radius: 10px; padding: 4px 8px; max-width: 100%; }
.selector:hover, .selector:focus-visible { border-color: var(--accent); outline: none; }
.salir { background: none; border: 0; color: var(--mute); cursor: pointer; padding: 0; font-size: 13px; text-decoration: underline; }
.fresco.viejo { color: var(--high); font-weight: 600; }

nav.pestanas { border-bottom: 1px solid var(--line); background: var(--paper); }
nav.pestanas .fila { max-width: 1200px; margin: 0 auto; padding: 0 16px; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
nav.pestanas button { background: none; border: 0; padding: 12px 14px; color: var(--dim); font-size: 16px; cursor: pointer;
  border-bottom: 3px solid transparent; white-space: nowrap; }
nav.pestanas button[aria-selected="true"] { color: var(--accent-ink); border-bottom-color: var(--accent); font-weight: 600; }
nav.pestanas .cuenta { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 6px; border-radius: 10px;
  background: var(--crit); color: #fff; font-size: 12px; font-weight: 600; line-height: 20px; }

main { max-width: 1200px; margin: 0 auto; padding: 24px 16px 48px; transition: opacity .15s; }
main[aria-busy="true"] { opacity: .45; pointer-events: none; }
.aviso-base { font-size: 13px; color: var(--mute); text-align: center; margin-top: 28px; }

/* ---------------------------------------------------------------- tarjetas */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px 22px; min-width: 0; }
.kpi .etq { font-size: 12.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
.kpi .valor { font-family: var(--f-display); font-weight: 700; font-size: 36px; letter-spacing: -.02em; margin: 6px 0 4px; line-height: 1.1; }
.kpi .pie { font-size: 14px; color: var(--dim); display: flex; gap: 8px; align-items: center; }
.punto { width: 10px; height: 10px; border-radius: 50%; flex: none; }

.dos { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; }
.card h3 { font-family: var(--f-display); font-size: 19px; font-weight: 700; margin: 0 0 4px; letter-spacing: -.01em; }
.card .sub { color: var(--mute); font-size: 13px; margin: 0 0 8px; }
.card .cortes { color: var(--dim); font-size: 13px; margin-top: 10px; }
.cab { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ver-datos { background: none; border: 1px solid var(--line2); border-radius: 8px; padding: 3px 10px; font-size: 12.5px; color: var(--dim); cursor: pointer; }
.leyenda { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13.5px; color: var(--dim); margin: 4px 0 2px; }
.leyenda span { display: inline-flex; align-items: center; gap: 7px; }
.leyenda i { width: 16px; height: 3px; border-radius: 2px; display: inline-block; }
.grafico { min-height: 280px; }
.tabla-datos { max-height: 300px; overflow: auto; margin-top: 8px; }

.ia { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.ia .chip { display: inline-block; background: var(--accent); color: #fff; font-weight: 700; border-radius: 8px; padding: 2px 10px; margin-right: 10px; font-size: 14px; }
.ia h3 { display: flex; align-items: center; }
.ia p { margin: 12px 0; line-height: 1.55; }
.ia .progreso { height: 8px; background: color-mix(in srgb, var(--accent) 18%, transparent); border-radius: 4px; overflow: hidden; margin: 14px 0 6px; }
.ia .progreso i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.ia ul.tendencias { margin: 8px 0 12px; padding-left: 18px; line-height: 1.55; }
.ia ul.tendencias li { margin: 4px 0; }
.ia .nota + .nota { margin-top: 8px; }
.ia .nota { font-family: var(--f-mono); font-size: 12.5px; color: var(--mute); }

/* ---------------------------------------------------------------- tablas */
.tabla { margin-top: 16px; padding: 0; overflow: hidden; }
.tabla .scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink);
  background: var(--accent-soft); padding: 14px 18px; white-space: nowrap; }
td { padding: 14px 18px; border-top: 1px solid var(--line); vertical-align: middle; }
td.fuerte { font-weight: 600; }
.tabla-datos th { position: sticky; top: 0; padding: 8px 12px; }
.tabla-datos td { padding: 6px 12px; font-size: 13.5px; }

.estado { display: inline-flex; align-items: center; gap: 7px; border-radius: 999px; padding: 4px 12px; font-weight: 600; font-size: 14px; white-space: nowrap; }
.estado.Normal { background: var(--ok-soft); color: var(--ok); }
.estado.Medio { background: var(--warn-soft); color: #B7791F; }
.estado.Alto { background: var(--high-soft); color: #C0612A; }
.estado.Crítico { background: var(--crit-soft); color: var(--crit); }
:root[data-theme="dark"] .estado.Medio, :root[data-theme="dark"] .estado.Alto { color: var(--ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .estado.Medio, :root:not([data-theme="light"]) .estado.Alto { color: var(--ink); } }
.estado.Resuelta { background: var(--surface-alt); color: var(--dim); }
.estado::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.estado.Normal::before { background: var(--ok); } .estado.Medio::before { background: var(--warn); }
.estado.Alto::before { background: var(--high); } .estado.Crítico::before { background: var(--crit); }
.estado.Resuelta::before { background: var(--ok); }
.nota-alerta { color: var(--high); font-weight: 500; }
.mute { color: var(--mute); }

/* ---------------------------------------------------------------- alertas */
.lista-alertas .alerta { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; padding: 16px 20px; border-top: 1px solid var(--line); align-items: start; }
.lista-alertas .alerta:first-child { border-top: 0; }
.lista-alertas .titulo { font-weight: 600; }
.lista-alertas .texto { color: var(--dim); font-size: 14px; margin-top: 4px; }
.lista-alertas .cuando { font-family: var(--f-mono); font-size: 12.5px; color: var(--mute); text-align: right; white-space: nowrap; }
.vacio { padding: 28px; text-align: center; color: var(--mute); }

.pie-pagina { text-align: center; color: var(--mute); font-size: 12.5px; padding: 0 16px 32px; font-family: var(--f-mono); }
.cargando { color: var(--mute); padding: 40px; text-align: center; }
.error { background: var(--crit-soft); color: var(--crit); padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; }

/* ---------------------------------------------------------------- modo operador */
.operador { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.operador select.cliente { background-color: var(--surface); border: 1px solid var(--line2); border-radius: 8px; padding: 2px 6px;
  font-family: var(--f-mono); font-weight: 600; font-size: 13px; color: var(--ink); cursor: pointer; }
.chip-op { font-family: var(--f-mono); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  background: var(--warn-soft); color: var(--ink); border-radius: 999px; padding: 2px 8px; }

/* ---------------------------------------------------------------- facturación (solo operador) */
.barra-fact { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.barra-fact .nota-fact { flex: 1; font-size: 13px; font-family: var(--f-mono); }
.boton-sec { display: inline-block; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line2); background: var(--surface);
  color: var(--accent-ink); font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer; }
.boton-sec.primario { background: var(--accent); border-color: var(--accent); color: #fff; }
.boton-sec:hover { filter: brightness(1.05); }
.fact-total { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.fact-total .valor { color: var(--accent-ink); }
.kpis .kpi .valor { overflow-wrap: anywhere; }
.cab-tabla { padding: 18px 20px 10px; }
.cab-tabla .sub { margin: 4px 0 0; max-width: 820px; }
th.der { text-align: right; }
td.num { text-align: right; white-space: nowrap; }
tfoot td { font-weight: 700; border-top: 2px solid var(--line2); background: var(--surface-alt); }
tr.fila-operador td { color: var(--dim); font-style: italic; }
.cat { font-family: var(--f-mono); font-size: 12px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line2); white-space: nowrap; }
.cat-flota { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.cat-desarrollo { background: var(--warn-soft); color: var(--ink); border-color: transparent; }
.cat-operacion { background: var(--surface-alt); color: var(--dim); }

.chip-ia { display: inline-block; background: var(--accent); color: #fff; font-weight: 700; border-radius: 6px; padding: 0 8px;
  margin-right: 8px; font-size: 13px; vertical-align: 2px; }
ul.hojas { margin: 12px 0 0; padding-left: 18px; line-height: 1.6; }
ul.hojas li { margin: 6px 0; }

/* ---------------------------------------------------------------- cómo leer esta página (como konIA) */
.como-leer { margin-top: 20px; font-size: 13.5px; color: var(--dim); line-height: 1.6; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; padding: 16px 20px; }
.como-leer h4 { margin: 0 0 6px; font-size: 14.5px; font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.como-leer p { margin: 0 0 8px; }
.como-leer dl { margin: 10px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.como-leer dt { font-weight: 600; color: var(--ink); font-family: var(--f-mono); font-size: 12.5px; padding-top: 1px; }
.como-leer dd { margin: 0; }
.como-leer .sem { font-weight: 700; }
.como-leer .sem-Normal { color: var(--ok); }
.como-leer .sem-Medio { color: #B7791F; }
.como-leer .sem-Alto { color: #C0612A; }
.como-leer .sem-Crítico { color: var(--crit); }
:root[data-theme="dark"] .como-leer .sem-Medio { color: var(--warn); }
:root[data-theme="dark"] .como-leer .sem-Alto { color: var(--high); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .como-leer .sem-Medio { color: var(--warn); }
  :root:not([data-theme="light"]) .como-leer .sem-Alto { color: var(--high); }
}
.como-leer .frescura { margin: 12px 0 0; padding-top: 10px; border-top: 1px dashed var(--line2); font-size: 12.5px; color: var(--mute); }
.como-leer .frescura b { color: var(--dim); }
@media (max-width: 560px) {
  .como-leer dl { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .como-leer dd { margin-bottom: 8px; }
}

/* ---------------------------------------------------------------- login */
.login-caja { max-width: 400px; margin: 10vh auto 0; padding: 0 16px; }
.login-caja .card { padding: 32px 28px; margin-top: 28px; }
.login-caja label { display: block; font-size: 13.5px; color: var(--dim); margin: 14px 0 6px; font-weight: 500; }
.login-caja input { width: 100%; padding: 11px 13px; border: 1px solid var(--line2); border-radius: 10px; background: var(--surface); }
.login-caja input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.boton { margin-top: 22px; width: 100%; padding: 12px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
.boton:hover { filter: brightness(1.06); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 960px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dos { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .kpi .valor { font-size: 30px; }
  .top .centro { order: 3; flex-basis: 100%; justify-content: flex-start; min-width: 0; }
  .top .derecha { order: 2; flex-basis: 100%; text-align: left; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
  .top .derecha > * { margin: 0 !important; }
  .lista-alertas .alerta { grid-template-columns: auto 1fr; }
  .lista-alertas .cuando { grid-column: 2; text-align: left; }
}
