/* BI-DMS — visual direction carried over from mockup.html, with one addition:
   a staleness channel (--stale) that composes with the volume bar instead of
   competing with it for the cell's colour. */

/* El atributo `hidden` del HTML se apaga solo con la hoja del navegador, y
   cualquier regla de autor que declare `display` la gana: `.alerts` (una clase)
   ya le ganaba, y `#detail` en loyalty.css le ganaba por goleada — dejando un
   velo del 72 % pintado sobre toda la página, que además se comía los clics.
   `hidden` significa «esto no se muestra»; que no dependa del orden ni de la
   especificidad de quien venga después. */
[hidden] { display: none !important; }

:root {
  /* Latente's palettes (pereaf13/Latente, frontend/src/styles.css), the owner's choice of 2026-10-14: the two
     products read the same dealer from two viewpoints and are to meet in one picture of it, so they look alike.
     Dark is the house; light is data-theme="light" on <html> (shell.js). The names stay ASI's, so no page changes
     to follow; the values are Latente's. Red is a verdict or a brand moment, never identity; the identity is
     Iris; green, amber and red say a state against a threshold and nothing else. */
  color-scheme: dark;
  --ground:    #0e1014;   /* Latente --bg */
  --topbar:    #111319;
  --panel:     #151820;
  --panel-hi:  #181b22;   /* --panel-2 */
  --table-head: #1b1f28;
  --inset:     #12141a;
  --rule:      #2a2f3a;   /* --border */
  --quiet:     #232936;   /* --border-soft, the track of a bar */
  --ink:       #e6e8ee;
  --ink-strong: #f3f5f9;
  --ink-mid:   #aeb6c4;   /* --muted */
  --ink-low:   #8b93a2;   /* --muted-2 */
  --accent:    #818cf8;   /* Iris: identity, the active item, a title's rule */
  --accent-soft: #a5b1fc;
  --marca:     #bb0a30;   /* Audi red: brand moments only */
  --link:      #8fb4ff;
  --focus:     #6ea8ff;

  --flow:      #3fb27f;   /* recibido, ok      */
  --low:       #e0a83f;   /* bajo vs base      */
  --gone:      #d95757;   /* no llegó, malo    */
  --hollow:    #9d86e9;   /* vacío             */
  --stale:     #5b9bd5;   /* rezago de cierre — its own channel */

  --on-state:  #0e1014;   /* text on a button of a state colour */
  --on-accent: #ffffff;   /* text on Iris, in both themes */
  --on-series: #0e1014;   /* text on a chart's series 2 to 6, mid-tones in both themes: 5.7:1 or more */
  --on-series-1: #0e1014; /* text on series 1, Iris, which is light here and deep on paper */
  --popover:   #111319;   /* a tooltip */
  --scrim:     rgba(6, 8, 12, .62);
  --shadow:    rgba(0, 0, 0, .6);
  /* Chart series, none of them a state colour: Latente's brand tones, the same in both themes. */
  --series-1:  var(--accent);       /* Iris, darker on paper */
  --series-2:  #3d8bff;
  --series-3:  #2ec4b6;
  --series-4:  #9d86e9;
  --series-5:  #c89b6d;
  --series-6:  #8fa3c7;

  --cell-w: 9px;
  --bar-w: 5px;      /* escala con la celda: en pantalla ancha las barras
                        también crecen, no sólo el espacio entre ellas */
  --cell-h: 20px;
  --label-base: 236px;   /* piso; fitCells reparte lo que sobra */
  --label-w: 236px;

  /* Tope generoso en vez de 1180: en un monitor ancho, ese límite dejaba la
     mitad de la pantalla vacía mientras la rejilla se apretaba. La prosa sí
     queda acotada aparte — una línea de texto de 2000px no se lee. */
  --page-max: 2400px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --ground:    #f4f1ea;
  --topbar:    #fbf8f2;
  --panel:     #fffdf8;
  --panel-hi:  #faf7f0;
  --table-head: #efe9dd;
  --inset:     #f0ebe1;
  --rule:      #d9d1c1;
  --quiet:     #e6dfd1;
  --ink:       #2b2926;
  --ink-strong: #14120f;
  --ink-mid:   #5b544a;
  --ink-low:   #6e6659;
  --accent:    #4f46e5;
  --accent-soft: #4338ca;
  --marca:     #bb0a30;
  --link:      #2f62c4;
  --focus:     #2f7ad6;
  --flow:      #14714f;
  --low:       #8a5a11;
  --gone:      #ab3a30;
  --hollow:    #6b55c7;
  --stale:     #2a6496;
  --on-state:  #fffdf8;
  --on-series-1: #fffdf8; /* paper on the deep Iris: 6.2:1 */
  --popover:   #fffdf8;
  --scrim:     rgba(43, 41, 38, .34);
  --shadow:    rgba(43, 41, 38, .22);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: "IBM Plex Sans Condensed", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: var(--page-max); margin: 0 auto; padding: 22px 24px 60px; }

/* ---------- header ---------- */
.masthead {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 14px;
  padding-bottom: 12px; border-bottom: 1px solid var(--rule);
}
.masthead h1 {
  margin: 0; font-size: 19px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
}
.masthead .sub { font-size: 12.5px; color: var(--ink-low); letter-spacing: .02em; }
.masthead .spacer { flex: 1; }

.masthead h1.product-name, .gate h1.product-name {
  font-size: 25px; line-height: 1.15; letter-spacing: -.025em;
  text-transform: none; color: var(--ink);
  border-left: 3px solid var(--accent); padding-left: 12px;
}
.gate h1.product-name { font-size: 32px; }

.heartbeat {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px; color: var(--ink-mid);
  display: flex; align-items: center; gap: 7px;
}
.pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--flow);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--flow) 55%, transparent);
  animation: pulse 2.6s ease-out infinite;
}
.pulse.warn { background: var(--low); animation: none; }
.pulse.dead { background: var(--gone); animation: none; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--flow) 50%, transparent); }
  70%  { box-shadow: 0 0 0 7px color-mix(in srgb, var(--flow) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--flow) 0%, transparent); }
}
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

.signout {
  background: none; border: 1px solid var(--rule); border-radius: 2px;
  color: var(--ink-low); cursor: pointer; margin-left: 8px;
  font-family: "IBM Plex Mono", monospace; font-size: 10px;
  letter-spacing: .08em; padding: 3px 7px;
  text-decoration: none; line-height: normal;
}
.signout:hover { color: var(--ink-mid); border-color: var(--ink-low); }
.masthead a.signout[aria-current="page"] { color: var(--ink); border-color: var(--accent); }
.masthead .sub a { color: var(--ink-mid); }
/* shell.js draws the menu and the two switches; they flow in the masthead's row as the links did. */
.shell-nav { display: contents; }
.shell-toggles { display: inline-flex; gap: 6px; align-items: center; margin-left: 10px; align-self: center; }
/* Latente's pill: the language and the theme are the same kind of control, so they share it. */
.langtoggle { display: inline-flex; border: 1px solid var(--rule); border-radius: 7px; overflow: hidden; flex: none; }
.langtoggle button {
  background: transparent; border: none; color: var(--ink-mid); font: 700 10.5px "IBM Plex Mono", monospace;
  letter-spacing: .04em; padding: 3px 7px; cursor: pointer; line-height: 1.4;
}
.langtoggle button.on { background: var(--accent); color: var(--on-accent); }
.langtoggle button:not(.on):hover { color: var(--ink); background: var(--panel-hi); }
.langtoggle button:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.themetoggle button { min-width: 26px; font-size: 12px; line-height: 1.2; }
[data-shell="gate"] { position: fixed; top: 14px; right: 16px; display: flex; }
.who {
  font-family: "IBM Plex Mono", monospace; font-size: 10.5px;
  color: var(--ink-low); margin-left: 14px;
}
.signout:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

/* ---------- ingest warnings (§5.4) ---------- */
.alerts { margin-top: 12px; display: flex; flex-direction: column; gap: 5px; }
.alert {
  display: flex; align-items: baseline; gap: 10px;
  background: var(--panel); border: 1px solid var(--rule);
  border-left: 2px solid var(--low);
  border-radius: 2px; padding: 8px 12px; font-size: 12px; color: var(--ink-mid);
}
.alert.hard { border-left-color: var(--gone); }
.alert code {
  font-family: "IBM Plex Mono", monospace; font-size: 10px;
  color: var(--ink-low); letter-spacing: .04em; flex: none;
}

/* ---------- file type tabs ---------- */
.files { display: flex; gap: 2px; margin: 16px 0 0; flex-wrap: wrap; }
.file-tab {
  background: var(--panel); border: 1px solid var(--rule); border-bottom: none;
  color: var(--ink-low); cursor: pointer;
  padding: 9px 14px 8px; font-family: inherit; font-size: 12.5px;
  letter-spacing: .03em; display: flex; align-items: center; gap: 9px;
  border-radius: 3px 3px 0 0;
}
.file-tab:hover { color: var(--ink-mid); background: var(--panel-hi); }
.file-tab[aria-selected="true"] {
  background: var(--panel-hi); color: var(--ink); border-color: var(--rule);
  box-shadow: inset 0 2px 0 0 var(--flow);
}
.file-tab:focus-visible { outline: 2px solid var(--flow); outline-offset: -2px; }
.file-tab .kind {
  font-family: "IBM Plex Mono", monospace; font-size: 9px;
  letter-spacing: .1em; padding: 2px 4px; border-radius: 2px;
  background: color-mix(in srgb, var(--ink) 5%, transparent); color: var(--ink-low);
}
.file-tab .alarm {
  font-family: "IBM Plex Mono", monospace; font-size: 10.5px;
  color: var(--gone); font-weight: 600;
}

/* ---------- summary ---------- */
.board {
  background: var(--panel-hi); border: 1px solid var(--rule);
  border-radius: 0 3px 3px 3px; padding: 16px 18px;
}
.readout { display: flex; gap: 26px; flex-wrap: wrap; align-items: flex-end; }
.stat .n {
  font-family: "IBM Plex Mono", monospace;
  font-size: 25px; font-weight: 500; line-height: 1; letter-spacing: -.02em;
}
.stat .l {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--ink-low); margin-top: 5px;
}
.stat.ok .n     { color: var(--flow); }
.stat.low .n    { color: var(--low); }
.stat.gone .n   { color: var(--gone); }
.stat.hollow .n { color: var(--hollow); }
.stat.stale .n  { color: var(--stale); }
.stat.mute .n   { color: var(--ink-mid); }

.note {
  margin-left: auto; max-width: 340px; font-size: 11.5px;
  color: var(--ink-low); line-height: 1.5; text-align: right;
}

/* ---------- controls ---------- */
.controls {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin: 16px 0 6px; padding-top: 14px; border-top: 1px solid var(--rule);
}
.controls label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-low);
}
select, input[type="search"] {
  background: var(--ground); color: var(--ink);
  border: 1px solid var(--rule); border-radius: 2px;
  font-family: "IBM Plex Mono", monospace; font-size: 11.5px;
  padding: 6px 8px;
}
select:focus-visible, input:focus-visible { outline: 2px solid var(--flow); outline-offset: 1px; }
input[type="search"] { width: 150px; }

/* ---------- lane grid ---------- */
.grid-head {
  display: flex; align-items: flex-end;
  margin-top: 14px; padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
}
.grid-head .lead {
  width: var(--label-w); flex: none;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-low);
}
.ruler { position: relative; height: 15px; flex: 1; }
.ruler span {
  position: absolute; bottom: 0;
  font-family: "IBM Plex Mono", monospace; font-size: 9.5px;
  color: var(--ink-low); white-space: nowrap; transform: translateX(-1px);
}

.lanes { max-height: 560px; overflow-y: auto; overflow-x: auto; }
.lanes::-webkit-scrollbar { width: 9px; height: 9px; }
.lanes::-webkit-scrollbar-track { background: var(--panel); }
.lanes::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 5px; }

.lane {
  display: flex; align-items: center;
  height: 24px; border-bottom: 1px solid color-mix(in srgb, var(--rule) 40%, transparent);
}
.lane:hover { background: color-mix(in srgb, var(--ink) 2.8%, transparent); }

.lane .id {
  width: var(--label-w); flex: none; display: flex; align-items: baseline;
  gap: 7px; padding-right: 10px;
}
.lane .nm {
  font-size: 12.5px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lane .mk {
  font-family: "IBM Plex Mono", monospace; font-size: 8.5px;
  letter-spacing: .08em; padding: 1px 4px; border-radius: 2px; flex: none;
  background: color-mix(in srgb, var(--ink) 5.5%, transparent); color: var(--ink-low);
}
.lane .strip { display: flex; align-items: flex-end; height: var(--cell-h); }

.cell {
  width: var(--cell-w); height: var(--cell-h);
  display: flex; align-items: flex-end; justify-content: center;
  position: relative; flex: none;
}
.cell.wk { margin-left: 3px; }
.cell i { display: block; width: var(--bar-w); border-radius: 1px 1px 0 0; }
.cell.notexp::after {
  content: ""; position: absolute; bottom: 0; left: 2px; right: 2px;
  height: 1px; background: var(--quiet);
}
.cell.gone i  { background: var(--gone); width: var(--bar-w); border-radius: 1px; }
.cell.today   { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 22%, transparent); }

/* A day nobody reported.  The tint runs the full height of every lane, so it
   reads as one vertical event across the network — which is what it is —
   instead of as one red failure per dealer. */
.cell.net { background: color-mix(in srgb, var(--stale) 10%, transparent); }
.cell.net::after {
  content: ""; position: absolute; bottom: 0; left: 2px; right: 2px;
  height: 2px; background: var(--stale); opacity: .45; border-radius: 1px;
}
.cell.net.has::after { display: none; }   /* the few that did arrive keep their bar */

/* Staleness rides on top of the cell rather than replacing its colour, so a
   healthy-volume-but-stale day reads as both at once — which is the exact case
   §3.1 of the spec says is invisible on every other axis. */
.cell u.lag {
  position: absolute; top: 0; left: 2px; right: 2px; height: 2px;
  background: var(--stale); border-radius: 1px;
}
.cell u.lag.unknown { background: var(--ink-low); opacity: .55; }

/* ---------- tooltip ---------- */
#tip {
  position: fixed; z-index: 40; pointer-events: none; opacity: 0;
  transition: opacity .09s;
  background: var(--popover); border: 1px solid var(--rule);
  border-radius: 3px; padding: 9px 11px; min-width: 200px;
  box-shadow: 0 8px 24px var(--shadow);
  font-family: "IBM Plex Mono", monospace; font-size: 11px; line-height: 1.65;
}
#tip .t-nm { font-family: "IBM Plex Sans Condensed", sans-serif; font-size: 12.5px; color: var(--ink); margin-bottom: 3px; }
#tip .t-dt { color: var(--ink-low); font-size: 10px; letter-spacing: .04em; margin-bottom: 6px; }
#tip .t-row { display: flex; justify-content: space-between; gap: 18px; color: var(--ink-mid); }
#tip .t-row b { font-weight: 500; color: var(--ink); }
#tip .t-flag { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--rule); font-size: 10.5px; }

/* ---------- legend ---------- */
.legend {
  display: flex; gap: 18px; flex-wrap: wrap;
  margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--rule);
  font-size: 11px; color: var(--ink-low);
}
.legend div { display: flex; align-items: center; gap: 6px; }
.sw { width: 5px; height: 13px; border-radius: 1px; flex: none; }
.sw.h6 { height: 6px; }
.sw.dash { height: 5px; border-radius: 1px; }
.sw.none { height: 1px; background: var(--quiet); width: 9px; }
.sw.net {
  width: 9px; height: 13px; background: color-mix(in srgb, var(--stale) 14%, transparent);
  border-bottom: 2px solid color-mix(in srgb, var(--stale) 45%, transparent); border-radius: 0;
}
.sw.notch { height: 2px; width: 9px; background: var(--stale); }

.foot {
  margin-top: 20px; font-size: 11.5px; color: var(--ink-low);
  line-height: 1.65; max-width: 720px;
}
.foot p { margin: 0 0 9px; }
.foot em { font-style: normal; color: var(--ink-mid); }
.foot b { font-weight: 500; color: var(--ink-mid); }
.foot .tune { color: var(--ink-low); opacity: .8; }
.foot code {
  font-family: "IBM Plex Mono", monospace; font-size: 10.5px;
  background: color-mix(in srgb, var(--ink) 5%, transparent); padding: 1px 4px; border-radius: 2px; color: var(--ink-mid);
}

.blank {
  padding: 40px 4px; color: var(--ink-low); font-size: 12.5px; line-height: 1.7;
}
.blank code {
  font-family: "IBM Plex Mono", monospace; font-size: 11px;
  background: color-mix(in srgb, var(--ink) 5%, transparent); padding: 1px 5px; border-radius: 2px; color: var(--ink-mid);
}

@media (max-width: 780px) {
  :root { --label-base: 130px; --label-w: 130px; --cell-w: 7px; }
  .note { display: none; }
}

/* ---------- lane is clickable ---------- */
.lane { cursor: pointer; }
.lane:focus-visible { outline: 2px solid var(--flow); outline-offset: -2px; }
.lane .mk.crit { background: color-mix(in srgb, var(--gone) 16%, transparent); color: var(--gone); }

/* ---------- detail ---------- */
body.modal { overflow: hidden; }
#detail {
  position: fixed; inset: 0; z-index: 60; overflow-y: auto;
  background: var(--scrim); backdrop-filter: blur(2px);
  padding: 5vh 20px 60px;
}
.dt-body {
  max-width: 980px; margin: 0 auto; background: var(--panel-hi);
  border: 1px solid var(--rule); border-radius: 4px; padding: 20px 22px 24px;
  box-shadow: 0 18px 60px var(--shadow);
}
.dt-head { display: flex; align-items: flex-start; gap: 14px; }
.dt-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.dt-meta {
  margin: 5px 0 0; font-family: "IBM Plex Mono", monospace;
  font-size: 11px; color: var(--ink-low);
}
.dt-close {
  margin-left: auto; background: none; border: 1px solid var(--rule);
  color: var(--ink-mid); border-radius: 2px; cursor: pointer;
  font-size: 13px; padding: 4px 10px; flex: none;
}
.dt-close:hover { border-color: var(--ink-low); color: var(--ink); }

.dt-stats {
  display: flex; gap: 26px; flex-wrap: wrap;
  margin: 18px 0 4px; padding: 14px 0; border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.dt-stats div { display: flex; flex-direction: column; gap: 4px; }
.dt-stats b {
  font-family: "IBM Plex Mono", monospace; font-size: 17px;
  font-weight: 500; color: var(--ink);
}
.dt-stats span {
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-low);
}

.dt-strip-wrap { margin: 18px 0 6px; overflow-x: auto; }
.dt-strip { display: flex; align-items: flex-end; height: 46px; }
.dt-strip .cell { height: 46px; }
.dt-strip .cell i { width: 3px; }
.dt-axis {
  display: flex; justify-content: space-between; margin-top: 5px;
  font-family: "IBM Plex Mono", monospace; font-size: 10px; color: var(--ink-low);
}

.dt-table { width: 100%; border-collapse: collapse; margin-top: 16px; }
.dt-table th {
  text-align: left; font-size: 9.5px; text-transform: uppercase;
  letter-spacing: .1em; color: var(--ink-low); font-weight: 600;
  padding: 0 10px 7px 0; border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; background: var(--panel-hi);
}
.dt-table td {
  padding: 5px 10px 5px 0; font-size: 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--rule) 35%, transparent);
}
.dt-table .num, .dt-table th.num { text-align: right; }
.dt-table .st { color: var(--ink-mid); font-size: 11.5px; }
.dt-table tr.r-gone   .st { color: var(--gone); }
.dt-table tr.r-hollow .st { color: var(--hollow); }
.dt-table tr.r-low    .st { color: var(--low); }
.dt-table tr.r-net    .st { color: var(--stale); }
.dt-table tr.r-notexp td { opacity: .55; }
.dt-foot { margin: 12px 0 0; font-size: 11px; color: var(--ink-low); }

/* ---------- detail chart ---------- */
.dt-tools {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 18px 0 6px; padding-top: 14px; border-top: 1px solid var(--rule);
}
.dt-tools .spacer { flex: 1; }
.dt-tools .mono {
  font-family: "IBM Plex Mono", monospace; font-size: 11.5px; color: var(--ink-mid);
}
.dt-hint { font-size: 11px; color: var(--ink-low); }
.dt-tools button { padding: 3px 9px; }

.dt-readout {
  min-height: 19px; font-size: 12px; color: var(--ink-mid);
  display: flex; gap: 16px; flex-wrap: wrap; align-items: baseline;
  margin: 2px 0 4px; font-family: "IBM Plex Mono", monospace;
}
.dt-readout b { color: var(--ink); font-weight: 500; }
.dt-readout .d { color: var(--ink-low); }
.dt-readout .s { color: var(--ink-mid); font-family: "IBM Plex Sans Condensed", sans-serif; }

.dt-chart-wrap {
  width: 100%; overflow: hidden; cursor: grab; touch-action: none;
  user-select: none; border-radius: 3px; background: rgba(0,0,0,.14);
}
.dt-chart-wrap.dragging { cursor: grabbing; }
.dt-chart-wrap svg { display: block; }
.dt-chart-wrap text.ax {
  font-family: "IBM Plex Mono", monospace; font-size: 9.5px; fill: var(--ink-low);
}
.dt-chart-wrap text.lbl { font-size: 9px; letter-spacing: .1em; text-transform: uppercase; }
.dt-chart-wrap rect.b:hover { fill-opacity: .75; }

.dt-legend {
  display: flex; gap: 16px; flex-wrap: wrap; margin: 10px 0 0;
  font-size: 11px; color: var(--ink-low);
}
.dt-legend span { display: flex; align-items: center; gap: 6px; }
.dt-legend .sw { width: 9px; height: 9px; border-radius: 1px; display: inline-block; }
.dt-legend .ghost-sw { border: 1px dashed var(--ink-low); background: none; }
