/* 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. */

:root {
  --ground:    #101822;
  --panel:     #17212E;
  --panel-hi:  #1D2A39;
  --rule:      #26364a;
  --quiet:     #1A2430;
  --ink:       #E4ECF2;
  --ink-mid:   #9DB0C4;
  --ink-low:   #64798F;

  --flow:      #3FBF9F;   /* recibido      */
  --low:       #E0A33E;   /* bajo vs base  */
  --gone:      #E2574C;   /* no llegó      */
  --hollow:    #8B7BD8;   /* vacío         */
  --stale:     #5AA9E6;   /* rezago de cierre — its own channel */

  --cell-w: 9px;
  --cell-h: 20px;
  --label-w: 236px;
}

* { 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: 1180px; margin: 0 auto; padding: 22px 20px 60px; }

/* ---------- header ---------- */
.masthead {
  display: flex; 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; }

.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 rgba(63,191,159,.55);
  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 rgba(63,191,159,.5); }
  70%  { box-shadow: 0 0 0 7px rgba(63,191,159,0); }
  100% { box-shadow: 0 0 0 0 rgba(63,191,159,0); }
}
@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); }
.signout:focus-visible { outline: 2px solid var(--flow); 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: rgba(255,255,255,.05); 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: 300px; 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 rgba(38,54,74,.4);
}
.lane:hover { background: rgba(255,255,255,.028); }

.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: rgba(255,255,255,.055); 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: 5px; 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: 5px; border-radius: 1px; }
.cell.today   { box-shadow: inset 0 0 0 1px rgba(228,236,242,.22); }

/* 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: rgba(90,169,230,.10); }
.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: #0A121B; border: 1px solid var(--rule);
  border-radius: 3px; padding: 9px 11px; min-width: 200px;
  box-shadow: 0 8px 24px rgba(0,0,0,.6);
  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: rgba(90,169,230,.14);
  border-bottom: 2px solid rgba(90,169,230,.45); 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: rgba(255,255,255,.05); 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: rgba(255,255,255,.05); padding: 1px 5px; border-radius: 2px; color: var(--ink-mid);
}

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