/* Estilos del Panel de Comprobaciones. Ver docs/DESIGN.md */

:root {
  --canvas: #F3F3F1;
  --panel: #FFFFFF;
  --panel-2: #FAFAF8;
  --ink: #1A1A1A;
  --ink-2: #5A5A58;
  --ink-3: #8C8C89;
  --line: #E4E4E1;
  --line-2: #EEEEEB;
  --hover: #F6F6F4;
  --active-bg: #1A1A1A;
  --active-ink: #FFFFFF;
  --alert: #C4473A;
  --alert-soft: #F7E4E1;
  --alert-mid: #E9B5AE;
  --alert-text: #A9392D;
  --alarm-bg: #C4473A;
  --alarm-ink: #FFFFFF;
  --alarm-ink-2: rgba(255, 255, 255, .82);
  --ok: #3F6B43;
  --ok-soft: #E4ECE4;
  --sec-1: #C4473A;
  --sec-2: #C08A2E;
  --sec-3: #3D5A80;
  --sec-1-soft: #F7E4E1;
  --sec-2-soft: #F5EBD8;
  --sec-3-soft: #E2E8F0;
  --sec-2-text: #94681C;
  --sec-3-text: #3D5A80;
  --tip-bg: #1A1A1A;
  --tip-ink: #FFFFFF;
  --tip-line: #1A1A1A;
  --shadow: 0 10px 30px rgba(0, 0, 0, .10);
  --scrim: rgba(20, 20, 20, .38);

  --side: 256px;
  --ease: cubic-bezier(.65, 0, .35, 1);
  --t-fast: .16s;
  --t-mid: .26s;
  --t-slow: .42s;
  color-scheme: light;
}
html[data-theme="dark"] {
  --canvas: #111111;
  --panel: #191919;
  --panel-2: #1D1D1D;
  --ink: #E8E8E5;
  --ink-2: #A3A3A0;
  --ink-3: #6E6E6B;
  --line: #2A2A2A;
  --line-2: #232323;
  --hover: #212121;
  --active-bg: #2C2C2C;
  --active-ink: #F2F2EF;
  --alert: #D0594C;
  --alert-soft: #331D1A;
  --alert-mid: #6B302A;
  --alert-text: #EC8C80;
  --alarm-bg: #4A221E;
  --alarm-ink: #FBE3DF;
  --alarm-ink-2: rgba(251, 227, 223, .72);
  --ok: #86B58A;
  --ok-soft: #1C281D;
  --sec-1: #D0594C;
  --sec-2: #CC9842;
  --sec-3: #6E8DBB;
  --sec-1-soft: #331D1A;
  --sec-2-soft: #2F2617;
  --sec-3-soft: #1C2431;
  --sec-2-text: #DDB06A;
  --sec-3-text: #93ADD4;
  --tip-bg: #262626;
  --tip-ink: #E8E8E5;
  --tip-line: #353535;
  --shadow: 0 12px 34px rgba(0, 0, 0, .45);
  --scrim: rgba(0, 0, 0, .55);
  color-scheme: dark;
}
html[data-theme="dark"] .side-logo,
html[data-theme="dark"] .topbar-logo,
html[data-theme="dark"] .login-logo { filter: invert(1) brightness(.92); }

/* Al cambiar de tema los colores se funden en vez de saltar. */
html.is-theming *, html.is-theming *::before, html.is-theming *::after {
  transition: background-color var(--t-slow) var(--ease), border-color var(--t-slow) var(--ease),
    color var(--t-slow) var(--ease) !important;
}

/* Base */
* { box-sizing: border-box; }
/* hidden siempre gana a cualquier regla con display. */
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--canvas); color: var(--ink);
  font: 400 13px/1.5 "Space Grotesk", sans-serif; font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
::selection { background: var(--ink); color: var(--panel); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

.noscript-note { margin: 0; padding: 16px 22px; text-align: center; background: var(--alert); color: var(--alarm-ink); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.muted { color: var(--ink-3); }

/* Estructura: el fondo del menu lateral llega siempre abajo del todo */
.app {
  display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh;
  background: linear-gradient(to right, var(--panel) calc(var(--side) - 1px), var(--line) calc(var(--side) - 1px) var(--side), transparent var(--side));
}

/* Menu lateral */
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  padding: 22px 14px 16px; overflow-y: auto;
}
.side-resize { position: absolute; top: 0; right: 0; bottom: 0; width: 7px; z-index: 5; cursor: col-resize; }
.side-resize::after {
  content: ""; position: absolute; top: 0; bottom: 0; right: 0; width: 2px; background: var(--ink-3);
  opacity: 0; transition: opacity var(--t-fast) var(--ease);
}
.side-resize:hover::after, .is-resizing .side-resize::after { opacity: .6; }
body.is-resizing { cursor: col-resize; user-select: none; }
.side-logo { height: 26px; width: auto; margin: 2px 10px 30px; align-self: flex-start; }
.side-nav { position: relative; }
.side-group + .side-group { margin-top: 22px; }
.side-title {
  padding: 0 10px 8px; font-size: 11px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-3);
}
/* El bloque de la pagina activa */
.side-indicator {
  position: absolute; left: 0; right: 0; top: 0; height: 0; background: var(--active-bg);
  pointer-events: none;
}
.side-item {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 7px; height: 38px; padding: 0 10px;
  font-size: 13px; font-weight: 500; color: var(--ink-2);
  transition: color var(--t-mid) var(--ease), background-color var(--t-fast) var(--ease);
}
.side-item:hover { color: var(--ink); background: var(--hover); }
.side-item.is-active { color: var(--active-ink); background: transparent; cursor: default; }
/* El nombre se corta antes que el numero. */
.side-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-label img { width: 14px; height: 14px; vertical-align: -2px; margin-right: 6px; }
.side-label .sep { opacity: .45; margin: 0 6px; }
.side-item .badge { flex-shrink: 0; padding: 0 7px; }
.side-item.is-active .badge.is-bad { background: var(--alert); color: var(--alarm-ink); }
.side-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); }
.side-link {
  display: flex; align-items: center; justify-content: space-between; height: 30px; padding: 0 10px;
  font-size: 12.5px; color: var(--ink-2); transition: color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.side-link:hover { color: var(--ink); background: var(--hover); }
.side-link span { color: var(--ink-3); transition: transform var(--t-fast) var(--ease); }
.side-link:hover span { transform: translate(2px, -2px); }
.side-theme {
  display: flex; align-items: center; justify-content: space-between; margin-top: 12px; padding-left: 10px;
  font-size: 12.5px; color: var(--ink-2);
}
.side-logout { display: inline-block; margin: 14px 0 0 10px; font-size: 12.5px; color: var(--ink-2); }
.side-logout:hover { color: var(--ink); }

/* Interruptor de dos opciones: el bloque blanco se desliza */
.seg { position: relative; display: inline-flex; background: var(--line-2); padding: 3px; }
.seg-thumb {
  position: absolute; top: 3px; bottom: 3px; left: 0; background: var(--panel); box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
  transition: transform var(--t-mid) var(--ease), width var(--t-mid) var(--ease);
}
.seg-btn {
  position: relative; z-index: 1; height: 26px; padding: 0 10px; font-size: 12px; font-weight: 500; color: var(--ink-3);
  transition: color var(--t-mid) var(--ease);
}
.seg-btn.is-active { color: var(--ink); }

/* Barra superior y menu deslizante del movil */
.topbar, .scrim { display: none; }

/* Carga: una barra que recorre lo alto de la pagina mientras se pide algo */
.loadbar { position: fixed; top: 0; left: var(--side); right: 0; height: 2px; z-index: 60; overflow: hidden; pointer-events: none; }
.loadbar i {
  position: absolute; top: 0; bottom: 0; left: 0; width: 30%; background: var(--ink);
  transform: translateX(-110%); opacity: 0; transition: opacity var(--t-mid) var(--ease);
}
.loadbar.is-on i { opacity: 1; animation: sweep 1.1s var(--ease) infinite; }
@keyframes sweep { from { transform: translateX(-110%); } to { transform: translateX(360%); } }

/* Contenido */
.main { min-width: 0; padding: 26px 32px 56px; }
.view { max-width: 1400px; margin: 0 auto; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* Cabecera de pagina: los sistemas con su logo, la ayuda y los datos */
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.title { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 0; margin: 0; font-size: 26px; font-weight: 500; letter-spacing: -.02em; line-height: 1.15; }
.title .sys { display: inline-flex; align-items: center; gap: 9px; }
.title .sys img { width: 22px; height: 22px; }
.title .gt { color: var(--ink-3); font-weight: 400; margin: 0 10px; }
.title .help { margin-left: 12px; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 10px; min-height: 20px; }
.fact { display: inline-flex; align-items: baseline; gap: 6px; font-size: 13px; font-weight: 500; }
.fact .muted { font-weight: 400; }
.facts-group { display: inline-flex; flex-wrap: wrap; gap: 6px 16px; }
.facts-sep { width: 1px; height: 12px; background: var(--ink-3); opacity: .45; align-self: center; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 34px; padding: 0 14px;
  background: var(--panel); border: 1px solid var(--line); font-size: 12.5px; font-weight: 500; white-space: nowrap;
  transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.btn:hover:not(:disabled) { border-color: var(--ink-3); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { color: var(--ink-3); cursor: not-allowed; }
.btn.is-spinning svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.link-btn { font-size: 12.5px; color: var(--ink-2); }
.link-btn:hover { color: var(--ink); }

/* Filtros de la pagina: todos iguales, cada uno dice que filtra y que tiene */
.filters { display: flex; align-items: center; gap: 8px; margin-top: 20px; flex-wrap: wrap; min-height: 36px; }
.dd { position: relative; }
.filter {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px 0 12px;
  background: var(--panel); border: 1px solid var(--line); font-size: 12.5px; white-space: nowrap;
  transition: border-color var(--t-fast) var(--ease);
}
.filter:hover { border-color: var(--ink-3); }
.filter .k { color: var(--ink-3); }
.filter .v { font-weight: 500; }
.caret { width: 9px; height: 9px; color: var(--ink-3); transition: transform var(--t-mid) var(--ease); }
.filter.is-set { border-color: var(--ink); }
.dd.is-open > .filter, .dd.is-open > .btn { border-color: var(--ink); }
.dd.is-open .caret { transform: rotate(180deg); }

/* Desplegables: bajan un poco y se despliegan desde arriba */
.menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; min-width: 220px; max-height: 340px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 6px 0;
  transform-origin: top left; transform: translateY(-6px) scaleY(.96); opacity: 0; visibility: hidden;
  transition: transform var(--t-mid) var(--ease), opacity var(--t-fast) var(--ease), visibility 0s linear var(--t-mid);
}
.menu.is-right { left: auto; right: 0; transform-origin: top right; }
.dd.is-open .menu { transform: none; opacity: 1; visibility: visible; transition-delay: 0s; }
.menu-title { padding: 8px 14px 4px; font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 14px; text-align: left; font-size: 13px;
  transition: background-color var(--t-fast) var(--ease);
}
.menu-item:hover { background: var(--hover); }
/* Marca cuadrada donde se elige mas de uno, redonda donde solo uno. */
.mark {
  width: 14px; height: 14px; flex-shrink: 0; border: 1px solid var(--line); position: relative;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.mark.is-round { border-radius: 50%; }
.menu-item.is-on .mark { background: var(--ink); border-color: var(--ink); }
.menu-item.is-on .mark::after {
  content: ""; position: absolute; inset: 3px; background: var(--panel);
  clip-path: polygon(14% 52%, 0 66%, 38% 100%, 100% 22%, 86% 8%, 38% 72%);
}
.menu-item.is-on .mark.is-round::after { inset: 4px; border-radius: 50%; clip-path: none; }
.menu-sep { height: 1px; background: var(--line-2); margin: 6px 0; }

/* Rejilla y paneles */
.grid { display: grid; gap: 14px; margin-top: 14px; }
.stack { display: grid; gap: 14px; margin-top: 14px; }
.zone-start { margin-top: 22px; }
.grid.zone-first { margin-top: 10px; }
.l-shopify { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) minmax(380px, 1.35fr); }
.l-aw { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
.kpi-pair { margin: 0; grid-template-rows: 1fr 1fr; }
.rows + .sub-title { margin-top: 20px; }
#picks .zone-label { margin-right: 4px; }
.view > .panel { margin-top: 14px; }
.r-kpi4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.panel { position: relative; background: var(--panel); padding: 18px 20px 20px; min-width: 0; }
.panel-head { display: flex; align-items: center; gap: 10px; min-height: 30px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-title { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; font-weight: 600; }
.panel-head .end { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel-note { margin: 0; color: var(--ink-2); }
.sub-title { margin: 0 0 10px; font-size: 12px; font-weight: 500; color: var(--ink-2); }

/* Zona: separa lo que es de toda la pagina de lo que es de una parte de ella */
.zone-label { font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }
.zone-title { margin: 3px 0 0; font-size: 22px; font-weight: 500; letter-spacing: -.015em; }
.zone-stats { display: flex; gap: 12px 20px; flex-wrap: wrap; margin-left: auto; align-items: flex-end; min-width: 0; }
.zone-group { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.zone-group + .zone-group { padding-left: 20px; border-left: 1px solid var(--line); }
.zone-stat { font-size: 12px; color: var(--ink-3); }
.zone-stat b { display: block; font-size: 16px; font-weight: 500; color: var(--ink); letter-spacing: -.01em; }
.zone-stat b.is-bad { color: var(--alert-text); }
.zone-stat .sw { margin-right: 6px; }
/* La cabecera de la parte elegida se queda arriba al bajar. */
.sticky-zone {
  position: sticky; top: 0; z-index: 20; margin: 0 -32px; padding: 12px 32px; background: var(--canvas);
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  transition: box-shadow var(--t-mid) var(--ease);
}
.sticky-zone.is-stuck { box-shadow: 0 1px 0 var(--line); }

/* Cifras */
.kpi {
  position: relative; background: var(--panel); padding: 18px 20px; display: flex; flex-direction: column; min-height: 132px; text-align: left;
  transition: background-color var(--t-mid) var(--ease);
}
.kpi-label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); }
.kpi-value { margin-top: auto; padding-top: 14px; font-size: 34px; font-weight: 500; letter-spacing: -.025em; line-height: 1; }
.kpi-value small { font-size: 15px; color: var(--ink-3); font-weight: 400; letter-spacing: 0; margin-left: 4px; }
/* Sin dato no se miente con un cero. */
.kpi-value.is-unknown { color: var(--ink-3); font-size: 26px; }
.kpi-foot { margin-top: 10px; font-size: 12px; color: var(--ink-3); }
.kpi.is-alarm { background: var(--alarm-bg); color: var(--alarm-ink); }
.kpi.is-alarm .kpi-label, .kpi.is-alarm .kpi-foot, .kpi.is-alarm .kpi-value small { color: var(--alarm-ink-2); }
.kpi.is-alarm .help { border-color: var(--alarm-ink-2); color: var(--alarm-ink-2); }
.kpi.is-good .kpi-value { color: var(--ok); }
button.kpi:hover { background: var(--hover); }
button.kpi.is-on, button.kpi.is-on:hover { background: var(--line-2); }
.kpi-x { position: absolute; top: 14px; right: 16px; font-size: 15px; line-height: 1; color: var(--ink-2); opacity: 0; transform: scale(.6); transition: opacity var(--t-fast) var(--ease), transform var(--t-mid) var(--ease); }
button.kpi.is-on .kpi-x { opacity: 1; transform: none; }
.kpi-split { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 10px; }
.kpi-split span { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; background: var(--panel); color: var(--ink); font-weight: 600; font-size: 12px; }
.meter { height: 3px; background: var(--line-2); margin-top: 12px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--ink); transform-origin: left; transition: transform .7s var(--ease); }

/* Insignias rellenas. l1 a l3: el rojo sube con la cantidad, comparada con la mayor de su tabla */
.badge {
  display: inline-flex; align-items: center; justify-content: center; height: 22px; padding: 0 8px; font-size: 12px; font-weight: 600;
  background: var(--line-2); color: var(--ink-2); white-space: nowrap;
}
.badge.is-bad, .badge.l1 { background: var(--alert-soft); color: var(--alert-text); }
.badge.l2 { background: var(--alert-mid); color: var(--alert-text); }
html[data-theme="dark"] .badge.l2 { color: var(--alarm-ink); }
.badge.l3 { background: var(--alert); color: var(--alarm-ink); }
.badge.is-ok { background: var(--ok-soft); color: var(--ok); }
.badge.s1 { background: var(--sec-1-soft); color: var(--alert-text); }
.badge.s2 { background: var(--sec-2-soft); color: var(--sec-2-text); }
.badge.s3 { background: var(--sec-3-soft); color: var(--sec-3-text); }
.sw { display: inline-block; width: 8px; height: 8px; flex-shrink: 0; }
.sw.is-off { background: none !important; box-shadow: inset 0 0 0 1px var(--line); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.legend .sw { margin-right: 6px; }

/* Ayuda y aviso flotante, que sigue al raton */
.help {
  display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; border-radius: 50%;
  border: 1px solid var(--line); font-size: 9.5px; font-weight: 600; color: var(--ink-3); cursor: help; flex-shrink: 0;
  letter-spacing: 0; transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.help:hover { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.tip {
  position: fixed; left: 0; top: 0; z-index: 600; pointer-events: none; max-width: 320px;
  background: var(--tip-bg); color: var(--tip-ink); border: 1px solid var(--tip-line); padding: 9px 12px;
  font-size: 12px; font-weight: 400; line-height: 1.6; white-space: pre-line; box-shadow: var(--shadow);
  font-variant-numeric: normal; opacity: 0; transition: opacity var(--t-fast) var(--ease), transform .09s linear;
}
.tip.is-on { opacity: 1; }
.tip b { font-weight: 600; }
.tip .sw { margin-right: 7px; }

/* Grafica de barras apiladas: crecen desde la base */
.chart { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; height: 230px; }
.chart-y { display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end; padding-bottom: 22px; font-size: 11px; color: var(--ink-3); }
.chart-plot { position: relative; display: flex; align-items: stretch; gap: 4px; padding-bottom: 22px; }
.chart-plot::before, .hours::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; bottom: 22px; pointer-events: none;
  background: repeating-linear-gradient(to bottom, var(--line-2) 0 1px, transparent 1px 25%);
}
.bar { position: relative; flex: 1; min-width: 2px; display: flex; flex-direction: column; justify-content: flex-end; cursor: pointer; }
.bar-hit { position: absolute; inset: 0 -2px; transition: background-color var(--t-fast) var(--ease); }
.bar:hover .bar-hit, .bar.is-pick .bar-hit { background: var(--hover); }
.bar-stack {
  position: relative; display: flex; flex-direction: column-reverse; transform-origin: bottom;
  transform: scaleY(0); transition: transform .6s var(--ease), opacity var(--t-mid) var(--ease);
}
.chart.is-drawn .bar-stack { transform: scaleY(1); }
.bar-stack span { display: block; }
.bar.is-zero .bar-stack { height: 2px !important; background: var(--line); }
.bar.is-dim .bar-stack { opacity: .3; }
.bar em { position: absolute; left: 50%; bottom: -21px; transform: translateX(-50%); font-style: normal; font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.chart-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--ink-3); }

.hours { position: relative; display: flex; align-items: flex-end; gap: 3px; height: 230px; padding-bottom: 22px; }
.hours .h { position: relative; flex: 1; height: 100%; display: flex; align-items: flex-end; cursor: pointer; }
.hours .h:hover { background: var(--hover); }
.hours .h span { display: block; width: 100%; background: var(--ink-3); transform-origin: bottom; transform: scaleY(0); transition: transform .6s var(--ease), opacity var(--t-mid) var(--ease); }
.hours.is-drawn .h span { transform: scaleY(1); }
.hours .h.is-dim span { opacity: .3; }
.hours em { position: absolute; bottom: 0; font-size: 11px; font-style: normal; color: var(--ink-3); }
.time-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 1fr); gap: 28px; }

/* Pestanas: el bloque blanco se desliza a la elegida */
.tabs { position: relative; display: inline-flex; background: var(--line-2); padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; }
.tabs-thumb {
  position: absolute; top: 3px; bottom: 3px; left: 0; background: var(--panel); box-shadow: 0 1px 2px rgba(0, 0, 0, .07);
  transition: transform var(--t-mid) var(--ease), width var(--t-mid) var(--ease);
}
.tab {
  position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px;
  font-size: 12.5px; font-weight: 500; color: var(--ink-2); white-space: nowrap; transition: color var(--t-mid) var(--ease);
}
.tab:hover, .tab.is-active { color: var(--ink); }
.tab .n { color: var(--ink-3); }
.tab .n.is-bad { color: var(--alert-text); font-weight: 600; }

/* Lo elegido en la pagina: etiquetas que se quitan con la x */
.chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 6px 0 10px; font-size: 12px;
  background: var(--active-bg); color: var(--active-ink);
}
.chip b { font-weight: 400; opacity: .65; }
.chip button { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; opacity: .7; }
.chip button:hover { opacity: 1; }
.chip.is-fixed { background: var(--line-2); color: var(--ink-2); padding-right: 10px; }

/* Listas sencillas dentro de un panel */
.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 10px; padding: 12px 10px; margin: 0 -10px; text-align: left; width: calc(100% + 20px);
  transition: background-color var(--t-fast) var(--ease);
}
.row + .row { border-top: 1px solid var(--line-2); }
.row-main { min-width: 0; flex: 1; }
.row-name { font-weight: 500; }
button.row:hover, .row.is-on { background: var(--hover); }
.day-n { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.cause-bar { display: flex; height: 10px; overflow: hidden; background: var(--line-2); margin-bottom: 8px; }
.cause-bar i { display: block; height: 100%; transform-origin: left; transform: scaleX(0); transition: transform .7s var(--ease); }
.is-drawn .cause-bar i { transform: scaleX(1); }

/* Barra de una tabla: busqueda, columnas y CSV */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search { position: relative; display: inline-flex; align-items: center; }
.search input {
  height: 34px; width: 260px; padding: 0 30px 0 32px; border: 1px solid var(--line); background: var(--panel); outline: none;
  transition: border-color var(--t-fast) var(--ease), width var(--t-mid) var(--ease);
}
.search input:focus { border-color: var(--ink); width: 300px; }
.search input::placeholder { color: var(--ink-3); }
/* La X del navegador no se puede estilar: se usa la propia. */
.search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.search svg { position: absolute; left: 11px; color: var(--ink-3); pointer-events: none; }
.search .x { position: absolute; right: 6px; width: 22px; height: 22px; font-size: 15px; color: var(--ink-3); }
.search .x:hover { color: var(--ink); }

/* Tablas: anchos fijos por tipo de dato, iguales en todas */
.tablewrap { overflow-x: auto; margin-top: 12px; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.table th {
  padding: 9px 14px; text-align: left; font-size: 11.5px; font-weight: 500; color: var(--ink-3);
  background: var(--panel-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; user-select: none;
}
.table th.sortable { cursor: pointer; }
.table th.sortable:hover { color: var(--ink); }
.table th .arrow { display: inline-block; margin-left: 4px; font-size: 9px; opacity: 0; transition: transform var(--t-mid) var(--ease), opacity var(--t-fast) var(--ease); }
.table th.sortable:hover .arrow { opacity: .4; }
.table th.is-sorted .arrow { opacity: 1; }
.table th.is-asc .arrow { transform: rotate(180deg); }
.table th .sw { margin-right: 6px; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table .num { text-align: right; }
/* Copiar un codigo: sale al pasar por la celda, encima del final del texto */
.table td.has-copy { position: relative; padding-right: 34px; }
.copy {
  position: absolute; right: 6px; top: 50%; width: 24px; height: 24px; margin-top: -12px; display: inline-flex; align-items: center;
  justify-content: center; color: var(--ink-3); background: var(--panel); opacity: 0; transition: opacity var(--t-fast) var(--ease);
}
.copy svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.4; }
tr:hover .copy, .copy:focus-visible { opacity: 1; background: var(--hover); }
.copy:hover { color: var(--ink); }
.copy.is-done { color: var(--ok); opacity: 1; }
.table td.bad { color: var(--alert-text); }
.table .struck { display: block; font-size: 11.5px; color: var(--ink-3); text-decoration: line-through; overflow: hidden; text-overflow: ellipsis; }
.table .link { border-bottom: 1px solid currentColor; transition: color var(--t-fast) var(--ease); }
.table .link:hover { color: var(--alert-text); }
.table tbody tr.r { transition: background-color var(--t-fast) var(--ease); }
.table tbody tr.r.is-click { cursor: pointer; }
.table tbody tr.r.is-click:hover td, .table tbody tr.r.is-open td { background: var(--hover); }
.table tbody tr.r.is-open td { border-bottom-color: var(--hover); }
.table tbody tr.r.is-selected td { background: var(--line-2); }
.table tbody tr.r.is-selected td.name { font-weight: 600; }
.table td.chev-td { padding: 0 0 0 14px; text-overflow: clip; }
.chev { display: inline-block; width: 10px; color: var(--ink-3); transition: transform var(--t-mid) var(--ease), color var(--t-mid) var(--ease); }
.table tr.is-open .chev { transform: rotate(90deg); color: var(--ink); }
.table td.empty { padding: 30px 14px; text-align: center; color: var(--ink-3); white-space: normal; cursor: default; }
.table td.name { font-weight: 500; }
.share { display: flex; width: 100%; height: 6px; background: var(--line-2); }
.more-row { display: flex; justify-content: center; margin-top: 12px; }
#picks { margin: 2px 0 4px; }
.share i { display: block; height: 100%; }
.share-fill { display: flex; height: 100%; }
.fail { display: flex; align-items: center; gap: 10px; }
.fail b { flex: none; min-width: 44px; text-align: right; font-weight: 500; }
.fail.is-ok b { color: var(--ok); }

/* Esqueleto de la primera carga */
.skeleton td span { display: block; height: 11px; background: var(--line-2); animation: pulse 1.2s var(--ease) infinite; }
.skeleton:nth-child(even) td span { animation-delay: .2s; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }
.skel { display: inline-block; height: 11px; vertical-align: middle; background: var(--line-2); animation: pulse 1.2s var(--ease) infinite; }
.skel-value { display: block; width: 55%; height: 30px; }
.skel-block { display: block; width: 100%; height: 100%; }

/* Detalle de una fila: se despliega hacia abajo y mide lo que se ve de la tabla, no la fila */
.table tr.detail td { padding: 0; border-bottom: 0; background: var(--hover); white-space: normal; overflow: visible; }
.detail-in { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--t-slow) var(--ease); }
/* clip y no hidden: hidden haria de contenedor de scroll y el detalle no acompanaria. */
.detail-in > div { overflow: clip; min-height: 0; }
tr.detail.is-open .detail-in { grid-template-rows: 1fr; }
tr.detail.is-open td { border-bottom: 1px solid var(--line-2); }
.detail-stick { position: sticky; left: 0; width: var(--view-w, 100%); }
.detail-card { display: grid; grid-template-columns: 1fr 1fr; margin: 4px 14px 16px 38px; background: var(--panel); }
.detail-col { display: flex; flex-direction: column; min-width: 0; padding: 16px 18px; }
.detail-col + .detail-col { border-left: 1px solid var(--line-2); }
.detail-col h4 { margin: 0 0 10px; font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }
.di { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 10px; font-size: 12.5px; line-height: 24px; }
.di span:first-child { color: var(--ink-3); }
.di span:last-child { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.di-sep { height: 8px; }
.detail-btns { display: flex; gap: 8px; margin-top: auto; padding-top: 16px; }

/* Paginador */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; font-size: 12px; color: var(--ink-3); flex-wrap: wrap; }
.pages { display: flex; gap: 4px; }
.pg {
  min-width: 30px; height: 30px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-size: 12px;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.pg:hover:not(:disabled):not(.is-active) { border-color: var(--ink-3); }
.pg.is-active { background: var(--active-bg); border-color: var(--active-bg); color: var(--active-ink); cursor: default; }
.pg:disabled { color: var(--ink-3); cursor: default; }
.pg.is-gap { border: 0; background: none; cursor: default; }

/* Barra de aviso de la pagina: algo de lo que depende no esta bien */
.alertbar {
  display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; margin-top: 14px; padding: 10px 14px;
  background: var(--alert-soft); color: var(--alert-text); animation: rise var(--t-slow) var(--ease) both;
}
.alertbar .k { font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; }
.alertbar .v { font-weight: 500; }
.alertbar .badge { background: var(--panel); color: var(--alert-text); transition: background-color var(--t-fast) var(--ease); }
.alertbar a.badge:hover { background: var(--hover); }
.alertbar .help { border-color: currentColor; color: inherit; }
.alertbar .end { margin-left: auto; font-weight: 500; }
.alertbar .end:hover { color: var(--ink); }

/* Aviso en lugar de una tabla cuya fuente no esta disponible */
.notice { margin-top: 12px; padding: 16px; background: var(--panel-2); color: var(--ink-2); }

/* Tabla pequena de un panel lateral */
.mini { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.mini th { padding: 0 0 8px; text-align: right; font-size: 11.5px; font-weight: 500; color: var(--ink-3); white-space: nowrap; }
.mini td { padding: 10px 0; text-align: right; border-top: 1px solid var(--line-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini th:first-child, .mini td:first-child { text-align: left; }
.mini td + td, .mini th + th { padding-left: 8px; }
.mini .c-n { width: 64px; }
.mini .c-s { width: 38px; }
.mini .c-r { width: 58px; }
.mini td:first-child { font-weight: 500; }
.mini .badge { padding: 0 6px; min-width: 26px; }
.mini tbody tr.is-click { cursor: pointer; transition: background-color var(--t-fast) var(--ease); }
.mini tbody tr.is-click:hover td { background: var(--hover); }
.mini tbody tr.is-on td { background: var(--line-2); }

/* Valores mas ligados al fallo */
.sig-head, .sig {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(120px, 1fr) 62px 62px 84px; align-items: center; gap: 14px;
  width: calc(100% + 20px); padding: 9px 10px; margin: 0 -10px; font-size: 12.5px; text-align: left;
  transition: background-color var(--t-fast) var(--ease);
}
.sig-head { padding-top: 0; padding-bottom: 8px; font-size: 11.5px; color: var(--ink-3); }
.sig-head span:nth-child(n+4), .sig .p, .sig .t, .sig .c { text-align: right; }
.sig + .sig { border-top: 1px solid var(--line-2); }
.sig:hover { background: var(--hover); }
.sig.is-on { background: var(--line-2); }
.sig .f { color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sig .v { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sig .more { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; margin-left: 6px; font-size: 11px; font-weight: 500; background: var(--line-2); color: var(--ink-2); vertical-align: 1px; }
/* La barra roja es lo que tienen las filas que fallan; la raya, lo que tiene toda la tabla. */
.sig .cmp { position: relative; height: 8px; background: var(--line-2); }
.sig .cmp i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--alert); transform-origin: left; transform: scaleX(0); transition: transform .6s var(--ease); }
.sig .cmp u { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: 0; transition: opacity var(--t-mid) var(--ease) .3s; }
.is-drawn .sig .cmp i { transform: scaleX(1); }
.is-drawn .sig .cmp u { opacity: 1; }
.sig .p { font-weight: 600; color: var(--alert-text); }
.sig .t { color: var(--ink-2); }
.sig .c { color: var(--ink-3); white-space: nowrap; }

/* Avisos */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 400; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; max-width: min(440px, calc(100vw - 40px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 14px; padding: 12px 12px 12px 16px;
  background: var(--tip-bg); color: var(--tip-ink); border: 1px solid var(--tip-line); box-shadow: var(--shadow); font-size: 13px;
  animation: toastIn var(--t-slow) var(--ease) both;
}
.toast.is-out { animation: toastOut var(--t-mid) var(--ease) both; }
.toast .btn { height: 28px; background: transparent; color: inherit; border-color: currentColor; }
.toast-x { font-size: 18px; line-height: 1; opacity: .6; padding: 0 4px; }
.toast-x:hover { opacity: 1; }
.toast-err { flex-direction: column; align-items: stretch; gap: 8px; background: var(--alert); color: var(--alarm-ink); border-color: var(--alert); }
.toast-err-row { display: flex; align-items: flex-start; gap: 14px; }
.toast-err-row span { flex: 1; line-height: 1.5; }
.toast-err-toggle { align-self: flex-start; font-size: 12px; font-weight: 600; border-bottom: 1px solid var(--alarm-ink-2); }
.toast-err pre {
  margin: 0; padding: 10px; max-height: 180px; overflow: auto; background: rgba(0, 0, 0, .22);
  font: 11px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-word;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(16px); } }

/* Dialogo: el fondo se oscurece y la tarjeta sube */
.modal {
  position: fixed; inset: 0; z-index: 500; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: var(--scrim); opacity: 0; visibility: hidden; transition: opacity var(--t-mid) var(--ease), visibility 0s linear var(--t-mid);
}
.modal.is-open { opacity: 1; visibility: visible; transition-delay: 0s; }
body.is-modal-open { overflow: hidden; }
.modal-card {
  width: 100%; max-width: 440px; background: var(--panel); padding: 22px 24px; box-shadow: var(--shadow);
  transform: translateY(18px); transition: transform var(--t-slow) var(--ease);
}
.modal.is-open .modal-card { transform: none; }
.modal-card h3 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-sub { margin: 8px 0 16px; color: var(--ink-2); line-height: 1.6; }
.modal-opt {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px; width: 100%; padding: 12px 14px; margin-top: 8px;
  border: 1px solid var(--line); text-align: left; transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.modal-opt:hover:not(:disabled) { border-color: var(--ink); background: var(--hover); }
.modal-opt:disabled { opacity: .6; cursor: progress; }
.modal-opt span { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.modal-actions { display: flex; justify-content: flex-end; margin-top: 16px; }

/* Acceso */
.login-body { background: var(--canvas); }
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
/* margin auto: en una ventana mas baja que la tarjeta, centrar con align-items cortaria su parte de arriba. */
.login-card {
  margin: auto; width: 100%; max-width: 380px; display: flex; flex-direction: column;
  background: var(--panel); padding: 36px 34px 32px; animation: rise var(--t-slow) var(--ease) both;
}
/* Sin align-self el flex estira el logo a lo ancho. */
.login-logo { align-self: flex-start; height: 40px; width: auto; display: block; }
.login-error { margin: 26px 0 0; padding: 11px 14px; background: var(--alert); color: var(--alarm-ink); line-height: 1.5; }
.login-field { display: block; margin-top: 22px; }
.login-label { display: block; margin-bottom: 8px; font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }
.login-field input {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line); background: var(--panel); outline: none;
  transition: border-color var(--t-fast) var(--ease);
}
.login-field input:focus { border-color: var(--ink); }
.login-remember { display: flex; align-items: center; gap: 10px; margin-top: 22px; cursor: pointer; user-select: none; color: var(--ink-2); }
.login-remember input { accent-color: var(--ink); width: 14px; height: 14px; margin: 0; flex-shrink: 0; cursor: pointer; }
.login-btn {
  margin-top: 28px; height: 42px; background: var(--ink); color: var(--panel); font-weight: 500;
  transition: opacity var(--t-fast) var(--ease);
}
.login-btn:hover { opacity: .85; }

/* Responsive */
@media (max-width: 1180px) {
  .r-kpi4, .r-kpi2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; grid-template-rows: auto !important; }
  .r-stack { grid-template-columns: minmax(0, 1fr) !important; }
}
@media (max-width: 860px) {
  .app { display: block; background: var(--canvas); }
  .side {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 90; width: min(300px, 86vw); height: auto;
    background: var(--panel); transform: translateX(-100%); transition: transform var(--t-slow) var(--ease);
  }
  .side-resize { display: none; }
  .is-drawer .side { transform: none; box-shadow: var(--shadow); }
  .scrim {
    display: block; position: fixed; inset: 0; z-index: 80; background: var(--scrim);
    opacity: 0; visibility: hidden; transition: opacity var(--t-slow) var(--ease), visibility 0s linear var(--t-slow);
  }
  .is-drawer .scrim { opacity: 1; visibility: visible; transition-delay: 0s; }
  .topbar {
    position: sticky; top: 0; z-index: 70; display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 16px;
    background: var(--panel); border-bottom: 1px solid var(--line);
  }
  .topbar-logo { height: 22px; }
  .topbar-page { margin-left: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; font-weight: 500; }
  .topbar-page img { width: 13px; height: 13px; vertical-align: -2px; margin-right: 5px; }
  .topbar-page .sep { opacity: .45; margin: 0 5px; }
  .burger { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; margin-left: -8px; }
  .loadbar { left: 0; top: 56px; }
  .main { padding: 20px 16px 48px; }
  .head { flex-direction: column; gap: 14px; }
  .title { font-size: 20px; }
  .title .sys img { width: 17px; height: 17px; }
  .facts, .facts-group { gap: 4px 16px; }
  .facts-sep { display: none; }
  .filters { flex-wrap: nowrap; overflow-x: auto; margin: 16px -16px 0; padding: 0 16px 4px; scrollbar-width: none; }
  .filters::-webkit-scrollbar { display: none; }
  .mini .c-n { width: 52px; }
  .mini .c-s { width: 30px; }
  .mini .c-r { width: 48px; }
  .mini td + td, .mini th + th { padding-left: 4px; }
  .r-kpi4, .r-kpi2 { gap: 10px !important; }
  .kpi { min-height: 112px; padding: 14px 16px; }
  .kpi-value { font-size: 26px; }
  .panel { padding: 16px; }
  .panel-head .end { margin-left: 0; width: 100%; }
  .toolbar { width: 100%; }
  .toolbar .search { flex: 1 1 100%; }
  .search input, .search input:focus { width: 100%; }
  .zone-stats { margin-left: 0; }
  .zone-group + .zone-group { padding-left: 0; border-left: 0; }
  .sticky-zone { top: 56px; margin: 0 -16px; padding: 10px 16px; gap: 6px 14px; }
  .sticky-zone.is-stuck { padding: 8px 16px; }
  .sticky-zone.is-stuck .zone-label, .sticky-zone.is-stuck .zone-group:first-child { display: none; }
  .sticky-zone.is-stuck .zone-title { font-size: 16px; margin: 0; }
  .sticky-zone.is-stuck .zone-stats { width: 100%; }
  .sticky-zone.is-stuck .zone-stat b { display: inline; font-size: 13px; margin-right: 4px; }
  .time-grid { grid-template-columns: minmax(0, 1fr); }
  .sig, .sig-head { grid-template-columns: minmax(0, 1fr) 54px 54px; gap: 4px 12px; }
  .sig .f { grid-column: 1 / -1; }
  .sig .cmp, .sig .c, .sig-head span:nth-child(1), .sig-head span:nth-child(3), .sig-head span:nth-child(6) { display: none; }
  .detail-card { grid-template-columns: 1fr; margin-left: 14px; }
  .detail-col + .detail-col { border-left: 0; border-top: 1px solid var(--line-2); }
  /* En el movil los desplegables salen desde abajo, a todo el ancho. */
  .menu { position: fixed; left: 12px !important; right: 12px !important; top: auto; bottom: 12px; max-height: 60vh; transform-origin: bottom; transform: translateY(16px); }
  .toasts { left: 12px; right: 12px; max-width: none; align-items: stretch; }
}

/* Menos movimiento: nada se anima, todo se ve */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* Impresion: el informe, sin menus, botones, buscadores ni avisos */
@media print {
  .side, .topbar, .loadbar, .filters, .toolbar, .pager, .toasts, .modal, .tip, .btn, .help, .chev-td { display: none !important; }
  .app { display: block; background: none; }
  body, .panel { background: #fff; }
  .table { table-layout: auto; min-width: 0 !important; }
  .table td { white-space: normal; }
  .sticky-zone { position: static; }
}
