/* ============================================================
   ATLAS — Design System v4  (Apple Light Edition)
   ============================================================ */

/* ── TOKENS ─────────────────────────────────────────────────── */
:root {
  /* Backgrounds — Apple clean white + silver surfaces */
  --bg:   #FAFAFA;      /* body: near-white */
  --s1:   #FFFFFF;      /* card: pure white */
  --s2:   #F5F5F7;      /* inner card / secondary surface (Apple grey) */
  --s3:   #ECECEF;      /* input / tertiary surface */

  /* Text hierarchy */
  --t1:   #1C1C1E;      /* primary — Apple systemLabel */
  --t2:   #636366;      /* secondary */
  --t3:   #98989D;      /* tertiary */
  --t4:   #AEAEB2;      /* quaternary / placeholder */

  /* Borders & micro-fills */
  --b1:   rgba(0,0,0,0.08);    /* standard border */
  --b2:   rgba(0,0,0,0.035);   /* very subtle bg fill */

  /* ── Brand: Crown warm gold (darker for legibility on light) ── */
  --cream:   #7A6040;
  --cream-l: rgba(122,96,64,0.08);
  --cream-b: rgba(122,96,64,0.20);

  /* ── ATLAS — terracota #C0542A (voz central del sistema, ≠ cream/gold) ── */
  --atlas:   #C0542A;
  --atlas-l: rgba(192,84,42,0.09);
  --atlas-b: rgba(192,84,42,0.22);

  /* State tokens */
  --state-ok:         #3D8E5A;  --state-ok-l:       rgba(61,142,90,0.10);
  --state-alert:      #C47A1A;  --state-alert-l:    rgba(196,122,26,0.10);
  --state-critical:   #C0392B;  --state-critical-l: rgba(192,57,43,0.10);
  --state-info:       #4A90D9;  --state-info-l:     rgba(74,144,217,0.10);
  --state-blocked:    #6B7280;  --state-blocked-l:  rgba(107,114,128,0.10);

  /* System blue */
  --blue:    #0064D2;
  --blue-l:  rgba(0,100,210,0.07);
  --blue-b:  rgba(0,100,210,0.18);

  /* Success green */
  --sage:    #3A7A50;
  --sage-l:  rgba(58,122,80,0.08);
  --sage-b:  rgba(58,122,80,0.18);

  /* Danger / alert red */
  --rose:    #B83235;
  --rose-l:  rgba(184,50,53,0.08);
  --rose-b:  rgba(184,50,53,0.18);

  /* Neutral slate */
  --slate:   #6E6E73;
  --slate-l: rgba(110,110,115,0.07);
  --slate-b: rgba(110,110,115,0.15);

  /* Border radius */
  --r-sm: 6px;
  --r:    10px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* Typography — Inter + Apple system stack */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;

  /* ── Compatibility aliases (used by app.js / pm modules) ─── */
  --bg-color:     var(--bg);
  --card-bg:      var(--s1);
  --glass-bg:     var(--s1);         /* pm_balancer.js dark panel → white card */
  --primary:      var(--cream);
  --primary-hover:#614e33;
  --text-main:    var(--t1);
  --text-muted:   var(--t2);
  --text-light:   var(--t1);
  --accent-blue:  var(--blue);
  --accent-red:   var(--rose);
  --accent-green: var(--sage);
  --glass-border: var(--b1);
}

/* ── DARK MODE ───────────────────────────────────────────────── */
[data-theme="dark"] {
  /* Backgrounds — Premium warm dark */
  --bg:   #0A0A0A;
  --s1:   #141210;
  --s2:   #1C1917;
  --s3:   #242018;

  /* Text hierarchy */
  --t1:   #F2F2F7;
  --t2:   #AEAEB2;
  --t3:   #7C7C80;
  --t4:   #48484A;

  /* Borders */
  --b1:   rgba(255,255,255,0.09);
  --b2:   rgba(255,255,255,0.04);

  /* ATLAS terracota — brighter for dark backgrounds */
  --atlas:   #D2643A;
  --atlas-l: rgba(210,100,58,0.12);
  --atlas-b: rgba(210,100,58,0.28);

  /* Brand: Crown gold brighter for dark backgrounds */
  --cream:   #C4A46A;
  --cream-l: rgba(196,164,106,0.12);
  --cream-b: rgba(196,164,106,0.28);
  --primary-hover: #d4b47a;

  /* System blue — Apple dark */
  --blue:    #409CFF;
  --blue-l:  rgba(64,156,255,0.10);
  --blue-b:  rgba(64,156,255,0.25);

  /* Success green — Apple dark */
  --sage:    #32D74B;
  --sage-l:  rgba(50,215,75,0.10);
  --sage-b:  rgba(50,215,75,0.22);

  /* Danger red — Apple dark */
  --rose:    #FF453A;
  --rose-l:  rgba(255,69,58,0.10);
  --rose-b:  rgba(255,69,58,0.22);

  /* Slate */
  --slate:   #8E8E93;
  --slate-l: rgba(142,142,147,0.10);
  --slate-b: rgba(142,142,147,0.20);
}

/* ── RESET ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.14); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.22); }
/* B217 — Scrollbar más visible en light mode */
[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.20); }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.32); }

/* ── TOP ACCENT BAR ──────────────────────────────────────────── */
body::before {
  content: '';
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--atlas) 20%, rgba(212,106,58,0.9) 50%, var(--atlas) 80%, transparent);
  z-index: 1000;
  pointer-events: none;
}

/* ── BASE ────────────────────────────────────────────────────── */
body {
  font-family: var(--font);
  background-color: var(--bg);
  /* B214 — Sin textura de papel/ruido: fondo limpio blanco/plata estilo Apple. */
  background-image: none;
  color: var(--t1);
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 27px 20px 24px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-container {
  width: 100%;
  max-width: 1100px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── HEADER ──────────────────────────────────────────────────── */
header {
  text-align: center;
  padding: 22px 0 8px;
  position: relative;
}

/* ── THEME TOGGLE ────────────────────────────────────────────── */
.theme-toggle {
  position: absolute;
  top: 18px;
  right: 0;
  background: transparent;
  border: 1px solid var(--b1);
  border-radius: var(--r);
  padding: 7px 10px;
  cursor: pointer;
  color: var(--t3);
  font-size: 1.1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.theme-toggle:hover { background: var(--b2); color: var(--t1); border-color: var(--slate-b); }
.theme-toggle:focus-visible { outline: 2px solid var(--atlas); outline-offset: 2px; }

.logo {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--atlas);
  letter-spacing: -0.8px;
}

.subtitle {
  display: block;
  font-size: 0.78rem;
  color: var(--t3);
  font-weight: 400;
  margin-top: 4px;
  letter-spacing: 0.2px;
}

/* ── APP NAV — B66: header compacto ──────────────────────────── */
.app-nav {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 0;
  padding: 0 clamp(12px,2vw,24px); height: 52px;
  background: rgba(10,10,10,0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(255,255,255,0.055);
  flex-shrink: 0;
}
[data-theme="light"] .app-nav {
  background: rgba(248,246,243,0.96);
  border-bottom: 1px solid rgba(0,0,0,0.07);
}
.app-nav__brand {
  font-family: var(--font-display,'Bricolage Grotesque',sans-serif);
  font-size: 10px; font-weight: 800;
  letter-spacing: 0.26em; text-transform: uppercase;
  color: rgba(255,255,255,0.18);
  white-space: nowrap; margin-right: 20px;
  flex-shrink: 0; user-select: none; pointer-events: none;
}
[data-theme="light"] .app-nav__brand { color: rgba(0,0,0,0.16); }
.app-nav__tabs {
  display: flex; align-items: center; gap: 1px; flex: 1;
  position: relative;
}
.mode-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; height: 34px; min-height: unset;
  border: none; border-radius: 8px;
  font-family: var(--font-display,'Bricolage Grotesque',sans-serif);
  font-size: 0.77rem; font-weight: 600;
  color: rgba(255,255,255,0.34); background: transparent;
  cursor: pointer; white-space: nowrap;
  transition: color 0.14s; letter-spacing: 0.01em;
  position: relative; z-index: 1;
}
[data-theme="light"] .mode-btn { color: rgba(0,0,0,0.36); }
.mode-btn i { font-size: 0.88rem; line-height: 1; }
.mode-btn:hover {
  background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.8);
}
[data-theme="light"] .mode-btn:hover {
  background: rgba(0,0,0,0.09); color: rgba(0,0,0,0.82);
}
.mode-btn.active { background: transparent; color: var(--atlas); }
.mode-btn .kbd-hint { display: none; }
.app-nav__actions {
  display: flex; align-items: center; gap: 3px;
  margin-left: auto; flex-shrink: 0; padding-left: 10px;
}
.app-nav__act {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,0.28); font-size: 0.92rem;
  transition: background 0.14s, color 0.14s; flex-shrink: 0;
}
[data-theme="light"] .app-nav__act { color: rgba(0,0,0,0.32); }
.app-nav__act:hover {
  background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.82);
}
[data-theme="light"] .app-nav__act:hover {
  background: rgba(0,0,0,0.06); color: rgba(0,0,0,0.78);
}
.app-nav__act--ai:hover { color: var(--atlas) !important; background: var(--atlas-l) !important; }
.app-nav__role {
  height: 26px; padding: 0 9px; margin-left: 4px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 6px; cursor: pointer;
  font-family: var(--font-display,'Bricolage Grotesque',sans-serif);
  font-size: 0.6rem; font-weight: 800;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  transition: all 0.15s; white-space: nowrap;
}
[data-theme="light"] .app-nav__role {
  background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.1); color: rgba(0,0,0,0.4);
}
.app-nav__role:hover {
  background: rgba(255,255,255,0.09); border-color: rgba(192,84,42,0.35); color: rgba(255,255,255,0.72);
}
[data-theme="light"] .app-nav__role:hover {
  background: rgba(0,0,0,0.07); border-color: rgba(192,84,42,0.35); color: rgba(0,0,0,0.72);
}
@media (max-width: 768px) {
  .app-nav__tabs { display: none; }
  .app-nav { height: 48px; }
}
.tab-indicator {
  position: absolute; top: 50%; left: 0; height: 34px;
  transform: translateY(-50%) translateX(var(--ind-x, 0px));
  width: var(--ind-w, 0px);
  background: rgba(192,84,42,0.14); border-radius: 8px;
  transition: transform var(--dur-base) var(--ease-spring), width var(--dur-base) var(--ease-spring);
  pointer-events: none; z-index: 0;
}
.app-nav.is-scrolled {
  box-shadow: 0 1px 0 rgba(255,255,255,0.04), 0 4px 24px rgba(0,0,0,0.35);
}
[data-theme="light"] .app-nav.is-scrolled {
  box-shadow: 0 1px 0 rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.10);
}

/* ── CARDS ───────────────────────────────────────────────────── */
.card {
  background: var(--s1);
  border: 1px solid var(--b1);
  border-radius: var(--r-xl);
  padding: 28px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 8px 24px rgba(0,0,0,0.04), inset 0 1px 0 rgba(255,255,255,0.85);
  transition: border-top-color 280ms var(--ease-out-quart, cubic-bezier(0.25,1,0.5,1));
}

h2 {
  margin-bottom: 16px;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--t1);
  letter-spacing: -0.5px;
}

h3 {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--atlas);
  letter-spacing: 0.9px;
  text-transform: uppercase;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}
.dashboard-header h2 { margin-bottom: 0; }

/* ── DROP ZONE ───────────────────────────────────────────────── */
.drop-zone {
  border: 1.5px dashed rgba(192,84,42,0.22);
  border-radius: var(--r-xl);
  padding: 52px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 220ms, background 220ms, transform 220ms var(--ease-spring, cubic-bezier(0.34,1.56,0.64,1));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: var(--s2);
  position: relative;
  overflow: hidden;
}
.drop-zone::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 120%, rgba(192,84,42,0.06), transparent 65%);
  opacity: 0;
  transition: opacity 280ms;
  pointer-events: none;
}
.drop-zone:hover::before,
.drop-zone.dragover::before { opacity: 1; }

.drop-zone:hover,
.drop-zone.dragover,
.drop-zone:focus-visible {
  border-color: var(--atlas-b);
  background: var(--s1);
  transform: scale(1.008);
  outline: none;
}

.drop-zone:focus-visible {
  box-shadow: 0 0 0 3px var(--atlas-l);
}

/* Drop zone uploading animation */
.drop-zone.is-analyzing {
  border-color: var(--atlas) !important;
  border-style: solid !important;
}
@keyframes dropAnalyze {
  0%   { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}
.drop-zone.is-analyzing::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--atlas), var(--mod-wo), var(--mod-pm), var(--atlas), transparent);
  background-size: 300%;
  animation: dropAnalyze 1.4s linear infinite;
}

.drop-zone .icon {
  font-size: 2.4rem;
  color: var(--t4);
  line-height: 1;
  display: block;
}

.drop-zone .text {
  color: var(--t3);
  font-size: 0.88rem;
  font-weight: 500;
}

/* ── MAPPING ─────────────────────────────────────────────────── */
.mapping-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
  margin-top: 24px;
  margin-bottom: 22px;
}

.map-group { display: flex; flex-direction: column; gap: 6px; }

.map-group label {
  font-size: 0.75rem;
  color: var(--t3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── INPUTS / SELECTS ────────────────────────────────────────── */
select, input[type="text"], input[type="number"], input[type="date"] {
  background: var(--s3);
  border: 1px solid var(--b1);
  color: var(--t1);
  padding: 8px 10px;
  min-height: 40px;
  border-radius: var(--r);
  font-family: var(--font);
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

select:focus,
input:focus {
  outline: none;
  border-color: var(--atlas-b);
  box-shadow: 0 0 0 3px var(--atlas-l);
}

/* ── ACTION FOOTER ───────────────────────────────────────────── */
.action-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.hidden { display: none; }

/* ── STATS GRID ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

#blocked-breakdown-chart { margin-top: 14px; }

.stat-card {
  background: var(--s2);
  border: 1px solid var(--b1);
  border-left: 3px solid var(--atlas-b);
  padding: 14px 12px;
  border-radius: var(--r-lg);
  text-align: center;
  transition: box-shadow 0.15s, transform 0.15s;
  position: relative; overflow: hidden;
  --spot-x: 50%; --spot-y: 50%; --spot-opacity: 0;
}

.stat-card:hover {
  box-shadow: 0 4px 14px rgba(0,0,0,0.07);
  transform: translateY(-1px);
}
.stat-card::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  pointer-events: none; opacity: var(--spot-opacity);
  transition: opacity var(--dur-base) var(--ease-out-quart);
  background: radial-gradient(180px circle at var(--spot-x) var(--spot-y), rgba(192,84,42,0.12), transparent 40%);
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 5px;
  color: var(--t1);
  letter-spacing: -0.8px;
  line-height: 1.1;
}

.stat-value.highlight   { color: var(--sage); }
.stat-value.warning     { color: var(--state-alert); }
.stat-value.danger      { color: var(--rose); }
.stat-value.accent-blue { color: var(--blue); }

/* Dynamic border-left + subtle gradient bg per stat semantic (modern browsers) */
.stat-card:has(.stat-value.highlight)   {
  border-left-color: var(--sage-b);
  background: linear-gradient(135deg, var(--s2) 55%, var(--sage-l));
}
.stat-card:has(.stat-value.warning)     {
  border-left-color: rgba(196,122,26,0.45);
  background: linear-gradient(135deg, var(--s2) 55%, var(--state-alert-l));
}
.stat-card:has(.stat-value.danger)      {
  border-left-color: var(--rose-b);
  background: linear-gradient(135deg, var(--s2) 55%, var(--rose-l));
}
.stat-card:has(.stat-value.accent-blue) {
  border-left-color: var(--blue-b);
  background: linear-gradient(135deg, var(--s2) 55%, var(--blue-l));
}

/* El color decía la CATEGORÍA de la tarjeta, no el estado del día: "Alertas"
   salía en rojo —cifra, fondo y borde— también con valor 0, con un "OK" escrito
   justo debajo. Un rojo que está ahí todos los días deja de avisar el día que de
   verdad hay algo, y de paso hace que la pantalla parezca alarmada cuando el
   plan va bien. El estado real viaja en data-value (lo sincroniza stat_bars.js
   con la cifra que se haya pintado, venga de donde venga); aquí solo se le hace
   caso. El color de la cifra se apaga más abajo, junto al bloque que lo fija
   con !important. */
.stat-card:has(.stat-value.danger[data-value="0"]),
.stat-card:has(.stat-value.warning[data-value="0"]) {
  border-left-color: var(--b1);
  background: var(--s2);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--t3);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.stat-label i {
  font-size: 0.85rem;
  opacity: 0.7;
}

/* ── AGING HEADER ────────────────────────────────────────────── */
.header-aging {
  background: var(--s2);
  border: 1px solid var(--b1);
  border-radius: var(--r-lg);
  padding: 11px 16px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.header-aging-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  white-space: nowrap;
  min-width: 130px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-aging-title i { font-size: 0.9rem; }

.header-aging-buckets { display: flex; gap: 7px; flex-wrap: wrap; flex: 1; }

.header-aging-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--s1);
  border: 1px solid var(--b1);
  border-radius: var(--r);
  padding: 7px 12px;
  min-width: 66px;
  flex: 1;
  cursor: default;
}

.aging-count {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.3px;
}

.aging-label { font-size: 0.67rem; color: var(--t3); margin-top: 3px; white-space: nowrap; }

/* Las dos cifras parpadeaban en bucle mientras la pantalla estuviera abierta.
   Un movimiento perpetuo no marca ningún momento, así que se deja de ver a los
   dos minutos — y el rojo bajaba la cifra al 45% de opacidad, atenuando el dato
   justo cuando importa leerlo. El aviso lo llevan ya el color, el fondo y el
   borde, que desde ahora sí reaccionan al valor. El halo crítico se queda
   porque no toca la legibilidad del número, y late despacio. */
.stat-value.danger[data-value="nonzero"] { animation: pulseRed 3.2s ease-in-out infinite; }
@keyframes pulseRed {
  0%, 100% { text-shadow: 0 0 0 transparent; }
  50%      { text-shadow: 0 0 10px var(--rose-l); }
}

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn-primary,
.btn-secondary {
  padding: 9px 18px;
  min-height: 44px;
  border-radius: var(--r);
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  letter-spacing: 0.15px;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--atlas);
  color: #fff;
  border-color: var(--atlas);
  box-shadow: 0 1px 4px rgba(192,84,42,0.20);
}

.btn-primary:hover {
  background: #9A3820;
  border-color: #9A3820;
  box-shadow: 0 4px 14px rgba(192,84,42,0.30);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--s2);
  color: var(--t2);
  border-color: var(--b1);
}

.btn-secondary:hover {
  background: var(--s3);
  color: var(--t1);
  border-color: rgba(0,0,0,0.12);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}
.btn-primary:active  { transform: translateY(0); box-shadow: none; transition-duration: 60ms; }
.btn-secondary:active { transform: translateY(0); box-shadow: none; transition-duration: 60ms; }

/* ── DASHBOARD ACTIONS ───────────────────────────────────────── */
.dashboard-actions {
  margin-top: 24px;
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  border-top: 1px solid var(--b1);
  padding-top: 20px;
}

/* ── LOG ─────────────────────────────────────────────────────── */
.log-container {
  margin-top: 14px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.75rem;
  color: var(--t3);
  max-height: 86px;
  overflow-y: auto;
  border-top: 1px solid var(--b1);
  padding-top: 10px;
}

/* ── ANIMATIONS ──────────────────────────────────────────────── */
.fade-in { animation: fadeIn 0.32s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── FOOTER ──────────────────────────────────────────────────── */
footer {
  text-align: center;
  margin-top: 12px;
  color: var(--t4);
  font-size: 0.72rem;
  letter-spacing: 0.1px;
}

/* ── TABLE ───────────────────────────────────────────────────── */
.calendar-container {
  margin-bottom: 22px;
  background: var(--s2);
  border-radius: var(--r-lg);
  padding: 18px;
}

.calendar-container h3 {
  margin-bottom: 11px;
  color: var(--atlas);
  font-size: 0.72rem;
}

.calendar-scroll {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--b1);
  border-radius: var(--r);
}

table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }

th, td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--b1);
  color: var(--t1);
}

th {
  background: var(--s2);
  position: sticky;
  top: 0;
  color: var(--t3);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  z-index: 10;
}

tr:hover { background: var(--b2); }

/* ── STATUS PILLS ────────────────────────────────────────────── */
.status-pill {
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-pill.planned  { background: var(--sage-l); color: var(--sage); }
.status-pill.overflow { background: var(--rose-l); color: var(--rose); }
.status-pill.pending  { background: var(--state-alert-l); color: var(--state-alert); }

/* ── VIEW SELECTOR ───────────────────────────────────────────── */
.view-selector { display: flex; gap: 6px; margin-bottom: 18px; }

.btn-tab {
  background: var(--s2);
  border: 1px solid var(--b1);
  color: var(--t2);
  padding: 8px 14px;
  min-height: 44px;
  cursor: pointer;
  border-radius: var(--r);
  flex: 1;
  font-family: var(--font);
  font-size: 0.83rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-tab.active {
  background: var(--atlas);
  color: #fff;
  border-color: var(--atlas);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(192,84,42,0.20);
}

.btn-tab i { font-size: 1rem; }

/* ── PRODUCTIVITY DASHBOARD ──────────────────────────────────── */
.productivity-container { margin-bottom: 22px; }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.card-inner {
  background: var(--s2);
  border: 1px solid var(--b1);
  border-radius: var(--r-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow 0.15s;
}

.card-inner:hover {
  box-shadow: 0 3px 12px rgba(0,0,0,0.06);
}

.card-inner h3 { font-size: 0.68rem; color: var(--atlas); font-weight: 700; }
.chart-container { min-height: 140px; display: flex; flex-direction: column; gap: 8px; }
.list-container { max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 5px; }

/* Los paneles con scroll cortaban la última fila por la mitad: una fila partida
   no dice si debajo queda una más o quince, y en "Top críticos" eso es la
   diferencia entre mirar y no mirar. El desvanecido lo dice sin ambigüedad y se
   apaga al llegar al final, así que nunca miente sobre si queda contenido. */
@supports (animation-timeline: scroll()) {
  .list-container {
    animation: listFade linear both;
    animation-timeline: scroll(self);
    animation-range: contain;
  }
  @keyframes listFade {
    from { mask-image: linear-gradient(to bottom, #000 82%, transparent 100%); }
    to   { mask-image: linear-gradient(to bottom, #000 100%, #000 100%); }
  }
}
.container-mini { display: flex; flex-direction: column; gap: 5px; }

/* ── BARS ────────────────────────────────────────────────────── */
.bar-row { display: flex; flex-direction: column; gap: 4px; }
.bar-label { font-size: 0.75rem; color: var(--t2); display: flex; justify-content: space-between; }
.bar-bg { background: var(--b1); height: 6px; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--atlas); border-radius: 4px; transition: width 0.4s ease-out; }
.bar-fill.accent { background: var(--blue); }

/* ── LIST ITEMS ──────────────────────────────────────────────── */
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: var(--s1);
  border: 1px solid var(--b1);
  border-radius: var(--r-sm);
  font-size: 0.82rem;
}

.list-item .badge { padding: 2px 6px; border-radius: 4px; background: var(--atlas-l); color: var(--atlas); font-weight: 600; }
.list-item.danger .badge { background: var(--rose-l); color: var(--rose); }

.list-item-mini {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--s1);
  border: 1px solid var(--b1);
  border-radius: var(--r);
  margin-bottom: 4px;
  font-size: 0.82rem;
  transition: background 0.12s;
}

.list-item-mini:hover { background: var(--s2); }
.list-item-mini b { color: var(--atlas); }

.backlog-scroll-container {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-right: 4px;
}

/* ── BADGES ──────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  background: var(--s2);
  border: 1px solid var(--b1);
  color: var(--t2);
  font-size: 0.73rem;
  font-weight: 600;
}

.badge.warning { background: var(--state-alert-l); color: var(--state-alert); border-color: rgba(196,122,26,0.25); }
.badge.danger  { background: var(--rose-l);  color: var(--rose);  border-color: var(--rose-b); }

/* ── BALANCE MINI ────────────────────────────────────────────── */
.balance-item { display: flex; align-items: center; gap: 10px; font-size: 0.87rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot.pm { background: var(--blue); }
.dot.wo { background: var(--mod-wo); }
.compact-balance { display: flex; flex-direction: column; gap: 7px; }
.balance-labels { display: flex; justify-content: space-between; font-size: 0.8rem; }
.multi-bar { height: 9px; background: var(--b1); border-radius: 5px; overflow: hidden; display: flex; }
.bar-part.wo { background: var(--mod-wo); }
.bar-part.pm { background: var(--blue); }

/* ── TIPS / RECOMMENDATIONS ──────────────────────────────────── */
.tips-container { padding: 6px; }

.recommendations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 11px;
  margin-top: 14px;
}

.tip-card {
  background: var(--s2);
  border: 1px solid var(--b1);
  border-radius: var(--r-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.tip-card:hover {
  border-color: rgba(0,0,0,0.13);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.tip-header { display: flex; justify-content: space-between; align-items: flex-start; }
.tip-id { display: flex; flex-direction: column; gap: 2px; }
.id-tag { font-weight: 700; color: var(--atlas); font-size: 1rem; }
.serial-tag { font-size: 0.73rem; color: var(--t3); font-family: 'Courier New', monospace; }
.tip-reason { font-size: 0.82rem; color: var(--t2); }

.move-action {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
  padding: 9px;
  background: var(--atlas-l);
  border-radius: var(--r);
  border-left: 2.5px solid var(--atlas-b);
}

.move-action .tech-name { font-weight: 600; }
.move-action .arrow { color: var(--atlas); font-size: 1rem; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--t3); }
.empty-state .icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* ── MAP ─────────────────────────────────────────────────────── */
.map-container { }
#map { background: #E8E6E0; }
.map-legend {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--t2);
}
.legend-item { display: flex; align-items: center; gap: 7px; }

/* Leaflet overrides — light mode */
.leaflet-container { background: #E8E6E0 !important; }
.leaflet-bar a {
  background-color: var(--s1) !important;
  color: var(--t1) !important;
  border-color: var(--b1) !important;
}
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--s1) !important;
  color: var(--t1) !important;
  border: 1px solid var(--b1);
  box-shadow: 0 4px 20px rgba(0,0,0,0.10) !important;
}
.marker-cluster-small     { background-color: rgba(122,96,64,0.20) !important; }
.marker-cluster-small div {
  background-color: rgba(122,96,64,0.60) !important;
  color: #fff !important;
  font-weight: 700 !important;
  font-family: var(--font) !important;
}

/* ── APP PM-WIDE ─────────────────────────────────────────────── */
.app-container.pm-wide { max-width: 1400px; }

/* ── PM MINI STATS ───────────────────────────────────────────── */
.pm-mini-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }

.pm-mini-stat {
  background: var(--mod-pm-l);
  border: 1px solid var(--mod-pm-b);
  border-radius: var(--r);
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 80px;
}

.pms-val { font-size: 1.5rem; font-weight: 800; color: var(--mod-pm); line-height: 1; letter-spacing: -0.5px; }
.pms-lbl { font-size: 0.68rem; color: var(--t3); white-space: nowrap; font-weight: 500; }

/* ── PM CONFIG ───────────────────────────────────────────────── */
.pm-config-block {
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--b1);
}
.pm-config-block:last-of-type { border-bottom: none; }
.pm-config-block h3 { font-size: 0.78rem; font-weight: 700; color: var(--mod-pm); margin-bottom: 10px; }
.pm-hint { font-size: 0.82rem; color: var(--t2); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.pm-holidays-row { display: flex; flex-wrap: wrap; gap: 6px; }

.pm-hol-pill {
  background: var(--rose-l);
  border: 1px solid var(--rose-b);
  color: var(--rose);
  font-size: 0.77rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}

.legend-pill { padding: 3px 10px; border-radius: var(--r-sm); font-size: 0.74rem; font-weight: 600; }
.absence-pill { background: rgba(99,102,241,0.10); color: #4338CA; }
.hol-pill     { background: var(--rose-l); color: var(--rose); }
.wknd-pill    { background: var(--s2); color: var(--t3); border: 1px solid var(--b1); }

/* ── PM RULES ────────────────────────────────────────────────── */
.pm-rules-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; }

.pm-rule-item {
  background: var(--s2);
  border: 1px solid var(--b1);
  border-radius: var(--r);
  padding: 9px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
}

.rule-icon { font-size: 1rem; }

/* ── PM ABSENCE TABLE ────────────────────────────────────────── */
.absence-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--b1);
  border-radius: var(--r);
}

.absence-table { border-collapse: collapse; font-size: 0.77rem; min-width: 100%; }
.absence-table thead tr { background: var(--s2); }
.absence-hdr {
  padding: 5px 3px;
  text-align: center;
  font-weight: 600;
  color: var(--t2);
  min-width: 28px;
  line-height: 1.3;
  border-bottom: 1px solid var(--b1);
  white-space: nowrap;
}
.absence-hdr div:first-child { font-size: 0.6rem; }
.absence-hdr div:last-child  { font-size: 0.8rem; color: var(--t1); }
.abs-hdr-wknd { opacity: 0.35; }
.abs-hdr-hol  { color: var(--rose); }

.absence-tech-name {
  padding: 5px 10px;
  white-space: nowrap;
  font-weight: 500;
  border-right: 1px solid var(--b1);
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.absence-cell { border: 1px solid transparent; height: 24px; transition: background 0.1s; }
.abs-cell-work    { cursor: pointer; background: rgba(58,122,80,0.05); }
.abs-cell-work:hover { background: rgba(99,102,241,0.08); }
.abs-cell-off     { background: repeating-linear-gradient(45deg, var(--b2), var(--b2) 3px, transparent 3px, transparent 6px); cursor: not-allowed; }
.abs-cell-absence { background: rgba(99,102,241,0.18) !important; position: relative; }
.abs-cell-absence::after {
  content: 'x';
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 0.6rem;
  color: #4338CA;
  font-weight: 700;
}

/* ── PM CALENDAR ─────────────────────────────────────────────── */
.pm-calendar-wrapper { display: flex; flex-direction: column; gap: 16px; }

.pm-cal-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 14px;
  background: var(--s1);
  border: 1px solid var(--b1);
  border-radius: var(--r-xl);
  padding: 20px 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.pm-cal-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pm-summary-row { display: flex; gap: 10px; flex-wrap: wrap; }

.pm-spill {
  flex: 1;
  min-width: 90px;
  border-radius: var(--r-lg);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border: 1px solid var(--b1);
}
.pm-spill.success { background: var(--sage-l);  border-color: var(--sage-b); }
.pm-spill.warning { background: var(--state-alert-l); border-color: rgba(196,122,26,0.25); }
.pm-spill.info    { background: var(--blue-l);  border-color: var(--blue-b); }
.spill-val { font-size: 1.5rem; font-weight: 700; color: var(--t1); line-height: 1; letter-spacing: -0.3px; }
.spill-lbl { font-size: 0.72rem; color: var(--t2); }

.pm-legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 16px;
  background: var(--s2);
  border-radius: var(--r);
  border: 1px solid var(--b1);
  font-size: 0.77rem;
  color: var(--t2);
}
.pm-leg-item { display: flex; align-items: center; gap: 5px; }
.pm-leg-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.pm-leg-dot.ideal   { background: rgba(58,122,80,0.55); }
.pm-leg-dot.light   { background: rgba(0,100,210,0.45); }
.pm-leg-dot.over    { background: rgba(184,50,53,0.55); }
.pm-leg-dot.absence { background: rgba(99,102,241,0.55); }
.pm-leg-dot.holiday { background: var(--b1); border: 1px solid var(--b1); }

/* ── PM TECH CARDS ───────────────────────────────────────────── */
#pm-tech-calendars { display: flex; flex-direction: column; gap: 18px; }

.pm-tech-card {
  background: var(--s1);
  border: 1px solid var(--b1);
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.pm-tech-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: var(--mod-pm-l);
  border-bottom: 1px solid var(--mod-pm-b);
  flex-wrap: wrap;
  gap: 8px;
}

.pm-tech-name { font-size: 0.95rem; font-weight: 700; color: var(--mod-pm); text-transform: none; letter-spacing: -0.1px; }

.pm-tech-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.pm-tbadge { padding: 2px 8px; border-radius: 14px; font-size: 0.72rem; font-weight: 600; }
.pm-tbadge.ok   { background: var(--sage-l);  color: var(--sage); }
.pm-tbadge.warn { background: var(--state-alert-l); color: var(--state-alert); }
.pm-tbadge.err  { background: var(--rose-l);  color: var(--rose); }

.pm-grid-dow { display: grid; grid-template-columns: repeat(7, 1fr); padding: 5px 10px 0; gap: 3px; }
.pm-dow-hdr {
  text-align: center;
  font-size: 0.63rem;
  font-weight: 700;
  color: var(--t3);
  padding: 3px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pm-month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; padding: 4px 10px 12px; }

.pm-day {
  border-radius: var(--r);
  padding: 5px;
  min-height: 66px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid transparent;
  position: relative;
}

.pm-day:not(.pm-day-off):not(.pm-day-abs):not(.pm-day-void):not(.pm-day-empty):hover {
  border-color: var(--b1);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.pm-day-num  { font-size: 0.7rem; font-weight: 700; color: var(--t2); }
.pm-day-tag  { font-size: 0.6rem; color: var(--t3); opacity: 0.8; }
.pm-day-hours {
  font-size: 0.63rem;
  font-weight: 700;
  color: var(--mod-pm);
  padding: 1px 4px;
  background: var(--mod-pm-l);
  border-radius: 3px;
  white-space: nowrap;
}

.pm-day-void  { background: transparent; border: none; min-height: 66px; }
.pm-day-off   { background: var(--b2); }
.pm-day-abs   { background: rgba(99,102,241,0.06); border-color: rgba(99,102,241,0.14); }
.pm-day-empty { background: var(--s3); border: 1px dashed rgba(0,0,0,0.06); }
.pm-day-ideal { background: rgba(58,122,80,0.06);  border-color: var(--sage-b); }
.pm-day-light { background: rgba(0,100,210,0.05);  border-color: var(--blue-b); }
.pm-day-over  { background: rgba(184,50,53,0.06);  border-color: var(--rose-b); }

.pm-chip {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 4px;
  border-radius: 4px;
  background: var(--s1);
  border: 1px solid var(--b1);
  cursor: default;
  transition: background 0.1s;
}
.pm-chip:hover { background: var(--s2); }

.chip-h      { font-size: 0.64rem; font-weight: 700; color: var(--mod-pm); }
.chip-serial { font-size: 0.58rem; font-family: 'Courier New', monospace; color: var(--blue); letter-spacing: 0.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-type   { font-size: 0.55rem; color: var(--t3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-loc    { font-size: 0.56rem; color: var(--t3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pm-unscheduled-panel {
  background: var(--rose-l);
  border: 1px solid var(--rose-b);
  border-radius: var(--r-lg);
  padding: 18px;
}
.pm-unscheduled-panel h3 { color: var(--rose); font-size: 0.72rem; margin-bottom: 7px; }

.pm-unsched-scroll {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--b1);
  border-radius: var(--r);
  margin-top: 11px;
}
.pm-unsched-scroll th { background: var(--s2); color: var(--mod-pm); font-size: 0.77rem; padding: 7px 10px; }
.pm-unsched-scroll td { padding: 6px 10px; font-size: 0.79rem; border-bottom: 1px solid var(--b1); color: var(--t1); }

/* ── BRAIN CHANGER (BAL) ─────────────────────────────────────── */
.bal-dashboard { display: flex; flex-direction: column; gap: 16px; }
.bal-stat-card { background: var(--s2); border: 1px solid var(--b1); border-left: 3px solid var(--mod-bal-b); border-radius: var(--r-lg); padding: 14px 10px; text-align: center; transition: box-shadow 0.15s, transform 0.15s; }
.bal-stat-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.07); transform: translateY(-1px); }
.bal-stat-val  { font-size: 1.7rem; font-weight: 800; line-height: 1.1; color: var(--t1); letter-spacing: -0.5px; }
.bal-stat-lbl  { font-size: 0.7rem; color: var(--t3); margin-top: 3px; font-weight: 500; }

.bal-freq-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(99,102,241,0.07);
  border: 1px solid rgba(99,102,241,0.16);
  border-radius: var(--r);
  padding: 10px 18px;
  min-width: 70px;
  flex: 1;
}
.bal-freq-val  { font-size: 1.3rem; font-weight: 700; color: #4F46E5; }
.bal-freq-lbl  { font-size: 0.7rem; color: var(--t3); margin-top: 2px; }

/* BAL heatmap cells — inline styled by pm_balancer.js */
/* (cells use var(--text-light) which we've mapped to --t1) */
.bal-hm-cell   { border-radius: var(--r); padding: 8px 3px; text-align: center; cursor: default; }
.bal-hm-month  { font-size: 0.64rem; font-weight: 700; color: var(--t2); text-transform: uppercase; letter-spacing: 0.5px; }
.bal-hm-val    { font-size: 0.88rem; font-weight: 700; color: var(--t1); margin-top: 2px; }

.bal-table-scroll { max-height: 380px; overflow-y: auto; border: 1px solid var(--b1); border-radius: var(--r); margin-top: 8px; }
.bal-table     { width: 100%; border-collapse: collapse; font-size: 0.79rem; }
.bal-table th  { background: var(--s2); color: #4F46E5; font-size: 0.73rem; padding: 9px 10px; text-align: left; position: sticky; top: 0; z-index: 5; }
.bal-table td  { padding: 7px 10px; border-bottom: 1px solid var(--b1); color: var(--t1); }
.bal-table tbody tr:hover { background: rgba(99,102,241,0.04); }
.bal-mo-pill   { display: inline-block; padding: 2px 6px; border-radius: 5px; font-size: 0.67rem; font-weight: 600; background: rgba(99,102,241,0.09); color: #4338CA; margin: 1px 2px; }

@media (max-width: 700px) { .bal-stats-row { grid-template-columns: repeat(3, 1fr); } }

/* ── CAT — CONFIG CARD ───────────────────────────────────────── */
.cat-config-card {
  background: var(--s1);
  border: 1px solid var(--b1);
  border-radius: var(--r-xl);
  padding: 24px;
  margin-bottom: 18px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* ── CAT — TECH GRID ─────────────────────────────────────────── */
.cat-tech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  margin: 16px 0;
}

.cat-tech-card {
  background: var(--s1);
  border: 1px solid var(--b1);
  border-radius: var(--r-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.cat-tech-card:hover {
  border-color: rgba(0,100,210,0.22);
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
}

.cat-tech-card.excluded { opacity: 0.45; border-color: var(--rose-b); }

/* ── CAT — EXCLUDED SECTION ──────────────────────────────────── */
.cat-excluded-section {
  margin-top: 28px;
  border-top: 1px dashed var(--b1);
  padding-top: 20px;
}
.cat-excluded-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.7px;
}
.cat-excluded-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cat-excluded-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--r-lg);
  border: 1px solid var(--b1);
  background: var(--s2);
  opacity: 0.75;
  transition: opacity 0.2s;
}
.cat-excluded-card:hover { opacity: 1; }

.cat-tech-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--b1);
  padding-bottom: 8px;
}

.cat-tech-name { font-weight: 700; color: var(--t1); font-size: 0.97rem; }
.cat-tech-code {
  font-family: 'Courier New', monospace;
  font-size: 0.73rem;
  color: var(--t3);
  background: var(--s2);
  padding: 2px 6px;
  border-radius: 4px;
}

.cat-tech-body { display: flex; flex-direction: column; gap: 9px; }
.cat-input-group { display: flex; flex-direction: column; gap: 4px; }
.cat-input-group label { font-size: 0.7rem; color: var(--t3); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }

.cat-text-input {
  background: var(--s3);
  border: 1px solid var(--b1);
  border-radius: var(--r-sm);
  color: var(--t1);
  padding: 7px 10px;
  font-family: var(--font);
  font-size: 0.86rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cat-text-input:focus { outline: none; border-color: var(--blue-b); box-shadow: 0 0 0 3px var(--blue-l); }

.cat-checkbox-group { display: flex; align-items: center; gap: 7px; font-size: 0.82rem; cursor: pointer; margin-top: 4px; }
.cat-checkbox-group input { cursor: pointer; width: 15px; height: 15px; accent-color: var(--mod-cat); }

.cat-dedicated-list {
  margin-top: 4px;
  max-height: 76px;
  overflow-y: auto;
  background: var(--s3);
  border-radius: var(--r-sm);
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cat-dedicated-tag {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--mod-cat-l);
  color: var(--mod-cat);
  border: 1px solid var(--mod-cat-b);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.67rem;
  font-weight: 600;
}

.cat-dedicated-tag button {
  background: none;
  border: none;
  color: var(--rose);
  cursor: pointer;
  font-size: 0.78rem;
  padding: 0 2px;
}

/* ── CAT — PROVINCE BADGES ───────────────────────────────────── */
.cat-prov-badge {
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  display: inline-block;
}

.cat-prov-badge.bcn   { background: var(--sage-l);  color: var(--sage);  border: 1px solid var(--sage-b); }
.cat-prov-badge.gi    { background: var(--blue-l);  color: var(--blue);  border: 1px solid var(--blue-b); }
.cat-prov-badge.tgn   { background: var(--mod-cat-l); color: var(--mod-cat); border: 1px solid var(--mod-cat-b); }
.cat-prov-badge.lld   { background: rgba(99,102,241,0.08); color: #4338CA; border: 1px solid rgba(99,102,241,0.18); }
.cat-prov-badge.bal   { background: rgba(219,39,119,0.07); color: #9D174D; border: 1px solid rgba(219,39,119,0.16); }
.cat-prov-badge.other { background: var(--rose-l); color: var(--rose); border: 1px solid var(--rose-b); }

/* ── CAT — ASSIGNMENT SELECTS ────────────────────────────────── */
select.cat-select-primary,
select.cat-select-backup { padding: 5px 8px; border-radius: var(--r-sm); font-size: 0.79rem; width: 100%; max-width: 160px; font-weight: 600; }

select.cat-select-primary             { background: var(--mod-cat-l); border-color: var(--mod-cat-b); color: var(--mod-cat); }
select.cat-select-primary.unassigned  { background: var(--rose-l) !important; border-color: var(--rose-b) !important; color: var(--rose) !important; }
select.cat-select-backup              { background: var(--blue-l);  border-color: var(--blue-b);  color: var(--blue); }
select.cat-select-backup.unassigned   { background: var(--s2); border-color: var(--b1); color: var(--t3); }

/* ── CAT — DASHBOARD LAYOUT ──────────────────────────────────── */
.cat-dashboard-layout { display: flex; gap: 20px; margin-top: 20px; align-items: flex-start; }
@media (max-width: 950px) { .cat-dashboard-layout { flex-direction: column; } .cat-sidebar { width: 100% !important; } }
.cat-main-content { flex: 1; display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.cat-sidebar { width: 300px; flex-shrink: 0; display: flex; flex-direction: column; gap: 14px; }

.cat-sidebar-card {
  background: var(--s1);
  border: 1px solid var(--b1);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.cat-sidebar-card h3 {
  font-size: 0.87rem;
  color: var(--mod-cat);
  margin-bottom: 11px;
  border-bottom: 1px solid var(--b1);
  padding-bottom: 7px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cat-sidebar-tech-row { display: flex; flex-direction: column; gap: 5px; padding: 8px 0; border-bottom: 1px solid var(--b1); }
.cat-sidebar-tech-row:last-child { border-bottom: none; }
.cat-tech-stats-labels { display: flex; justify-content: space-between; font-size: 0.8rem; font-weight: 600; }
.cat-tech-stats-labels .name           { color: var(--t1); }
.cat-tech-stats-labels .counts         { color: var(--t3); }
.cat-tech-stats-labels .counts span.primary-count { color: var(--mod-cat); }
.cat-tech-stats-labels .counts span.backup-count  { color: var(--blue); }

.cat-workload-bar-container { height: 7px; background: var(--b1); border-radius: 4px; overflow: hidden; display: flex; }
.cat-workload-fill { height: 100%; transition: width 0.3s ease; }
.cat-workload-fill.primary { background: var(--mod-cat); }
.cat-workload-fill.backup  { background: var(--blue); }

/* ── CAT — BAAN ──────────────────────────────────────────────── */
.cat-baan-log-container {
  background: var(--s2);
  border: 1px solid var(--b1);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-top: 11px;
}

.cat-baan-textarea {
  width: 100%;
  height: 170px;
  background: var(--s3);
  border: 1px solid var(--b1);
  border-radius: var(--r);
  color: var(--sage);
  font-family: 'Courier New', Courier, monospace;
  padding: 10px;
  font-size: 0.82rem;
  line-height: 1.55;
  resize: vertical;
  margin-top: 8px;
}
.cat-baan-textarea:focus { outline: none; border-color: var(--sage-b); box-shadow: 0 0 0 3px var(--sage-l); }

/* ── CAT — MAP POPUP ─────────────────────────────────────────── */
.cat-pin-popup { font-family: var(--font); color: var(--t1); display: flex; flex-direction: column; gap: 7px; }
.cat-pin-popup h4 { margin: 0; color: var(--mod-cat); border-bottom: 1px solid var(--b1); padding-bottom: 4px; font-size: 0.9rem; }
.cat-pin-popup p   { margin: 0; font-size: 0.77rem; line-height: 1.4; }
.cat-pin-popup .meta { font-size: 0.67rem; color: var(--t3); }

/* ── CAT — PROFILE BADGES ────────────────────────────────────── */
.cat-profile-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 10px; border: 1px solid; letter-spacing: 0.3px; }
.cat-profile-lead   { background: var(--mod-cat-l); color: var(--mod-cat); border-color: var(--mod-cat-b); }
.cat-profile-expert { background: var(--blue-l);  color: var(--blue);  border-color: var(--blue-b); }
.cat-profile-met    { background: var(--slate-l); color: var(--slate); border-color: var(--slate-b); }
.cat-profile-std    { background: var(--s2);      color: var(--t3);    border-color: var(--b1); }
.cat-profile-bat    { background: var(--sage-l);  color: var(--sage);  border-color: var(--sage-b); }
.cat-profile-tal    { background: var(--rose-l);  color: var(--rose);  border-color: var(--rose-b); }

/* ── CAT — LOAD TAGS ─────────────────────────────────────────── */
.cat-load-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: var(--r); }
.cat-load-high { background: var(--rose-l);  color: var(--rose);  border: 1px solid var(--rose-b); }
.cat-load-med  { background: var(--state-alert-l); color: var(--state-alert); border: 1px solid rgba(196,122,26,0.25); }
.cat-load-low  { background: var(--sage-l);  color: var(--sage);  border: 1px solid var(--sage-b); }

/* ── CAT — RESIDENT DOTS ─────────────────────────────────────── */
.cat-res-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; flex-shrink: 0; margin-right: 3px; }
.cat-res-p { background: var(--mod-cat); }
.cat-res-s { background: var(--slate); }
.cat-res-t { background: var(--t4); }

/* ── CAT — WHATSAPP BUTTON ───────────────────────────────────── */
.btn-wa {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--sage-l);
  color: var(--sage);
  border: 1px solid var(--sage-b);
  padding: 5px 11px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
}
.btn-wa:hover { background: rgba(58,122,80,0.14); border-color: rgba(58,122,80,0.28); }

/* ── CAT — RESIDENTS GRID ────────────────────────────────────── */
.cat-residents-grid { display: flex; flex-direction: column; gap: 4px; }
.cat-resident-row { display: flex; align-items: center; gap: 6px; }
.cat-resident-label { font-size: 9px; font-weight: 700; color: var(--t3); text-transform: uppercase; letter-spacing: 0.4px; min-width: 34px; flex-shrink: 0; }
.cat-resident-row select { flex: 1; padding: 4px 6px; font-size: 0.73rem; border-radius: var(--r-sm); background: var(--s3); border: 1px solid var(--b1); color: var(--t1); min-width: 0; }
.cat-resident-pct { display: none; }  /* Ocultar — info interna del algoritmo, no relevante para el usuario */

/* ── CAT — WORKLOAD BAR V2 ───────────────────────────────────── */
.cat-workload-bar-v2 { height: 4px; background: var(--b1); border-radius: 3px; overflow: hidden; margin-top: 3px; }
.cat-workload-fill-v2 { height: 100%; border-radius: 3px; transition: width 0.35s ease; }
.cat-workload-fill-v2.high { background: var(--rose); }
.cat-workload-fill-v2.med  { background: var(--state-alert); }
.cat-workload-fill-v2.low  { background: var(--sage); }

/* ── CAT — NO COVERAGE ───────────────────────────────────────── */
.cat-no-coverage-row { background: rgba(184,50,53,0.03) !important; }
.cat-no-coverage-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--rose-l);
  color: var(--rose);
  border: 1px solid var(--rose-b);
  padding: 2px 7px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 700;
}

/* ── CAT — EXPORT TABS ───────────────────────────────────────── */
.cat-export-tabs { display: flex; gap: 4px; margin-bottom: 11px; }
.cat-export-tab {
  flex: 1;
  padding: 7px;
  border-radius: var(--r);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--b1);
  background: var(--s2);
  color: var(--t2);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.cat-export-tab.active { background: var(--mod-cat-l); border-color: var(--mod-cat-b); color: var(--mod-cat); }

/* ── CAT — POOL BANNER ───────────────────────────────────────── */
.cat-pool-banner {
  background: var(--rose-l);
  border: 1px solid var(--rose-b);
  border-radius: var(--r);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  margin-bottom: 13px;
}
.cat-pool-banner strong { color: var(--rose); }

/* ── CAT — MODE BADGE ────────────────────────────────────────── */
.cat-mode-badge { display: inline-block; font-size: 10px; font-weight: 800; padding: 2px 5px; border-radius: 4px; letter-spacing: 0.5px; }
.cat-mode-m { background: rgba(196, 170, 130, 0.22); color: #C4AA82; border: 1px dashed #C4AA82; } /* C1 · pin manual */
.cat-mode-a { background: var(--blue-l);  color: var(--blue); }
.cat-mode-b { background: var(--mod-cat-l); color: var(--mod-cat); }
.cat-mode-c { background: var(--rose-l);  color: var(--rose); }
.cat-mode-d { background: var(--sage-l);  color: var(--sage); }

/* ── CAT — PROFILE SELECT ────────────────────────────────────── */
.cat-profile-select {
  background: var(--s3);
  border: 1px solid var(--b1);
  border-radius: var(--r-sm);
  color: var(--t1);
  padding: 6px 8px;
  font-family: var(--font);
  font-size: 0.79rem;
  width: 100%;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cat-profile-select:focus { outline: none; border-color: var(--mod-cat-b); box-shadow: 0 0 0 3px var(--mod-cat-l); }

/* ── CAT — RECALC FLASH ──────────────────────────────────────── */
.cat-recalc-flash { animation: catFlash 0.4s ease; }
@keyframes catFlash { 0% { background: var(--mod-cat-l); } 100% { background: transparent; } }

/* ── CAT — STAT PROFILE ──────────────────────────────────────── */
.cat-stat-perfil { font-size: 0.67rem; color: var(--t3); margin-top: 3px; font-style: italic; }

/* ── STYLE_CALENDAR.CSS OVERRIDES ────────────────────────────── */
/* style_calendar.css loads dynamically after this file, so we    */
/* use !important on dark-hardcoded values to enforce light mode. */
.calendar-container             { background: var(--s2) !important; }
table th                        { background: var(--s2) !important; color: var(--atlas) !important; }
table tr:hover                  { background: var(--b2) !important; }
.status-pill.planned            { background: var(--sage-l)  !important; color: var(--sage)  !important; }
.status-pill.overflow           { background: var(--rose-l)  !important; color: var(--rose)  !important; }
.status-pill.pending            { background: var(--state-alert-l) !important; color: var(--state-alert) !important; }

/* ── DARK MODE OVERRIDES ─────────────────────────────────────── */

/* Cards: softer shadow in dark mode */
[data-theme="dark"] .card {
  box-shadow: 0 1px 3px rgba(0,0,0,0.30), 0 8px 24px rgba(0,0,0,0.22),
              inset 0 1px 0 rgba(255,255,255,0.05);
}

/* Buttons: dark text on bright brand bg for legibility */
[data-theme="dark"] .btn-primary,
[data-theme="dark"] .mode-btn.active,
[data-theme="dark"] .btn-tab.active {
  color: #1C1C1E;
}

/* B214 — Dark mode también sin textura de ruido: fondo plano. */
[data-theme="dark"] body {
  background-image: none;
}

/* Leaflet map in dark mode */
[data-theme="dark"] #map,
[data-theme="dark"] .leaflet-container { background: #1a1a1e !important; }
[data-theme="dark"] .leaflet-bar a {
  background-color: var(--s2) !important;
  color: var(--t1) !important;
  border-color: var(--b1) !important;
}
[data-theme="dark"] .leaflet-popup-content-wrapper,
[data-theme="dark"] .leaflet-popup-tip {
  background: var(--s1) !important;
  color: var(--t1) !important;
  border-color: var(--b1) !important;
}
[data-theme="dark"] .marker-cluster-small { background-color: rgba(196,164,106,0.18) !important; }
[data-theme="dark"] .marker-cluster-small div {
  background-color: rgba(196,164,106,0.55) !important;
  color: #1C1C1E !important;
}

/* Indigo/purple hardcoded accents → lighter in dark mode */
[data-theme="dark"] .bal-freq-val            { color: #818CF8; }
[data-theme="dark"] .bal-table th            { color: #818CF8 !important; }
[data-theme="dark"] .bal-mo-pill             { background: rgba(129,140,248,0.12); color: #818CF8; }
[data-theme="dark"] .bal-table tbody tr:hover { background: rgba(129,140,248,0.05); }
[data-theme="dark"] .cat-prov-badge.lld      { background: rgba(129,140,248,0.12); color: #818CF8; border-color: rgba(129,140,248,0.25); }
[data-theme="dark"] .absence-pill            { background: rgba(129,140,248,0.14); color: #818CF8; }
[data-theme="dark"] .abs-cell-absence        { background: rgba(129,140,248,0.18) !important; }
[data-theme="dark"] .abs-cell-absence::after { color: #818CF8; }
[data-theme="dark"] .abs-cell-work:hover     { background: rgba(129,140,248,0.10); }
[data-theme="dark"] .legend-pill.absence-pill { background: rgba(129,140,248,0.14); color: #818CF8; }

/* ── SMOOTH THEME TRANSITION ─────────────────────────────────── */
/* Applied briefly via JS when toggling, then removed */
.theme-transitioning body,
.theme-transitioning .card,
.theme-transitioning .mode-selector,
.theme-transitioning .mode-btn,
.theme-transitioning .btn-primary,
.theme-transitioning .btn-secondary,
.theme-transitioning .btn-tab,
.theme-transitioning .stat-card,
.theme-transitioning .card-inner,
.theme-transitioning .drop-zone,
.theme-transitioning select,
.theme-transitioning input,
.theme-transitioning .header-aging,
.theme-transitioning .pm-tech-header,
.theme-transitioning .theme-toggle {
  transition: background-color 0.25s ease, border-color 0.2s ease, color 0.15s ease, box-shadow 0.25s ease !important;
}

/* ── TABLET BREAKPOINT ───────────────────────────────────────── */
@media (min-width: 601px) and (max-width: 900px) {
  body { padding: 20px 18px; }
  .app-container { gap: 16px; }
  .mode-selector { padding: 4px; gap: 3px; }
  .mode-btn { padding: 9px 14px; font-size: 0.82rem; }
  .stats-grid { grid-template-columns: repeat(5, 1fr); gap: 8px; }
  .stat-value { font-size: 1.7rem; }
  .card { padding: 22px 20px; }
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
  .cat-tech-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── FOCUS RING (accesibilidad) ──────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--atlas);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
:focus:not(:focus-visible) { outline: none; }

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 600px) {
  body { padding: 16px 14px; }
  .app-container { gap: 14px; }
  header { padding: 14px 0 4px; }
  .theme-toggle { top: 14px; padding: 6px 9px; font-size: 1rem; }
  .logo { font-size: 1.3rem !important; }
  .subtitle { font-size: 0.72rem; }

  .mode-selector {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    max-width: 100%;
    border-radius: var(--r);
    padding: 3px;
    justify-content: flex-start;
  }
  .mode-selector::-webkit-scrollbar { display: none; }
  .mode-btn { padding: 7px 12px; font-size: 0.79rem; white-space: nowrap; flex-shrink: 0; }

  .card { padding: 18px 15px; }
  h2 { font-size: 1.1rem; }

  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat-value { font-size: 1.55rem; }

  .drop-zone { padding: 34px 16px; gap: 8px; }
  .drop-zone .icon { font-size: 2rem; }

  .mapping-grid { grid-template-columns: 1fr 1fr; }

  .action-footer { flex-direction: column; }
  .action-footer button { width: 100%; }

  .dashboard-actions { gap: 8px; }
  .dashboard-actions button { font-size: 0.8rem; padding: 8px 12px; }

  .dashboard-grid { grid-template-columns: 1fr; }

  .cat-tech-grid { grid-template-columns: 1fr; }
  .cat-dashboard-layout { flex-direction: column; }
  .cat-sidebar { width: 100% !important; }
}

@media (max-width: 420px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .mapping-grid { grid-template-columns: 1fr; }
  .mode-btn { padding: 6px 10px; font-size: 0.75rem; }
}

/* ── REDUCED MOTION ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   BRAND REFRESH v5 — Terracota + Bricolage Grotesque (B50)
   Fuentes cargadas en index.html (ver comentario Output 2).
   No se elimina ningun token anterior — solo se redefinen
   --cream, --cream-l, --cream-b, --font y se añaden nuevos.
   ============================================================ */

/* ── FUENTE PRINCIPAL — Bricolage Grotesque ──────────────────── */
:root {
  --font: 'Bricolage Grotesque', -apple-system, BlinkMacSystemFont,
          'Helvetica Neue', Arial, sans-serif;
  --font-serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;

  /* ── Acento Terracota light — #C0542A sobre #FFFFFF: CR 4.73:1 AA */
  --cream:         #C0542A;
  --cream-l:       rgba(192, 84, 42, 0.09);
  --cream-b:       rgba(192, 84, 42, 0.22);
  --primary:       var(--cream);
  --primary-hover: #9C4020;

  /* ── Semánticos nuevos ───────────────────────────────────────── */
  /* --ok verde terroso: #3D6B45 sobre #FFF -> 5.1:1 AA           */
  --ok:       #3D6B45;
  --ok-l:     rgba(61, 107, 69, 0.10);
  --ok-b:     rgba(61, 107, 69, 0.22);
  /* --warn ambar oscuro: #9A6200 sobre #FFF -> 5.4:1 AA          */
  --warn:     #9A6200;
  --warn-l:   rgba(154, 98, 0, 0.09);
  --warn-b:   rgba(154, 98, 0, 0.22);
  /* --danger rojo terroso: #B0321E sobre #FFF -> 5.2:1 AA        */
  --danger:   #B0321E;
  --danger-l: rgba(176, 50, 30, 0.09);
  --danger-b: rgba(176, 50, 30, 0.22);
  /* --info azul pizarra: #2D5FA0 sobre #FFF -> 5.0:1 AA          */
  --info:     #2D5FA0;
  --info-l:   rgba(45, 95, 160, 0.09);
  --info-b:   rgba(45, 95, 160, 0.22);
}

/* ── Terracota dark — #D2643A sobre #2C2C2E: CR 5.18:1 AA ───── */
[data-theme="dark"] {
  --cream:         #D2643A;
  --cream-l:       rgba(210, 100, 58, 0.13);
  --cream-b:       rgba(210, 100, 58, 0.30);
  --primary-hover: #E27A50;

  /* Semánticos dark — subidos de luminosidad para contraste      */
  --ok:       #52C46A;  /* sobre #2C2C2E -> 5.3:1 */
  --ok-l:     rgba(82, 196, 106, 0.11);
  --ok-b:     rgba(82, 196, 106, 0.24);
  --warn:     #F5A623;  /* sobre #2C2C2E -> 7.1:1 */
  --warn-l:   rgba(245, 166, 35, 0.11);
  --warn-b:   rgba(245, 166, 35, 0.25);
  --danger:   #F06040;  /* sobre #2C2C2E -> 4.7:1 */
  --danger-l: rgba(240, 96, 64, 0.11);
  --danger-b: rgba(240, 96, 64, 0.24);
  --info:     #60A0E8;  /* sobre #2C2C2E -> 5.1:1 */
  --info-l:   rgba(96, 160, 232, 0.11);
  --info-b:   rgba(96, 160, 232, 0.24);
}

/* ── Cifras tabulares (stat cards, tablas) ───────────────────── */
.tabular { font-variant-numeric: tabular-nums; }

/* ── Titulos de seccion con serif ────────────────────────────── */
h2 {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ── Command palette item activo ─────────────────────────────── */
.cp-item-active { background: var(--atlas-l) !important; }

/* ── Paneles colapsables (briefing) ──────────────────────────── */
.brief-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  background: var(--s2);
  cursor: pointer;
  user-select: none;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.brief-panel-icon {
  font-size: 0.85rem;
  color: var(--t3);
  transition: transform 0.22s ease-out;
  flex-shrink: 0;
}
.brief-panel-body {
  padding: 16px;
}

/* ── Home dock ───────────────────────────────────────────────── */
#home-dock { margin-bottom: 20px; }

/* ── Header: boton Cmd+K ─────────────────────────────────────── */
.cmd-palette-btn {
  position: absolute;
  top: 18px;
  left: 0;
  background: transparent;
  border: 1px solid var(--b1);
  border-radius: var(--r);
  padding: 7px 10px;
  cursor: pointer;
  color: var(--t3);
  font-size: 0.78rem;
  font-family: var(--font);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.cmd-palette-btn:hover { background: var(--b2); color: var(--t1); border-color: var(--atlas-b); }
.cmd-palette-btn:focus-visible { outline: 2px solid var(--atlas); outline-offset: 2px; }
.cmd-palette-btn kbd {
  font-size: 0.65rem;
  background: var(--s3);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: 'Courier New', monospace;
  line-height: 1.4;
}
@media (max-width: 600px) { .cmd-palette-btn { display: none; } }

/* ── SKIP TO CONTENT (accesibilidad) ─────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--atlas);
  color: #fff;
  padding: 8px 16px;
  border-radius: 0 0 var(--r) var(--r);
  font-weight: 700;
  font-size: 0.85rem;
  z-index: 9999;
  text-decoration: none;
  transition: top 0.2s;
}
.skip-link:focus { top: 0; }

/* ══════════════════════════════════════════════════════════════════════
   CONTROL TOWER B51 — topbar · navscreen · home hero · octaedro
   ══════════════════════════════════════════════════════════════════════ */

/* Tokens adicionales (dark surface) */
:root {
  --ct-dark:    #0A0A0A;
  --ct-od1:     rgba(255,255,255,.92);
  --ct-od2:     #B8B0A6;
  --ct-od3:     #8C857C;
  --ct-hl:      rgba(255,255,255,.16);
  --font-display: 'Bricolage Grotesque','Inter',-apple-system,sans-serif;
  --ct-ease:    cubic-bezier(0.16,1,0.3,1);
}

/* ── Header layout ──────────────────────────────────────────────────── */
header { display: flex; flex-direction: column; padding: 0; gap: 0; }

/* ── Home hero header con octaedro ──────────────────────────────────── */
.home-hero-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 16px;
  padding: 18px 22px 14px;
  background: var(--ct-dark);
  border-radius: var(--r-xl, 20px);
  border: 1px solid var(--ct-hl);
}
.home-hero-text  { flex: 1 1 auto; }
.home-hero-sub .build-badge { color: var(--atlas); font-weight: 700; }

/* ══════════════════════════════════════════════════════════════════════
   ROLE MASK B53 — visibilidad CSS por rol (presentación pura, no datos)
   ATLAS calcula igual con cualquier rol. Solo se ocultan/muestran elementos.
   ══════════════════════════════════════════════════════════════════════ */

/* Técnico: sin scores individuales comparativos ni métricas de otros */
[data-role="technician"] .tech-score-badge,
[data-role="technician"] .perf-comparison,
[data-role="technician"] .all-techs-view,
[data-role="technician"] .atlas-rank-table,
[data-role="technician"] .global-kpi-panel { display: none !important; }

/* Battery man: mostrar solo filtros de batería */
[data-role="battery"] .wo-battery-filter { display: block !important; }
[data-role="battery"] .wo-std-filter      { display: none  !important; }

/* Taller: mostrar solo filtros de workshop */
[data-role="workshop"] .wo-workshop-filter { display: block !important; }
[data-role="workshop"] .wo-std-filter       { display: none  !important; }

/* Viewer (solo lectura): sin acciones de escritura */
[data-role="viewer"] .action-btn-primary,
[data-role="viewer"] .export-btn          { pointer-events: none; opacity: .45; }

/* Lead: acceso completo excepto datos sensibles de técnicos ajenos */
[data-role="lead"] .sensitive-tech-data   { display: none !important; }

/* Manager: acceso total (no se oculta nada) */

/* ══════════════════════════════════════════════════════════════════════
   HYBRID TOKENS B55 — sistema de diseño proyecto-beta × ATLAS
   ══════════════════════════════════════════════════════════════════════ */

/* Paleta de datos para gráficos ATLAS (ported de oklch proyecto-beta) */
:root {
  --ct-data:    #4A90D9;   /* sky — series principales */
  --ct-data-2:  #3BADA8;   /* teal — series secundarias */
  --ct-data-3:  #7B6FD4;   /* indigo — series terciarias */

  /* Motion tokens */
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-expo:  cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring:    cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-in-out:    cubic-bezier(0.45, 0, 0.55, 1);
  --dur-fast:  120ms;
  --dur-base:  220ms;
  --dur-slow:  400ms;
  --ease-snappy:    cubic-bezier(0.3, 0, 0.2, 1);
  --ease-back-soft: cubic-bezier(0.34, 1.26, 0.64, 1);
  --dur-instant: 80ms;
  --dur-panel:   420ms;
}

/* ── Breadcrumb en topbar ──────────────────────────────────────────── */
#ct-breadcrumb {
  font-family: var(--font-display);
  font-size: .7rem; font-weight: 500;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--ct-od3);
  background: var(--ct-dark);
  padding: 0 .5em;
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  max-width: clamp(80px,18vw,200px);
  transition: color var(--dur-base) var(--ease-out-quart);
}
@media (max-width: 480px) { #ct-breadcrumb { display: none; } }

/* ── Navscreen overlay (B201) ──────────────────────────────────────── */
#ct-navscreen {
  position: fixed;
  top: 44px; left: 0; right: 0; bottom: 0;
  z-index: 180;
  background: var(--ct-dark, #0A0A0A);
  display: flex; flex-direction: column;
  padding: clamp(32px,6vh,56px) clamp(20px,6vw,72px) clamp(24px,4vh,40px);
  overflow-y: auto;
  clip-path: inset(0 0 100% 0);
  transition: clip-path .45s var(--ct-ease, cubic-bezier(0.16,1,0.3,1));
  pointer-events: none;
}
#ct-navscreen.open {
  clip-path: inset(0);
  pointer-events: auto;
}
.ct-navscreen__inner {
  flex: 1; display: flex; flex-direction: column; max-width: 540px;
}
.ct-navscreen__list {
  list-style: none; margin: 0; padding: 0;
  flex: 1; display: flex; flex-direction: column;
  justify-content: center;
}
.ct-navscreen__item {
  border-bottom: 1px solid var(--ct-hl, rgba(255,255,255,.12));
  opacity: 0; transform: translateY(12px);
  transition: opacity .35s var(--ct-ease), transform .35s var(--ct-ease);
}
.ct-navscreen__item:first-child {
  border-top: 1px solid var(--ct-hl, rgba(255,255,255,.12));
}
#ct-navscreen.open .ct-navscreen__item {
  opacity: 1; transform: translateY(0);
}
#ct-navscreen.open .ct-navscreen__item:nth-child(1) { transition-delay: .05s; }
#ct-navscreen.open .ct-navscreen__item:nth-child(2) { transition-delay: .10s; }
#ct-navscreen.open .ct-navscreen__item:nth-child(3) { transition-delay: .15s; }
#ct-navscreen.open .ct-navscreen__item:nth-child(4) { transition-delay: .20s; }
#ct-navscreen.open .ct-navscreen__item:nth-child(5) { transition-delay: .25s; }
#ct-navscreen.open .ct-navscreen__item:nth-child(6) { transition-delay: .30s; }
#ct-navscreen.open .ct-navscreen__item:nth-child(7) { transition-delay: .35s; }
@media (prefers-reduced-motion: reduce) {
  .ct-navscreen__item { opacity: 1 !important; transform: none !important; transition: none !important; }
}
.ct-navscreen__link {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 4px;
  text-decoration: none;
  color: var(--ct-od1, rgba(255,255,255,.92));
  font-family: var(--font-display, 'Bricolage Grotesque', sans-serif);
  font-size: clamp(1.1rem, 3.5vw, 2rem);
  font-weight: 700; letter-spacing: -.02em;
  transition: color .2s var(--ct-ease), padding-left .2s var(--ct-ease);
}
.ct-navscreen__link:hover,
.ct-navscreen__link:focus-visible {
  color: var(--atlas, #C0542A);
  padding-left: 10px;
  outline: none;
}
.ct-navscreen__num {
  font-size: clamp(.48rem, 1vw, .64rem);
  font-weight: 700; letter-spacing: .18em; text-transform: uppercase;
  color: var(--ct-od3, #8C857C); flex-shrink: 0;
  align-self: flex-start; margin-top: .55em;
  min-width: 22px;
}
.ct-navscreen__label { flex: 1; }

/* Menu button icon swap */
#ctMenuBtn .ct-menu-icon--close { display: none; }
#ctMenuBtn.is-open .ct-menu-icon--open  { display: none; }
#ctMenuBtn.is-open .ct-menu-icon--close { display: inline-block; }

/* Active module highlight in navscreen */
.ct-navscreen__link[aria-current="page"] {
  color: var(--atlas, #C0542A);
}
.ct-navscreen__link[aria-current="page"] .ct-navscreen__num {
  color: var(--atlas, #C0542A); opacity: .7;
}

/* ── Status badges en navscreen ────────────────────────────────────── */
.ct-nav-badge {
  display: inline-flex; align-items: center;
  font-family: var(--font-display); font-size: .58rem;
  font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 20px; margin-left: auto; flex-shrink: 0;
}
.ct-nav-badge[data-badge-type="live"] {
  background: rgba(61,142,90,.18); color: #4CAF6B;
  box-shadow: 0 0 0 0 rgba(61,142,90,.4);
  animation: ctBadgePulse 2.4s ease-in-out infinite;
}
.ct-nav-badge[data-badge-type="soon"] {
  background: rgba(255,255,255,.08); color: var(--ct-od3);
}
.ct-nav-badge[data-badge-type="beta"] {
  background: rgba(196,122,26,.18); color: #E8941A;
}
@keyframes ctBadgePulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(61,142,90,.3); }
  50%      { box-shadow: 0 0 0 4px rgba(61,142,90,.0); }
}

/* ── Tools footer en navscreen ─────────────────────────────────────── */
.ct-navscreen__tools {
  display: flex; align-items: center; gap: 4px;
  padding: 16px 0 0;
  border-top: 1px solid var(--ct-hl);
  margin-top: 16px;
}
.ct-navscreen__tools-label {
  font-family: var(--font-display); font-size: .6rem;
  font-weight: 600; letter-spacing: .22em; text-transform: uppercase;
  color: var(--ct-od3); margin-right: 4px;
}
.ct-tool-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 10px;
  color: var(--ct-od3); text-decoration: none;
  transition: color var(--dur-fast), background var(--dur-fast);
  flex-shrink: 0;
}
.ct-tool-btn:hover { color: #fff; background: rgba(255,255,255,.09); }
.ct-tool-btn .ti  { font-size: 1.25rem; }

/* ── Quick Actions para técnicos (home section) ─────────────────────── */
.ct-qa-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px; margin-bottom: 18px;
}
.ct-qa-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 5px;
  padding: 16px 16px 14px;
  background: var(--s2); border: 1.5px solid var(--b1);
  border-radius: var(--r-lg, 14px); cursor: pointer;
  text-align: left; transition: background var(--dur-fast),
    border-color var(--dur-fast), transform var(--dur-fast) var(--ease-spring);
  min-height: 88px;
}
.ct-qa-btn:hover {
  background: var(--s3); border-color: var(--atlas-b);
  transform: translateY(-1px);
}
.ct-qa-btn:active { transform: translateY(0); }
.ct-qa-btn .ti { font-size: 1.5rem; }
.ct-qa-label { font-size: clamp(0.82rem, 1.6vw, 0.92rem); font-weight: 700; color: var(--t1); line-height: 1.2; }
.ct-qa-sub   { font-size: clamp(0.66rem, 1.2vw, 0.76rem); color: var(--t3); line-height: 1.3; }

/* ── WhatsApp button en topbar ─────────────────────────────────────── */
.comms-wa-btn {
  position: relative;
  color: rgba(255,255,255,.45) !important;
}
.comms-wa-btn:hover { color: #25D366 !important; }
.comms-wa-dot {
  position: absolute; top: 6px; right: 6px;
  width: 7px; height: 7px; border-radius: 50%;
  background: #25D366;
  box-shadow: 0 0 0 1.5px var(--ct-dark,#0A0A0A);
}

/* ── Page header component ─────────────────────────────────────────── */
.ct-page-header {
  margin-bottom: 18px; padding-bottom: 14px;
  border-bottom: 1px solid var(--b1);
}
.ct-page-header__title {
  font-family: var(--font-display);
  font-size: clamp(1.1rem,2.2vw,1.5rem);
  font-weight: 760; letter-spacing: -.015em;
  color: var(--t1); margin: 0 0 .2em;
}
.ct-page-header__sub {
  font-size: .78rem; color: var(--t3); margin: 0; line-height: 1.5;
}

/* ══════════════════════════════════════════════════════════════════════
   SHORTCUTS OVERLAY B57
   ══════════════════════════════════════════════════════════════════════ */
/* (estilos inline en shortcuts_overlay.js — sin CSS externo necesario) */

/* ══════════════════════════════════════════════════════════════════════
   MOBILE NAV B58 — bottom navigation bar (≤768px)
   ══════════════════════════════════════════════════════════════════════ */

/* Ocultar mode-selector en móvil (reemplazado por bottom nav) */
@media (max-width: 768px) {
  .mode-selector { display: none !important; }
}

/* Espacio para bottom nav (B244 — altura 64px) */
@media (max-width: 768px) {
  #main-content {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }
}

/* ══════════════════════════════════════════════════════════════════════
   ATLAS WIDGET B59 — métricas en tiempo real en home
   ══════════════════════════════════════════════════════════════════════ */
.atlas-widget {
  margin-bottom: 16px;
  border-radius: var(--r-lg, 14px);
  border: 1px solid var(--b1);
  overflow: hidden;
  background: var(--s1);
}
.atlas-widget--loaded { background: var(--s2); }

.aw-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px 8px;
  border-bottom: 1px solid var(--b1);
}
.aw-header-title {
  font-family: var(--font-display); font-size: .68rem;
  font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
  color: var(--t3);
}
.aw-live-badge {
  font-size: .6rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  background: var(--state-ok-l); color: var(--state-ok);
  padding: 2px 8px; border-radius: 20px;
  animation: ctBadgePulse 2.4s ease-in-out infinite;
}

.aw-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 0;
}
.aw-cell {
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 8px 10px;
  border-right: 1px solid var(--b1);
  text-align: center;
  transition: background var(--dur-fast);
}
.aw-cell:last-child { border-right: none; }
.aw-cell:hover { background: var(--s3); }

.aw-val {
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.5vw, 1.35rem);
  font-weight: 760; letter-spacing: -.02em;
  line-height: 1.1; color: var(--t1);
  transition: color .3s;
}
.aw-lbl {
  font-size: .65rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--t3); margin-top: 3px;
}
.aw-sub {
  font-size: .62rem; color: var(--t3); margin-top: 1px; opacity: .7;
}

.aw-empty {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px;
  font-size: .8rem; color: var(--t3);
}
.aw-empty .ti { font-size: 1rem; }

/* ══════════════════════════════════════════════════════════════════════
   B60 — Control Tower deepening + mascota + topbar bigger buttons
   ════════════════════════════════════════════════════════════════════ */

/* Topbar right cluster */
.ct-topbar__actions {
  display: flex; align-items: center; gap: 4px;
}

/* Theme switch: smooth CSS-property crossfade */
html.theme-transitioning,
html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
  transition:
    background-color 240ms ease-out,
    border-color     240ms ease-out,
    color            200ms ease-out,
    box-shadow       240ms ease-out !important;
}

/* Generic topbar icon button (bell, etc.) */
.topbar-icon-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--t3);
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  font-size: 0.95rem;
  position: relative;
  transition: background 0.14s, color 0.14s;
}
.topbar-icon-btn:hover { background: rgba(255,255,255,0.09); color: var(--t1); }
[data-theme="light"] .topbar-icon-btn:hover { background: rgba(0,0,0,0.06); }

.topbar-badge {
  position: absolute; top: 3px; right: 3px;
  min-width: 14px; height: 14px;
  background: var(--state-critical);
  color: #fff;
  border-radius: 7px;
  font-size: 0.48rem; font-weight: 800;
  padding: 0 2px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  animation: badgePop 0.22s cubic-bezier(0.34,1.56,0.64,1) 1;
}

/* Theme toggle button */
.theme-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--t3);
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  font-size: 0.95rem;
  transition: background 0.14s, color 0.14s;
}
.theme-toggle:hover {
  background: rgba(255,255,255,0.09);
  color: var(--t1);
}
[data-theme="light"] .theme-toggle:hover {
  background: rgba(0,0,0,0.06);
}

/* Cmd palette & theme toggle: match bigger topbar button targets */
.ct-topbar__actions .cmd-palette-btn,
.ct-topbar__actions .theme-toggle {
  min-width: 44px !important; min-height: 44px !important;
  border-radius: 10px !important;
}
.ct-topbar__actions .cmd-palette-btn:hover,
.ct-topbar__actions .theme-toggle:hover {
  background: rgba(255,255,255,.09) !important;
}

/* Topbar: deeper CT feel — slightly more opaque */
.ct-topbar {
  background: rgba(6,5,4,.98) !important;
  box-shadow: 0 1px 0 rgba(255,255,255,.07), 0 4px 20px rgba(0,0,0,.4) !important;
}

/* Navscreen logout button */
.ct-tool-btn--logout { margin-left: auto; }

/* CT sections: slightly darker surfaces in dark mode */
[data-theme="dark"] .card {
  background: rgba(14,12,10,.97) !important;
}
[data-theme="dark"] #home-section {
  background: rgba(10,10,10,1) !important;
  border: 1px solid rgba(192,84,42,.12) !important;
}

@media (max-width: 520px) {
  .home-hero-header { flex-direction: column-reverse; align-items: flex-start; }
}

/* ══════════════════════════════════════════════════════════════════════
   B68 — Tokens semánticos por módulo + transiciones de sección
   ══════════════════════════════════════════════════════════════════════ */

/* Módulos ATLAS — aliases de --atlas (todos los módulos usan el mismo acento) */
:root {
  --mod-home: var(--atlas); --mod-home-l: var(--atlas-l); --mod-home-b: var(--atlas-b);
  --mod-wo:   var(--atlas); --mod-wo-l:   var(--atlas-l); --mod-wo-b:   var(--atlas-b);
  --mod-pm:   var(--atlas); --mod-pm-l:   var(--atlas-l); --mod-pm-b:   var(--atlas-b);
  --mod-bal:  var(--atlas); --mod-bal-l:  var(--atlas-l); --mod-bal-b:  var(--atlas-b);
  --mod-cat:  var(--atlas); --mod-cat-l:  var(--atlas-l); --mod-cat-b:  var(--atlas-b);
}
[data-theme="dark"] {
  --state-ok:       #4CAF70;
  --state-alert:    #E8A832;
  --state-critical: #E84545;
  --state-info:     #5BA8F5;
  --state-blocked:  #9CA3AF;
}

/* Acento activo de tab por módulo */
.mode-btn[data-mode="home"].active { color: var(--mod-home) !important; }
.mode-btn[data-mode="wo"].active   { color: var(--mod-wo)   !important; }
.mode-btn[data-mode="pm"].active   { color: var(--mod-pm)   !important; }
.mode-btn[data-mode="bal"].active  { color: var(--mod-bal)  !important; }
.mode-btn[data-mode="cat"].active  { color: var(--mod-cat)  !important; }

/* Transiciones de módulo B245 — 3D perspective */
@keyframes moduleExitLeft {
  to { opacity: 0; transform: perspective(1100px) rotateX(-4deg) rotateY(-1deg) translateX(-28px) scale(0.96); }
}
@keyframes moduleExitRight {
  to { opacity: 0; transform: perspective(1100px) rotateX(-4deg) rotateY(1deg) translateX(28px) scale(0.96); }
}
@keyframes moduleEnterLeft {
  from { opacity: 0; transform: perspective(1100px) rotateX(9deg) rotateY(-1deg) translateX(30px) translateY(18px) scale(0.97); }
}
@keyframes moduleEnterRight {
  from { opacity: 0; transform: perspective(1100px) rotateX(9deg) rotateY(1deg) translateX(-30px) translateY(18px) scale(0.97); }
}

.module-exit-left  { animation: moduleExitLeft  180ms cubic-bezier(0.4,0,1,1) forwards; }
.module-exit-right { animation: moduleExitRight 180ms cubic-bezier(0.4,0,1,1) forwards; }
.module-enter-left { animation: moduleEnterLeft 380ms cubic-bezier(0.16,1,0.3,1) forwards; }
.module-enter-right{ animation: moduleEnterRight 380ms cubic-bezier(0.16,1,0.3,1) forwards; }

@media (max-width: 768px) {
  .module-exit-left, .module-exit-right,
  .module-enter-left, .module-enter-right { animation: none; }
}

/* ══════════════════════════════════════════════════════════════════════
   B67 — Micro-interactions, reveals & feedback
   ══════════════════════════════════════════════════════════════════════ */

/* Section reveal stagger */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity var(--dur-slow) var(--ease-out-expo),
              transform var(--dur-slow) var(--ease-out-expo);
}
.reveal.is-visible { opacity: 1; transform: translateY(0); }

/* Loading state en botones */
.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.is-loading::after {
  content: ''; position: absolute; inset: 0; margin: auto;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.7);
  border-top-color: transparent;
  border-radius: 50%;
  animation: btnSpin 0.7s linear infinite;
}
@keyframes btnSpin { to { transform: rotate(360deg); } }

/* Drop zone feedback */
#drop-zone.drop-hover {
  border-color: rgba(192,84,42,0.6) !important;
  background: rgba(192,84,42,0.06) !important;
  transition: border-color 0.18s, background 0.18s;
}
#drop-zone.drop-ok {
  border-color: rgba(61,142,90,0.6) !important;
  background: rgba(61,142,90,0.06) !important;
  transition: border-color 0.18s, background 0.18s;
}

/* ══════════════════════════════════════════════════════════════════════
   B69 — ATLAS Side Rail · Premium Layout · Kinesthesia · Assets
   ══════════════════════════════════════════════════════════════════════ */

/* ── Ocultar app-nav horizontal (reemplazada por el rail vertical) ── */
.app-nav { display: none !important; }

/* ── Body offset para el rail ───────────────────────────────────────── */
@media (min-width: 769px) {
  body { padding-left: calc(64px + 20px); }
}

/* ── ATLAS Side Rail ────────────────────────────────────────────────── */
#atlas-rail {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 64px;
  display: flex; flex-direction: column;
  background: rgba(8,7,6,0.97);
  backdrop-filter: blur(22px) saturate(1.5);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
  border-right: 1px solid rgba(255,255,255,0.045);
  z-index: 200;
  overflow: hidden;
  transition: width 260ms cubic-bezier(0.16, 1, 0.3, 1);
  will-change: width;
}
[data-theme="light"] #atlas-rail {
  background: rgba(250,248,246,0.97);
  border-right: 1px solid rgba(0,0,0,0.07);
  box-shadow: 2px 0 20px rgba(0,0,0,0.06);
}
#atlas-rail:hover { width: 220px; }
/* Al expandirse, el rail se pone ENCIMA del contenido y se come los primeros
   ~150px de cada línea. En modo claro ya había una sombra que lo delataba como
   capa flotante; en modo noche su fondo casi coincide con el del lienzo, así que
   no parecía una capa sino texto recortado — y el modo noche es el que se usa a
   diario. Misma sombra, calibrada para oscuro. */
#atlas-rail:hover { box-shadow: 8px 0 32px rgba(0,0,0,0.55); }
[data-theme="light"] #atlas-rail:hover { box-shadow: 6px 0 26px rgba(0,0,0,0.16); }

/* Rail brand header */
.rail-brand {
  height: 64px; flex-shrink: 0;
  display: flex; align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  overflow: hidden;
}
[data-theme="light"] .rail-brand { border-bottom-color: rgba(0,0,0,0.06); }
.rail-brand__logo {
  width: 64px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display,'Bricolage Grotesque',sans-serif);
  font-size: 11px; font-weight: 900;
  letter-spacing: 0.28em; text-transform: uppercase;
  color: var(--atlas);
  user-select: none;
}
.rail-brand__name {
  font-family: var(--font-display,'Bricolage Grotesque',sans-serif);
  font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 180ms 50ms;
}
[data-theme="light"] .rail-brand__name { color: rgba(0,0,0,0.35); }
#atlas-rail:hover .rail-brand__name { opacity: 1; }

/* Rail nav list */
.rail-nav {
  list-style: none; margin: 0;
  padding: 10px 8px 0;
  display: flex; flex-direction: column; gap: 2px;
  flex: 1;
  overflow: hidden;
}

/* Rail items — reutiliza .mode-btn, agrega .rail-item */
.rail-item {
  width: 100%; height: 48px;
  padding: 0;
  display: flex; align-items: center;
  border: none; border-radius: 10px;
  background: transparent; cursor: pointer;
  position: relative; overflow: hidden;
  transition: background 140ms, color 140ms;
  color: rgba(255,255,255,0.28);
  font-family: var(--font-display,'Bricolage Grotesque',sans-serif);
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.01em;
}
[data-theme="light"] .rail-item { color: rgba(0,0,0,0.30); }
.rail-item:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.8);
}
[data-theme="light"] .rail-item:hover {
  background: rgba(0,0,0,0.05);
  color: rgba(0,0,0,0.72);
}
/* Active indicator bar */
.rail-item.active::before {
  content: '';
  position: absolute; left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%; min-height: 20px;
  background: currentColor;
  border-radius: 0 3px 3px 0;
}
.rail-item[data-mode="home"].active { color: var(--mod-home) !important; background: var(--mod-home-l) !important; box-shadow: inset 4px 0 18px rgba(192,84,42,0.22) !important; }
.rail-item[data-mode="wo"].active   { color: var(--mod-wo)   !important; background: var(--mod-wo-l)   !important; box-shadow: inset 4px 0 18px rgba(192,84,42,0.22) !important; }
.rail-item[data-mode="pm"].active   { color: var(--mod-pm)   !important; background: var(--mod-pm-l)   !important; box-shadow: inset 4px 0 18px rgba(192,84,42,0.22) !important; }
.rail-item[data-mode="bal"].active  { color: var(--mod-bal)  !important; background: var(--mod-bal-l)  !important; box-shadow: inset 4px 0 18px rgba(192,84,42,0.22) !important; }
.rail-item[data-mode="cat"].active  { color: var(--mod-cat)  !important; background: var(--mod-cat-l)  !important; box-shadow: inset 4px 0 18px rgba(192,84,42,0.22) !important; }

/* Icon + label inside item */
.rail-item__icon {
  width: 48px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; line-height: 1;
}
.rail-item__label {
  white-space: nowrap;
  opacity: 0;
  transition: opacity 160ms 50ms;
  pointer-events: none;
}
#atlas-rail:hover .rail-item__label { opacity: 1; }

/* Rail footer */
.rail-footer {
  padding: 8px;
  display: flex; flex-direction: column; gap: 2px;
  border-top: 1px solid rgba(255,255,255,0.04);
  flex-shrink: 0;
}
[data-theme="light"] .rail-footer { border-top-color: rgba(0,0,0,0.06); }
.rail-foot-btn {
  width: 100%; height: 44px;
  padding: 0;
  display: flex; align-items: center;
  border: none; border-radius: 8px;
  background: transparent; cursor: pointer;
  color: rgba(255,255,255,0.28);
  transition: background 140ms, color 140ms;
  overflow: hidden;
}
[data-theme="light"] .rail-foot-btn { color: rgba(0,0,0,0.28); }
.rail-foot-btn:hover {
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.75);
}
[data-theme="light"] .rail-foot-btn:hover {
  background: rgba(0,0,0,0.05);
  color: rgba(0,0,0,0.68);
}
.rail-foot-btn__icon {
  width: 48px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}
.rail-foot-btn__text {
  font-family: var(--font-display,'Bricolage Grotesque',sans-serif);
  font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 160ms 50ms;
}
#atlas-rail:hover .rail-foot-btn__text { opacity: 1; }

/* Role badge — textContent compatible (role_mask.js sets badge.textContent) */
.rail-foot-btn--role {
  font-family: var(--font-display,'Bricolage Grotesque',sans-serif);
  font-size: 0.54rem; font-weight: 900;
  letter-spacing: 0.16em; text-transform: uppercase;
  justify-content: center;
}
#atlas-rail:hover .rail-foot-btn--role {
  justify-content: flex-start;
  padding-left: 16px;
}
/* AI button accent */
.rail-foot-btn--ai:hover { color: var(--atlas) !important; background: var(--atlas-l) !important; }
/* Ctrl+K hint */
.rail-foot-btn--cmd:hover { color: rgba(255,255,255,0.8) !important; }

/* ── prefers-reduced-motion: no width/opacity transitions ── */
@media (prefers-reduced-motion: reduce) {
  #atlas-rail, .rail-item__label, .rail-brand__name,
  .rail-foot-btn__text { transition: none !important; }
}

/* ── Mobile: rail hidden, bottom nav activo ─────────────────────── */
@media (max-width: 768px) {
  #atlas-rail { display: none; }
}

/* ══════════════════════════════════════════════════════════════════════
   B69 — Accordion / Collapsibles
   ══════════════════════════════════════════════════════════════════════ */
.atlas-accordion { border-radius: var(--r-lg); overflow: hidden; }
.atlas-accordion + .atlas-accordion { margin-top: 2px; }
.accordion-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; cursor: pointer;
  background: var(--s1);
  border: 1px solid var(--b1);
  border-radius: var(--r-lg);
  transition: background 140ms, border-radius 120ms;
  user-select: none;
}
.accordion-header:hover { background: var(--s2); }
.accordion-header.open {
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  border-bottom-color: transparent;
  border-left-color: var(--atlas-b);
  background: var(--s2);
}
.accordion-title {
  font-family: var(--font-display,'Bricolage Grotesque',sans-serif);
  font-size: 0.82rem; font-weight: 700;
  letter-spacing: 0.01em; color: var(--t1);
  display: flex; align-items: center; gap: 8px;
}
.accordion-chevron {
  font-size: 0.78rem; color: var(--t3);
  transition: transform 220ms var(--ease-spring);
}
.accordion-header.open .accordion-chevron { transform: rotate(90deg); }
.accordion-body {
  background: var(--s1);
  border: 1px solid var(--b1); border-top: none;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  padding: 0;
  overflow: hidden;
  max-height: 0;
  transition: max-height 300ms cubic-bezier(0.16, 1, 0.3, 1),
              padding 300ms cubic-bezier(0.16, 1, 0.3, 1);
}
.accordion-body.open {
  padding: 14px 18px 18px;
  max-height: 1200px;
}

/* ══════════════════════════════════════════════════════════════════════
   B89 — Status dots semánticos (reemplazan inline styles en atlas_home.js)
   ══════════════════════════════════════════════════════════════════════ */
.atlas-status-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  display: inline-block;
}
.atlas-status-dot--ok {
  background: var(--state-ok);
  box-shadow: 0 0 6px var(--state-ok);
  animation: dotPulse 2.6s ease-in-out infinite;
}
.atlas-status-dot--alert    { background: var(--state-alert);    box-shadow: 0 0 5px var(--state-alert); }
.atlas-status-dot--critical { background: var(--state-critical); box-shadow: 0 0 5px var(--state-critical); }
.atlas-status-dot--info     { background: var(--state-info);     box-shadow: 0 0 5px var(--state-info-b); }
.atlas-status-dot--blocked  { background: var(--state-blocked); }
@keyframes dotPulse {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.45; }
}
@media (prefers-reduced-motion: reduce) { .atlas-status-dot--ok { animation: none; } }

/* ══════════════════════════════════════════════════════════════════════
   B69 — Status badges semánticos
   ══════════════════════════════════════════════════════════════════════ */
.atlas-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.07em; text-transform: uppercase;
  white-space: nowrap;
}
.atlas-badge--ok       { color: var(--state-ok);       background: var(--state-ok-l); }
.atlas-badge--alert    { color: var(--state-alert);    background: var(--state-alert-l); }
.atlas-badge--critical { color: var(--state-critical); background: var(--state-critical-l); }
.atlas-badge--info     { color: var(--state-info);     background: var(--state-info-l); }
.atlas-badge--blocked  { color: var(--state-blocked);  background: var(--state-blocked-l); }
.atlas-badge i { font-size: 0.72rem; }

/* ══════════════════════════════════════════════════════════════════════
   B69 — Sparkline container (Chart.js)
   ══════════════════════════════════════════════════════════════════════ */
.atlas-sparkline {
  width: 100%; height: 48px;
  display: block;
}
.metric-card {
  background: var(--s1); border: 1px solid var(--b1);
  border-radius: var(--r-lg); padding: 16px 18px 12px;
  display: flex; flex-direction: column; gap: 6px;
  position: relative; overflow: hidden;
}
.metric-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--mod-accent, var(--atlas)), transparent);
  opacity: 0.7;
}
.metric-card::after {
  content: '';
  position: absolute; top: -24px; right: -24px;
  width: 90px; height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--mod-accent, var(--atlas)), transparent 70%);
  opacity: 0.06;
  pointer-events: none;
}
.metric-card__label {
  font-size: 0.65rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--t3);
}
.metric-card__value {
  font-family: var(--font-display,'Bricolage Grotesque',sans-serif);
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 800; color: var(--t1); line-height: 1;
}
.metric-card__delta {
  font-size: 0.72rem; font-weight: 600;
  color: var(--state-ok);
}
.metric-card__delta--down { color: var(--state-critical); }

/* ══════════════════════════════════════════════════════════════════════
   B69 — Tippy.js theme override
   ══════════════════════════════════════════════════════════════════════ */
.tippy-box[data-theme~='atlas'] {
  background: rgba(18,16,14,0.96);
  border: 1px solid rgba(255,255,255,0.09);
  backdrop-filter: blur(12px);
  color: rgba(255,255,255,0.9);
  font-family: var(--font-display,'Bricolage Grotesque',sans-serif);
  font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.03em;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.tippy-box[data-theme~='atlas'] .tippy-arrow { color: rgba(18,16,14,0.96); }

/* ══════════════════════════════════════════════════════════════════════
   B69 — Narrative fade overlay (ui_motion.js)
   ══════════════════════════════════════════════════════════════════════ */
#atlas-fade-overlay {
  position: fixed; inset: 0;
  background: #0A0A0A;
  opacity: 0; pointer-events: none;
  z-index: 1000;
  transition: opacity 300ms ease-in-out;
}
#atlas-fade-overlay.active { opacity: 1; pointer-events: auto; }

/* ══════════════════════════════════════════════════════════════════════
   B69 — 3-column context panel (desktop ≥1200px)
   ══════════════════════════════════════════════════════════════════════ */
@media (min-width: 1200px) {
  .app-container { max-width: 1280px; }
}
/* B228 — aprovechar el ancho en monitores grandes (antes sobraba mucho horizontal) */
@media (min-width: 1500px) { .app-container { max-width: 1420px; } }
@media (min-width: 1700px) { .app-container { max-width: 1560px; } }
@media (min-width: 1920px) { .app-container { max-width: 1720px; } }
/* B228 — un poco más de aire bajo la topbar (las barras respiran) */
@media (min-width: 769px) {
  #main-content { padding-top: 8px; }
  .app-container { gap: 22px; }
}

/* Context side panel */
#atlas-context-panel {
  position: fixed; right: 0; top: 0; bottom: 0;
  width: 0; overflow: hidden;
  background: rgba(10,9,8,0.97);
  border-left: 1px solid rgba(255,255,255,0.04);
  z-index: 150;
  transition: width 260ms cubic-bezier(0.16, 1, 0.3, 1);
  display: flex; flex-direction: column;
}
[data-theme="light"] #atlas-context-panel {
  background: rgba(250,248,246,0.97);
  border-left-color: rgba(0,0,0,0.07);
}
#atlas-context-panel.open {
  width: 280px;
}
.context-panel__header {
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
[data-theme="light"] .context-panel__header { border-bottom-color: rgba(0,0,0,0.06); }
.context-panel__title {
  font-family: var(--font-display,'Bricolage Grotesque',sans-serif);
  font-size: 0.68rem; font-weight: 800;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: rgba(255,255,255,0.4);
}
[data-theme="light"] .context-panel__title { color: rgba(0,0,0,0.35); }
.context-panel__close {
  width: 40px; height: 40px; border-radius: 10px;
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,0.3); font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
  transition: background 140ms, color 140ms;
}
.context-panel__close:hover { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.8); }
[data-theme="light"] .context-panel__close { color: rgba(0,0,0,0.3); }
[data-theme="light"] .context-panel__close:hover { background: rgba(0,0,0,0.05); color: rgba(0,0,0,0.7); }
.context-panel__body {
  flex: 1; overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}

/* ══════════════════════════════════════════════════════════════════════
   B75 — Drop zone premium + stat-card animations + shortcuts premium
   ══════════════════════════════════════════════════════════════════════ */

/* Stat-cards: entrance animation when dashboard becomes visible */
@keyframes statCardIn {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}
.stats-grid.animate-in .stat-card {
  animation: statCardIn 260ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
.stats-grid.animate-in .stat-card:nth-child(1) { animation-delay:  0ms; }
.stats-grid.animate-in .stat-card:nth-child(2) { animation-delay: 50ms; }
.stats-grid.animate-in .stat-card:nth-child(3) { animation-delay:100ms; }
.stats-grid.animate-in .stat-card:nth-child(4) { animation-delay:150ms; }
.stats-grid.animate-in .stat-card:nth-child(5) { animation-delay:200ms; }
.stats-grid.animate-in .stat-card:nth-child(6) { animation-delay:250ms; }

/* Stat-value animation */
@keyframes countUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.stat-value.animated {
  animation: countUp 400ms cubic-bezier(0.16,1,0.3,1) both;
}

/* Dashboard header actions: reveal on show */
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* Drop-zone hint text: link style */
.drop-zone strong { color: var(--atlas) !important; }

/* ══════════════════════════════════════════════════════════════════════
   B72 — Stat-cards semánticos + rail refinements + borders premium
   ══════════════════════════════════════════════════════════════════════ */

/* Stat-value colors con tokens de estado */
.stat-value.accent-blue { color: var(--mod-wo) !important; }
.stat-value.highlight   { color: var(--state-ok) !important; }
.stat-value.warning     { color: var(--state-alert) !important; }
.stat-value.danger      { color: var(--state-critical) !important; }
.stat-value.accent-green { color: var(--mod-pm) !important; }
/* Salvo cuando la cifra es 0: entonces no hay nada de lo que avisar y la tarjeta
   vuelve a neutro. Va aquí, en el mismo bloque, porque estas reglas llevan
   !important y desde arriba no se las puede corregir. Ver la nota de la l. ~552. */
.stat-value.danger[data-value="0"],
.stat-value.warning[data-value="0"] { color: var(--t2) !important; }

/* Rail separator between nav and footer */
.rail-spacer {
  flex: 1;
  min-height: 16px;
  position: relative;
}
.rail-spacer::after {
  content: '';
  position: absolute;
  bottom: 0; left: 12px; right: 12px;
  height: 1px;
  background: rgba(255,255,255,0.04);
}
[data-theme="light"] .rail-spacer::after {
  background: rgba(0,0,0,0.06);
}

/* Home section card: terracota top border pulse */
#home-section {
  border-top: 2px solid rgba(192,84,42,0.5) !important;
  background: linear-gradient(180deg, rgba(192,84,42,0.02) 0%, transparent 60px) !important;
}
[data-theme="light"] #home-section {
  border-top-color: rgba(192,84,42,0.3) !important;
  background: linear-gradient(180deg, rgba(192,84,42,0.015) 0%, transparent 60px) !important;
}

/* Section cards: top border colored by active module */
body[data-mode="wo"]  #upload-section,
body[data-mode="wo"]  #dashboard-section,
body[data-mode="wo"]  #mapping-section   { border-top: 2px solid rgba(192,84,42,0.45) !important; }
body[data-mode="pm"]  #pm-section        { border-top: 2px solid rgba(192,84,42,0.45) !important; }
body[data-mode="bal"] #bal-section       { border-top: 2px solid rgba(192,84,42,0.45) !important; }
body[data-mode="cat"] #cat-section       { border-top: 2px solid rgba(192,84,42,0.45) !important; }

/* Animated gradient border on active stat-card */
.stat-card:hover::before {
  opacity: 1 !important;
}

/* ══════════════════════════════════════════════════════════════════════
   B70 — Home dashboard components
   ══════════════════════════════════════════════════════════════════════ */

/* Atlas module quick-nav buttons */
.atlas-module-quick {
  display: block; width: 100%;
  text-align: left; cursor: pointer;
  font-family: inherit;
  transition: box-shadow 150ms ease-out, border-top-color 140ms ease;
  border-top-width: 2px !important;
  will-change: transform;
}
.atlas-module-quick:hover {
  box-shadow: 0 8px 28px rgba(0,0,0,0.26), 0 2px 8px rgba(0,0,0,0.16),
              0 0 0 1px var(--b1);
  background: var(--s2) !important;
}
.atlas-module-quick:active {
  box-shadow: none;
}

/* Home hero: ATLAS large heading */
.home-hero-title {
  font-family: var(--font-display,'Bricolage Grotesque',sans-serif);
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
  background: linear-gradient(90deg,
    var(--t1) 0%,
    var(--atlas) 30%,
    rgba(255,255,255,0.92) 50%,
    var(--atlas) 70%,
    var(--t1) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: titleShimmer 6s ease-in-out infinite;
}
@keyframes titleShimmer {
  0%, 100% { background-position: 0% 50%; }
  50%       { background-position: 100% 50%; }
}
.home-hero-sub {
  font-family: var(--font-display, 'Bricolage Grotesque', sans-serif);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--t3);
  margin-top: 5px;
}
.build-badge {
  font-family: 'Courier New', monospace;
  font-size: 0.68rem;
  background: var(--atlas-l);
  color: var(--atlas);
  padding: 1px 7px;
  border-radius: 4px;
  letter-spacing: 0.04em;
}

/* ══════════════════════════════════════════════════════════════════════
   B84 — Hero context strip + depth gradient
   ══════════════════════════════════════════════════════════════════════ */

/* Hero depth: subtle terracota glow from left edge */
.home-hero-header {
  background:
    radial-gradient(ellipse 70% 120% at -8% 50%, rgba(192,84,42,0.08) 0%, transparent 55%),
    var(--ct-dark) !important;
}

/* Context strip injected by atlas_home.js */
.home-hero-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.home-hero-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ct-od3);
}
.home-hero-chip .ti {
  color: var(--atlas);
  font-size: 0.76rem;
}

/* ══════════════════════════════════════════════════════════════════════
   B86 — CT Topbar: breadcrumb + context bar above main content
   ══════════════════════════════════════════════════════════════════════ */

#ct-topbar {
  position: fixed;
  left: 64px; right: 0; top: 0;
  height: 44px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px 0 18px;
  background: rgba(8,7,6,0.93);
  backdrop-filter: blur(18px) saturate(1.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  border-bottom: 1px solid rgba(255,255,255,0.055);
  z-index: 150;
  transition: border-bottom-color 240ms var(--ease-out-quart, cubic-bezier(0.25,1,0.5,1)),
              left 260ms cubic-bezier(0.16,1,0.3,1);
}
[data-theme="light"] #ct-topbar {
  background: rgba(250,248,246,0.97);
  border-bottom-color: rgba(0,0,0,0.07);
  box-shadow: 0 1px 8px rgba(0,0,0,0.05);
}
.ct-topbar__brand {
  display: flex; align-items: center; gap: 9px;
}
.ct-topbar__logo {
  font-family: var(--font-display);
  font-size: 0.62rem; font-weight: 800;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--atlas);
  width: 21px; height: 21px;
  background: var(--atlas-l);
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ct-topbar__sep {
  color: var(--t3); font-size: 0.85rem; opacity: 0.3;
}
/* Override standalone breadcrumb rule inside topbar */
#ct-topbar #ct-breadcrumb {
  background: transparent;
  padding: 0; max-width: none;
}
/* Module-color breadcrumb + topbar border */
body[data-mode="wo"]  #ct-topbar #ct-breadcrumb { color: var(--mod-wo);  }
body[data-mode="pm"]  #ct-topbar #ct-breadcrumb { color: var(--mod-pm);  }
body[data-mode="bal"] #ct-topbar #ct-breadcrumb { color: var(--mod-bal); }
body[data-mode="cat"] #ct-topbar #ct-breadcrumb { color: var(--mod-cat); }

body[data-mode="wo"]  #ct-topbar { border-bottom-color: var(--mod-wo-b);  }
body[data-mode="pm"]  #ct-topbar { border-bottom-color: var(--mod-pm-b);  }
body[data-mode="bal"] #ct-topbar { border-bottom-color: var(--mod-bal-b); }
body[data-mode="cat"] #ct-topbar { border-bottom-color: var(--mod-cat-b); }
.ct-topbar__date {
  font-size: 0.63rem; font-weight: 600;
  letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--t3); opacity: 0.65;
}

/* Body: top padding for topbar */
@media (min-width: 769px) {
  body { padding-top: 44px; }
}
@media (min-width: 769px) {
  /* Rail expand: slide topbar right to follow — progressive enhancement */
  body:has(#atlas-rail:hover) #ct-topbar { left: 220px; }
}
@media (max-width: 768px) {
  #ct-topbar { left: 0; }
  body { padding-top: 44px; }
}

/* ══════════════════════════════════════════════════════════════════════
   B85 — Section h2 module underlines + context stat-card borders + skeleton
   ══════════════════════════════════════════════════════════════════════ */

/* Section h2: module-color bottom rule */
#upload-section > h2,
#mapping-section > h2,
#dashboard-section > h2  { padding-bottom: 12px; border-bottom: 1.5px solid var(--mod-wo-b);  margin-bottom: 20px; }
#pm-section  h2          { padding-bottom: 12px; border-bottom: 1.5px solid var(--mod-pm-b);  margin-bottom: 20px; }
#bal-section h2          { padding-bottom: 12px; border-bottom: 1.5px solid var(--mod-bal-b); margin-bottom: 20px; }
#cat-section h2          { padding-bottom: 12px; border-bottom: 1.5px solid var(--mod-cat-b); margin-bottom: 20px; }

/* Stat-card left accent: module-specific in context */
#dashboard-section .stat-card { border-left-color: var(--mod-wo-b); }
#pm-section        .stat-card { border-left-color: var(--mod-pm-b); }
#bal-section       .stat-card { border-left-color: var(--mod-bal-b); }
#cat-section       .stat-card { border-left-color: var(--mod-cat-b); }

/* ── B214 — Empty state limpio para módulos sin datos cargados ────────
   Solo aplica cuando la sección está realmente vacía (:empty). En cuanto
   el módulo JS inyecta contenido, este estado desaparece automáticamente.
   No interfiere con initPMPlanner / initBalancer / initCatAssignment. */
#pm-section:empty,
#bal-section:empty,
#cat-section:empty {
  display: block;
  min-height: 320px;
  background: var(--s1);
  border: 1px solid var(--b1);
  border-radius: var(--r-xl);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.08);
  position: relative;
}
#pm-section:empty::before,
#bal-section:empty::before,
#cat-section:empty::before {
  content: 'Cargando módulo…';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--t3);
  letter-spacing: 0.01em;
  text-align: center;
}

/* Shimmer skeleton loader */
@keyframes atlas-shimmer {
  0%   { background-position: -480px 0; }
  100% { background-position:  480px 0; }
}
.atlas-skeleton-line {
  height: 13px;
  border-radius: 7px;
  background: linear-gradient(
    90deg,
    var(--b1) 25%,
    var(--b2) 50%,
    var(--b1) 75%
  );
  background-size: 480px 100%;
  animation: atlas-shimmer 1.6s ease-in-out infinite;
  margin-bottom: 9px;
}
@media (prefers-reduced-motion: reduce) {
  .atlas-skeleton-line { animation: none; opacity: 0.4; }
}

/* ══════════════════════════════════════════════════════════════════════
   B87 — Print stylesheet
   ══════════════════════════════════════════════════════════════════════ */
@media print {
  /* Hide navigation chrome */
  #atlas-rail,
  #ct-topbar,
  .mobile-nav,
  .skip-link,
  #atlas-fade-overlay,
  #atlas-context-panel,
  .atlas-onboarding-overlay,
  .cp-overlay,
  .ai-panel,
  .shortcuts-dock,
  footer { display: none !important; }

  /* Remove body offsets — fill page */
  body {
    padding-left: 0 !important;
    padding-top: 0 !important;
    background: #fff !important;
    color: #000 !important;
    font-size: 10pt;
  }

  /* Sections: no clip-path, no shadows */
  .card, .stat-card, .metric-card {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
    background: #fff !important;
    page-break-inside: avoid;
  }

  /* Avoid orphan stat grids */
  .stats-grid, .stats-cards-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
  }

  /* Print primary actions */
  .btn-primary, .btn-secondary { display: none !important; }

  /* Section visibility: show only active, hide hidden */
  section.hidden { display: none !important; }
  section:not(.hidden) { display: block !important; }

  /* Remove animations */
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ══════════════════════════════════════════════════════════════════════
   B69 — Scrollbar dark mode (premium warm dark)
   ══════════════════════════════════════════════════════════════════════ */
[data-theme="dark"] ::-webkit-scrollbar-track { background: transparent; }
[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.10);
  border-radius: 4px;
}
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

/* ══════════════════════════════════════════════════════════════════════
   B91 — CoV gauge ring + hero breath + card glint
   ══════════════════════════════════════════════════════════════════════ */

/* CoV ring gauge */
.cov-gauge-wrap {
  position: relative;
  width: 64px; height: 64px;
  margin: 4px auto 8px;
  flex-shrink: 0;
}
.cov-gauge { display: block; width: 64px; height: 64px; }
.cov-gauge__label {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display, 'Bricolage Grotesque', sans-serif);
  font-size: 0.66rem;
  font-weight: 800;
  color: var(--t1);
  line-height: 1;
  white-space: nowrap;
  text-align: center;
  pointer-events: none;
}

/* Hero breathing overlay — pulsing terracota glow */
.home-hero-header { position: relative; overflow: hidden; }
.home-hero-text   { position: relative; z-index: 1; }
.home-hero-header::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 90% 160% at -5% 50%,
    rgba(192,84,42,0.14) 0%, transparent 65%);
  animation: heroBreath 9s ease-in-out infinite;
  pointer-events: none; z-index: 0;
}
@keyframes heroBreath {
  0%, 100% { opacity: 0.3; }
  50%       { opacity: 1.0; }
}

/* P1 — Hero gradient legible en modo claro (B177) */
[data-theme="light"] .home-hero-title {
  background: linear-gradient(90deg,
    rgba(255,255,255,0.92) 0%,
    var(--atlas) 30%,
    rgba(255,255,255,0.92) 50%,
    var(--atlas) 70%,
    rgba(255,255,255,0.92) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: titleShimmer 6s ease-in-out infinite;
}
[data-theme="light"] .home-hero-sub {
  color: rgba(255,255,255,0.7);
}

/* Card glint sweep */
.card-glint {
  position: absolute; inset: 0;
  background: linear-gradient(105deg,
    transparent 35%,
    rgba(255,255,255,0.055) 50%,
    transparent 65%);
  animation: cardGlint 7s ease-in-out infinite;
  pointer-events: none;
  z-index: 2;
  border-radius: inherit;
  overflow: hidden;
}
.metric-card:nth-child(1) .card-glint { animation-delay: 0.0s; }
.metric-card:nth-child(2) .card-glint { animation-delay: 0.9s; }
.metric-card:nth-child(3) .card-glint { animation-delay: 1.8s; }
.metric-card:nth-child(4) .card-glint { animation-delay: 2.7s; }
@keyframes cardGlint {
  0%, 60%, 100% { transform: translateX(-220%) skewX(-10deg); }
  40%            { transform: translateX(320%)  skewX(-10deg); }
}

/* ══════════════════════════════════════════════════════════════════════
   B94 — Section bg gradient tint + smooth border transition + green pulse
   ══════════════════════════════════════════════════════════════════════ */

/* Section module-gradient overlay (pseudo-element approach, no background conflict) */
#upload-section, #dashboard-section, #mapping-section,
#pm-section, #bal-section, #cat-section {
  position: relative; overflow: visible;
}
#upload-section::after, #dashboard-section::after, #mapping-section::after,
#pm-section::after, #bal-section::after, #cat-section::after {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(192,84,42,0.04) 0%, transparent 80px);
  opacity: 0; transition: opacity 300ms var(--ease-out-quart, cubic-bezier(0.25,1,0.5,1));
  z-index: 0;
}
body[data-mode="wo"]  #upload-section::after,
body[data-mode="wo"]  #dashboard-section::after,
body[data-mode="wo"]  #mapping-section::after { opacity: 1; }
body[data-mode="pm"]  #pm-section::after  { opacity: 1; }
body[data-mode="bal"] #bal-section::after { opacity: 1; }
body[data-mode="cat"] #cat-section::after { opacity: 1; }

/* ══════════════════════════════════════════════════════════════════════
   B97 — Mouse spotlight on stat-cards + module-colored view tabs
   ══════════════════════════════════════════════════════════════════════ */

/* WO section headers (matching PM/BAL/CAT treatment from B68) */
#upload-section   h2 { padding-bottom: 12px; border-bottom: 1.5px solid var(--mod-wo-b);  margin-bottom: 20px; }
#dashboard-section h2 { padding-bottom: 12px; border-bottom: 1.5px solid var(--mod-wo-b); margin-bottom: 20px; }
#mapping-section  h2 { padding-bottom: 12px; border-bottom: 1.5px solid var(--mod-wo-b);  margin-bottom: 20px; }

/* Module-colored active tab in each context */
body[data-mode="wo"]  .btn-tab.active,
body[data-mode="pm"]  .btn-tab.active,
body[data-mode="bal"] .btn-tab.active,
body[data-mode="cat"] .btn-tab.active {
  background: var(--atlas); border-color: var(--atlas);
  box-shadow: 0 2px 8px rgba(192,84,42,0.22);
}

/* Hover enhancement for non-active tabs */
.btn-tab:hover:not(.active) {
  background: var(--s1);
  color: var(--t1);
  border-color: var(--b2);
  transform: translateY(-1px);
}

/* ══════════════════════════════════════════════════════════════════════
   B99 — Tippy atlas-dark theme for rail tooltips
   ══════════════════════════════════════════════════════════════════════ */

.tippy-box[data-theme~="atlas-dark"] {
  background: rgba(18,16,14,0.96);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.55), 0 1px 0 rgba(255,255,255,0.06) inset;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.tippy-box[data-theme~="atlas-dark"] .tippy-content { padding: 10px 12px; }
.tippy-box[data-theme~="atlas-dark"] .tippy-arrow::before { border-right-color: rgba(18,16,14,0.96); }

/* ══════════════════════════════════════════════════════════════════════
   B98 — Module-colored focus rings + page progress bar
   ══════════════════════════════════════════════════════════════════════ */

/* Module-specific focus ring color overrides */
body[data-mode="wo"]  :focus-visible { outline-color: var(--mod-wo);  }
body[data-mode="pm"]  :focus-visible { outline-color: var(--mod-pm);  }
body[data-mode="bal"] :focus-visible { outline-color: var(--mod-bal); }
body[data-mode="cat"] :focus-visible { outline-color: var(--mod-cat); }

/* Page progress bar — activated by nav_sync.js */
#atlas-progress {
  position: fixed; top: 0; left: 64px; right: 0; height: 2px;
  z-index: 500; pointer-events: none;
  background: var(--atlas);
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 320ms cubic-bezier(0.1,0.7,0.3,1), opacity 200ms ease;
  opacity: 0;
}
#atlas-progress.is-running  { opacity: 1; transform: scaleX(0.85); }
#atlas-progress.is-done     { opacity: 1; transform: scaleX(1); }
#atlas-progress.is-fading   { opacity: 0; transform: scaleX(1); transition: opacity 300ms ease; }

@media (max-width: 768px) {
  #atlas-progress { left: 0; }
}

/* ══════════════════════════════════════════════════════════════════════
   B100 — Accordion / collapsible blocks
   ══════════════════════════════════════════════════════════════════════ */

.aging-collapse-btn {
  background: none; border: none; cursor: pointer; padding: 2px 4px;
  color: var(--t4); margin-left: auto; border-radius: 4px;
  transition: color 0.12s, background 0.12s;
  display: inline-flex; align-items: center; line-height: 1;
}
.aging-collapse-btn:hover { color: var(--t2); background: rgba(255,255,255,0.06); }
.aging-collapse-btn i { font-size: 0.85rem; transition: transform 220ms var(--ease-out-expo, ease-out); }

/* Aging block accordion */
.header-aging { transition: padding 180ms ease; }
.header-aging .header-aging-title { cursor: default; }
.header-aging-buckets {
  overflow: hidden;
  max-height: 240px;
  transition: max-height 220ms ease-out, opacity 180ms ease;
  opacity: 1;
}
.header-aging.is-collapsed { padding-top: 8px; padding-bottom: 8px; }
.header-aging.is-collapsed .header-aging-buckets { max-height: 0; opacity: 0; }
.header-aging.is-collapsed .aging-collapse-btn i { transform: rotate(180deg); }

/* Generic data-collapsible */
[data-collapsible-body] {
  overflow: hidden; max-height: 600px;
  transition: max-height 260ms ease-out, opacity 180ms ease;
  opacity: 1;
}
[data-collapsible].is-collapsed [data-collapsible-body] { max-height: 0; opacity: 0; }
[data-collapsible].is-collapsed .aging-collapse-btn i   { transform: rotate(180deg); }

/* ══════════════════════════════════════════════════════════════════════
   B103 — Productivity cards + list-item + bar-fill shimmer
   ══════════════════════════════════════════════════════════════════════ */

/* Card-inner improvements */
.card-inner {
  transition: box-shadow 0.18s, transform 0.18s, border-color 0.18s;
}
.card-inner:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.13);
  transform: translateY(-1px);
}
body[data-mode="wo"] .card-inner h3  { color: var(--mod-wo); }
body[data-mode="pm"] .card-inner h3  { color: var(--mod-pm); }
body[data-mode="bal"] .card-inner h3 { color: var(--mod-bal); }
body[data-mode="cat"] .card-inner h3 { color: var(--mod-cat); }

/* List-item hover with module left accent */
.list-item {
  transition: background 0.12s, border-left-color 0.12s, transform 0.12s;
  border-left: 2px solid transparent;
}
.list-item:hover {
  background: var(--s2);
  transform: translateX(2px);
}
body[data-mode="wo"]  .list-item:hover { border-left-color: var(--mod-wo); }
body[data-mode="pm"]  .list-item:hover { border-left-color: var(--mod-pm); }
body[data-mode="bal"] .list-item:hover { border-left-color: var(--mod-bal); }
body[data-mode="cat"] .list-item:hover { border-left-color: var(--mod-cat); }

/* Bar fill: shimmer sweep after fill animation */
.bar-fill {
  position: relative;
  overflow: hidden;
}
.bar-fill::after {
  content: '';
  position: absolute; top: 0; left: -100%; width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.30), transparent);
  animation: barShimmer 2.2s ease-out 0.5s 1 forwards;
}
@keyframes barShimmer {
  0%   { left: -60%; opacity: 1; }
  80%  { left: 140%; opacity: 1; }
  100% { left: 140%; opacity: 0; }
}

/* ══════════════════════════════════════════════════════════════════════
   B104 — PM planner hover states + pm_visual.js tips
   ══════════════════════════════════════════════════════════════════════ */

.pm-tech-card {
  transition: box-shadow 0.16s, transform 0.16s;
}
.pm-tech-card:hover {
  box-shadow: 0 4px 18px rgba(0,0,0,0.12);
  transform: translateY(-2px);
}

.pm-mini-stat {
  transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
  cursor: default;
}
.pm-mini-stat:hover {
  box-shadow: 0 4px 14px rgba(192,84,42,0.15);
  transform: translateY(-1px);
  border-color: var(--mod-pm);
}

.pm-rule-item {
  transition: background 0.12s, border-color 0.12s;
  border-left: 2px solid transparent;
}
.pm-rule-item:hover {
  background: var(--mod-pm-l);
  border-left-color: var(--mod-pm);
}

/* ══════════════════════════════════════════════════════════════════════
   B105 — BAL heatmap cell hover + clock
   ══════════════════════════════════════════════════════════════════════ */

.bal-hm-cell {
  transition: transform 0.12s, box-shadow 0.12s;
  cursor: default;
}
.bal-hm-cell:hover {
  transform: scale(1.08);
  box-shadow: 0 3px 10px rgba(0,0,0,0.18);
  z-index: 2;
  position: relative;
}

.bal-freq-pill {
  transition: transform 0.12s, box-shadow 0.12s;
  cursor: default;
}
.bal-freq-pill:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(99,102,241,0.22);
}

/* ══════════════════════════════════════════════════════════════════════
   B106 — Home refresh button
   ══════════════════════════════════════════════════════════════════════ */

.hero-refresh-btn {
  position: absolute; top: 10px; right: 10px; z-index: 3;
  width: 30px; height: 30px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px; cursor: pointer;
  color: var(--t4); font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}
.hero-refresh-btn:hover { color: var(--t1); background: rgba(255,255,255,0.10); border-color: rgba(255,255,255,0.20); }
.hero-refresh-btn i { transition: transform 0s; }
.hero-refresh-btn.is-spinning i { animation: refreshSpin 0.6s ease-out 1; }
@keyframes refreshSpin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════════════════════
   B107 — Rail alert badges
   ══════════════════════════════════════════════════════════════════════ */

.rail-badge {
  position: absolute;
  top: 4px; right: 4px;
  font-size: 0.5rem; font-weight: 800;
  line-height: 1; min-width: 14px; height: 14px;
  padding: 0 3px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
}
.rail-badge--hidden { opacity: 0; transform: scale(0.6); pointer-events: none; }
.rail-badge--danger {
  background: var(--state-critical);
  color: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
  animation: badgePop 0.22s cubic-bezier(0.34,1.56,0.64,1) 1;
}
.rail-badge--dot {
  width: 7px; height: 7px; min-width: 7px; border-radius: 50%;
  padding: 0; top: 5px; right: 5px;
}
.rail-badge--dot.rail-badge--ok   { background: var(--state-ok); }
.rail-badge--dot.rail-badge--warn { background: var(--state-alert); }
.rail-badge--dot.rail-badge--crit { background: var(--state-critical); animation: dotBlink 1.4s ease-in-out infinite; }

@keyframes badgePop {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
@keyframes dotBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* Ensure rail items have position:relative for badge absolute positioning */
.rail-item { position: relative; }

/* ══════════════════════════════════════════════════════════════════════
   B108 — Mobile bottom navigation
   ══════════════════════════════════════════════════════════════════════ */

.mobile-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  height: 64px;
  background: var(--s1);
  border-top: 1px solid var(--b1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.mobile-nav__btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; background: none; border: none; cursor: pointer;
  color: var(--t4); font-size: clamp(0.6rem, 1.6vw, 0.68rem); font-weight: 600; letter-spacing: 0.2px;
  padding: 8px 4px; min-height: 48px; position: relative;
  transition: color 0.12s;
}
.mobile-nav__btn i { font-size: 1.3rem; line-height: 1; }

.mobile-nav__btn.active { color: var(--atlas); }
body[data-mode="wo"]  .mobile-nav__btn[data-mode="wo"].active  { color: var(--mod-wo); }
body[data-mode="pm"]  .mobile-nav__btn[data-mode="pm"].active  { color: var(--mod-pm); }
body[data-mode="bal"] .mobile-nav__btn[data-mode="bal"].active { color: var(--mod-bal); }
body[data-mode="cat"] .mobile-nav__btn[data-mode="cat"].active { color: var(--mod-cat); }

/* Active indicator dot above icon */
.mobile-nav__btn.active::before {
  content: '';
  position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
  width: 18px; height: 2px; border-radius: 1px;
  background: currentColor; opacity: 0.7;
}

@media (max-width: 768px) {
  .mobile-nav { display: flex; }
  #atlas-rail  { display: none !important; }
  #ct-topbar   { left: 0 !important; }
  body {
    padding-left: 0 !important;
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px)) !important;
  }
  #atlas-progress { left: 0; }
}

/* ══════════════════════════════════════════════════════════════════════
   B115 — Module background textures + keyboard echo chip
   ══════════════════════════════════════════════════════════════════════ */

/* Body module-bg overlay via ::after — changes SVG pattern per active mode */
body::after {
  content: '';
  position: fixed; inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 360ms ease-out, background-image 0s;
}

/* B214 — Texturas SVG por módulo (líneas, puntos, hexágonos) eliminadas.
   Causaban la "pantalla con textura de puntos" en los módulos vacíos.
   Fondo limpio blanco/plata en todos los modos. */
body[data-mode="wo"]::after,
body[data-mode="pm"]::after,
body[data-mode="bal"]::after,
body[data-mode="cat"]::after {
  background-image: none;
  opacity: 0;
}

/* ── Keyboard echo chip ──────────────────────────────────────── */
#kbd-echo {
  position: fixed;
  bottom: 80px; right: 18px;
  z-index: 910;
  display: flex; align-items: center; gap: 5px;
  background: var(--s1);
  border: 1px solid var(--b1);
  border-radius: 10px;
  padding: 6px 10px;
  box-shadow: 0 4px 18px rgba(0,0,0,.14);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .18s, transform .2s cubic-bezier(0.16,1,0.3,1);
  pointer-events: none;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--t2);
  white-space: nowrap;
}
#kbd-echo.visible {
  opacity: 1;
  transform: translateY(0);
}
#kbd-echo kbd {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--s2);
  border: 1px solid var(--b1);
  border-bottom: 2px solid var(--b1);
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 0.68rem;
  font-family: 'Courier New', monospace;
  color: var(--t1);
  min-width: 24px; text-align: center;
}

/* ══════════════════════════════════════════════════════════════════════
   B118 — Glassmorphism dark mode + micro-interaction polish
   ══════════════════════════════════════════════════════════════════════ */

/* Glass surfaces in dark mode — selective for key content cards */
@supports (backdrop-filter: blur(1px)) {
  [data-theme="dark"] .card,
  [data-theme="dark"] .stat-card {
    background: rgba(20, 18, 16, 0.78) !important;
    backdrop-filter: blur(16px) saturate(1.3);
    -webkit-backdrop-filter: blur(16px) saturate(1.3);
    border-color: rgba(255,255,255,0.07) !important;
  }

  [data-theme="dark"] .card-inner {
    background: rgba(26, 23, 19, 0.75) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-color: rgba(255,255,255,0.055) !important;
  }

  [data-theme="dark"] .metric-card {
    background: rgba(18, 16, 13, 0.82) !important;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-color: rgba(255,255,255,0.06) !important;
  }
}

/* Button press micro-interaction — all interactive buttons */
.btn-primary:active,
.btn-secondary:active {
  transform: scale(0.97) translateY(1px);
  transition: transform 0.06s ease-in;
}

/* Mode buttons spring back on release */
.mode-btn:active { transform: scale(0.95); transition: transform 0.06s ease-in; }

/* Rail item subtle scale on press */
.rail-item__btn:active { transform: scale(0.93); }

/* Stat card active press */
.stat-card:active { transform: scale(0.98); transition: transform 0.06s; }

/* Focus-visible improvements — show ring always on keyboard focus */
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.mode-btn:focus-visible,
.theme-toggle:focus-visible,
.topbar-icon-btn:focus-visible {
  outline: 2px solid var(--atlas);
  outline-offset: 2px;
}

/* Smooth color transitions on interactive elements */
.btn-primary,
.btn-secondary,
.mode-btn,
.btn-tab,
.rail-item__btn {
  transition-property: background, color, border-color, transform, box-shadow;
  transition-duration: 140ms;
  transition-timing-function: ease-out;
}

/* Stat value number: subtle text glow in dark mode on hover */
[data-theme="dark"] .stat-card:hover .stat-value {
  text-shadow: 0 0 20px currentColor;
  transition: text-shadow 0.2s ease-out;
}

/* Dark mode metric card inner glow on hover */
[data-theme="dark"] .metric-card:hover {
  border-color: rgba(192,84,42,0.25) !important;
  box-shadow: 0 0 0 1px rgba(192,84,42,0.1), 0 8px 32px rgba(0,0,0,0.3) !important;
}

/* ══════════════════════════════════════════════════════════════════════
   B119 — Button ripple effect + new reusable keyframes
   ══════════════════════════════════════════════════════════════════════ */

@keyframes rippleExpand {
  to { transform: scale(1); opacity: 0; }
}

@keyframes slideInFromBottom {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes floatUp {
  0%   { transform: translateY(0); }
  50%  { transform: translateY(-5px); }
  100% { transform: translateY(0); }
}

@keyframes bounceIn {
  0%   { transform: scale(0.5); opacity: 0; }
  60%  { transform: scale(1.12); opacity: 1; }
  80%  { transform: scale(0.95); }
  100% { transform: scale(1); }
}

/* Utility animation classes */
.anim-slide-up   { animation: slideInFromBottom 0.32s cubic-bezier(0.16,1,0.3,1) forwards; }
.anim-fade-scale { animation: fadeInScale 0.28s cubic-bezier(0.16,1,0.3,1) forwards; }
.anim-float      { animation: floatUp 3s ease-in-out infinite; }
.anim-bounce-in  { animation: bounceIn 0.4s cubic-bezier(0.16,1,0.3,1) forwards; }

/* ══════════════════════════════════════════════════════════════════════
   B124 — Section entrance animations + module badge flash
   ══════════════════════════════════════════════════════════════════════ */

/* Sections need relative positioning for badge */
section[id$="-section"] { position: relative; overflow: clip; }

/* Fade + lift entrance when section becomes visible */
.section-entering {
  animation: sectionFadeIn 320ms cubic-bezier(0.16,1,0.3,1) both;
}
@keyframes sectionFadeIn {
  from { opacity: 0; transform: translateY(10px) scale(0.998); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* Transient module label badge — top-right corner */
.section-mod-badge {
  position: absolute;
  top: 0; right: 0;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px 4px 8px;
  background: var(--badge-c, var(--atlas));
  color: #fff;
  font-family: var(--font-display, 'Bricolage Grotesque', sans-serif);
  font-size: 0.60rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  border-radius: 0 var(--radius, 12px) 0 8px;
  pointer-events: none; z-index: 4;
  opacity: 0; transform: translateY(-6px) translateX(4px);
  animation: badgeIn 220ms cubic-bezier(0.16,1,0.3,1) 60ms forwards;
}
.section-mod-badge i { font-size: 0.75rem; opacity: 0.88; }
.section-mod-badge.is-out {
  animation: badgeOut 360ms ease forwards;
}
@keyframes badgeIn {
  to { opacity: 0.92; transform: translateY(0) translateX(0); }
}
@keyframes badgeOut {
  to { opacity: 0; transform: translateY(-6px) translateX(4px); }
}

/* h2 underline reveal — brief accent line draws in from left */
.h2-line-reveal {
  position: relative;
}
.h2-line-reveal::after {
  content: '';
  display: block;
  height: 2px;
  width: 0;
  margin-top: 5px;
  background: var(--h2-line-c, var(--atlas));
  border-radius: 2px;
  animation: h2Line 480ms cubic-bezier(0.16,1,0.3,1) 100ms forwards;
}
@keyframes h2Line {
  to { width: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  .section-entering        { animation: none; }
  .section-mod-badge       { animation: none; opacity: 0.92; transform: none; }
  .section-mod-badge.is-out{ opacity: 0; }
  .h2-line-reveal::after   { animation: none; width: 52px; }
}

/* ══════════════════════════════════════════════════════════════════════
   B125 — Swipe gesture navigation hint arrow
   ══════════════════════════════════════════════════════════════════════ */

#gesture-hint {
  position: fixed;
  top: 50%; transform: translateY(-50%);
  font-size: 3rem; font-weight: 900; line-height: 1;
  color: var(--atlas);
  pointer-events: none;
  z-index: 800;
  opacity: 0;
  transition: opacity 80ms linear;
  user-select: none;
  text-shadow: 0 0 24px rgba(192,84,42,0.3);
}
#gesture-hint[data-dir="left"]  { right: 18px; }
#gesture-hint[data-dir="right"] { left: 18px; }

@media (prefers-reduced-motion: reduce) {
  #gesture-hint { display: none; }
}

/* ══════════════════════════════════════════════════════════════════════
   B126 — ATLAS Status Bar (bottom metrics strip)
   ══════════════════════════════════════════════════════════════════════ */

#atlas-status-bar {
  position: fixed;
  bottom: 0;
  left: 64px; /* account for vertical rail */
  right: 0;
  height: 26px;
  background: rgba(10,8,6,0.92);
  border-top: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  padding: 0 10px 0 14px;
  gap: 10px;
  z-index: 390;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.67rem;
  color: rgba(255,255,255,0.45);
  /* Start hidden, slide up when .is-visible */
  transform: translateY(100%);
  opacity: 0;
  transition: transform 260ms cubic-bezier(0.16,1,0.3,1),
              opacity    200ms ease;
  pointer-events: none;
}
#atlas-status-bar.is-visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
[data-theme="light"] #atlas-status-bar {
  background: rgba(238,236,234,0.94);
  border-top-color: rgba(0,0,0,0.08);
  color: rgba(0,0,0,0.45);
}

.atlas-sb-metrics {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 7px;
  overflow: hidden;
  white-space: nowrap;
}
.atlas-sb-metrics strong { color: rgba(255,255,255,0.80); }
[data-theme="light"] .atlas-sb-metrics strong { color: rgba(0,0,0,0.72); }

.atlas-sb-sep  { opacity: 0.25; }

.atlas-sb-badge {
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 700;
  font-size: 0.60rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.atlas-sb-badge--ok   { background: rgba(5,150,105,0.22); color: #32D74B; }
.atlas-sb-badge--warn { background: rgba(217,119,6,0.22);  color: #D97706; }
.atlas-sb-badge--crit { background: rgba(220,38,38,0.22);  color: #FF453A; }

.atlas-sb-over { color: #FF453A; }
.atlas-sb-over i { font-size: 0.72rem; vertical-align: middle; }
.atlas-sb-ok   { color: #32D74B; }
.atlas-sb-ok i { font-size: 0.72rem; vertical-align: middle; }

.atlas-sb-close {
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,0.25); padding: 0 2px;
  font-size: 0.75rem; line-height: 1;
  display: flex; align-items: center;
  border-radius: 3px;
  transition: color 0.12s, background 0.12s;
  flex-shrink: 0;
}
.atlas-sb-close:hover { color: rgba(255,255,255,0.65); background: rgba(255,255,255,0.08); }
[data-theme="light"] .atlas-sb-close { color: rgba(0,0,0,0.25); }
[data-theme="light"] .atlas-sb-close:hover { color: rgba(0,0,0,0.65); background: rgba(0,0,0,0.06); }

/* Hide on mobile — mobile nav occupies bottom */
@media (max-width: 768px) {
  #atlas-status-bar { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #atlas-status-bar { transition: none; }
}

/* ══════════════════════════════════════════════════════════════════════
   B127 — Chart Zoom Modal (30-day CoV history)
   ══════════════════════════════════════════════════════════════════════ */

#chart-zoom-overlay {
  position: fixed; inset: 0; z-index: 7000;
  background: rgba(0,0,0,0.60);
  backdrop-filter: blur(12px) brightness(0.5);
  -webkit-backdrop-filter: blur(12px) brightness(0.5);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity 200ms ease;
}
#chart-zoom-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

#chart-zoom-card {
  background: var(--s1, #141210);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 16px;
  width: 100%; max-width: 720px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.05), 0 24px 64px rgba(0,0,0,0.55);
  overflow: hidden;
  transform: scale(0.93) translateY(12px);
  transition: transform 280ms cubic-bezier(0.16,1,0.3,1);
  padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
}
#chart-zoom-overlay.is-open #chart-zoom-card {
  transform: scale(1) translateY(0);
}
[data-theme="light"] #chart-zoom-card {
  background: #FFFFFF;
  border-color: rgba(0,0,0,0.10);
}

.czoom-header {
  display: flex; align-items: center; justify-content: space-between;
}
.czoom-title {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-display, 'Bricolage Grotesque', sans-serif);
  font-size: 0.95rem; font-weight: 700; color: var(--t1);
}
.czoom-title i { color: var(--atlas); font-size: 1.1rem; }
.czoom-close {
  background: rgba(255,255,255,0.07); border: none; cursor: pointer;
  border-radius: 8px; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  color: var(--t3); font-size: 0.9rem;
  transition: background 0.12s, color 0.12s;
}
.czoom-close:hover { background: rgba(255,255,255,0.14); color: var(--t1); }
[data-theme="light"] .czoom-close { background: rgba(0,0,0,0.05); }
[data-theme="light"] .czoom-close:hover { background: rgba(0,0,0,0.10); }

.czoom-legend {
  display: flex; gap: 16px; align-items: center;
}
.czoom-legend-item {
  display: flex; align-items: center; gap: 5px;
  font-size: 0.68rem; color: var(--t3);
}
.czoom-legend-dot {
  width: 8px; height: 8px; border-radius: 50%;
}
.czoom-legend-cov .czoom-legend-dot  { background: #C0542A; }
.czoom-legend-km  .czoom-legend-dot  { background: #409CFF; border: 1px dashed #409CFF; }

.czoom-canvas-wrap {
  width: 100%;
  height: 260px;
  position: relative;
}
#chart-zoom-canvas { width: 100% !important; height: 100% !important; }

.czoom-note {
  display: flex; gap: 10px; flex-wrap: wrap;
}
.czoom-zone {
  font-size: 0.62rem; font-family: 'Courier New', monospace;
  padding: 2px 8px; border-radius: 4px; font-weight: 600;
}
.czoom-zone-ok   { background: rgba(5,150,105,0.15); color: #32D74B; }
.czoom-zone-warn { background: rgba(217,119,6,0.15);  color: #D97706; }
.czoom-zone-crit { background: rgba(220,38,38,0.15);  color: #FF453A; }

/* Expand hint on sparkline */
.czoom-expand-hint {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px;
  color: var(--t4); cursor: pointer;
  font-size: 0.72rem; border-radius: 4px;
  transition: color 0.12s, background 0.12s;
  vertical-align: middle;
  margin-left: 4px;
}
.czoom-expand-hint:hover { color: var(--atlas); background: rgba(192,84,42,0.10); }

@media (max-width: 768px) {
  #chart-zoom-card { padding: 14px; }
  .czoom-canvas-wrap { height: 200px; }
}

@media (prefers-reduced-motion: reduce) {
  #chart-zoom-overlay, #chart-zoom-card { transition: none; }
}

/* ══════════════════════════════════════════════════════════════════════
   B128 — Share Briefing card (WhatsApp summary in home section)
   ══════════════════════════════════════════════════════════════════════ */

.share-briefing-card {
  background: var(--s1);
  border: 1px solid var(--b1);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.share-briefing-header { display: flex; align-items: center; justify-content: space-between; }
.share-briefing-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.72rem; font-weight: 700;
  color: var(--t2); text-transform: uppercase; letter-spacing: 0.08em;
}
.share-briefing-title i {
  color: #25D366; font-size: 1rem;
}
.share-briefing-title .atlas-badge { margin-left: 4px; }

.share-briefing-preview {
  background: var(--s2);
  border: 1px solid var(--b1);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.68rem;
  color: var(--t2);
  line-height: 1.65;
  white-space: pre-wrap;
  max-height: 130px;
  overflow-y: auto;
  user-select: text;
}
[data-theme="dark"] .share-briefing-preview {
  background: rgba(255,255,255,0.03);
}

.share-briefing-actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.share-briefing-hint {
  font-size: 0.62rem; color: var(--t4);
}

#share-briefing-btn.is-copied {
  background: rgba(5,150,105,0.12);
  border-color: var(--state-ok);
  color: var(--state-ok);
}

.btn--sm {
  font-size: 0.72rem;
  padding: 5px 12px;
  min-height: 28px;
}

/* ══════════════════════════════════════════════════════════════════════
   B129 — Plan Score: letter grade in home hero
   ══════════════════════════════════════════════════════════════════════ */

#plan-score {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  opacity: 0;
  transform: translateY(6px);
  animation: psEntrance 400ms cubic-bezier(0.16,1,0.3,1) 200ms forwards;
}
#plan-score.is-flipping .ps-grade {
  animation: psFlip 360ms cubic-bezier(0.16,1,0.3,1) forwards;
}
@keyframes psEntrance {
  to { opacity: 1; transform: translateY(0); }
}
@keyframes psFlip {
  0%   { transform: rotateX(0deg);   opacity: 1; }
  45%  { transform: rotateX(90deg);  opacity: 0; }
  55%  { transform: rotateX(-90deg); opacity: 0; }
  100% { transform: rotateX(0deg);   opacity: 1; }
}

.ps-grade {
  font-family: var(--font-display, 'Bricolage Grotesque', sans-serif);
  font-size: 2.6rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  min-width: 48px;
  text-align: center;
  transition: color 400ms ease;
}
.ps-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ps-label {
  font-family: var(--font-display, 'Bricolage Grotesque', sans-serif);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  transition: color 400ms ease;
}
.ps-sub {
  font-size: 0.62rem;
  color: rgba(255,255,255,0.40);
  line-height: 1.4;
}
[data-theme="light"] .ps-sub { color: rgba(0,0,0,0.38); }

/* Grade color variants */
.plan-score--aplus .ps-grade, .plan-score--aplus .ps-label { color: #32D74B; }
.plan-score--a     .ps-grade, .plan-score--a     .ps-label { color: #30D158; }
.plan-score--b     .ps-grade, .plan-score--b     .ps-label { color: #409CFF; }
.plan-score--c     .ps-grade, .plan-score--c     .ps-label { color: #D97706; }
.plan-score--d     .ps-grade, .plan-score--d     .ps-label { color: #FF9F0A; }
.plan-score--f     .ps-grade, .plan-score--f     .ps-label { color: #FF453A; }
.plan-score--idle  .ps-grade, .plan-score--idle  .ps-label { color: rgba(255,255,255,0.25); }
[data-theme="light"] .plan-score--idle .ps-grade,
[data-theme="light"] .plan-score--idle .ps-label { color: rgba(0,0,0,0.22); }

@media (prefers-reduced-motion: reduce) {
  #plan-score       { animation: none; opacity: 1; transform: none; }
  .ps-grade         { animation: none !important; }
}

/* ══════════════════════════════════════════════════════════════════════
   B131 — Monthly Report card (historical performance table)
   ══════════════════════════════════════════════════════════════════════ */

.monthly-report-card {
  background: var(--s1);
  border: 1px solid var(--b1);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.mr-header {
  display: flex; align-items: center; justify-content: space-between;
}
.mr-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.72rem; font-weight: 700;
  color: var(--t2); text-transform: uppercase; letter-spacing: 0.08em;
}
.mr-title i { color: var(--atlas); font-size: 1rem; }

.mr-table-wrap { overflow-x: auto; }
.mr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
}
.mr-table th {
  text-align: left; padding: 5px 8px 5px 4px;
  color: var(--t4); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  font-size: 0.60rem;
  border-bottom: 1px solid var(--b2);
  white-space: nowrap;
}
.mr-table td { padding: 6px 8px 6px 4px; white-space: nowrap; }
.mr-row + .mr-row td { border-top: 1px solid var(--b2); }

.mr-period { font-weight: 700; color: var(--t3); font-size: 0.68rem; }
.mr-val    { color: var(--t1); font-family: 'Courier New', monospace; font-weight: 600; }
.mr-sub    { color: var(--t3); font-size: 0.65rem; font-weight: 400; display: flex; gap: 4px; }
.mr-sep    { opacity: 0.4; }

.mr-cov--ok   { color: #32D74B; }
.mr-cov--warn { color: #D97706; }
.mr-cov--crit { color: #FF453A; }

.mr-trend { font-size: 0.9rem; }
.mr-trend--ok   i { color: #32D74B; }
.mr-trend--warn i { color: #FF453A; }
.mr-trend i { color: var(--t4); }

.mr-note {
  font-size: 0.60rem; color: var(--t4); margin: 0;
  padding-top: 4px; border-top: 1px solid var(--b2);
  line-height: 1.5;
}

/* ══════════════════════════════════════════════════════════════════════
   B134 — CoV Mosaic heatmap (GitHub contribution-style)
   ══════════════════════════════════════════════════════════════════════ */

.cov-mosaic-card {
  background: var(--s1);
  border: 1px solid var(--b1);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cov-mosaic-header { display: flex; align-items: center; justify-content: space-between; }
.cov-mosaic-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.72rem; font-weight: 700;
  color: var(--t2); text-transform: uppercase; letter-spacing: 0.08em;
}
.cov-mosaic-title i { color: var(--atlas); font-size: 1rem; }

.cov-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.cov-cell-header {
  font-size: 0.56rem;
  text-align: center;
  color: var(--t4);
  font-weight: 600;
  padding: 1px 0;
  text-transform: uppercase;
}

.cov-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  min-width: 10px;
  cursor: default;
  transition: transform 80ms ease, box-shadow 80ms ease;
}
.cov-cell:hover {
  transform: scale(1.2);
  box-shadow: 0 2px 8px rgba(0,0,0,0.30);
  z-index: 2;
  position: relative;
}

.cov-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.cov-legend-prefix {
  font-size: 0.60rem;
  color: var(--t4);
}
.cov-legend-cell {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 2px;
}
.cov-legend-lbl {
  font-size: 0.58rem;
  color: var(--t4);
  margin-right: 4px;
  font-family: 'Courier New', monospace;
}

/* ══ B135 — perf_radar ══════════════════════════════════════════════ */
#perf-radar-panel {
  display: flex;
  flex-direction: column;
}
#perf-radar-panel h3 {
  margin-bottom: 8px;
}
#perf-radar-panel canvas {
  max-width: 100%;
}

/* ══ B136 — card_sheen ══════════════════════════════════════════════ */
.stat-card,
.dashboard-item.card-inner,
.cov-mosaic-card,
.monthly-report-card,
.share-briefing-card {
  position: relative;
  overflow: hidden;
}
.card-sheen-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  border-radius: inherit;
  z-index: 10;
}
@media (prefers-reduced-motion: reduce) {
  .card-sheen-overlay { display: none; }
}

/* ══ B137 — hotkeys_panel ═══════════════════════════════════════════ */
.hk-backdrop {
  position: fixed;
  inset: 0;
  z-index: 8500;
  background: rgba(0,0,0,0.40);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  backdrop-filter: blur(2px);
}
.hk-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}
#hotkeys-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 8600;
  width: min(420px, 96vw);
  background: var(--s1);
  border-left: 1px solid var(--b1);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  overflow: hidden;
  outline: none;
}
#hotkeys-panel.is-open {
  transform: translateX(0);
}
.hk-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--b1);
  flex-shrink: 0;
}
.hk-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--t1);
  display: flex;
  align-items: center;
  gap: 8px;
}
.hk-title i { color: var(--atlas); }
.hk-close {
  background: none;
  border: none;
  color: var(--t3);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  line-height: 1;
  font-size: 1rem;
  transition: color 0.15s, background 0.15s;
}
.hk-close:hover { color: var(--t1); background: var(--b1); }
.hk-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.hk-group {}
.hk-group-label {
  font-size: 0.70rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--atlas);
  margin-bottom: 8px;
}
.hk-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--b1);
}
.hk-row:last-child { border-bottom: none; }
.hk-keys {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  min-width: 100px;
}
.hk-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid var(--b2);
  background: var(--s2);
  color: var(--t1);
  font-family: 'Courier New', monospace;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 1px 0 var(--b2);
}
.hk-plus {
  color: var(--t4);
  font-size: 0.75rem;
  padding: 0 1px;
}
.hk-desc {
  font-size: 0.82rem;
  color: var(--t2);
  line-height: 1.35;
}
.hk-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--b1);
  font-size: 0.75rem;
  color: var(--t4);
  flex-shrink: 0;
}
[data-theme="dark"] .hk-key { box-shadow: 0 1px 0 rgba(0,0,0,0.5); }

/* ══ B138 — performance_factors ═════════════════════════════════════ */
#perf-factors-card {
  background: var(--s1);
  border: 1px solid var(--b1);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 12px;
}
.pf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.pf-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--t1);
}
.pf-title i { color: var(--atlas); }
.pf-score {
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-family: 'Bricolage Grotesque', 'Inter', sans-serif;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.pf-grade {
  font-size: 0.72rem;
  font-weight: 500;
  opacity: 0.75;
  font-family: 'Inter', sans-serif;
}
.pf-factors {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pf-factor {}
.pf-factor-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.pf-factor-label {
  font-size: 0.78rem;
  color: var(--t2);
}
.pf-factor-pct {
  font-size: 0.80rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.pf-bar-track {
  width: 100%;
  height: 5px;
  background: var(--b1);
  border-radius: 99px;
  overflow: hidden;
}
.pf-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.7s cubic-bezier(0.16,1,0.3,1);
}
.pf-note {
  display: block;
  font-size: 0.70rem;
  color: var(--t4);
  margin-top: 2px;
}
.pf-ceiling {
  margin-top: 12px;
  padding: 8px 12px;
  background: rgba(217,119,6,0.09);
  border-left: 3px solid #d97706;
  border-radius: 0 8px 8px 0;
  font-size: 0.75rem;
  color: var(--t2);
  display: flex;
  gap: 6px;
  align-items: flex-start;
}
.pf-ceiling i { color: #d97706; flex-shrink: 0; margin-top: 1px; }
.pf-recs {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.pf-rec {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  font-size: 0.74rem;
  color: var(--t3);
}
.pf-rec i { color: var(--atlas); flex-shrink: 0; margin-top: 1px; }
.pf-empty {
  font-size: 0.80rem;
  color: var(--t4);
  text-align: center;
  padding: 8px 0;
}

/* ══ B139 — loading_bar ══════════════════════════════════════════════ */
#atlas-loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  z-index: 9900;
  background: linear-gradient(90deg, var(--atlas, #C0542A) 0%, #e85d04 60%, #fbbf24 100%);
  box-shadow: 0 0 8px rgba(192,84,42,0.70);
  opacity: 0;
  pointer-events: none;
  border-radius: 0 1px 1px 0;
}

/* ══ B140 — doc_status_chips ════════════════════════════════════════ */
.dsc-wrap {
  margin-bottom: 12px;
}
.dsc-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--t3);
  margin-bottom: 7px;
}
.dsc-header i { color: var(--atlas); font-size: 0.88rem; }
.dsc-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.dsc-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 99px;
  border: 1px solid var(--b1);
  font-size: 0.73rem;
  color: var(--t2);
  cursor: default;
  user-select: none;
  transition: transform 0.15s, box-shadow 0.15s;
}
.dsc-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0,0,0,0.10);
}
.dsc-icon { font-size: 0.82rem; color: var(--t3); }
.dsc-label { font-weight: 500; }
.dsc-crit {
  font-size: 0.58rem;
  color: var(--atlas);
  line-height: 1;
}
.dsc-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ══ B141 — workflow_steps ══════════════════════════════════════════ */
#wo-steps {
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 12px 20px 6px;
}
body[data-mode="wo"] #wo-steps { display: flex; }
.wf-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.wf-step-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--b2);
  background: var(--s1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.90rem;
  color: var(--t4);
  transition: border-color 0.25s, background 0.25s, color 0.25s, box-shadow 0.25s;
  flex-shrink: 0;
}
.wf-step-label {
  font-size: 0.68rem;
  color: var(--t4);
  text-align: center;
  white-space: nowrap;
  transition: color 0.25s;
}
.wf-connector {
  flex-shrink: 0;
  width: 60px;
  height: 2px;
  background: var(--b2);
  margin-top: 16px; /* vertically align with circle midpoint (34px / 2 = 17px, -1px for border) */
  transition: background 0.3s;
}
.wf-step.is-active .wf-step-circle {
  border-color: var(--atlas);
  background: rgba(192,84,42,0.10);
  color: var(--atlas);
  box-shadow: 0 0 0 4px rgba(192,84,42,0.12);
}
.wf-step.is-active .wf-step-label { color: var(--atlas); font-weight: 600; }
.wf-step.is-completed .wf-step-circle {
  border-color: #1a7f37;
  background: rgba(26,127,55,0.10);
  color: #1a7f37;
}
.wf-step.is-completed .wf-step-label { color: #1a7f37; }
.wf-step.is-completed + .wf-connector { background: #1a7f37; }
@media (max-width: 480px) {
  .wf-connector { width: 30px; }
  .wf-step-label { display: none; }
}

/* ══ B142 — nav_badges ══════════════════════════════════════════════ */
.rail-item {
  position: relative;
}
.rb-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  font-size: 0.58rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-family: 'Courier New', monospace;
  color: #fff;
  background: #1a7f37;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
  transition: background 0.3s, opacity 0.3s;
  z-index: 2;
}

/* ══ B146 — time_greeting ═══════════════════════════════════════════ */
.tg-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.78rem;
  color: var(--t3);
  animation: tgFadeIn 0.6s ease both;
}
@keyframes tgFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.tg-greet {
  font-weight: 600;
  color: var(--t2);
}
.tg-sep {
  opacity: 0.4;
}
.tg-date {
  font-variant-numeric: tabular-nums;
  text-transform: capitalize;
}
.tg-time {
  font-family: 'Courier New', monospace;
  font-size: 0.80rem;
  font-weight: 600;
  color: var(--atlas);
  letter-spacing: 0.04em;
}

/* ══ B144 — expandable ══════════════════════════════════════════════ */
.ec-body {
  overflow: hidden;
  max-height: 900px;
  transition: max-height 0.38s cubic-bezier(0.16,1,0.3,1);
}
.is-collapsed .ec-body {
  max-height: 0;
}
.ec-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px 5px;
  color: var(--t4);
  line-height: 1;
  border-radius: 5px;
  transition: color 0.15s, background 0.15s, transform 0.25s;
  flex-shrink: 0;
  margin-left: auto;
  font-size: 0.85rem;
}
.ec-toggle-btn:hover { color: var(--t1); background: var(--b1); }
.is-collapsed .ec-toggle-btn { transform: rotate(-90deg); }
/* Ensure headers that receive the button are flex-row */
.cov-mosaic-header,
.dsc-header,
.mr-header,
.pf-header { display: flex !important; align-items: center; }

/* ── B147 — session_insights ─────────────────────────────────────────── */
.si-card {
  background: var(--s1);
  border: 1px solid var(--b2);
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 12px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.si-card.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.si-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.70rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--t3);
  margin-bottom: 10px;
}
.si-header .ti { font-size: 0.85rem; color: var(--atlas); }
.si-chips {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.si-chip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--t2);
  line-height: 1.4;
}
.si-chip .ti {
  font-size: 0.85rem;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── B148 — toast notifications ─────────────────────────────────────── */
#atlas-toasts {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9800;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 340px;
}
.at-toast {
  background: var(--s2);
  border: 1px solid var(--b2);
  border-radius: 10px;
  overflow: hidden;
  pointer-events: all;
  box-shadow: 0 4px 18px rgba(0,0,0,0.18);
  opacity: 0;
  transform: translateX(28px);
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16,1,0.3,1);
}
.at-toast.at-visible {
  opacity: 1;
  transform: translateX(0);
}
.at-toast.at-leaving {
  opacity: 0;
  transform: translateX(28px);
  transition: opacity 0.28s ease, transform 0.28s ease;
}
.at-body {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
}
.at-body .ti { font-size: 1rem; flex-shrink: 0; }
.at-msg {
  flex: 1;
  font-size: 0.78rem;
  color: var(--t1);
  line-height: 1.35;
}
.at-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--t4);
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 0.72rem;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.at-close:hover { color: var(--t1); background: var(--b1); }
.at-bar {
  height: 3px;
  background: var(--b2);
  overflow: hidden;
}
.at-bar-fill {
  height: 100%;
  width: 100%;
}
@media (max-width: 480px) {
  #atlas-toasts { right: 8px; left: 8px; max-width: none; }
}

/* ── B149 — cov_sparkline ───────────────────────────────────────────── */
.spk-wrap {
  display: flex;
  align-items: center;
  margin-left: auto;
  opacity: 0.85;
  flex-shrink: 0;
}
.spk-wrap:hover { opacity: 1; }
.spk-svg {
  display: block;
  overflow: visible;
}

/* ── B153 — print_report ────────────────────────────────────────────── */
.pr-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid var(--b2);
  border-radius: 7px;
  padding: 5px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--t3);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.pr-btn:hover {
  color: var(--atlas);
  border-color: var(--atlas);
  background: rgba(192,84,42,0.06);
}
.pr-btn .ti { font-size: 0.85rem; }

/* ── B155 — module_header_stats ─────────────────────────────────────── */
.mhs-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 8px 16px;
  background: var(--s1);
  border-bottom: 1px solid var(--b1);
  font-size: 0.72rem;
}
.mhs-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.mhs-pill .ti { font-size: 0.78rem; }
.mhs-val {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-family: 'Courier New', monospace;
}
.mhs-lbl { color: var(--t4); }
.mhs-sep {
  color: var(--t4);
  font-size: 0.65rem;
  opacity: 0.5;
}

/* ── B156 — data_age_indicator ──────────────────────────────────────── */
.dai-bar {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.68rem;
  padding: 4px 0 8px;
  opacity: 0.75;
  transition: opacity 0.2s;
}
.dai-bar:hover { opacity: 1; }
.dai-bar .ti { font-size: 0.72rem; }

/* ── B157 — gauge_arc ───────────────────────────────────────────────── */
.ga-card {
  background: var(--s1);
  border: 1px solid var(--b2);
  border-radius: 12px;
  padding: 12px 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-bottom: 10px;
  max-width: 220px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.ga-card.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.ga-label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--t4);
}
.ga-svg { display: block; }
.ga-val {
  font-family: 'Courier New', monospace;
  font-size: 1.30rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-top: -4px;
}

/* ── B158 — quick_actions_fab ───────────────────────────────────────── */
#qaf-wrap {
  position: fixed;
  bottom: 24px;
  right: 20px;
  z-index: 8000;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 10px;
}
#qaf-main {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--atlas);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(192,84,42,0.40);
  transition: background 0.2s, box-shadow 0.2s, transform 0.2s;
}
#qaf-main:hover {
  background: #a8441f;
  box-shadow: 0 6px 22px rgba(192,84,42,0.55);
  transform: scale(1.06);
}
#qaf-icon { transition: transform 0.25s cubic-bezier(0.16,1,0.3,1); }
.qaf-action-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--s2);
  color: var(--t2);
  border: 1px solid var(--b2);
  cursor: pointer;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.14);
  opacity: 0;
  transform: translateY(12px) scale(0.85);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.16,1,0.3,1),
              background 0.15s, color 0.15s;
}
.qaf-action-btn:hover { background: var(--atlas); color: #fff; border-color: var(--atlas); }
#qaf-wrap.is-open .qaf-action-btn {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}
#qaf-wrap.is-open .qaf-action-btn:nth-child(1) { transition-delay: 0.03s; }
#qaf-wrap.is-open .qaf-action-btn:nth-child(2) { transition-delay: 0.06s; }
#qaf-wrap.is-open .qaf-action-btn:nth-child(3) { transition-delay: 0.09s; }
#qaf-wrap.is-open .qaf-action-btn:nth-child(4) { transition-delay: 0.12s; }
@media (max-width: 640px) {
  #qaf-wrap { bottom: 80px; }
}

/* ── B159 — status_panel ────────────────────────────────────────────── */
.sp-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.50);
  backdrop-filter: blur(4px);
  z-index: 9400;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.sp-overlay.is-visible {
  opacity: 1;
  pointer-events: all;
}
.sp-panel {
  width: 340px;
  max-width: 95vw;
  max-height: 92vh;
  background: var(--s1);
  border-left: 1px solid var(--b2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(100%);
  transition: transform 0.30s cubic-bezier(0.16,1,0.3,1);
  min-height: 100vh;
}
.sp-panel.is-visible { transform: translateX(0); }
.sp-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--b2);
  flex-shrink: 0;
}
.sp-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--t1);
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}
.sp-title .ti { color: var(--atlas); }
.sp-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--t4);
  padding: 4px 6px;
  border-radius: 5px;
  font-size: 0.85rem;
  transition: color 0.15s, background 0.15s;
}
.sp-close:hover { color: var(--t1); background: var(--b1); }
.sp-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 24px;
}
.sp-section {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--b1);
}
.sp-section:last-child { border-bottom: none; }
.sp-section-title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--t4);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.sp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}
.sp-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sp-key {
  font-size: 0.72rem;
  color: var(--t3);
  flex: 1;
}
.sp-val {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--t1);
  font-variant-numeric: tabular-nums;
}
.sp-mods {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.sp-mod-chip {
  font-size: 0.60rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
  line-height: 1.5;
}
.sp-mod-ok      { background: rgba(26,127,55,0.12); color: #1a7f37; }
.sp-mod-missing { background: var(--b1); color: var(--t4); }

/* ── B160 — announcement_banner ────────────────────────────────────── */
#atlas-banners {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.ab-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border-left: 3px solid #d97706;
  font-size: 0.76rem;
  color: var(--t2);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.ab-banner.ab-visible {
  opacity: 1;
  transform: translateY(0);
}
.ab-banner.ab-hiding {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.28s ease, transform 0.28s ease;
}
.ab-icon { font-size: 0.9rem; flex-shrink: 0; }
.ab-msg  { flex: 1; line-height: 1.4; }
.ab-dismiss {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--t4);
  padding: 3px 5px;
  border-radius: 4px;
  font-size: 0.72rem;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.ab-dismiss:hover { color: var(--t1); background: var(--b1); }

/* ══════════════════════════════════════════════════════════════════════
   B219 — Light mode micro-polish
   ══════════════════════════════════════════════════════════════════════ */

/* hero-refresh-btn: white bg/border invisible in light */
[data-theme="light"] .hero-refresh-btn {
  background: rgba(0,0,0,0.05);
  border-color: rgba(0,0,0,0.10);
  color: var(--t3);
}
[data-theme="light"] .hero-refresh-btn:hover {
  background: rgba(0,0,0,0.08);
  border-color: rgba(0,0,0,0.16);
  color: var(--t1);
}

/* aging-collapse-btn hover: white bg invisible in light */
[data-theme="light"] .aging-collapse-btn:hover { background: rgba(0,0,0,0.05); }

/* rail cmd-btn: white text invisible in light */
[data-theme="light"] .rail-foot-btn--cmd:hover { color: rgba(0,0,0,0.72) !important; }

/* ct-topbar action buttons hover: white bg invisible in light */
[data-theme="light"] .ct-topbar__actions .cmd-palette-btn:hover,
[data-theme="light"] .ct-topbar__actions .theme-toggle:hover {
  background: rgba(0,0,0,0.06) !important;
}

/* Toast: clear the 44px topbar on desktop (was top:16px) */
@media (min-width: 769px) { #atlas-toasts { top: 60px; } }

/* Card shadow: slightly more present on near-white #FAFAFA bg */
[data-theme="light"] .card {
  box-shadow: 0 1px 3px rgba(0,0,0,0.07), 0 6px 20px rgba(0,0,0,0.06),
              inset 0 1px 0 rgba(255,255,255,0.95);
}

/* ── cat-algo-details: algorithm explanation popover (B214) ── */
.cat-algo-details { position:relative; display:inline-flex; align-items:center; }
.cat-algo-details > summary {
  list-style:none; cursor:pointer;
  color:var(--t3); font-size:0.9rem; padding:2px 4px; line-height:1;
  transition:color .15s;
}
.cat-algo-details > summary::-webkit-details-marker { display:none; }
.cat-algo-details > summary:hover,
.cat-algo-details[open] > summary { color:var(--atlas,#C0542A); }
.cat-algo-panel {
  position:absolute; top:calc(100% + 6px); left:0; z-index:60;
  width:288px;
  background:var(--s2);
  border:1px solid var(--glass-border);
  border-radius:10px;
  padding:14px 16px;
  font-size:0.78rem;
  font-weight:400;
  color:var(--t2);
  line-height:1.55;
  box-shadow:0 6px 24px rgba(0,0,0,.35);
  white-space:normal;
}

/* ══════════════════════════════════════════════════════════════════════
   ══ B222 ══  Control tower polish: topbar compacto, hero denso,
   gauge legible, cov-mosaic colapsable. Solo añade — no toca tokens.
   ══════════════════════════════════════════════════════════════════════ */

/* ── DISEÑO 3 — Topbar más compacto (44px → 40px) ─────────────────────── */
#ct-topbar { height: 40px; }
@media (min-width: 769px) { body { padding-top: 40px; } }
/* Toast clears the now-shorter topbar */
@media (min-width: 769px) { #atlas-toasts { top: 54px; } }
/* Tighter right cluster + smaller icon targets in the bar */
.ct-topbar__actions { gap: 2px; }
#ct-topbar .topbar-icon-btn,
#ct-topbar .theme-toggle { width: 30px; height: 30px; font-size: 0.9rem; }

/* ── DISEÑO 5 — Hero ATLAS: compacto, dos columnas, sin vacío ─────────── */
.home-hero-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 18px;
  /* B224: sin tope de altura — el max-height:160px + overflow:hidden recortaba el
     badge de nota del plan ("Mejorar") al fondo del hero. Que crezca con su contenido. */
  padding: 16px 22px 18px;
  margin-bottom: 14px;
}
/* Izquierda: título + tagline + strip de métricas, apilados y compactos */
.home-hero-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.home-hero-title { font-size: clamp(1.9rem, 4vw, 2.9rem); }
.home-hero-sub { margin-top: 2px; }
/* Strip (fecha prominente + CoV badge + estado) en línea, bajo el título */
.home-hero-strip { margin-top: 8px; gap: 12px; }
.home-hero-chip { font-size: 0.78rem; }
.home-hero-chip .ti { font-size: 0.84rem; }
/* Derecha: botón refresh ocupa la columna auto, sin dejar hueco vacío */
.home-hero-header .hero-refresh-btn {
  grid-column: 2;
  position: relative;
  align-self: flex-start;
  flex-shrink: 0;
}
@media (max-width: 520px) {
  .home-hero-header {
    grid-template-columns: 1fr;
    max-height: none;
  }
  .home-hero-header .hero-refresh-btn {
    grid-column: 1;
    justify-self: end;
  }
}

/* ── DISEÑO 6 — COV Gauge: legible, centrado, número dominante ────────── */
.ga-card {
  min-width: 200px;
  min-height: 160px;
  max-width: 240px;
  justify-content: center;
  padding: 14px 18px 10px;
}
.ga-svg {
  width: 100%;
  max-width: 180px;
  height: auto;
  margin: 0 auto;
}
.ga-val {
  font-size: 1.8rem;
  margin-top: 2px;
}

/* ── BUG 2 — COV Mosaic toggle (colapso por defecto) ──────────────────── */
.cov-toggle-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--t3);
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  min-width: 30px;
  border-radius: 8px;
  font-size: 1rem;
  flex-shrink: 0;
  transition: background 0.14s ease-out, color 0.14s ease-out;
}
.cov-toggle-btn:hover { color: var(--atlas); background: var(--atlas-l); }
.cov-toggle-btn .ti {
  transition: transform 0.18s ease-out;
}
/* Colapsado: chevron apunta a la derecha, grid y leyenda ocultos */
.cov-mosaic-card.is-collapsed .cov-toggle-btn .ti { transform: rotate(-90deg); }
.cov-mosaic-card.is-collapsed .cov-grid,
.cov-mosaic-card.is-collapsed .cov-legend { display: none; }

/* ══════════════════════════════════════════════════════════════════════
   ══ B246 ══  Topbar stability: progress bar, clock, mobile fixes
   ══════════════════════════════════════════════════════════════════════ */

/* ── 1. Progress bar below topbar — was top:0 z-index:500, running over clock ── */
#atlas-progress { top: 40px; }

/* ── 2. Mobile topbar: lock position, drop left-transition, fix body offset ── */
@media (max-width: 768px) {
  #ct-topbar {
    left: 0 !important;
    /* Remove `left` from transition — prevents topbar sliding from :has(rail:hover)
       whose specificity (2,1,1) beats the mobile left:0 override (1,0,0) */
    transition: border-bottom-color 240ms var(--ease-out-quart, cubic-bezier(0.25,1,0.5,1));
  }
  body { padding-top: 40px; }
  #atlas-toasts { top: 54px; }
}

/* ── 3. Clock legibility: was opacity:0.65 on var(--t3) — too dim ── */
.ct-topbar__date { opacity: 0.85; }

/* ══════════════════════════════════════════════════════════════════════
   ══ B247 ══  Premium interactions: depth reveal, tilt reactivation,
               rail pulse, progress bar clearance
   ══════════════════════════════════════════════════════════════════════ */

/* ── 1. Progress bar: 6px clearance below topbar (was 0px gap) ── */
#atlas-progress { top: 46px; }

/* ══════════════════════════════════════════════════════════════════════
   ══ B248 ══  Profile avatar, topbar fix, shortcuts reorder
   ══════════════════════════════════════════════════════════════════════ */

/* ── 1. Progress bar: restore to topbar bottom — 46px was cutting into card area ── */
#atlas-progress { top: 40px; }

/* ── 2. Profile avatar in topbar ── */
#_profile-avatar-btn {
  flex-shrink: 0;
  font-family: var(--font-display, 'Bricolage Grotesque', sans-serif);
}

/* ── 3. Shortcut drag states ── */
[data-shortcut-id].is-dragging { opacity: 0.38; }
[data-shortcut-id].is-drag-over {
  outline: 2px solid var(--atlas) !important;
  background: var(--atlas-l) !important;
  transform: scale(1.04);
}

/* ── 2. Rail pulse — active icon breathes at 3.2s, off on hover ── */
@keyframes atlas-rail-pulse {
  0%, 100% { opacity: 1;    transform: scale(1); }
  50%       { opacity: 0.62; transform: scale(0.88); }
}
.rail-item.active .rail-item__icon {
  animation: atlas-rail-pulse 3.2s ease-in-out infinite;
}
.rail-item:hover .rail-item__icon,
.rail-item:focus-within .rail-item__icon { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .rail-item.active .rail-item__icon { animation: none; }
}

/* ══ B251 ══  Topbar breathing room · profile chip in home */
/* Topbar actions: gap 2px → 6px, right padding so content clears the edge */
.ct-topbar__actions { gap: 6px !important; padding-right: 8px; }
/* Safety: hide avatar button if ever re-injected */
#_profile-avatar-btn { display: none !important; }

/* ══ B252 ══  Profile pending: block app content until first-run profile is set */
html._atlas-profile-pending #main-content,
html._atlas-profile-pending #atlas-rail,
html._atlas-profile-pending #ct-topbar { visibility: hidden; }


/* ════════════════════════════════════════════════════════════════
   GUÍA BAAN — B266 (pestaña informativa, contenido en baan_guide.js)
   ════════════════════════════════════════════════════════════════ */
#baan-section:not(.hidden) { display: flex; flex-direction: column; gap: 24px; }

#baan-section h2 { display: flex; align-items: center; gap: 8px; }
#baan-section h2 .ti { color: var(--atlas); font-size: 1.15rem; }

.baan-hero {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  background: var(--atlas-l);
  border: 1px solid var(--atlas-b);
  border-left: 3px solid var(--atlas);
  border-radius: var(--r-lg);
}
.baan-hero .ti { font-size: 1.6rem; color: var(--atlas); flex-shrink: 0; }
.baan-hero p { color: var(--t1); font-size: 0.95rem; line-height: 1.65; font-weight: 500; margin: 0; }

.baan-section-intro {
  color: var(--t3);
  font-size: 0.875rem;
  line-height: 1.6;
  margin-bottom: 18px;
}

/* Estados */
.baan-status-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 12px; }
.baan-status-row {
  padding: 14px 16px;
  background: var(--s2);
  border: 1px solid var(--b2);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.baan-status-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.baan-status-plan { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.7px; color: var(--t3); }
.baan-status-desc { font-size: 0.84rem; color: var(--t2); line-height: 1.55; margin: 0; }
.baan-status-action { font-size: 0.82rem; color: var(--t1); line-height: 1.55; display: flex; gap: 6px; margin: 0; }
.baan-status-action .ti { color: var(--atlas); flex-shrink: 0; margin-top: 2px; }

.baan-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.baan-pill-blue  { background: var(--blue-l);  color: var(--blue);  border: 1px solid var(--blue-b); }
.baan-pill-sage  { background: var(--sage-l);  color: var(--sage);  border: 1px solid var(--sage-b); }
.baan-pill-atlas { background: var(--atlas-l); color: var(--atlas); border: 1px solid var(--atlas-b); }
.baan-pill-rose  { background: var(--rose-l);  color: var(--rose);  border: 1px solid var(--rose-b); }
.baan-pill-slate { background: var(--slate-l); color: var(--t2);    border: 1px solid var(--slate-b); }
.baan-pill-muted { background: var(--s3);      color: var(--t3);    border: 1px solid var(--b1); }

/* Tablas de campos */
.baan-table-wrap { overflow-x: auto; border: 1px solid var(--b2); border-radius: var(--r-lg); }
.baan-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; min-width: 640px; }
.baan-table th {
  text-align: left;
  padding: 10px 14px;
  background: var(--s2);
  color: var(--t3);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-bottom: 1px solid var(--b1);
}
.baan-table td { padding: 11px 14px; border-bottom: 1px solid var(--b2); color: var(--t2); line-height: 1.55; vertical-align: top; }
.baan-table tbody tr:last-child td { border-bottom: none; }
.baan-td-name { font-weight: 600; color: var(--t1); white-space: nowrap; }
.baan-td-why { color: var(--t3); }
.baan-req { color: var(--atlas); font-weight: 800; }

/* Métricas */
.baan-metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 12px; }
.baan-metric-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--s2);
  border: 1px solid var(--b2);
  border-radius: var(--r-lg);
}
.baan-metric-card > .ti { font-size: 1.3rem; color: var(--blue); flex-shrink: 0; margin-top: 2px; }
.baan-metric-name { font-size: 0.88rem; font-weight: 600; color: var(--t1); margin-bottom: 3px; }
.baan-metric-from { font-size: 0.78rem; color: var(--t3); line-height: 1.5; }

/* Errores */
.baan-errors-list { display: flex; flex-direction: column; gap: 10px; }
.baan-error-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  background: var(--rose-l);
  border: 1px solid var(--rose-b);
  border-radius: var(--r-lg);
}
.baan-error-item > .ti { color: var(--rose); font-size: 1.1rem; flex-shrink: 0; margin-top: 2px; }
.baan-error-text { font-size: 0.86rem; font-weight: 600; color: var(--t1); margin-bottom: 2px; }
.baan-error-effect { font-size: 0.8rem; color: var(--t2); line-height: 1.5; }

/* Checklist */
.baan-checklist { display: flex; flex-direction: column; gap: 8px; }
.baan-check-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 10px 16px;
  background: var(--s2);
  border: 1px solid var(--b2);
  border-radius: var(--r-lg);
  font-family: var(--font);
  font-size: 0.88rem;
  color: var(--t1);
  text-align: left;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}
.baan-check-item:hover { border-color: var(--b1); }
.baan-check-item .ti { font-size: 1.2rem; color: var(--t3); flex-shrink: 0; transition: color 150ms ease; }
.baan-check-item.done { background: var(--sage-l); border-color: var(--sage-b); }
.baan-check-item.done .ti { color: var(--sage); }
.baan-check-item.done span { color: var(--t2); text-decoration: line-through; }
.baan-check-item:focus-visible { outline: 2px solid var(--atlas); outline-offset: 2px; }

/* Informes */
.baan-reports-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 12px; }
.baan-report-card {
  padding: 16px;
  background: var(--s2);
  border: 1px solid var(--b2);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.baan-report-head { display: flex; align-items: center; gap: 12px; }
.baan-report-head .ti { font-size: 1.4rem; color: var(--atlas); }
.baan-report-name { font-size: 0.95rem; font-weight: 700; color: var(--t1); }
.baan-report-meta { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.7px; color: var(--t3); }
.baan-report-desc { font-size: 0.83rem; color: var(--t2); line-height: 1.55; margin: 0; }
.baan-report-cols {
  font-size: 0.76rem;
  color: var(--t3);
  background: var(--s3);
  border: 1px solid var(--b2);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  line-height: 1.6;
}

@media (max-width: 767px) {
  .baan-status-list, .baan-metrics-grid, .baan-reports-grid { grid-template-columns: 1fr; }
  .baan-hero { flex-direction: column; gap: 8px; }
}
/* B267 — subtítulos de la sección pantalla de órdenes */
.baan-subhead {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--atlas);
  margin: 18px 0 10px;
}
.baan-subhead:first-of-type { margin-top: 4px; }
/* B268 — protocolo en 3 momentos */
.baan-protocol { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px; margin-bottom: 20px; }
.baan-step {
  background: var(--s2);
  border: 1px solid var(--b2);
  border-top: 3px solid var(--atlas);
  border-radius: var(--r-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.baan-step-head { display: flex; align-items: flex-start; gap: 12px; }
.baan-step-num {
  font-size: 1.6rem; font-weight: 800; color: var(--atlas);
  line-height: 1; flex-shrink: 0; margin-top: 2px;
}
.baan-step-title { font-size: 0.95rem; font-weight: 700; color: var(--t1); display: flex; align-items: center; gap: 6px; }
.baan-step-title .ti { color: var(--atlas); }
.baan-step-sub { font-size: 0.78rem; color: var(--t3); line-height: 1.5; margin-top: 2px; }
.baan-step-items { display: flex; flex-direction: column; gap: 10px; }
.baan-step-item { border-left: 2px solid var(--b1); padding-left: 10px; }
.baan-step-field { font-size: 0.85rem; font-weight: 600; color: var(--t1); display: flex; gap: 5px; }
.baan-step-field .ti { color: var(--atlas); flex-shrink: 0; margin-top: 2px; font-size: 0.85rem; }
.baan-step-tip { font-size: 0.78rem; color: var(--t3); line-height: 1.5; margin-top: 2px; }
@media (max-width: 1023px) { .baan-protocol { grid-template-columns: 1fr; } }
/* B272 — banner de fuente Excel por módulo */
.src-hint {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
  background: var(--atlas-l);
  border: 1px solid var(--atlas-b);
  border-left: 3px solid var(--atlas);
  border-radius: var(--r-lg);
}
.src-hint > .ti { color: var(--atlas); font-size: 1.15rem; flex-shrink: 0; margin-top: 1px; }
.src-hint__body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.src-hint__file { font-size: 0.84rem; font-weight: 700; color: var(--t1); }
.src-hint__path { font-size: 0.76rem; color: var(--t3); line-height: 1.5; }

/* ══════════════════════════════════════════════════════════════════════
   B273 — CONTROL TOWER V2 · home "Torre de control / Briefing"
   Dirección A (briefing operativo) + feed "Cómo decidió" de B.
   Solo tokens. Móvil ≤768px con lenguaje Nike/Apple: display grande,
   stacking 1 col, CTAs full-width, tap-targets ≥44px.
   ══════════════════════════════════════════════════════════════════════ */

/* La cabecera hero heredada (ATLAS + build) la sustituye la topbar v2 */
#home-section:not(.hidden) .home-hero-header { display: none; }

.ctv2 { display: flex; flex-direction: column; gap: 18px; }

/* ── Top bar ── */
.ctv2-topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ctv2-titlewrap { display: flex; flex-direction: column; gap: 2px; }
.ctv2-title {
  margin: 0;
  font-family: var(--font-display,'Bricolage Grotesque',sans-serif);
  font-weight: 700;
  font-size: clamp(1.45rem, 3.2vw, 1.65rem);
  letter-spacing: -0.3px;
  color: var(--t1);
}
.ctv2-clock { font-family: 'Courier New', monospace; font-size: 0.75rem; color: var(--t3); }
.ctv2-topbar__spacer { flex: 1; }
.ctv2-search {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 9px 14px;
  background: var(--s2); border: 1px solid var(--b1); border-radius: var(--r);
  color: var(--t3); font-size: 0.8rem; cursor: pointer;
  transition: border-color 140ms ease-out;
}
.ctv2-search:hover { border-color: var(--atlas-b); }
.ctv2-search .ti { font-size: 0.95rem; }
.ctv2-kbd {
  font-family: 'Courier New', monospace; font-size: 0.68rem; color: var(--t4);
  border: 1px solid var(--b1); border-radius: var(--r-sm); padding: 2px 6px;
}
.ctv2-rolechip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 8px 13px;
  background: var(--cream-l); border: 1px solid var(--cream-b); border-radius: var(--r);
  color: var(--cream); font-family: 'Courier New', monospace;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 1px; cursor: pointer;
}
.ctv2-rolechip__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cream); }

/* ── Card de briefing ── */
.ctv2-brief {
  background: linear-gradient(135deg, var(--s2), var(--s1));
  border: 1px solid var(--b1); border-radius: var(--r-lg);
  padding: 26px 30px;
  display: flex; flex-direction: column; gap: 14px;
}
.ctv2-kicker {
  display: flex; align-items: center; gap: 10px;
  font-family: 'Courier New', monospace; font-size: 0.7rem;
  letter-spacing: 2px; color: var(--atlas);
}
.ctv2-kicker--mute { color: var(--t3); }
@keyframes ctv2-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.ctv2-pulse {
  width: 8px; height: 8px; border-radius: 50%; background: var(--atlas);
  animation: ctv2-pulse 2.4s ease-in-out infinite;
}
.ctv2-brief__sentence {
  margin: 0;
  font-family: var(--font-display,'Bricolage Grotesque',sans-serif);
  font-weight: 500;
  font-size: clamp(1.25rem, 2.2vw, 1.75rem);
  line-height: 1.35; letter-spacing: -0.2px;
  color: var(--t1); max-width: 1040px; text-wrap: pretty;
}
.ctv2-hot { font-weight: 700; color: var(--atlas); }
.ctv2-mono { font-family: 'Courier New', monospace; font-size: 0.88em; }
.ctv2-brief__ctas { display: flex; gap: 10px; flex-wrap: wrap; }
.ctv2-btn {
  min-height: 44px; padding: 10px 18px;
  border-radius: var(--r); font-size: 0.82rem; cursor: pointer;
  transition: background 140ms ease-out, border-color 140ms ease-out, color 140ms ease-out;
}
.ctv2-btn--primary {
  background: var(--atlas); color: var(--s1); border: 1px solid var(--atlas);
  font-weight: 600;
}
.ctv2-btn--primary:hover { filter: brightness(1.12); }
.ctv2-btn--ghost {
  background: transparent; color: var(--t2); border: 1px solid var(--b1);
  font-weight: 500;
}
.ctv2-btn--ghost:hover { border-color: var(--atlas); color: var(--atlas); }

/* ── Alertas ── */
.ctv2-alerts {
  background: var(--state-critical-l); border-left: 3px solid var(--state-critical);
  border-radius: var(--r); padding: 10px 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.ctv2-alerts__row { display: flex; align-items: flex-start; gap: 8px; font-size: 0.84rem; color: var(--t1); }
.ctv2-alerts__row .ti { color: var(--state-critical); flex-shrink: 0; margin-top: 2px; }

/* ── KPIs ── */
.ctv2-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.ctv2-kpi {
  background: var(--s1); border: 1px solid var(--b1); border-radius: var(--r-lg);
  padding: 18px 22px; display: flex; flex-direction: column; gap: 6px;
}
.ctv2-kpi__label { font-size: 0.75rem; color: var(--t3); }
.ctv2-kpi__row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.ctv2-kpi__num {
  font-family: 'Courier New', monospace; font-weight: 700;
  font-size: clamp(1.7rem, 2.6vw, 2.1rem); color: var(--t1); line-height: 1;
}
.ctv2-kpi__sec { font-family: 'Courier New', monospace; font-size: 0.8rem; }
.ctv2-kpi__sec.is-ok   { color: var(--state-ok); }
.ctv2-kpi__sec.is-warn { color: var(--state-alert); }
.ctv2-kpi__sec.is-crit { color: var(--state-critical); }
.ctv2-kpi__sec.is-mute { color: var(--t3); }
.ctv2-kpi__ctx { font-size: 0.72rem; color: var(--t4); line-height: 1.4; }

/* ── Grid principal: módulos + carga ── */
.ctv2-main { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: stretch; }
.ctv2-mods { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ctv2-mod {
  background: var(--s1); border: 1px solid var(--b1); border-radius: var(--r-lg);
  padding: 20px 22px; min-height: 44px;
  display: flex; flex-direction: column; gap: 12px;
  text-align: left; cursor: pointer; font-family: inherit;
  transition: border-color 140ms ease-out, transform 140ms ease-out;
}
.ctv2-mod:hover { border-color: var(--atlas-b); transform: translateY(-2px); }
.ctv2-mod__head { display: flex; align-items: center; gap: 10px; }
.ctv2-mod__code {
  font-family: 'Courier New', monospace; font-size: 0.7rem; font-weight: 700;
  color: var(--atlas); background: var(--atlas-l); border-radius: var(--r-sm);
  padding: 3px 8px;
}
.ctv2-mod__name {
  font-family: var(--font-display,'Bricolage Grotesque',sans-serif);
  font-weight: 600; font-size: 1rem; color: var(--t1); flex: 1;
}
.ctv2-badge {
  font-family: 'Courier New', monospace; font-size: 0.68rem;
  border-radius: var(--r-sm); padding: 3px 8px; white-space: nowrap;
}
.ctv2-badge.is-ok   { color: var(--state-ok);       background: var(--state-ok-l); }
.ctv2-badge.is-warn { color: var(--state-alert);    background: var(--state-alert-l); }
.ctv2-badge.is-crit { color: var(--state-critical); background: var(--state-critical-l); }
.ctv2-badge.is-mute { color: var(--t3);             background: var(--s2); }
.ctv2-mod__body { font-size: 0.82rem; line-height: 1.55; color: var(--t2); flex: 1; }
.ctv2-mod__foot {
  border-top: 1px solid var(--b1); padding-top: 11px;
  font-size: 0.75rem; line-height: 1.5; color: var(--t3);
}
.ctv2-mod__foot span { color: var(--atlas); }

/* ── Carga de hoy ── */
.ctv2-load {
  background: var(--s1); border: 1px solid var(--b1); border-radius: var(--r-lg);
  padding: 20px 22px; display: flex; flex-direction: column; gap: 13px;
}
.ctv2-load__head { display: flex; align-items: baseline; gap: 10px; }
.ctv2-load__title {
  font-family: var(--font-display,'Bricolage Grotesque',sans-serif);
  font-weight: 600; font-size: 1rem; color: var(--t1); flex: 1;
}
.ctv2-load__unit { font-family: 'Courier New', monospace; font-size: 0.68rem; color: var(--t3); }
.ctv2-tech { display: flex; flex-direction: column; gap: 5px; }
.ctv2-tech__row { display: flex; align-items: baseline; gap: 8px; }
.ctv2-tech__name { font-size: 0.82rem; font-weight: 600; color: var(--t1); }
.ctv2-tech__zone { font-size: 0.7rem; color: var(--t4); flex: 1; }
.ctv2-tech__hours { font-family: 'Courier New', monospace; font-size: 0.76rem; color: var(--t2); }
.ctv2-tech__hours.is-warn { color: var(--state-alert); }
.ctv2-tech__hours.is-crit { color: var(--state-critical); }
.ctv2-bar { height: 7px; border-radius: var(--r-sm); background: var(--s2); overflow: hidden; }
.ctv2-bar__fill { height: 100%; border-radius: var(--r-sm); background: var(--atlas); }
.ctv2-bar__fill.is-warn { background: var(--state-alert); }
.ctv2-bar__fill.is-crit { background: var(--state-critical); }
.ctv2-load__foot {
  border-top: 1px solid var(--b1); padding-top: 12px; margin-top: auto;
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  font-size: 0.75rem; color: var(--t3);
}
.ctv2-load__free { font-family: 'Courier New', monospace; font-size: 0.75rem; color: var(--state-ok); }
.ctv2-load__empty { font-size: 0.82rem; color: var(--t3); line-height: 1.5; padding: 8px 0; }

/* ── Feed "Cómo decidió" ── */
.ctv2-feedwrap { display: flex; flex-direction: column; gap: 10px; }
.ctv2-move {
  background: var(--s1); border: 1px solid var(--b1); border-left: 2px solid var(--atlas);
  border-radius: var(--r); padding: 13px 16px;
  display: flex; align-items: baseline; gap: 14px;
}
.ctv2-move__id {
  font-family: 'Courier New', monospace; font-size: 0.8rem; font-weight: 700;
  color: var(--t1); flex-shrink: 0;
}
.ctv2-move__txt { font-size: 0.84rem; line-height: 1.5; color: var(--t2); }
.ctv2-move__txt strong { color: var(--t1); }

/* ── Gestión y memoria (paneles heredados) ── */
.ctv2-legacy { margin-top: 6px; }
.ctv2-legacy__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin-bottom: 12px;
}

/* ── Tablet (≤1024px): una columna en el grid principal ── */
@media (max-width: 1024px) {
  .ctv2-main { grid-template-columns: 1fr; }
}

/* ── Móvil ≤768px — lenguaje Nike/Apple: display grande, 1 col, CTA full-width ── */
@media (max-width: 768px) {
  .ctv2 { gap: 14px; }
  #home-section.card { padding: 18px 14px; }

  /* El hero manda en móvil: los strips heredados (accesos rápidos B266 y widget
     de métricas) duplican las cards de módulo y los KPIs nuevos — fuera del fold. */
  #home-section #ct-quick-actions,
  #home-section #atlas-widget { display: none; }

  .ctv2-topbar { align-items: flex-start; }
  .ctv2-title { font-size: clamp(1.6rem, 7.5vw, 1.9rem); letter-spacing: -0.5px; }
  .ctv2-search { min-width: 44px; justify-content: center; padding: 9px 11px; }
  .ctv2-search__ph, .ctv2-search .ctv2-kbd { display: none; }

  .ctv2-brief { padding: 22px 18px; border-radius: var(--r-xl); }
  .ctv2-brief__sentence { font-size: clamp(1.3rem, 5.9vw, 1.6rem); line-height: 1.3; }
  .ctv2-brief__ctas { flex-direction: column; }
  .ctv2-btn { width: 100%; min-height: 48px; font-size: 0.92rem; text-align: center; border-radius: var(--r-lg); }

  .ctv2-kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .ctv2-kpi { padding: 14px 16px; }
  .ctv2-kpi__num { font-size: clamp(1.5rem, 7.5vw, 1.9rem); }

  .ctv2-mods { grid-template-columns: 1fr; gap: 10px; }
  .ctv2-main { gap: 10px; }
  .ctv2-mod { padding: 18px 16px; }
  .ctv2-move { flex-direction: column; gap: 4px; padding: 12px 14px; }
}

/* ── Móvil estrecho (~390px): respiración y números aún protagonistas ── */
@media (max-width: 420px) {
  #home-section.card { padding: 16px 12px; border-radius: var(--r-lg); }
  .ctv2-kpi__ctx { font-size: 0.68rem; }
  .ctv2-rolechip { min-height: 40px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   TEMA TORRE (C4b · v2 · 2026-07-04) — override final del tema de Atlas.
   Reviste Atlas como la TORRE DE CONTROL interna de Fulgor, portando los
   tokens EXACTOS del design system (packages/config/tailwind/theme.css) vía oklch:
     · neutros CÁLIDOS (rampa hue 62-75, nunca gris puro)
     · acción = ÍNDIGO escaso en claro / LAVANDA en oscuro (el índigo muere ~2:1
       sobre lienzo oscuro; la torre usa lavanda) — --atlas = --cream = --primary
     · dato/analítica = cielo frío (--blue), distinto de la acción
     · estados apagados-en-claro (etiqueta pasa AA sobre su tinte /15) y vivos-en-oscuro
     · HUESO #f1e7d6 = constante de marca (ADR 0049): plate cálido / etiqueta SOBRE
       índigo-u-oscuro; CASI INVISIBLE en blanco → jamás texto/icono en fondo claro.
   Firmas de la torre reafirmadas: rail activo NEUTRO (no glow de color), badges con
   fórmula de tinte (tono en borde+relleno, texto neutro), separación por HAIRLINE,
   foco = anillo acento + halo. Corrige además dos defectos de layout (solape topbar
   y badges del rail). SOLO remapea variables ya existentes + reglas de firma de bajo
   riesgo; no reestructura HTML ni toca JS.
   ROLLBACK EXACTO: borrar desde ESTE comentario hasta el FINAL del fichero.
   ═══════════════════════════════════════════════════════════════════════════ */
:root {
  /* ── Tipografía torre: IBM Plex Sans (UI/headings) + IBM Plex Mono (etiquetas
        de dato) + Cormorant (serif de display, ya cargada). Link en index.html. */
  --font:         'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:    'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* ── Superficies (claro): rampa neutro-CÁLIDA hue 75, no gris puro ── */
  --bg: oklch(0.992 0.004 75);   /* canvas: papel cálido */
  --s1: oklch(1 0 0);            /* surface: card/tabla */
  --s2: oklch(0.975 0.004 75);  /* canvas-subtle: rail bg, thead, row hover */
  --s3: oklch(0.985 0.004 75);  /* surface-raised: nav activo, badge neutro, menú hover */

  /* ── Tinta (claro): neutro-cálido hue 62 ── */
  --t1: oklch(0.16 0.004 62);   /* texto */
  --t2: oklch(0.511 0.011 62);  /* texto-muted */
  --t3: oklch(0.55 0.012 62);   /* texto-subtle: eyebrows/captions */
  --t4: oklch(0.60 0.012 62);   /* placeholder (un paso desde --t3) */

  /* ── Bordes hairline: la torre separa por BORDES ── */
  --b1: oklch(0.91 0.006 70);              /* hairline estándar */
  --b2: oklch(0.16 0.004 62 / 0.035);      /* relleno cálido MUY sutil (no es borde) */
  --b-strong: oklch(0.84 0.008 65);        /* hairline fuerte / outlines / nav activo */

  /* ── Constantes de marca (INVARIANTES de tema — tintas del logo, ADR 0049) ── */
  --hueso:   #f1e7d6;                      /* plate cálido / etiqueta sobre índigo-u-oscuro */
  --hueso-l: rgba(241,231,214,0.10);
  --hueso-b: rgba(241,231,214,0.22);
  --indigo:  #1c4286;
  --negro:   #0e0b09;

  /* ── ACENTO = acción (índigo escaso y estructural: CTA/foco/la ÚNICA cifra clave).
        --atlas = --cream = --primary, todos al mismo índigo. Nunca tiñe un dato,
        nunca rellena texto largo. ── */
  --atlas:   oklch(0.393 0.122 261);       /* = #1c4286 */
  --atlas-l: oklch(0.393 0.122 261 / 0.10);
  --atlas-b: oklch(0.393 0.122 261 / 0.30);
  --cream:   oklch(0.393 0.122 261);
  --cream-l: oklch(0.393 0.122 261 / 0.10);
  --cream-b: oklch(0.393 0.122 261 / 0.30);
  --primary:       oklch(0.393 0.122 261);
  --primary-hover: oklch(0.34 0.12 261);   /* índigo un paso más profundo */

  /* ── Dato / analítica = cielo frío (--blue eje; --info/--state-info badges;
        --ct-data* serie de gráficos). No se mezcla con la acción índigo. ── */
  --blue:   oklch(0.60 0.18 240);          /* L 0.62→0.60 para pasar AA como etiqueta (APCA) */
  --blue-l: oklch(0.60 0.18 240 / 0.10);
  --blue-b: oklch(0.60 0.18 240 / 0.24);
  --state-info: oklch(0.60 0.18 240);  --state-info-l: oklch(0.60 0.18 240 / 0.14);
  --info:   oklch(0.60 0.18 240);  --info-l: oklch(0.60 0.18 240 / 0.10);  --info-b: oklch(0.60 0.18 240 / 0.24);
  --ct-data:   oklch(0.60 0.18 240);
  --ct-data-3: oklch(0.393 0.122 261);

  /* ── Éxito (apagado-en-claro, etiqueta AA sobre tinte /15) ── */
  --sage:   oklch(0.49 0.14 155);  --sage-l: oklch(0.49 0.14 155 / 0.14);  --sage-b: oklch(0.49 0.14 155 / 0.40);
  --ok:     oklch(0.49 0.14 155);  --ok-l: oklch(0.49 0.14 155 / 0.14);    --ok-b: oklch(0.49 0.14 155 / 0.40);
  --state-ok: oklch(0.49 0.14 155);  --state-ok-l: oklch(0.49 0.14 155 / 0.14);

  /* ── Peligro: rojo hue 25 (el rojo Sanzo-Wada de la torre) ── */
  --rose:   oklch(0.53 0.2 25);  --rose-l: oklch(0.53 0.2 25 / 0.14);  --rose-b: oklch(0.53 0.2 25 / 0.40);
  --danger: oklch(0.53 0.2 25);  --danger-l: oklch(0.53 0.2 25 / 0.14);  --danger-b: oklch(0.53 0.2 25 / 0.40);
  --state-critical: oklch(0.53 0.2 25);  --state-critical-l: oklch(0.53 0.2 25 / 0.14);

  /* ── Aviso: ámbar oscuro hue 78 ── */
  --warn: oklch(0.52 0.12 78);  --warn-l: oklch(0.52 0.12 78 / 0.14);  --warn-b: oklch(0.52 0.12 78 / 0.40);
  --state-alert: oklch(0.52 0.12 78);  --state-alert-l: oklch(0.52 0.12 78 / 0.14);

  /* ── Bloqueado: NEUTRO cálido SIN tinte (ausencia; dashed en reglas) ── */
  --state-blocked:  oklch(0.55 0.012 62);  --state-blocked-l: oklch(0.55 0.012 62 / 0.12);
  --slate:  oklch(0.55 0.012 62);  --slate-l: oklch(0.55 0.012 62 / 0.12);  --slate-b: oklch(0.55 0.012 62 / 0.24);

  /* ── Sombras: apenas visibles, tinte navy FRÍO hue 240 ── */
  --shadow-soft:     0 1px 2px oklch(0.18 0.012 240 / .04), 0 2px 4px oklch(0.18 0.012 240 / .04);
  --shadow-raised:   0 1px 2px oklch(0.18 0.012 240 / .04), 0 8px 24px oklch(0.18 0.012 240 / .06);
  --shadow-floating: 0 2px 6px oklch(0.18 0.012 240 / .05), 0 16px 48px oklch(0.18 0.012 240 / .12);

  /* ── Curva de motion única de la torre ── */
  --ease-firma: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Re-aserción de modo oscuro ──────────────────────────────────────────────
   Va DESPUÉS de los [data-theme="dark"] previos; re-afirma superficies + acentos.
   Acento = LAVANDA (el índigo muere sobre lienzo oscuro). Algunos tokens de texto
   se aclaran un paso respecto al valor exacto de la torre para pasar el gate APCA
   sobre cards oscuras (anotado inline). El gate arranca en CLARO. */
[data-theme="dark"] {
  --bg: oklch(0.16 0.004 62);
  --s1: oklch(0.215 0.004 62);
  --s2: oklch(0.195 0.004 62);
  --s3: oklch(0.25 0.005 62);
  --t1: oklch(0.985 0.002 75);
  --t2: oklch(0.78 0.008 70);   /* torre 0.72 → 0.78 (APCA: muted legible en card) */
  --t3: oklch(0.70 0.008 70);   /* torre 0.65 → 0.70 (APCA ≥45 subtle) */
  --t4: oklch(0.56 0.008 70);
  --b1: oklch(0.31 0.006 62);
  --b2: oklch(1 0 0 / 0.04);
  --b-strong: oklch(0.41 0.008 62);

  --atlas:   oklch(0.725 0.084 294.5);     /* = #a99cd6 lavanda (NO azul) */
  --atlas-l: oklch(0.725 0.084 294.5 / 0.16);
  --atlas-b: oklch(0.725 0.084 294.5 / 0.34);
  --cream:   oklch(0.725 0.084 294.5);
  --cream-l: oklch(0.725 0.084 294.5 / 0.16);
  --cream-b: oklch(0.725 0.084 294.5 / 0.34);
  --primary:       oklch(0.725 0.084 294.5);
  --primary-hover: oklch(0.78 0.084 294.5);

  --blue:    oklch(0.72 0.18 240);  --blue-l:  oklch(0.72 0.18 240 / 0.16);  --blue-b:  oklch(0.72 0.18 240 / 0.30);
  --state-info: oklch(0.72 0.18 240);  --state-info-l: oklch(0.72 0.18 240 / 0.16);
  --info:    oklch(0.72 0.18 240);  --info-l:  oklch(0.72 0.18 240 / 0.16);  --info-b:  oklch(0.72 0.18 240 / 0.30);
  --ct-data: oklch(0.72 0.18 240);  --ct-data-3: oklch(0.725 0.084 294.5);

  --sage:    oklch(0.68 0.16 155);  --sage-l:  oklch(0.68 0.16 155 / 0.16);  --sage-b:  oklch(0.68 0.16 155 / 0.40);
  --ok:      oklch(0.68 0.16 155);  --ok-l: oklch(0.68 0.16 155 / 0.16);     --ok-b: oklch(0.68 0.16 155 / 0.40);
  --state-ok:       oklch(0.68 0.16 155);  --state-ok-l:       oklch(0.68 0.16 155 / 0.16);

  --rose:    oklch(0.70 0.2 25);  --rose-l:  oklch(0.70 0.2 25 / 0.16);  --rose-b:  oklch(0.70 0.2 25 / 0.40);  /* torre 0.62/0.21 → 0.70/0.20 (APCA: peligro ≥45 sobre lienzo oscuro) */
  --danger:  oklch(0.70 0.2 25);  --danger-l: oklch(0.70 0.2 25 / 0.16);  --danger-b: oklch(0.70 0.2 25 / 0.40);
  --state-critical: oklch(0.70 0.2 25);  --state-critical-l: oklch(0.70 0.2 25 / 0.16);

  --warn:    oklch(0.78 0.17 80);  --warn-l: oklch(0.78 0.17 80 / 0.16);  --warn-b: oklch(0.78 0.17 80 / 0.40);
  --state-alert:    oklch(0.78 0.17 80);  --state-alert-l:    oklch(0.78 0.17 80 / 0.16);

  --slate:   oklch(0.65 0.008 70);  --slate-l: oklch(0.65 0.008 70 / 0.16);  --slate-b: oklch(0.65 0.008 70 / 0.24);
  --state-blocked:  oklch(0.65 0.008 70);  --state-blocked-l:  oklch(0.65 0.008 70 / 0.14);
}

/* ── Contraste tipográfico torre: headings con tracking apretado ── */
h1, .ctv2-title, .ctv2-brief__sentence, .home-hero-title { letter-spacing: -0.02em; }

/* ── Eyebrows / labels / datos → IBM Plex Mono (conservan uppercase + tracking) ── */
h3,
.app-nav__brand, .app-nav__role,
#ct-breadcrumb, .ct-navscreen__num,
.ctv2-clock, .ctv2-kbd, .ctv2-rolechip, .ctv2-kicker, .ctv2-mono,
.ctv2-kpi__num, .ctv2-kpi__sec, .ctv2-mod__code,
.serial-tag, .chip-serial, .cmd-palette-btn kbd,
.build-badge {
  font-family: var(--font-mono);
}
#footer-build { font-family: var(--font-mono) !important; } /* vence el font-family inline */

/* ── Cards: HAIRLINE (--b1, ya en .card base) + sombra fría apenas visible ── */
.card {
  box-shadow: var(--shadow-soft);
}

/* ── Estado BLOQUEADO: neutro + borde dashed (sin tinte de color) ── */
.atlas-badge--blocked {
  color: var(--state-blocked);
  background: transparent;
  border: 1px dashed var(--state-blocked);
}
.atlas-status-dot--blocked { background: var(--state-blocked); }

/* ═══ FIRMA 2 — fórmula de tinte en badges de estado ══════════════════════════
   Tono llevado por BORDE (/40) + relleno (/15); la etiqueta puede ir en color si
   debe mostrar estado, pero sobre su tinte pasa AA. ctv2-badge/atlas-badge no
   traían borde: se lo añadimos con el tono /40. (idle/blocked = dashed arriba.) */
.ctv2-badge, .atlas-badge { border: 1px solid var(--b1); }
.ctv2-badge.is-ok,   .atlas-badge--ok       { border-color: var(--ok-b); }
.ctv2-badge.is-warn, .atlas-badge--alert    { border-color: var(--warn-b); }
.ctv2-badge.is-crit, .atlas-badge--critical { border-color: var(--rose-b); }
.atlas-badge--info                          { border-color: var(--info-b); }
/* Badges de estado hardcodeados (status bar) → re-tokenizados a la paleta torre */
.atlas-sb-badge--ok   { background: var(--ok-l);   color: var(--ok);   border: 1px solid var(--ok-b); }
.atlas-sb-badge--warn { background: var(--warn-l); color: var(--warn); border: 1px solid var(--warn-b); }
.atlas-sb-badge--crit { background: var(--rose-l); color: var(--rose); border: 1px solid var(--rose-b); }

/* ═══ FIRMA 1 — rail ACTIVO neutro (nunca glow de color) ═══════════════════════
   surface-raised (--s3) + hairline fuerte a la izquierda + texto semibold --t1.
   Sustituye el glow índigo/terracota inset del base y de la pasada previa. El
   acento queda reservado a CTA/foco/la única cifra clave. */
.rail-item[data-mode="home"].active,
.rail-item[data-mode="wo"].active,
.rail-item[data-mode="pm"].active,
.rail-item[data-mode="bal"].active,
.rail-item[data-mode="cat"].active {
  color: var(--t1) !important;
  background: var(--s3) !important;
  box-shadow: none !important;
  font-weight: 600 !important;
}
.rail-item.active::before { background: var(--b-strong); width: 3px; }

/* ═══ DEFECTO 1b — badges métricos del rail contenidos + apagados ══════════════
   nav_badges.js pinta un relleno sólido INLINE (verde/naranja/rojo) por umbral;
   como el JS queda fuera de alcance, el tono se sustituye por un chip NEUTRO cálido
   (bg surface-raised + hairline fuerte + texto --t1), encogido y re-espaciado para
   que no aturda ni pise el borde del rail. El estado de color sigue vivo en los KPI
   del contenido, no en el rail. */
.rb-badge {
  top: 4px; right: 4px;
  min-width: 15px; height: 15px;
  padding: 0 4px;
  font-size: 0.5rem;
  font-family: var(--font-mono);
  background: var(--s3) !important;   /* vence el background inline sólido */
  color: var(--t1) !important;
  border: 1px solid var(--b-strong);
  border-radius: 9999px;
  box-shadow: var(--shadow-soft);
}

/* ── Secciones: borde superior = HAIRLINE neutro (no lavado de acento).
      Neutraliza la terracota/índigo del base (#home-section y module-tops). ── */
#home-section {
  border-top: 1px solid var(--b1) !important;
  background: var(--s1) !important;
}
[data-theme="light"] #home-section {
  border-top-color: var(--b1) !important;
  background: var(--s1) !important;
}
[data-theme="dark"] #home-section {
  background: var(--s1) !important;
  border: 1px solid var(--b1) !important;
}
body[data-mode="wo"]  #upload-section,
body[data-mode="wo"]  #dashboard-section,
body[data-mode="wo"]  #mapping-section,
body[data-mode="pm"]  #pm-section,
body[data-mode="bal"] #bal-section,
body[data-mode="cat"] #cat-section { border-top: 1px solid var(--b1) !important; }

/* ── Línea superior (body::before): de lavado de acento a hairline neutro sutil ── */
body::before {
  background: var(--b1);
  height: 2px;
}

/* ═══ DEFECTO 1a — solape topbar/contenido ════════════════════════════════════
   1) topbar OPACA (var(--bg)) + hairline + sombra suave: el contenido que pasa por
      debajo nunca sangra a través como "solape". 2) despeje real bajo la barra: el
      contenido arranca ~16px por debajo (se sube el padding de #main-content, no el
      body). Sticky-in-flow sería refactor de base fuera de alcance. */
#ct-topbar {
  background: var(--bg);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-bottom: 1px solid var(--b1);
  box-shadow: var(--shadow-soft);
}
[data-theme="light"] #ct-topbar {
  background: var(--bg);
  border-bottom-color: var(--b1);
  box-shadow: var(--shadow-soft);
}
@media (min-width: 769px) {
  main#main-content { padding-top: 16px; }
}

/* ── CTA: relleno acento + etiqueta HUESO sobre índigo (uso canónico del hueso;
      en oscuro el relleno es lavanda claro → texto oscuro, no hueso). ── */
[data-theme="light"] .btn-primary {
  color: var(--hueso);
  border-color: var(--atlas);
}
.btn-primary { box-shadow: 0 1px 4px oklch(0.393 0.122 261 / 0.20); }
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 4px 14px oklch(0.393 0.122 261 / 0.30);
}
.tab-indicator { background: var(--atlas-l); }

/* ── Firma transversal: foco = anillo 2px acento + offset + halo (adapta por tema
      vía --atlas: índigo en claro, lavanda en oscuro). ── */
:focus-visible {
  outline: 2px solid var(--atlas);
  outline-offset: 2px;
}
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
  box-shadow: 0 0 0 4px var(--atlas-b);
}

/* Cifras: tabular-nums en KPIs/estadísticas/valores. */
[class*="kpi"],
[class*="__num"],
[class*="__value"],
[class*="stat-val"],
[class*="-num"],
[class*="metric-card__"] {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* Headings: tracking-tight (firma de la torre). */
h1, h2, h3, h4 { letter-spacing: -0.025em; }
/* ═══ FIN TEMA TORRE (C4b) — fin del override; nada debajo de esta línea ═══ */
