:root {
  color-scheme: light;
  /* ------------------------------------------------------------------------
     RONDA A — visual depth restyle (2026-07-18). Same B43 palette, new depth
     system: every new tone below is DERIVED from the existing family
     (accent #3b6ff5 · ink #1b2430 · ground #f2f4f8) via color-mix /
     transparency / lighter-darker steps. No flat solid fills on cards: cards
     carry a 145° near-white gradient, a layered shadow pair and an optional
     ambient corner glow (blurred radial blob, opacity ≤ .18) keyed by state.

     COMPUTED CONTRAST (WCAG 2.1, sRGB relative luminance):
       ink      #1b2430 on --surface  #fbfcfe  → 15.2:1  AAA
       ink      #1b2430 on #ffffff             → 15.7:1  AAA
       muted    #5c6b84 on --surface  #fbfcfe  →  5.2:1  AA   (floor kept)
       muted    #5c6b84 on #ffffff             →  5.3:1  AA
       muted    #5c6b84 on --surface-hover #f5f8fe → 5.0:1 AA
       accent-ink #2a55c9 on accent-soft #dce7ff → 5.2:1 AA
       #ffffff  on accent-strong #2e5fe0        →  5.5:1  AA
       ok-ink   #166a4a on ok tint (≈#e9f8f2)   →  6.1:1  AA
       warn-ink #8a5a00 on warn tint (≈#fdf1e0) →  5.4:1  AA
       alarm-ink #b3261e on alarm tint (≈#fce9ea) → 5.6:1 AA
     No text color was lightened anywhere; only backgrounds moved, and every
     text/background pairing stays ≥ 4.9:1 (muted) / ≥ 5.2:1 (semantic inks).
  ------------------------------------------------------------------------ */
  --brand-red: #c8102e;

  /* Legacy names (kept — the whole page rides them) mapped onto the new set. */
  --background: #eef1f7;                 /* ground, one step deeper so cards float */
  --ground: var(--background);
  --surface: #fbfcfe;                    /* card body: cool near-white */
  --surface-elevated: #ffffff;           /* card highlight edge / active menu item */
  --surface-hover: color-mix(in srgb, var(--accent) 5%, #ffffff);
  --border: #dbe1ed;                     /* one step deeper than the old #e1e6ef */
  --line: var(--border);
  --ink: #1b2430;
  --muted: #5c6b84;
  --text-primary: var(--ink);
  --text-secondary: var(--muted);
  --accent: #3b6ff5;
  --accent-strong: #2e5fe0;
  --accent-ink: #2a55c9;
  --accent-soft: #dce7ff;
  --ok: #34c08b;
  --ok-ink: #166a4a;
  --warn: #f5a623;
  --warn-ink: #8a5a00;
  --alarm: #e5484d;
  --alarm-ink: #b3261e;
  --success: var(--ok);
  --warning: var(--warn);
  --danger: var(--alarm);
  --info: var(--accent);
  --text: var(--ink);
  --focus: var(--accent);

  /* Depth: layered shadows (ambient sheet + soft drop) on the ink hue. */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 30px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 2px 4px rgba(15, 23, 42, 0.05), 0 18px 44px rgba(15, 23, 42, 0.10);
  --card-shadow: var(--shadow-md);

  /* Radii scale; the legacy --card-radius rides the large step. */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --card-radius: var(--radius-lg);

  /* Ambient glow palette: full-strength derived hues; the card ::after blob
     applies blur(45px) + opacity ≤ .18, so the color NEVER reads as a fill.
     The violet is derived (accent 55% + alarm 45%), not a new pigment. */
  --glow-accent: color-mix(in srgb, var(--accent) 80%, #ffffff);
  --glow-success: color-mix(in srgb, var(--ok) 80%, #ffffff);
  --glow-warning: color-mix(in srgb, var(--warn) 85%, #ffffff);
  --glow-danger: color-mix(in srgb, var(--alarm) 78%, #ffffff);
  --glow-info: color-mix(in srgb, var(--accent) 55%, var(--alarm));
  --glow-violet: var(--glow-info);

  /* Aliases so the shipped dashboard SVG builders (var(--rule)/var(--dim)) and the published
     portal link resolve on this page too — same palette, second name, no new colors. */
  --rule: var(--line);
  --dim: var(--muted);
  /* Workbench lanes (lateral-menu round): menu | hero | dock. Pin/peel collapse these. */
  --sidebar-width: 13.5rem;
  --menu-w: var(--sidebar-width);
  --dock-w: 24rem;
  /* Micro-interaction contract (Ronda A): one shared duration, 150–250 ms band. */
  --t-fast: 0.18s;
  /* ------------------------------------------------------------------------
     RONDA B — responsive contract (2026-07-18): fluid spacing/type tokens.
     Clamp bands are RE-ANCHORED to the Ronda A densities (the approved compact
     desktop look is the ceiling); they breathe down, never inflate the ship.
  ------------------------------------------------------------------------ */
  --page-padding: clamp(10px, 8px + 0.5vw, 20px);
  --section-gap: clamp(10px, 8px + 0.4vw, 16px);
  --card-padding: clamp(11px, 9px + 0.35vw, 17px);
  --grid-gap: clamp(10px, 8px + 0.35vw, 15px);
  --header-height: 3.4rem;
  /* B43 type_ui token; matches dashboard.html + portal (the viewer was the one page on Inter). */
  font-family: "IBM Plex Sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Ronda B global guards: no grid/flex child may force its track wider than the
   viewport, no replaced element may overflow its box, and the document NEVER
   scrolls horizontally — overflow is a per-container, affordanced decision. */
* { box-sizing: border-box; min-width: 0; }
img, svg, canvas, video { max-width: 100%; }

html, body { height: 100%; overflow-x: clip; }

body {
  margin: 0;
  overflow: hidden;
  color: var(--text-primary);
  background:
    radial-gradient(60rem 30rem at 85% -10%, color-mix(in srgb, var(--accent) 6%, transparent), transparent 60%),
    var(--background);
}

button, input, select { font: inherit; }

button {
  min-height: 2.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: linear-gradient(180deg, var(--surface-elevated), color-mix(in srgb, var(--surface) 92%, var(--border)));
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: background-color var(--t-fast) ease, border-color var(--t-fast) ease,
    color var(--t-fast) ease, box-shadow var(--t-fast) ease, transform var(--t-fast) ease;
}

button:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); background: var(--surface-hover); }
button[aria-pressed="true"] { border-color: var(--accent); background: linear-gradient(180deg, color-mix(in srgb, var(--accent-soft) 70%, #ffffff), var(--accent-soft)); color: var(--accent-ink); font-weight: 600; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.num { font-variant-numeric: tabular-nums; }

.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 40;
  padding: 0.65rem 0.85rem;
  color: #ffffff;
  background: var(--accent-strong);
  border-radius: var(--radius-sm);
  transform: translateY(-160%);
}

.skip-link:focus { transform: translateY(0); }

/* Lateral-menu round (2026-07-16): the shell is a split workbench — header row, then three
   lanes [menu | hero pane | content dock]. The menu pin trades width with the HERO only; the
   dock keeps its reserved lane until the operator peels it (A-graft). */
.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: var(--section-gap);
  height: 100%;
  width: 100%;
  max-width: 1920px;
  margin-inline: auto;
  padding: var(--page-padding);
}

.work {
  display: grid;
  grid-template-columns: var(--menu-w) minmax(0, 1fr) var(--dock-w);
  gap: var(--section-gap);
  min-height: 0;
}

.app-shell[data-menu="collapsed"] .work { --menu-w: 4rem; }
.app-shell[data-dock="peeled"] .work { --dock-w: 3.4rem; }

/* Slim header (Ronda A): tighter bar, breadcrumb/eyebrow + title left, live status right. */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  min-height: 3.4rem;
  padding: 0.5rem 1.05rem;
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, var(--surface-elevated), var(--surface));
  box-shadow: var(--shadow-sm);
}

.app-header h1 { margin: 0.08rem 0 0; font-size: clamp(0.98rem, 1.5vw, 1.18rem); color: var(--ink); letter-spacing: -0.01em; }
.eyebrow { margin: 0; color: var(--accent-ink); font-size: 0.62rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; }

.system-summary { display: flex; align-items: center; gap: 0.55rem; color: var(--muted); font-size: 0.8rem; }
/* Integration point 2 (cartelera dashboard): the jump into the operator board. */
/* Back to the projects portal. Only rendered in the published build (the portal is its parent);
   quieter than .cartelera-link so the primary action stays the primary action. */
.portal-link { color: var(--dim); text-decoration: none; border: 1px solid var(--rule); padding: 0.3rem 0.7rem; font-size: 0.78rem; font-weight: 600; white-space: nowrap; border-radius: var(--radius-sm); transition: border-color var(--t-fast) ease, color var(--t-fast) ease; }
.portal-link:hover, .portal-link:focus-visible { border-color: var(--accent-strong); color: var(--ink); }
.cartelera-link {
  color: #ffffff;
  text-decoration: none;
  border: 1px solid var(--accent-strong);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 90%, #ffffff), var(--accent-strong));
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  border-radius: var(--radius-sm);
  transition: background-color var(--t-fast) ease, border-color var(--t-fast) ease, box-shadow var(--t-fast) ease;
}
.cartelera-link:hover, .cartelera-link:focus-visible { border-color: var(--accent-ink); background: var(--accent-ink); }
.status-dot { width: 0.58rem; height: 0.58rem; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 14%, transparent); }
html[data-app-ready="true"] .status-dot { color: var(--ok); background: currentColor; }
html[data-app-error="true"] .status-dot { color: var(--alarm-ink); background: currentColor; }

/* The phone drawer trigger: hidden on every tier that renders the menu as a lane. */
.menu-drawer { display: none; padding: 0.3rem 0.65rem; font-size: 0.78rem; white-space: nowrap; }

/* ---------------------------------------------------------------------------
   MENU (left lane). Ronda A: compact rail — tighter items, elevated active
   surface with a left accent bar, grouped taxonomy, connectivity chip bottom.
--------------------------------------------------------------------------- */
.menu {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0.6rem 0.5rem 0.55rem;
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  border-radius: var(--card-radius);
  background: linear-gradient(180deg, var(--surface-elevated) 0%, color-mix(in srgb, var(--surface) 94%, var(--accent-soft)) 100%);
  box-shadow: var(--shadow-md);
}

/* Brand block (client round 5): the real Cinemex logo as a rounded chip above the pin. The
   logo carries its own red field, so it rounds into a chip that sits on the light sidebar. */
.brand { display: flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0.5rem 0.55rem; border-bottom: 1px solid color-mix(in srgb, var(--border) 65%, transparent); margin-bottom: 0.35rem; }
.brand-logo { flex: none; height: 2.6rem; width: auto; max-width: 100%; border-radius: 9px; display: block; }
.app-shell[data-menu="collapsed"] .brand { justify-content: center; padding-inline: 0; }

.pin-button { display: flex; align-items: center; gap: 0.5rem; min-height: 1.8rem; padding: 0.24rem 0.5rem; font-size: 0.7rem; color: var(--muted); box-shadow: none; background: none; border-color: transparent; }
.pin-button:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.menu .pin-button { margin: 0 0.25rem 0.4rem; }
.menu nav { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.menu-group { margin: 0.6rem 0.5rem 0.22rem; color: var(--muted); font-size: 0.6rem; font-weight: 800; letter-spacing: 0.13em; text-transform: uppercase; }
.menu nav ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.1rem; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  min-height: 2rem;
  padding: 0.26rem 0.55rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  box-shadow: none;
  color: var(--ink);
  font-size: 0.78rem;
  text-align: left;
  white-space: nowrap;
  transition: background-color var(--t-fast) ease, border-color var(--t-fast) ease,
    color var(--t-fast) ease, box-shadow var(--t-fast) ease;
}
.nav-item svg { flex: none; color: var(--muted); transition: color var(--t-fast) ease; }
.nav-item:hover { border-color: transparent; background: color-mix(in srgb, var(--accent) 7%, transparent); }
/* Active section = ELEVATED surface: white card + soft shadow + left accent bar. */
.nav-item[aria-current="page"] {
  background: var(--surface-elevated);
  color: var(--accent-ink);
  font-weight: 600;
  border-color: color-mix(in srgb, var(--border) 70%, transparent);
  box-shadow: inset 3px 0 0 0 var(--accent), var(--shadow-sm);
}
.nav-item[aria-current="page"] svg { color: var(--accent-ink); }
.nav-badge { margin-left: auto; padding: 0.05rem 0.4rem; border-radius: 0.45rem; background: color-mix(in srgb, var(--warn) 16%, #ffffff); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); color: var(--warn-ink); font-size: 0.66rem; font-weight: 700; }
/* Connectivity status (truthful line restyled as a compact chip with a live dot). */
.menu-foot {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.5rem 0.25rem 0;
  padding: 0.32rem 0.55rem;
  border: 1px solid color-mix(in srgb, var(--ok) 28%, transparent);
  border-radius: 999px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--ok) 10%, #ffffff), color-mix(in srgb, var(--ok) 4%, #ffffff));
  color: var(--ok-ink);
  font-size: 0.62rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.menu-foot::before {
  content: "";
  flex: none;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent);
}

.app-shell[data-menu="collapsed"] .nav-text,
.app-shell[data-menu="collapsed"] .nav-badge,
.app-shell[data-menu="collapsed"] .menu-group,
.app-shell[data-menu="collapsed"] .menu .pin-text,
.app-shell[data-menu="collapsed"] .menu-foot { display: none; }
.app-shell[data-menu="collapsed"] .nav-item,
.app-shell[data-menu="collapsed"] .menu .pin-button { justify-content: center; }

.menu-scrim { display: none; }

/* ---------------------------------------------------------------------------
   HERO PANE (center lane): the viewer. The Vista deck died in the client round 3
   (2026-07-18): the camera select is a compact overlay ON the canvas now.
--------------------------------------------------------------------------- */
.heropane { display: grid; grid-template-rows: minmax(0, 1fr); min-width: 0; min-height: 0; }

.viewer { position: relative; min-width: 0; min-height: 0; overflow: hidden; border: 1px solid color-mix(in srgb, var(--border) 80%, transparent); border-radius: var(--card-radius); background: #e6eaf2; box-shadow: var(--shadow-md); }
.viewer canvas { display: block; width: 100%; height: 100%; }
.viewer-placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }
html[data-app-ready="true"] .viewer-placeholder { display: none; }
.viewer-badge { position: absolute; right: 0.75rem; bottom: 0.75rem; padding: 0.34rem 0.55rem; border: 1px solid color-mix(in srgb, var(--border) 80%, transparent); border-radius: var(--radius-sm); color: var(--muted); background: color-mix(in srgb, #ffffff 86%, transparent); backdrop-filter: blur(8px); font-size: 0.7rem; }

/* Correction item B (still binding) — the surviving essentials float over the canvas.
   Ronda A: frosted surface so the panel keeps legibility over any 3D backdrop. */
.selection-card {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 4;
  width: min(19rem, calc(100% - 1.5rem));
  padding: 0.75rem 0.9rem;
  border: 1px solid color-mix(in srgb, var(--border) 85%, transparent);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, #ffffff 88%, transparent);
  backdrop-filter: blur(10px) saturate(1.15);
  box-shadow: var(--shadow-md);
  font-size: 0.8rem;
  line-height: 1.45;
}
.selection-card h2 { margin: 0 0 0.4rem; font-size: 0.82rem; color: var(--ink); }
.selection-card p { margin: 0; color: var(--ink); }
.selection-path { margin: 0.45rem 0 0; padding: 0; list-style: none; }
.selection-path li { display: flex; justify-content: space-between; gap: 0.5rem; padding: 0.16rem 0; border-top: 1px dashed var(--line); font-size: 0.72rem; }
.selection-path span { color: var(--muted); }
.selection-cartelera { display: inline-block; margin-top: 0.55rem; padding: 0.28rem 0.6rem; border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); border-radius: var(--radius-sm); color: var(--accent-ink); background: linear-gradient(180deg, color-mix(in srgb, var(--accent-soft) 60%, #ffffff), var(--accent-soft)); font-size: 0.75rem; font-weight: 600; text-decoration: none; white-space: nowrap; transition: border-color var(--t-fast) ease; }
.selection-cartelera:hover, .selection-cartelera:focus-visible { border-color: var(--accent-strong); }

.fatal-panel { position: absolute; inset: 50% auto auto 50%; z-index: 5; width: min(30rem, calc(100% - 2rem)); padding: 1.2rem; border: 1px solid var(--alarm); border-radius: var(--card-radius); background: var(--surface-elevated); transform: translate(-50%, -50%); box-shadow: var(--shadow-lg); }
.fatal-panel[hidden] { display: none; }
.fatal-panel h2 { margin-top: 0; color: var(--alarm-ink); }
.fatal-panel p { color: var(--ink); line-height: 1.5; }

/* ---------------------------------------------------------------------------
   CONTENT DOCK (right lane): reserved, own scroll; peels to a labeled rail.
--------------------------------------------------------------------------- */
.dock { display: flex; flex-direction: column; min-height: 0; gap: 0.6rem; }
.dock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.5rem 0.85rem;
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, var(--surface-elevated), var(--surface));
  box-shadow: var(--shadow-sm);
}
.dock-heading { min-width: 0; }
.dock-head h2 { margin: 0; font-size: 0.92rem; }
.dock-head span { display: block; color: var(--muted); font-size: 0.68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-head .pin-button { flex: none; }

/* Peeled: the lane narrows to a rail carrying one labeled reopen affordance. */
.dock-reopen {
  display: none;
  flex: 1;
  min-height: 0;
  writing-mode: vertical-rl;
  padding: 0.9rem 0.45rem;
  border-radius: var(--card-radius);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  box-shadow: var(--shadow-md);
}
.app-shell[data-dock="peeled"] .dock-head,
.app-shell[data-dock="peeled"] .dock-scroll { display: none; }
.app-shell[data-dock="peeled"] .dock-reopen { display: block; }

.dock-scroll { min-height: 0; flex: 1; overflow-y: auto; display: grid; gap: 0.6rem; align-content: start; }
.dock-content { display: grid; gap: 0.6rem; align-content: start; min-width: 0; }

/* ---------------------------------------------------------------------------
   FULL-PAGE SECTIONS (client direction, mirrored from the DHL sibling): every
   section except Tablero hides the hero pane AND the dock lane and owns the
   whole content area beside the menu. A slim breadcrumb header ("Inicio /
   Sección") replaces the dock's old sticky jump-back.
--------------------------------------------------------------------------- */
.page { display: none; }
.app-shell[data-view="page"] .heropane,
.app-shell[data-view="page"] .dock { display: none; }
.app-shell[data-view="page"] .work { grid-template-columns: var(--menu-w) minmax(0, 1fr); }
.app-shell[data-view="page"] .page {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-width: 0;
  min-height: 0;
}
.page-head {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  flex-wrap: wrap;
  padding: 0.5rem 0.85rem;
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, var(--surface-elevated), var(--surface));
  box-shadow: var(--shadow-sm);
}
.page-crumb {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
/* The active section reads as a breadcrumb CHIP, not plain text. */
.page-crumb span {
  color: var(--accent-ink);
  font-weight: 600;
  padding: 0.08rem 0.5rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 24%, transparent);
  background: color-mix(in srgb, var(--accent) 8%, #ffffff);
}
.page-sub { color: var(--muted); font-size: 0.72rem; }
.page-scroll { flex: 1; min-height: 0; overflow-y: auto; }

/* Full-width content grid: cards flow into columns; KPI rows, the category strip, the
   Tendencias grid and explicitly marked cards (.page-span) span every column. */
.page-content {
  display: grid;
  gap: var(--grid-gap);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 21rem), 1fr));
  align-content: start;
  min-width: 0;
}
.page-content > .kpi-row,
.page-content > .cat-row,
.page-content > .trend-group,
.page-content > .page-span { grid-column: 1 / -1; }

/* Tendencias on the full page: per-category groups (Temperaturas / Energía), each a card grid. */
.trend-group { display: grid; gap: 0.55rem; }
.trend-group-head { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.page .trend-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 16.5rem), 1fr)); align-content: start; }

/* Horarios on the full page: a real weekly grid (7 day columns). The wrapper scrolls
   inside the card on narrow tiers — the document never scrolls horizontally. */
.week-scroll { overflow-x: auto; }
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(8.5rem, 1fr)); gap: 0.55rem; }
.week-day {
  display: grid;
  gap: 0.4rem;
  align-content: start;
  padding: 0.5rem;
  border: 1px solid color-mix(in srgb, var(--border) 85%, transparent);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--surface-elevated), color-mix(in srgb, var(--surface) 96%, var(--border)));
  min-width: 0;
}
.week-day-head { margin: 0; color: var(--muted); font-size: 0.64rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.week-slot {
  display: grid;
  gap: 0.14rem;
  padding: 0.38rem 0.5rem;
  border-radius: 0.45rem;
  border: 1px solid color-mix(in srgb, var(--accent) 16%, transparent);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent-soft) 55%, #ffffff), var(--accent-soft));
  font-size: 0.72rem;
}
.week-slot b { color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.week-equip { color: var(--ink); font-weight: 600; }

/* Sparkline hover tooltip (Tendencias): compact hora relativa + valor on the B43 white card. */
.spark-tip {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: var(--surface-elevated);
  box-shadow: var(--shadow-md);
  color: var(--ink);
  font-size: 0.7rem;
  white-space: nowrap;
}
.spark-tip[hidden] { display: none; }

/* ---------------------------------------------------------------------------
   CARD SYSTEM (Ronda A). One base anatomy, four temperaments:
     · KPI cards        — compact, ambient glow ON, hover lift.
     · Content cards    — wide, neutral, structured; glow OFF.
     · Summary cards    — glow keyed by severity via their icon tile (never a fill).
     · Informative      — muted: hairline border, small shadow.
   The glow is a blurred radial blob in a corner (::after), driven by
   --card-glow; without the variable the blob is transparent — glow is opt-in.
--------------------------------------------------------------------------- */
.card {
  position: relative;
  /* Ronda B: `clip` contains the glow blob exactly like `hidden` did, but it is NOT a scroll
     container — so sticky table headers inside cards can stick to the page scroller. */
  overflow: clip;
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, color-mix(in srgb, var(--surface-elevated) 96%, #ffffff), var(--surface));
  box-shadow: var(--shadow-md);
  padding: var(--card-padding) calc(var(--card-padding) + 0.15rem);
  min-width: 0;
}
.card::after {
  content: "";
  position: absolute;
  width: 65%;
  height: 70%;
  right: -20%;
  bottom: -45%;
  border-radius: 999px;
  background: var(--card-glow, transparent);
  filter: blur(45px);
  opacity: var(--card-glow-opacity, 0.18);
  pointer-events: none;
}
/* Content children stay above the blob. */
.card > * { position: relative; z-index: 1; }
.card h3 { margin: 0 0 0.5rem; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.card .note { margin: 0; color: var(--ink); font-size: 0.78rem; line-height: 1.5; }

/* Glow temperament map — keyed off EXISTING markup (icon tile state classes),
   so no builder changed. KPI/promo default to the accent ambience. */
.kpi-card, .kpi-hero, .promo-card, .kpi-row > .card { --card-glow: var(--glow-accent); }
.kpi-card:has(.icon-tile.tile-ok) { --card-glow: var(--glow-success); }
.kpi-card:has(.icon-tile.tile-warn) { --card-glow: var(--glow-warning); }
.kpi-card:has(.icon-tile.tile-alarm) { --card-glow: var(--glow-danger); }
/* Energía: the distribution donut leans violet (accent+alarm derivation). */
.donut-card { --card-glow: var(--glow-violet); --card-glow-opacity: 0.14; }
/* Informative/muted cards: hairline + small shadow, no ambience. */
.info-card, .deriv-card, .vent-aside, .clima-fuente, .trend-card { box-shadow: var(--shadow-sm); }
.info-card { --card-glow: var(--glow-accent); --card-glow-opacity: 0.10; }
/* Alert summary row: the glow bleeds from the ICON corner (top-left), tenue. */
.alert-summary > .kpi-card::after { right: auto; bottom: auto; left: -22%; top: -45%; }

/* Interactive/KPI hover: lift + accent border + deeper shadow (150–250 ms). */
.card { transition: box-shadow var(--t-fast) ease, border-color var(--t-fast) ease, transform var(--t-fast) ease; }
.kpi-card:hover, .kpi-hero:hover, .promo-card:hover, .kpi-row > .card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 25%, var(--border));
  box-shadow: var(--shadow-lg);
}

/* Ronda B: KPI rows reflow by available space (auto-fit + fluid floor), not by device. */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 8rem), 1fr)); gap: var(--grid-gap); }
.kpi-row .card { padding: calc(var(--card-padding) * 0.85) var(--card-padding); }
.kpi { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; }
.kpi small { font-size: 0.7rem; font-weight: 500; color: var(--muted); }
.kpi-sub { margin-top: 0.15rem; color: var(--muted); font-size: 0.68rem; }

/* ---------------------------------------------------------------------------
   TABLES (Ronda A): technical monitoring density — tinted small-caps header
   band, tighter legible rows, hover wash, hairline separators.
--------------------------------------------------------------------------- */
.table-scroll { overflow-x: auto; }
.dock table, .page table { width: 100%; border-collapse: collapse; font-size: 0.74rem; }
.dock th, .page th {
  text-align: left;
  padding: 0.34rem 0.45rem;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 90%, var(--ink));
  background: color-mix(in srgb, var(--accent) 4%, transparent);
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
}
.dock th:first-child, .page th:first-child { border-top-left-radius: var(--radius-sm); }
.dock th:last-child, .page th:last-child { border-top-right-radius: var(--radius-sm); }
.dock td, .page td { padding: 0.3rem 0.45rem; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }
.dock tbody tr, .page tbody tr { transition: background-color var(--t-fast) ease; }
.dock tbody tr:hover td, .page tbody tr:hover td { background: var(--surface-hover); }
.dock tr:last-child td, .page tr:last-child td { border-bottom: 0; }
.dock td.num, .dock th.num, .page td.num, .page th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------------------
   STATE BADGE VOCABULARY (Ronda A): one look for every state — semantic ink,
   status dot, low-opacity tinted background + subtle border. The existing
   pill/sev/dot classes ARE the vocabulary; they only gained depth here.
   Estados cubiertos: Correcto/Automático/Resuelta (ok) · En espera (ok) ·
   Enfriando/Activa (accent) · Advertencia (warn) · Crítica (critical).
--------------------------------------------------------------------------- */
.pill { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.1rem 0.5rem; border-radius: 999px; border: 1px solid color-mix(in srgb, currentColor 24%, transparent); font-size: 0.67rem; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 0.42rem; height: 0.42rem; border-radius: 50%; background: currentColor; }
.pill-ok { color: var(--ok-ink); background: color-mix(in srgb, var(--ok) 12%, #ffffff); }
.pill-accent { color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 11%, #ffffff); }
.pill-warn { color: var(--warn-ink); background: color-mix(in srgb, var(--warn) 14%, #ffffff); }
.pill-critical { color: var(--alarm-ink); background: color-mix(in srgb, var(--alarm) 11%, #ffffff); }

.desvio { color: var(--muted); font-size: 0.72rem; font-variant-numeric: tabular-nums; }
.desvio.fuera { color: var(--warn-ink); font-weight: 700; }

/* Alertas filter chips (fidelity pass): PILL buttons — the pressed pill is the active filter
   (accent-soft bg + accent-ink text via the shared aria-pressed button rule). */
.cat-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.cat-chip { display: inline-flex; align-items: center; gap: 0.4rem; min-height: 1.9rem; padding: 0.24rem 0.7rem; border: 1px solid var(--border); border-radius: 999px; background: linear-gradient(180deg, var(--surface-elevated), color-mix(in srgb, var(--surface) 94%, var(--border))); color: var(--muted); font-size: 0.7rem; font-weight: 600; }
.cat-chip b { color: var(--ink); }
.cat-chip[aria-pressed="true"] b { color: inherit; }

/* Alertas rows (fidelity pass → Ronda A): severity is a BADGE now — dot + ink
   + tinted wash + hairline, never text-color-only, never a full-row fill. */
.cat-cell { display: inline-flex; align-items: center; gap: 0.45rem; white-space: nowrap; }
.cat-cell svg { flex: none; color: var(--muted); }
.cell-device { font-weight: 700; }
.sev {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.08rem 0.5rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, currentColor 24%, transparent);
  background: color-mix(in srgb, currentColor 9%, #ffffff);
  font-size: 0.68rem;
  font-weight: 600;
  white-space: nowrap;
}
.sev::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: currentColor; }
.sev-warn { color: var(--warn-ink); }
.sev-critical { color: var(--alarm-ink); }

/* Alertas pagination footer: right-aligned — honest count, then prev/next. */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 0.6rem; margin-top: 0.55rem; padding-top: 0.55rem; border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent); }
.pager-count { color: var(--muted); font-size: 0.72rem; }
.pager-buttons { display: inline-flex; align-items: center; gap: 0.45rem; }
.pager-page { color: var(--muted); font-size: 0.72rem; }
.pager-button { min-height: 1.8rem; min-width: 1.8rem; padding: 0.1rem 0.5rem; font-size: 0.8rem; line-height: 1; }
.pager-button:disabled { color: var(--muted); background: var(--surface); border-color: var(--line); cursor: default; opacity: 0.45; box-shadow: none; }

.scene-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; }
/* Single-view correction (2026-07-18): scenes are read-only program facts now — cards, not
   buttons. Nothing here moves the model. */
.scene-item { display: grid; gap: 0.15rem; padding: 0.55rem 0.7rem; border: 1px solid color-mix(in srgb, var(--border) 85%, transparent); border-radius: var(--radius-sm); background: linear-gradient(160deg, var(--surface-elevated), var(--surface)); text-align: left; font-size: 0.8rem; }
.scene-item span { color: var(--muted); font-size: 0.68rem; }

.trend-grid { display: grid; gap: 0.6rem; }
/* Fidelity pass: instrument tiles — hairline border, bold title + muted timeframe subtitle. */
.trend-card { border: 1px solid color-mix(in srgb, var(--border) 90%, transparent); }
.trend-card h3 { margin-bottom: 0.15rem; text-transform: none; letter-spacing: 0; font-size: 0.78rem; font-weight: 700; color: var(--ink); }
.trend-sub { margin: 0 0 0.45rem; color: var(--muted); font-size: 0.64rem; }
.trend-row { display: flex; align-items: center; gap: 0.55rem; }
.trend-label { flex: none; width: 2.6rem; color: var(--muted); font-size: 0.66rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.trend-value { flex: none; font-size: 0.74rem; }
.chispa { flex: 1; min-width: 0; height: 1.7rem; }

.dia-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.45rem; }
.dia { display: grid; gap: 0.15rem; justify-items: center; padding: 0.45rem 0.5rem; border: 1px solid color-mix(in srgb, var(--border) 85%, transparent); border-radius: var(--radius-sm); background: linear-gradient(180deg, var(--surface-elevated), color-mix(in srgb, var(--surface) 95%, var(--accent-soft))); font-size: 0.72rem; text-align: center; }
.dia span { color: var(--muted); font-size: 0.66rem; }
/* Fidelity pass: condition glyph per chip; the high leads in ink, the low reads muted. */
.dia .dia-glyph { display: grid; place-items: center; color: var(--accent-ink); }
.dia-temps { display: flex; align-items: baseline; justify-content: center; gap: 0.4rem; }
.dia .dia-hi { color: var(--ink); font-size: 0.78rem; }
.dia .dia-lo { color: var(--muted); font-size: 0.7rem; }

/* Clima hero (client round 3): current conditions large — temp + state + key readings. */
.clima-hero { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.clima-now { display: flex; align-items: center; gap: 0.7rem; }
.clima-glyph { display: grid; place-items: center; color: var(--accent-ink); }
.clima-temp { font-size: clamp(2rem, 1.5rem + 1.4vw, 2.6rem); font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
.clima-temp small { font-size: 1rem; font-weight: 500; color: var(--muted); }
.clima-cond { color: var(--muted); font-size: 0.9rem; }
.clima-reads { display: flex; gap: 0.55rem; }
.clima-read { display: grid; gap: 0.12rem; min-width: 6.5rem; padding: 0.45rem 0.6rem; border: 1px solid color-mix(in srgb, var(--border) 85%, transparent); border-radius: var(--radius-sm); background: linear-gradient(180deg, var(--surface-elevated), var(--surface)); font-size: 0.78rem; }
.clima-read span { color: var(--muted); font-size: 0.66rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; }

/* Energía KPI heroes (fidelity pass): small muted label on top (the card h3), HUGE number,
   inline muted unit, muted period subtitle below. */
.kpi-hero .kpi { font-size: clamp(1.7rem, 1.15rem + 1.3vw, 2.45rem); font-weight: 650; line-height: 1.05; letter-spacing: -0.015em; }
.kpi-hero .kpi small { font-size: 1rem; }
.kpi-hero .kpi-sub { margin-top: 0.3rem; }

/* ---------------------------------------------------------------------------
   CLIENT ROUND 4 (2026-07-18, approved mockups): shared card anatomy — icon
   tiles, KPI heads, toolbars, sortable headers, table footers, donut, alerts
   layout. Existing tokens only (the sidebar logo is the one sanctioned
   exception, and it lives in index.html).
--------------------------------------------------------------------------- */
.kpi-row-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }
.kpi-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.45rem; }
.kpi-head h3 { margin: 0; }
/* Icon tiles: soft gradient + inner highlight so the tile reads dimensional. */
.icon-tile {
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--accent) 16%, transparent);
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent-soft) 55%, #ffffff), var(--accent-soft));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65), var(--shadow-sm);
  color: var(--accent-ink);
  flex: none;
}
.icon-tile svg { width: 1.15rem; height: 1.15rem; }
.tile-warn { border-color: color-mix(in srgb, var(--warn) 30%, transparent); background: linear-gradient(145deg, color-mix(in srgb, var(--warn) 10%, #ffffff), color-mix(in srgb, var(--warn) 20%, #ffffff)); color: var(--warn-ink); }
.tile-alarm { border-color: color-mix(in srgb, var(--alarm) 26%, transparent); background: linear-gradient(145deg, color-mix(in srgb, var(--alarm) 8%, #ffffff), color-mix(in srgb, var(--alarm) 16%, #ffffff)); color: var(--alarm-ink); }
.tile-ok { border-color: color-mix(in srgb, var(--ok) 30%, transparent); background: linear-gradient(145deg, color-mix(in srgb, var(--ok) 9%, #ffffff), color-mix(in srgb, var(--ok) 18%, #ffffff)); color: var(--ok-ink); }
.kpi-info { margin-left: auto; display: grid; place-items: center; color: var(--muted); cursor: help; }
.kpi-card .kpi, .promo-card .kpi { font-size: clamp(1.35rem, 1.15rem + 0.5vw, 1.6rem); }
.kpi-card .kpi small { font-size: 0.85rem; }
.promo-card .note { margin-bottom: 0.55rem; }
.btn-accent {
  border-color: var(--accent-strong);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #ffffff), var(--accent-strong));
  color: #ffffff;
  font-weight: 600;
  padding: 0.32rem 0.85rem;
  font-size: 0.78rem;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.btn-accent:hover, .btn-accent:focus-visible { border-color: var(--accent-ink); background: var(--accent-ink); color: #ffffff; }

.toolbar { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.55rem; }
.search-box { display: flex; align-items: center; gap: 0.4rem; flex: 1; min-width: 12rem; max-width: 24rem; padding: 0 0.6rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-elevated); box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04); color: var(--muted); transition: border-color var(--t-fast) ease, box-shadow var(--t-fast) ease; }
.search-box:focus-within { border-color: var(--accent); box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04), 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
.search-box input { flex: 1; min-width: 0; min-height: 2.1rem; border: 0; outline: none; background: none; color: var(--ink); font-size: 0.78rem; }
.toolbar-button { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.3rem 0.7rem; font-size: 0.75rem; }
.hvac-modes { margin-bottom: 0.55rem; }

.th-sort { display: inline-flex; align-items: center; gap: 0.25rem; min-height: 0; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; }
.th-sort:hover, .th-sort:focus-visible { background: none; border: 0; box-shadow: none; color: var(--ink); }
th.num .th-sort { justify-content: flex-end; }

.dev-pos { color: var(--warn-ink); font-weight: 600; }
.dev-neg { color: var(--accent-ink); font-weight: 600; }
.dev-zero { color: var(--muted); }

.unit-pair b { font-weight: 700; }
.unit-cell { display: inline-flex; align-items: center; gap: 0.45rem; white-space: nowrap; }
.tag-chip { display: inline-block; padding: 0.08rem 0.45rem; border: 1px solid color-mix(in srgb, var(--border) 90%, var(--ink)); border-radius: 0.4rem; background: linear-gradient(180deg, var(--surface-elevated), var(--ground)); font-size: 0.7rem; font-weight: 600; }
.dot { display: inline-block; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: currentColor; flex: none; }
.dot-ok { color: var(--ok); }
.dot-accent { color: var(--accent); }
td.row-action, th.row-action { text-align: right; width: 2.1rem; }
.row-link, .kebab { display: inline-grid; place-items: center; width: 1.75rem; min-height: 1.75rem; padding: 0; border: 1px solid transparent; border-radius: 0.45rem; color: var(--muted); background: none; box-shadow: none; }
.row-link:hover, .row-link:focus-visible, .kebab:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.dock td .chispa, .page td .chispa { display: block; width: 8.5rem; height: 1.35rem; }

.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.55rem; padding-top: 0.55rem; border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent); color: var(--muted); font-size: 0.72rem; }
.legend { display: inline-flex; align-items: center; gap: 0.55rem; flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--ink); }
.table-foot-right { display: inline-flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; margin-left: auto; }
.rows-per-page { display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.rows-per-page select { min-height: 1.9rem; border: 1px solid var(--border); border-radius: 0.45rem; background: var(--surface-elevated); color: var(--ink); font-size: 0.72rem; padding: 0 0.3rem; }
.pager-button.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; }
.pager-gap { color: var(--muted); }
.table-note { margin: 0.45rem 0 0; color: var(--muted); font-size: 0.66rem; }

.kpi-spark { margin-top: 0.5rem; }
.kpi-spark .chispa { display: block; width: 100%; height: 2rem; }
.donut-wrap { display: flex; align-items: center; gap: 0.9rem; }
.donut { width: 6.2rem; height: 6.2rem; flex: none; }
.donut-legend { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.3rem; font-size: 0.72rem; flex: 1; min-width: 0; }
.donut-legend li { display: flex; align-items: center; gap: 0.45rem; }
.donut-legend li > span { color: var(--ink); }
.donut-legend b { margin-left: auto; color: var(--ink); }
.seg-clim { color: var(--accent); }
.seg-vent { color: var(--ok); }
.seg-luz { color: var(--warn); }
.seg-otros { color: var(--muted); }
.donut-foot { margin: 0.55rem 0 0; color: var(--muted); font-size: 0.66rem; }

.alert-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: var(--grid-gap); }
.page-content > .alert-summary { grid-column: 1 / -1; }
.sum-chevron { margin-left: auto; display: inline-grid; place-items: center; width: 1.75rem; min-height: 1.75rem; padding: 0; color: var(--muted); }
.cat-chip-empty { opacity: 0.5; }
.sev-ok { color: var(--ok-ink); }
.alerts-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 0.7rem; align-items: start; }
.action-row td { background: color-mix(in srgb, var(--accent) 4%, var(--ground)); }
.action-menu { display: flex; gap: 0.5rem; flex-wrap: wrap; padding: 0.15rem 0; }
.action-item { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 1.9rem; padding: 0.2rem 0.6rem; border: 1px solid var(--border); border-radius: 0.45rem; background: var(--surface-elevated); color: var(--ink); font-size: 0.72rem; font-weight: 600; text-decoration: none; cursor: pointer; box-shadow: var(--shadow-sm); transition: border-color var(--t-fast) ease, background-color var(--t-fast) ease, color var(--t-fast) ease; }
.action-item:hover, .action-item:focus-visible { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.deriv-art { display: block; width: 100%; height: auto; margin-top: 0.6rem; }

/* Retained by Cuarto de máquinas (bus summary rows). */
.detail-row { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; padding: 0.3rem 0; border-top: 1px dashed var(--line); font-size: 0.75rem; }
.detail-row > span:first-child { color: var(--muted); }

/* Cuarto de máquinas equipment cards + RS-485 bus summary (client round 3 + fidelity pass):
   ~46px accent-soft icon tile, "RTU-NN Zona" tagline, compound value-box labels. */
.rtu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); gap: 0.55rem; }
.rtu-card { display: grid; gap: 0.45rem; align-content: start; padding: 0.65rem 0.75rem; border: 1px solid color-mix(in srgb, var(--border) 85%, transparent); border-radius: var(--radius-sm); min-width: 0; }
.rtu-head { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.rtu-head .pill { margin-left: auto; align-self: flex-start; flex: none; }
.rtu-icon { display: grid; place-items: center; width: 2.9rem; height: 2.9rem; border-radius: 0.6rem; background: linear-gradient(145deg, color-mix(in srgb, var(--accent-soft) 55%, #ffffff), var(--accent-soft)); color: var(--accent-ink); flex: none; }
.rtu-icon svg { width: 1.5rem; height: 1.5rem; }
.rtu-id { display: grid; gap: 0.1rem; line-height: 1.25; min-width: 0; flex: 1; }
.rtu-tagline { display: flex; align-items: baseline; gap: 0.35rem; min-width: 0; }
.rtu-tag { color: var(--muted); font-size: 0.7rem; font-weight: 600; white-space: nowrap; }
.rtu-tagline b { font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.rtu-meta { color: var(--muted); font-size: 0.64rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.val-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem; }
.val-box { display: grid; gap: 0.1rem; padding: 0.35rem 0.5rem; border: 1px solid color-mix(in srgb, var(--border) 85%, transparent); border-radius: 0.45rem; background: linear-gradient(180deg, var(--surface-elevated), var(--surface)); font-size: 0.76rem; min-width: 0; }
.val-box span { color: var(--muted); font-size: 0.6rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.val-box b small { color: var(--muted); font-size: 0.85em; font-weight: 500; }
.rtu-drop { margin: 0; color: var(--muted); font-size: 0.68rem; }
.bus-summary { display: grid; }
.bus-summary .note { margin-bottom: 0.35rem; }

/* ---------------------------------------------------------------------------
   EMBED mode (correction item E, still binding): bare interactive canvas only.
--------------------------------------------------------------------------- */
body.embed .app-header,
body.embed .menu,
body.embed .menu-scrim,
body.embed .dock,
body.embed .skip-link,
body.embed .selection-card,
body.embed .viewer-badge { display: none; }
body.embed .app-shell { grid-template-rows: minmax(0, 1fr); gap: 0; padding: 0; }
body.embed .work { display: block; }
body.embed .heropane { display: block; height: 100%; }
body.embed .viewer { height: 100%; border-radius: 0; box-shadow: none; }

/* ---------------------------------------------------------------------------
   RESPONSIVE TIERS (BRIEF: four tiers).
   Tier 4 — desktop ≥1440px: widest dock lane.
--------------------------------------------------------------------------- */
@media (min-width: 1440px) {
  :root { --dock-w: 26.5rem; }
}

/* Tier 3 — laptop 1024–1439px: same skeleton; the sidebar and the dock narrow before the
   hero does (RONDA B: the sidebar gives ground here too). */
@media (max-width: 1439px) {
  :root { --dock-w: 21rem; --sidebar-width: 12rem; }
}

/* Tier 2 — tablet 768–1023px (RONDA B): the menu STARTS collapsed to an icon rail (JS
   default, pinnable back). REORGANIZE, never shrink: the third lane dies — on Tablero the
   dock drops BELOW the hero at full width; full pages own the whole area beside the rail. */
@media (max-width: 1023px) {
  .app-header h1 { font-size: 1rem; }
  #app-status { display: none; }
  .work {
    grid-template-columns: var(--menu-w) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1.15fr) minmax(0, 1fr);
  }
  .menu { grid-column: 1; grid-row: 1 / -1; }
  .heropane { grid-column: 2; grid-row: 1; }
  .dock { grid-column: 2; grid-row: 2; }
  .app-shell[data-view="page"] .work { grid-template-rows: minmax(0, 1fr); }
  .app-shell[data-view="page"] .page { grid-column: 2; grid-row: 1 / -1; }
  /* Peeled dock: a slim horizontal reopen bar under the hero, not a vertical rail. */
  .app-shell[data-dock="peeled"] .work { grid-template-rows: minmax(0, 1fr) auto; }
  .dock-reopen { flex: none; writing-mode: horizontal-tb; padding: 0.55rem 0.9rem; }
}

/* Round-4 wide two-column layouts fold before the phone tier stacks them. */
@media (max-width: 1279px) {
  .alerts-layout { grid-template-columns: minmax(0, 1fr); }
}

/* Tier 1 — phone <768px (RONDA B): vertical stack, the BODY owns the scroll. The 3D hero is
   full width at a real usable height (dvh so browser chrome never lies); the menu becomes an
   accessible overlay drawer with a scrim, scroll lock and focus trap (wired in main.js). */
@media (max-width: 767px) {
  body { overflow: auto; }
  body[data-drawer-lock] { overflow: hidden; }
  .app-shell { display: block; height: auto; }
  .app-header { position: sticky; top: 0.35rem; z-index: 20; }
  .app-header > div { min-width: 0; flex: 1; }
  .app-header h1, .eyebrow { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .menu-drawer { display: inline-flex; align-items: center; gap: 0.4rem; flex: none; }
  .work { display: flex; flex-direction: column; gap: var(--section-gap); margin-top: var(--section-gap); }
  .heropane { display: contents; }
  .viewer { height: clamp(17rem, 58dvh, 34rem); flex: none; }
  /* One-finger vertical pan keeps scrolling the PAGE over the canvas; horizontal drags orbit.
     (!important beats the inline touch-action OrbitControls writes on the canvas.) */
  .viewer canvas { touch-action: pan-y !important; }
  .menu {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: min(16rem, 85vw);
    padding-bottom: calc(0.55rem + env(safe-area-inset-bottom));
    border-radius: 0 var(--card-radius) var(--card-radius) 0;
    transform: translateX(-105%);
    transition: transform 0.18s ease;
  }
  .app-shell[data-drawer="open"] .menu { transform: translateX(0); }
  .app-shell[data-drawer="open"] .menu-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 25;
    min-height: 0;
    border: 0;
    border-radius: 0;
    background: rgba(27, 36, 48, 0.35);
  }
  /* Inside the drawer the menu is always the full labeled list; pin/collapse is a lane concept. */
  .app-shell[data-menu="collapsed"] .nav-text,
  .app-shell[data-menu="collapsed"] .nav-badge,
  .app-shell[data-menu="collapsed"] .menu-group,
  .app-shell[data-menu="collapsed"] .menu-foot { display: revert; }
  .app-shell[data-menu="collapsed"] .menu-foot { display: flex; }
  .app-shell[data-menu="collapsed"] .nav-item { justify-content: flex-start; }
  .menu .pin-button { display: none; }

  .dock { display: flex; }
  .dock-head .pin-button { display: none; }
  .app-shell[data-dock="peeled"] .dock-head,
  .app-shell[data-dock="peeled"] .dock-scroll { display: revert; }
  .app-shell[data-dock="peeled"] .dock-reopen { display: none; }
  .dock-scroll { overflow: visible; display: block; }
  .dock-content { margin-top: 0.65rem; }

  /* Full pages on the phone: the body is the scroller (no nested scroll), one column,
     nothing wider than the viewport (the week grid scrolls inside its own card). */
  .page-scroll { overflow: visible; }
  .page-content { grid-template-columns: minmax(0, 1fr); }

  /* The derivación aside drops under the alerts table on the phone. */
  .alerts-layout { grid-template-columns: minmax(0, 1fr); }
  .table-foot-right { margin-left: 0; }
  .scene-grid { grid-template-columns: 1fr; }
  .dia-strip { grid-template-columns: repeat(2, 1fr); }
  .selection-card { width: min(15rem, calc(100% - 1.5rem)); }
  /* The drawer keeps the logo left-aligned. */
  .app-shell[data-menu="collapsed"] .brand { justify-content: flex-start; padding-inline: 0.55rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  /* Depth stays; MOTION goes: no hover lifts for reduced-motion operators. */
  .kpi-card:hover, .kpi-hero:hover, .promo-card:hover, .kpi-row > .card:hover, .scene-select:hover { transform: none; }
}

/* ---------------------------------------------------------------------------
   CLIENT ROUND 5 (2026-07-18): the five remaining section mockups.
   Ventiladores / Cuarto / Iluminación / Clima / Horarios — B43 tokens only.
--------------------------------------------------------------------------- */

/* Shared two-column section layout: main table card + right aside (~1/3). */
.split-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 0.7rem; align-items: start; }
.split-main { min-width: 0; }
.split-main .card + section { margin-top: 0.7rem; }

/* Ventiladores top strip: the estado card leads a five-column row. */
.kpi-row-5 { grid-template-columns: 1.6fr repeat(4, minmax(0, 1fr)); }
.estado-card { --card-glow: var(--glow-success); --card-glow-opacity: 0.14; }
.estado-card .note { margin: 0; }
.estado-card .pill { vertical-align: baseline; }

/* Aside vocabulary (Ventiladores + Cuarto). */
.vent-aside { display: grid; gap: 0.55rem; align-content: start; }
.vent-aside h3 { margin-bottom: 0; }
.aside-sub { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.66rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
/* Status banners: tinted GRADIENT wash (light source top-left), never a flat fill. */
.ok-banner {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.6rem 0.7rem;
  border: 1px solid color-mix(in srgb, var(--ok) 32%, transparent);
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, color-mix(in srgb, var(--ok) 13%, #ffffff), color-mix(in srgb, var(--ok) 5%, #ffffff));
}
.ok-banner b { display: block; color: var(--ok-ink); font-size: 0.8rem; }
.ok-banner p { margin: 0.1rem 0 0; color: var(--ink); font-size: 0.72rem; }
.ok-banner.banner-warn { border-color: color-mix(in srgb, var(--warn) 38%, transparent); background: linear-gradient(135deg, color-mix(in srgb, var(--warn) 13%, #ffffff), color-mix(in srgb, var(--warn) 5%, #ffffff)); }
.ok-banner.banner-warn b { color: var(--warn-ink); }
.count-badge { padding: 0.06rem 0.5rem; border-radius: 0.45rem; border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent); background: color-mix(in srgb, var(--accent) 9%, #ffffff); color: var(--accent-ink); font-weight: 700; }
.info-banner { display: flex; gap: 0.45rem; align-items: flex-start; margin: 0.25rem 0 0; padding: 0.55rem 0.65rem; border-radius: var(--radius-sm); border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent); background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 10%, #ffffff), color-mix(in srgb, var(--accent) 4%, #ffffff)); color: var(--accent-ink); font-size: 0.7rem; }
.info-banner svg { flex: none; margin-top: 0.1rem; }

/* Bus donut segments: same categorical 4-hue family the Energía donut established. */
.seg-bus-a { color: var(--accent); }
.seg-bus-b { color: var(--ok); }
.seg-bus-c { color: var(--warn); }
.seg-bus-d { color: var(--muted); }

/* Cuarto top strip: 8 tracks — two info cards (span 2) + four KPI cards. It is a direct
   page-content child, so it must span every page column like the kpi rows do. */
.page-content > .cuarto-strip { grid-column: 1 / -1; }
.cuarto-strip { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 0.6rem; }
.cuarto-strip .info-card { grid-column: span 2; }
.info-card .note { margin-bottom: 0.55rem; }
.cuarto-iso { display: block; width: 100%; max-width: 13rem; height: auto; margin-top: auto; }
.sub-ok { color: var(--ok-ink); font-weight: 600; }
.sub-alarm { color: var(--alarm-ink); font-weight: 600; }
.health-line { margin: 0; font-size: 0.78rem; color: var(--muted); }
.rack-svg { display: block; width: 100%; height: auto; }
.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem; }
.mini-stat { display: grid; gap: 0.12rem; padding: 0.45rem 0.55rem; border: 1px solid color-mix(in srgb, var(--border) 85%, transparent); border-radius: 0.5rem; background: linear-gradient(180deg, var(--surface-elevated), var(--surface)); }
.mini-stat span { color: var(--muted); font-size: 0.6rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.mini-stat b { font-size: 0.82rem; }
.mini-stat small { color: var(--muted); font-size: 0.64rem; }

/* Iluminación. */
.ilum-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 0.7rem; align-items: stretch; }
/* Scene cards are the ONE truly clickable card family: lift + cursor + ring. */
.scene-select { display: grid; gap: 0.2rem; justify-items: start; cursor: pointer; box-shadow: var(--shadow-sm); transition: transform var(--t-fast) ease, border-color var(--t-fast) ease, box-shadow var(--t-fast) ease, background-color var(--t-fast) ease; }
.scene-select .icon-tile { margin-bottom: 0.15rem; }
.scene-select:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); box-shadow: var(--shadow-md); }
.scene-select[aria-pressed="true"] { border-color: var(--accent); background: linear-gradient(160deg, color-mix(in srgb, var(--accent-soft) 55%, #ffffff), var(--accent-soft)); box-shadow: inset 0 0 0 1px var(--accent), var(--shadow-sm); }
.scene-select[aria-pressed="true"] span { color: var(--accent-ink); }
.kpi-chip { margin-top: 0.5rem; }
.chip-static { cursor: default; }
.progress { margin-top: 0.5rem; height: 0.4rem; border-radius: 999px; background: color-mix(in srgb, var(--accent-soft) 70%, #ffffff); box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.06); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, color-mix(in srgb, var(--ok) 80%, #ffffff), var(--ok)); }
.tl { display: grid; }
.tl-item { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.35rem; border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent); transition: background-color var(--t-fast) ease; }
.tl-item:last-child { border-bottom: 0; }
.tl-item.tl-active {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent-soft) 60%, #ffffff), color-mix(in srgb, var(--accent-soft) 90%, #ffffff));
  border-radius: 0.5rem;
  border-bottom-color: transparent;
  box-shadow: inset 3px 0 0 0 var(--accent);
}
.tl-time { flex: none; width: 2.9rem; color: var(--muted); font-size: 0.72rem; font-weight: 700; }
.tl-dot { flex: none; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--line); }
.tl-dot.completada { background: var(--ok); }
.tl-dot.activa { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.tl-body { display: grid; gap: 0.05rem; min-width: 0; flex: 1; }
.tl-body b { font-size: 0.78rem; }
.tl-body > span > span, .tl-body span { color: var(--muted); font-size: 0.68rem; }
.tl-body b + span { color: var(--muted); }
.link-btn { margin-top: 0.55rem; border: 0; background: none; box-shadow: none; padding: 0.2rem 0; color: var(--accent-ink); font-size: 0.75rem; font-weight: 600; cursor: pointer; text-align: left; }
.link-btn:hover, .link-btn:focus-visible { background: none; border: 0; box-shadow: none; text-decoration: underline; }
.ilum-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.7rem; align-items: start; }
.zone-map { display: block; width: 100%; height: auto; }
.map-ok { color: var(--ok); }
.map-warn { color: var(--warn); }
.map-alarm { color: var(--alarm); }
.map-nodata { color: var(--line); }
.map-legend { display: flex; flex-wrap: wrap; gap: 0.35rem 0.8rem; margin-top: 0.5rem; color: var(--muted); font-size: 0.66rem; }
.map-legend .dot { width: 0.45rem; height: 0.45rem; }
.auto-row { display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.5rem 0.2rem; border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent); }
.auto-row:last-child { border-bottom: 0; }
.page-foot { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.7rem; }

/* Clima. */
.clima-top { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1.6fr) minmax(0, 0.85fr); gap: 0.7rem; align-items: stretch; }
.clima-hero-card, .clima-forecast-card, .clima-fuente { display: grid; gap: 0.55rem; align-content: start; }
.clima-hero-card { --card-glow: var(--glow-accent); }
.clima-illus { display: grid; place-items: center; width: 5.4rem; height: 5.4rem; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--accent) 16%, transparent); background: radial-gradient(circle at 32% 28%, color-mix(in srgb, var(--accent-soft) 40%, #ffffff), var(--accent-soft)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), var(--shadow-sm); color: var(--accent-ink); flex: none; }
.clima-main { display: grid; gap: 0.1rem; }
.dia-strip-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.dia-strip-5 .dia { min-width: 0; }
.dia-meta { display: inline-flex; align-items: center; justify-content: center; gap: 0.25rem; flex-wrap: wrap; color: var(--muted); font-size: 0.62rem; }
.carousel-dots { display: flex; justify-content: center; gap: 0.45rem; }
.dot-btn { width: 0.55rem; min-height: 0.55rem; height: 0.55rem; padding: 0; border-radius: 50%; border: 1px solid var(--muted); background: var(--surface-elevated); box-shadow: none; }
.dot-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
.clima-fuente .cat-chip { justify-self: start; }
.uv-scale { display: block; width: 100%; max-width: 11rem; height: 1rem; margin-top: 0.45rem; }
.uv-b1 { color: var(--ok); } .uv-b2 { color: var(--ok); }
.uv-b3 { color: var(--warn); } .uv-b4 { color: var(--warn); }
.uv-b5 { color: var(--alarm); }
.rain-bars { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.4rem; align-items: end; margin-top: 0.55rem; height: 5rem; }
.rain-bar { display: grid; grid-template-rows: auto 1fr auto; justify-items: center; gap: 0.2rem; height: 100%; }
.rain-bar span { color: var(--muted); font-size: 0.62rem; }
.rain-bar i { align-self: end; width: 0.85rem; border-radius: 0.3rem 0.3rem 0 0; background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 75%, #ffffff), var(--accent)); }
.rain-bar b { color: var(--muted); font-size: 0.6rem; font-weight: 600; white-space: nowrap; }
.ring-wrap { display: grid; place-items: center; margin-top: 0.35rem; }
.hvac-ring { width: 6rem; height: 6rem; }
.cond-strip { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.cond-summary { display: flex; gap: 0.6rem; align-items: flex-start; flex: 1 1 18rem; min-width: 0; }
.cond-summary .note { margin: 0; }
.cond-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 8rem), 1fr)); gap: 0.45rem; flex: 1 1 20rem; }

/* Horarios. */
.next-change {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  margin-top: 0.55rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent-soft) 55%, #ffffff), var(--accent-soft));
}
.next-label { color: var(--accent-ink); font-size: 0.66rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.next-change b { color: var(--ink); font-size: 0.82rem; }
.next-change .countdown { margin-left: auto; border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.resumen-semanal { display: grid; gap: 0.55rem; }
.dot-muted { color: var(--line); background: var(--line); }
/* NOTA aside: amber AMBIENCE (corner glow + amber hairline), not an amber fill. */
.nota-card { display: grid; gap: 0.5rem; align-content: start; border-color: color-mix(in srgb, var(--warn) 42%, transparent); --card-glow: var(--glow-warning); --card-glow-opacity: 0.16; }
.lineamiento { display: flex; gap: 0.5rem; align-items: flex-start; font-size: 0.74rem; color: var(--ink); }
.lineamiento .check-ink { color: var(--ok-ink); flex: none; margin-top: 0.05rem; }
.history-list { display: grid; gap: 0.3rem; padding: 0.5rem 0.6rem; border: 1px solid color-mix(in srgb, var(--border) 85%, transparent); border-radius: 0.5rem; background: linear-gradient(180deg, var(--surface-elevated), var(--surface)); }

/* Round-5 responsive folds: mirror the round-4 tiers. */
@media (max-width: 1279px) {
  .kpi-row-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-row-5 .estado-card { grid-column: span 2; }
  .cuarto-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .cuarto-strip .kpi-card { grid-column: span 2; }
  .split-layout { grid-template-columns: minmax(0, 1fr); }
  .ilum-top { grid-template-columns: minmax(0, 1fr); }
  .ilum-grid { grid-template-columns: minmax(0, 1fr); }
  .clima-top { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .clima-fuente { grid-column: span 2; }
}
@media (max-width: 767px) {
  .kpi-row-5 { grid-template-columns: minmax(0, 1fr); }
  .kpi-row-5 .estado-card { grid-column: auto; }
  .cuarto-strip { grid-template-columns: minmax(0, 1fr); }
  .cuarto-strip .info-card, .cuarto-strip .kpi-card { grid-column: auto; }
  .clima-top { grid-template-columns: minmax(0, 1fr); }
  .clima-fuente { grid-column: auto; }
  .dia-strip-5 { grid-template-columns: repeat(2, 1fr); }
  .cond-stats { grid-template-columns: minmax(0, 1fr); }
}

/* ===========================================================================
   RONDA B — RESPONSIVE OVERHAUL (2026-07-18). Reorganize by available space,
   never just shrink: per-width table strategies, tablet restack, phone cards,
   drawer a11y, touch targets. Everything below rides the Ronda A tokens.
=========================================================================== */

/* Anchored jumps land below the sticky chrome. */
.page-content > *, .dock-content > * { scroll-margin-top: calc(var(--header-height) + 1rem); }

/* --- Per-row detail reveal (tablet): hidden columns come back as labeled pairs. --- */
.row-expand {
  display: none;
  place-items: center;
  width: 1.75rem;
  min-height: 1.75rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 0.45rem;
  color: var(--muted);
  background: none;
  box-shadow: none;
}
.row-expand:hover, .row-expand:focus-visible { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.row-expand svg { transition: transform var(--t-fast) ease; }
.row-expand[aria-expanded="true"] svg { transform: rotate(180deg); }
.detail-pair { display: none; align-items: center; gap: 0.4rem; font-size: 0.72rem; color: var(--muted); }
.detail-pair > span { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; }
.detail-pair b { color: var(--ink); font-size: 0.74rem; }
.row-detail-row .detail-pair { display: inline-flex; }
.row-detail-row .action-menu { gap: 0.5rem 1.1rem; }

/* --- Horizontal-scroll affordance: edge shadows that fade as the edge arrives. --- */
.table-scroll, .week-scroll {
  background:
    linear-gradient(90deg, var(--surface) 45%, rgba(251, 252, 254, 0)) left / 26px 100% no-repeat local,
    linear-gradient(270deg, var(--surface) 45%, rgba(251, 252, 254, 0)) right / 26px 100% no-repeat local,
    linear-gradient(90deg, rgba(15, 23, 42, 0.10), rgba(15, 23, 42, 0)) left / 12px 100% no-repeat scroll,
    linear-gradient(270deg, rgba(15, 23, 42, 0.10), rgba(15, 23, 42, 0)) right / 12px 100% no-repeat scroll;
}

/* --- Desktop/laptop ≥1280: full tables, headers STICK to the page scroller while the card
   scrolls under (the alerts card keeps its own x-scroll, so it opts out). --- */
@media (min-width: 1280px) {
  .page .table-scroll { overflow-x: visible; background: none; }
  .page .alerts-layout .table-scroll { overflow-x: auto; }
  .page thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: color-mix(in srgb, var(--accent) 5%, var(--surface-elevated));
  }
}

/* --- Tablet & phone ≤1023: secondary columns hide (reachable via the row reveal, the
   phone cards and the CSV); touch targets grow to the 44px contract. --- */
@media (max-width: 1023px) {
  .page .cell-sec { display: none; }
  .row-expand { display: inline-grid; }
  .action-row .detail-pair { display: inline-flex; }
  .page td.row-action, .page th.row-action { width: 4.2rem; white-space: nowrap; }
  /* First column stays put while the rest scrolls under it. */
  .page .table-scroll th:first-child, .page .table-scroll td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: linear-gradient(90deg, var(--surface) 86%, rgba(251, 252, 254, 0));
  }
  .page .table-scroll th:first-child { background: color-mix(in srgb, var(--accent) 4%, var(--surface)); }
  /* Touch targets: 44px minimum, no hover dependence (active/focus states already exist). */
  .nav-item, .toolbar-button, .cat-chip, .menu-drawer, .action-item, .search-box input { min-height: 2.75rem; }
  .pager-button { min-height: 2.5rem; min-width: 2.5rem; }
  .row-link, .kebab, .row-expand, .sum-chevron { width: 2.4rem; min-height: 2.4rem; }
  .toolbar { gap: 0.55rem; }
  .cat-row { gap: 0.5rem; }
  /* Horarios: the week folds into a 3-column grid instead of scrolling sideways. */
  .week-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .week-scroll { overflow-x: visible; background: none; }
}

/* 600–767: the week folds once more; KPI heroes stay two-up via auto-fit. */
@media (max-width: 767px) {
  .week-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* --- Phone ≤599 (RONDA B core): every table becomes a stack of labeled CARDS built from
   the SAME builder output (data-th labels, CSS-only transform). Identity leads, state
   badges stay badges, secondary data returns, the action affordance floats top-right. --- */
@media (max-width: 599px) {
  .eyebrow { display: none; }
  .viewer-badge { display: none; }
  .menu-drawer { padding: 0.3rem 0.55rem; }
  .app-header { gap: 0.5rem; }
  .viewer { height: clamp(16rem, 55dvh, 30rem); }

  /* Selection detail reads as a bottom sheet over the model. */
  .selection-card {
    top: auto;
    right: 0;
    left: 0;
    bottom: 0;
    width: auto;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
  }

  /* Filter/category chips scroll sideways instead of wrap-crushing; taps stay deliberate. */
  .cat-row { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 0.25rem; scrollbar-width: thin; }
  .cat-chip { flex: none; }

  /* Clima forecast: controlled horizontal carousel with snap. */
  .dia-strip, .dia-strip-5 { display: flex; overflow-x: auto; gap: 0.45rem; padding-bottom: 0.3rem; scroll-snap-type: x proximity; scrollbar-width: thin; }
  .dia { flex: 0 0 8.6rem; scroll-snap-align: start; }

  /* Toolbar: full-width search on top, actions beneath. */
  .search-box { min-width: 0; flex-basis: 100%; max-width: none; }
  .clima-reads { flex-wrap: wrap; }
  .cuarto-iso { max-width: 10rem; }
  .table-foot { row-gap: 0.4rem; }
  .table-foot-right { margin-left: 0; }

  /* TABLE → CARD LIST. */
  .page .table-scroll, .dock .table-scroll { overflow: visible; background: none; }
  .page table, .dock table, .page tbody, .dock tbody { display: block; width: 100%; }
  .page thead, .dock thead { display: none; }
  .page tbody tr, .dock tbody tr {
    position: relative;
    display: grid;
    gap: 0.45rem;
    margin-bottom: 0.55rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid color-mix(in srgb, var(--border) 85%, transparent);
    border-radius: var(--radius-md);
    background: linear-gradient(160deg, var(--surface-elevated), var(--surface));
    box-shadow: var(--shadow-sm);
  }
  .page tbody tr:last-child, .dock tbody tr:last-child { margin-bottom: 0; }
  .page tbody tr:hover td, .dock tbody tr:hover td { background: none; }
  .page td, .dock td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.15rem 0.7rem;
    padding: 0;
    border-bottom: 0;
    font-size: 0.78rem;
  }
  .page td.cell-sec, .dock td.cell-sec { display: flex; }
  .page td[data-th]::before, .dock td[data-th]::before {
    content: attr(data-th);
    flex: none;
    margin-right: auto;
    color: var(--muted);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
  }
  /* Identity cell leads the card and clears the floating action corner. */
  .page td:first-child, .dock td:first-child { justify-content: flex-start; padding-right: 2.4rem; font-size: 0.85rem; }
  .page td.row-action, .dock td.row-action { position: absolute; top: 0.5rem; right: 0.55rem; width: auto; padding: 0; }
  .row-expand { display: none; }
  .page td .chispa, .dock td .chispa { width: min(58%, 11rem); height: 1.6rem; }
  /* Kebab/detail rows read as sheets attached to their card. */
  .page tr.action-row, .dock tr.action-row {
    margin-top: -0.8rem;
    border-top: 0;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
  }
  .action-row td { background: none; }
  .page td[colspan], .dock td[colspan] { display: block; }
}
