/* app.css · Panel de control maestro · Persianas Centre Nou (demo, datos simulados)
   Design system y layout. Tokens: DISENO.md 1. Layout: DISENO.md 2-4. Solo tema oscuro (sala de control). */

/* ------------------------------------------------------------------ */
/* Fuentes autoalojadas                                                */
/* ------------------------------------------------------------------ */
@font-face { font-family: 'Space Grotesk'; src: url('../assets/fonts/SpaceGrotesk.woff2') format('woff2'); font-weight: 300 700; font-display: swap; }
@font-face { font-family: 'DM Sans'; src: url('../assets/fonts/DMSans.woff2') format('woff2'); font-weight: 300 700; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'DM Sans'; src: url('../assets/fonts/DMSans-ext.woff2') format('woff2'); font-weight: 300 700; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* ------------------------------------------------------------------ */
/* Tokens                                                              */
/* ------------------------------------------------------------------ */
:root {
  --bg: #070614;
  --bg-2: #0B1020;
  --surface: #0F172A;
  --glass: rgba(15, 23, 42, .62);
  --glass-strong: rgba(10, 14, 30, .84);
  --glass-bar: rgba(7, 6, 20, .72);
  --glass-side: rgba(7, 6, 20, .82);
  --logo-fondo: #404040; /* fondo propio del logo del cliente: el logo se ve a sangre, sin marco blanco */
  --field: rgba(255, 255, 255, .04);
  --hover: rgba(255, 255, 255, .05);

  --text: #E7F6FF;
  --text-strong: #FFFFFF;
  --text-2: #8FA3C8;
  --text-3: #64748B;

  --border: rgba(255, 255, 255, .08);
  --border-2: rgba(255, 255, 255, .14);
  --border-field: rgba(255, 255, 255, .10);

  --accent: #0067FF;
  --accent-hover: #1A78FF;
  --accent-soft: rgba(0, 103, 255, .14);
  --accent-soft-2: rgba(0, 103, 255, .22);
  --accent-ring: rgba(0, 103, 255, .35);
  --blue-2: #4D94FF;
  --green: #22C55E;
  --amber: #F2A900;
  --red: #EF4444;
  --red-soft: #FCA5A5;
  --violet: #A855F7;
  --teal: #00B3A4;

  --font-display: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-text: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --fs-11: 11px; --fs-12: 12px; --fs-13: 13px; --fs-14: 14px; --fs-16: 16px;
  --fs-20: 20px; --fs-22: 22px; --fs-26: 26px; --fs-28: 28px;
  --lh-tight: 1.15; --lh-text: 1.45;

  --r-6: 6px; --r-8: 8px; --r-10: 10px; --r-12: 12px; --r-14: 14px; --r-16: 16px; --r-pill: 999px;

  --shadow-card: 0 8px 24px rgba(0, 0, 0, .28);
  --shadow-float: 0 24px 80px rgba(0, 0, 0, .50);
  --shadow-primary: 0 6px 20px rgba(0, 103, 255, .35);
  --ring-focus: 0 0 0 3px var(--accent-ring);
  --blur-14: blur(14px) saturate(140%);
  --blur-16: blur(16px) saturate(140%);
  --blur-24: blur(24px) saturate(140%);

  --ease: cubic-bezier(.2, .8, .2, 1);
  --t-hover: 180ms; --t-ui: 240ms; --t-feed: 220ms; --t-num: 600ms;

  --topbar-h: 56px;
  --sidebar-w: 220px;
  --drawer-w: 420px;
  --gap: 12px;
  --edge: 16px;

  --z-canvas: 0;
  --z-etiquetas3d: 5;
  --z-sin3d: 8;
  --z-overlay: 20;
  --z-sidebar: 30;
  --z-topbar: 40;
  --z-banner: 45;
  --z-drawer: 50;
  --z-menu: 60;
  --z-login: 100;

  /* Huecos vivos (los cambian las clases de body) */
  --izq: var(--sidebar-w);
  --der: 0px;
  color-scheme: dark;
}
body.drawer-abierto { --der: var(--drawer-w); }

/* ------------------------------------------------------------------ */
/* Base                                                                */
/* ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-text);
  font-size: var(--fs-14);
  line-height: var(--lh-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-align: inherit; }
button:disabled { cursor: default; }
input { font: inherit; color: inherit; }
ul, ol { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, p { margin: 0; }
img { display: block; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--ring-focus); }

.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.ico-14 { width: 14px; height: 14px; }
.ico-16 { width: 16px; height: 16px; }
.ico-18 { width: 18px; height: 18px; }
.ico-20 { width: 20px; height: 20px; }
.ico-28 { width: 28px; height: 28px; }

.num { font-family: var(--font-display); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

.punto { --c: var(--text-2); width: 6px; height: 6px; border-radius: 50%; background: var(--c); flex: none; display: inline-block; }
.punto-rojo { --c: var(--red); }
.punto-vivo { --c: var(--green); width: 8px; height: 8px; box-shadow: 0 0 0 0 rgba(34, 197, 94, .5); animation: latido 1.6s ease-in-out infinite; }
@keyframes latido { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px; border-radius: var(--r-pill);
  border: 1px solid var(--border); font-size: var(--fs-12); color: var(--text-2); white-space: nowrap;
}

.pildora {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--r-pill);
  border: 1px solid var(--border-2); font-size: var(--fs-13); color: var(--text);
  transition: background var(--t-hover) var(--ease), border-color var(--t-hover) var(--ease), transform var(--t-hover) var(--ease);
}
.pildora:hover { background: var(--hover); border-color: rgba(255, 255, 255, .22); }
.pildora:active { transform: scale(.98); }
.pildora .ico { color: var(--text-2); transition: transform var(--t-hover) var(--ease); }
.pildora:hover .ico { transform: translateX(2px); color: var(--text); }

.btn-icono {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-8);
  color: var(--text-2); transition: background var(--t-hover) var(--ease), color var(--t-hover) var(--ease);
}
.btn-icono:hover { background: var(--hover); color: var(--text); }

.btn-fantasma {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; border-radius: var(--r-8);
  font-size: var(--fs-13); color: var(--text-2);
  transition: background var(--t-hover) var(--ease), color var(--t-hover) var(--ease);
}
.btn-fantasma:hover { color: var(--text); background: var(--hover); }

.vidrio { background: var(--glass); -webkit-backdrop-filter: var(--blur-14); backdrop-filter: var(--blur-14); border: 1px solid var(--border); }

/* Scrollbars finas */
.drawer-scroll, .feed-lista, #kpis { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
.drawer-scroll::-webkit-scrollbar { width: 6px; }
.drawer-scroll::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 6px; }
.drawer-scroll::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------------ */
/* Mundo 3D y sin 3D                                                   */
/* ------------------------------------------------------------------ */
#mundo { position: fixed; inset: 0; z-index: var(--z-canvas); background: var(--bg); }
#escena { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }
#escena:focus-visible { box-shadow: none; }

#sin3d {
  position: fixed; z-index: var(--z-sin3d); display: none;
  top: calc(50% + 40px);
  left: calc(var(--izq) + (100vw - var(--izq) - var(--der)) / 2);
  transform: translate(-50%, -50%);
  width: min(420px, calc(100vw - 32px)); padding: 24px; border-radius: var(--r-16);
  background: var(--glass-strong); -webkit-backdrop-filter: var(--blur-16); backdrop-filter: var(--blur-16);
  border: 1px solid var(--border); box-shadow: var(--shadow-float);
  transition: left var(--t-ui) var(--ease);
}
#sin3d .sin3d-icono { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: var(--r-12); background: var(--accent-soft); color: var(--accent); margin-bottom: 14px; }
#sin3d h2 { font-family: var(--font-display); font-size: var(--fs-16); font-weight: 600; color: var(--text-strong); line-height: 1.3; margin-bottom: 6px; }
#sin3d p { font-size: var(--fs-13); color: var(--text-2); margin-bottom: 16px; }
.sin3d-acciones { display: flex; flex-wrap: wrap; gap: 8px; }

body.sin-3d #mundo {
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(77, 148, 255, .08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(77, 148, 255, .08) 1px, transparent 1px),
    radial-gradient(ellipse at 50% 30%, #13254D 0%, #070614 70%);
  background-size: 40px 40px, 40px 40px, 100% 100%;
  background-position: center center;
}
body.sin-3d #escena { display: none; }
body.sin-3d:not(.vista-login) #sin3d { display: block; }

/* ------------------------------------------------------------------ */
/* Login                                                               */
/* ------------------------------------------------------------------ */
#login {
  position: fixed; inset: 0; z-index: var(--z-login);
  display: grid; place-items: center; padding: 16px;
  transition: opacity 600ms var(--ease), visibility 0s linear 0s;
}
#login::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 40%, rgba(7, 6, 20, .15), rgba(7, 6, 20, .72));
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  transition: opacity 600ms var(--ease);
}
body:not(.vista-login) #login { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 600ms var(--ease), visibility 0s linear 600ms; }

.login-centro { position: relative; display: flex; flex-direction: column; align-items: center; transform: translateY(-4vh); width: 100%; }
.login-card {
  position: relative; width: 400px; max-width: 100%; padding: 32px; border-radius: var(--r-16);
  background: rgba(15, 23, 42, .62); -webkit-backdrop-filter: var(--blur-24); backdrop-filter: var(--blur-24);
  border: 1px solid var(--border); box-shadow: var(--shadow-float), inset 0 1px 0 rgba(255, 255, 255, .04);
  transition: opacity 260ms var(--ease), transform 260ms var(--ease);
  animation: entrada-card 520ms var(--ease) both;
}
.login-card::before { /* filo de luz superior */
  content: ''; position: absolute; left: 24px; right: 24px; top: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(77, 148, 255, .55), transparent);
}
@keyframes entrada-card { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }
body.saliendo-login .login-card { opacity: 0; transform: scale(.98); }
body.saliendo-login #login::before { opacity: 0; }
body.saliendo-login .login-demo, body.saliendo-login .login-datos, body.saliendo-login .login-pie { opacity: 0; transition: opacity 260ms var(--ease); }

.login-logo { width: 56px; height: 56px; border-radius: 14px; background: var(--logo-fondo); object-fit: contain; padding: 0; margin-bottom: 20px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .14), 0 6px 18px rgba(0, 0, 0, .35); }
#login-titulo { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-26); line-height: var(--lh-tight); color: var(--text-strong); letter-spacing: -.015em; margin-bottom: 6px; }
.login-sub { font-size: var(--fs-14); color: var(--text-2); margin-bottom: 24px; }

.campo { display: block; }
.campo + .campo { margin-top: 14px; }
.campo-etiqueta { display: block; font-size: var(--fs-12); color: var(--text-2); margin-bottom: 6px; }
.campo input {
  display: block; width: 100%; height: 44px; padding: 0 14px; border-radius: var(--r-10);
  background: var(--field); border: 1px solid var(--border-field); color: var(--text); font-size: var(--fs-14);
  transition: border-color var(--t-hover) var(--ease), box-shadow var(--t-hover) var(--ease), background var(--t-hover) var(--ease);
}
.campo input:hover { border-color: rgba(255, 255, 255, .16); }
.campo input:focus { border-color: var(--accent); box-shadow: var(--ring-focus); background: rgba(255, 255, 255, .055); }
.campo input[aria-invalid="true"] { border-color: rgba(239, 68, 68, .55); }
.campo-clave { position: relative; display: block; }
.campo-clave input { padding-right: 48px; }
.btn-ojo { position: absolute; right: 6px; top: 6px; width: 32px; height: 32px; display: grid; place-items: center; border-radius: var(--r-8); color: var(--text-2); transition: color var(--t-hover) var(--ease), background var(--t-hover) var(--ease); }
.btn-ojo:hover { color: var(--text); background: var(--hover); }

.btn-primario {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; height: 44px; margin-top: 20px; border-radius: var(--r-10);
  background: var(--accent); color: #fff; font-family: var(--font-text); font-weight: 600; font-size: 15px;
  box-shadow: var(--shadow-primary), inset 0 1px 0 rgba(255, 255, 255, .18);
  transition: background var(--t-hover) var(--ease), transform var(--t-hover) var(--ease), box-shadow var(--t-hover) var(--ease);
}
.btn-primario:hover { background: var(--accent-hover); }
.btn-primario:active { transform: scale(.99); }
.btn-primario:focus-visible { box-shadow: var(--shadow-primary), var(--ring-focus); }
.btn-primario:disabled { opacity: .85; }
.spinner { display: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: giro 700ms linear infinite; }
.btn-primario.cargando .spinner { display: block; }
@keyframes giro { to { transform: rotate(360deg); } }

#login-error { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: var(--fs-13); color: var(--red-soft); animation: aparecer 180ms var(--ease) both; }
@keyframes aparecer { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
.login-card.sacudida { animation: sacudida 320ms var(--ease); }
@keyframes sacudida { 0% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } 100% { transform: translateX(0); } }

.login-demo {
  margin-top: 16px; display: inline-flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 6px;
  padding: 6px 12px; border-radius: var(--r-pill); border: 1px solid var(--border);
  background: rgba(7, 6, 20, .45); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  font-size: var(--fs-12); color: var(--text-2); text-align: center;
}
.login-demo code { font-family: var(--font-mono); font-size: 12px; color: var(--text); background: var(--field); border: 1px solid var(--border); border-radius: var(--r-6); padding: 1px 6px; }

.login-datos { position: absolute; left: 24px; bottom: 24px; display: grid; gap: 8px; font-size: var(--fs-12); color: var(--text-2); }
.login-datos li { display: flex; align-items: center; gap: 8px; }
.login-pie { position: absolute; left: 0; right: 0; bottom: 20px; text-align: center; font-size: var(--fs-12); color: var(--text-3); pointer-events: none; }

/* ------------------------------------------------------------------ */
/* Panel: visibilidad y cascada                                        */
/* ------------------------------------------------------------------ */
#panel { position: fixed; inset: 0; z-index: var(--z-overlay); pointer-events: none; }
#panel > * { pointer-events: auto; }
body.vista-login #panel { visibility: hidden; }
body.vista-login #panel > * { pointer-events: none; }

body.entrando .cascada { animation: cascada 320ms var(--ease) both; animation-delay: var(--d, 0ms); }
body.entrando-rapido #panel { animation: fundido 240ms var(--ease) both; }
@keyframes cascada { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fundido { from { opacity: 0; } to { opacity: 1; } }

/* ------------------------------------------------------------------ */
/* Barra superior                                                      */
/* ------------------------------------------------------------------ */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); z-index: var(--z-topbar);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; padding: 0 16px;
  background: var(--glass-bar); -webkit-backdrop-filter: var(--blur-16); backdrop-filter: var(--blur-16);
  border-bottom: 1px solid var(--border);
}
.tb-izq { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tb-logo { width: 28px; height: 28px; border-radius: var(--r-8); background: var(--logo-fondo); object-fit: contain; padding: 0; flex: none; box-shadow: 0 0 0 1px rgba(255, 255, 255, .14); }
.tb-marca { font-family: var(--font-display); font-weight: 600; font-size: 15px; color: var(--text-strong); white-space: nowrap; letter-spacing: -.01em; }
.selector-marca { position: relative; }
.chip-marca { height: 28px; gap: 6px; padding: 0 8px 0 10px; color: var(--text); background: rgba(255, 255, 255, .03); transition: background var(--t-hover) var(--ease), border-color var(--t-hover) var(--ease); }
.chip-marca:hover, .chip-marca[aria-expanded="true"] { background: var(--hover); border-color: var(--border-2); }
.chip-marca .ico { color: var(--text-2); transition: transform var(--t-hover) var(--ease); }
.chip-marca[aria-expanded="true"] .ico { transform: rotate(180deg); }

.menu {
  position: absolute; top: calc(100% + 8px); left: 0; width: 240px; z-index: var(--z-menu); padding: 6px;
  background: #0B1020; /* dentro de la barra el blur no actúa: opaco */ -webkit-backdrop-filter: var(--blur-16); backdrop-filter: var(--blur-16);
  border: 1px solid var(--border); border-radius: var(--r-12); box-shadow: var(--shadow-float);
  animation: menu-in 160ms var(--ease) both; transform-origin: top left;
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.menu-fila { display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border-radius: var(--r-8); font-size: var(--fs-13); color: var(--text); transition: background var(--t-hover) var(--ease); }
.menu-fila:hover { background: var(--hover); }
.menu-fila > span:not(.menu-mas) { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-logo { width: 20px; height: 20px; border-radius: 6px; background: var(--logo-fondo); object-fit: contain; padding: 0; box-shadow: 0 0 0 1px rgba(255, 255, 255, .14); }
.menu-check { color: var(--accent); visibility: hidden; }
.menu-fila[aria-checked="true"] .menu-check { visibility: visible; }
.menu-mas { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; border: 1px dashed var(--border-2); color: var(--text-2); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.tooltip {
  position: absolute; z-index: var(--z-menu); left: calc(100% + 8px); bottom: 6px; white-space: nowrap;
  padding: 7px 10px; border-radius: var(--r-8); font-size: var(--fs-12); color: var(--text);
  background: rgba(10, 14, 30, .97); -webkit-backdrop-filter: var(--blur-16); backdrop-filter: var(--blur-16);
  border: 1px solid var(--border-2); box-shadow: var(--shadow-card);
  animation: aparecer 160ms var(--ease) both;
}
.tooltip::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--violet); margin-right: 8px; vertical-align: 1px; }

.tb-centro { display: flex; align-items: center; gap: 10px; justify-self: center; }
#reloj { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-22); font-variant-numeric: tabular-nums; color: var(--text-strong); letter-spacing: -.01em; white-space: nowrap; }
.chip-horario { height: 26px; color: var(--text); transition: background var(--t-ui) var(--ease), border-color var(--t-ui) var(--ease); }
.chip-horario .punto { --c: var(--green); }
.chip-horario.fuera { background: var(--accent-soft); border-color: rgba(0, 103, 255, .4); }
.chip-horario.fuera .punto { --c: var(--accent); animation: latido 1.6s ease-in-out infinite; }
.horario-punto-movil { display: none; --c: var(--green); }
.horario-punto-movil.fuera { --c: var(--accent); animation: latido 1.6s ease-in-out infinite; }

.tb-der { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-width: 0; }
.btn-noche {
  position: relative; overflow: hidden; display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 14px; border-radius: var(--r-10); white-space: nowrap;
  background: var(--accent); color: #fff; font-size: var(--fs-13); font-weight: 600;
  box-shadow: var(--shadow-primary), inset 0 1px 0 rgba(255, 255, 255, .18);
  transition: background var(--t-hover) var(--ease), opacity var(--t-hover) var(--ease);
}
.btn-noche:hover:not(:disabled) { background: var(--accent-hover); }
.btn-noche:disabled { background: #0B4CC0; }
.btn-noche-barra { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: rgba(255, 255, 255, .18); opacity: 0; }
.btn-noche-barra span { display: block; height: 100%; width: 100%; background: #fff; transform-origin: left; transform: scaleX(0); }
.btn-noche.activo .btn-noche-barra { opacity: 1; }

.segmentado { display: inline-flex; align-items: center; gap: 2px; height: 32px; padding: 2px; border-radius: var(--r-10); background: rgba(255, 255, 255, .06); border: 1px solid var(--border); }
.seg {
  height: 26px; min-width: 34px; padding: 0 8px; border-radius: 8px; border: 1px solid transparent;
  display: inline-grid; place-items: center; font-family: var(--font-display); font-size: var(--fs-12); font-weight: 600; color: var(--text-2);
  font-variant-numeric: tabular-nums; transition: background var(--t-hover) var(--ease), color var(--t-hover) var(--ease), border-color var(--t-hover) var(--ease);
}
.seg:hover { color: var(--text); background: var(--hover); }
.seg[aria-pressed="true"] { background: var(--accent-soft-2); border-color: var(--accent); color: #fff; }
.seg-pausa { min-width: 30px; padding: 0; }
.seg-pausa.pausado { color: var(--amber); }
.vel-movil { position: relative; display: none; }
.vel-movil .btn-icono { width: auto; gap: 4px; padding: 0 8px; display: inline-flex; align-items: center; font-family: var(--font-display); font-weight: 600; font-size: var(--fs-12); }
.menu-vel { left: auto; right: 0; width: 200px; transform-origin: top right; }

/* ------------------------------------------------------------------ */
/* Sidebar                                                             */
/* ------------------------------------------------------------------ */
#sidebar {
  position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: var(--sidebar-w); z-index: var(--z-sidebar);
  display: flex; flex-direction: column; padding: 12px;
  background: var(--glass-side); -webkit-backdrop-filter: var(--blur-14); backdrop-filter: var(--blur-14);
  border-right: 1px solid var(--border);
}
.nav-lista { display: grid; gap: 2px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; height: 40px; padding: 0 12px; border-radius: var(--r-10);
  font-size: var(--fs-14); font-weight: 500; color: var(--text-2); white-space: nowrap;
  transition: background var(--t-hover) var(--ease), color var(--t-hover) var(--ease);
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.activo { background: var(--accent-soft); color: var(--text-strong); }
.nav-item.activo .ico { color: var(--accent); }
.nav-item.activo::before { content: ''; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 2px; background: var(--accent); }
.nav-item span { overflow: hidden; text-overflow: ellipsis; }

.nav-sub { display: grid; gap: 2px; overflow: hidden; max-height: 0; opacity: 0; transition: max-height var(--t-ui) var(--ease), opacity var(--t-ui) var(--ease), margin var(--t-ui) var(--ease); }
.nav-grupo.abierto .nav-sub { max-height: 160px; opacity: 1; margin: 2px 0 4px; }
.nav-subitem {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 32px; padding: 0 10px 0 44px; border-radius: var(--r-8);
  font-size: var(--fs-13); color: var(--text-2); transition: background var(--t-hover) var(--ease), color var(--t-hover) var(--ease);
}
.nav-subitem:hover { background: var(--hover); color: var(--text); }
.nav-subitem.activo { color: var(--text-strong); background: rgba(255, 255, 255, .04); }
.nav-subitem .punto { width: 8px; height: 8px; }
.nav-subitem .sub-nombre { flex: 1; min-width: 0; }
.nav-subitem .sub-estado { font-size: var(--fs-11); color: var(--text-3); white-space: nowrap; }
.nav-subitem .sub-estado.camino { color: var(--blue-2); }
.nav-subitem .sub-estado.trabajando { color: var(--amber); }
.nav-subitem .sub-estado.guardia { color: var(--violet); }
.sidebar-pie { margin-top: auto; padding: 0 12px 4px; font-size: var(--fs-11); color: var(--text-3); }
.ia-estado { margin-top: auto; display: grid; gap: 8px; padding: 12px; border-radius: var(--r-12); background: var(--field); border: 1px solid var(--border); }
.ia-estado + .sidebar-pie { margin-top: 12px; }
.ia-estado-titulo { font-size: var(--fs-11); font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.ia-fila { display: flex; align-items: center; gap: 8px; font-size: var(--fs-12); color: var(--text-2); white-space: nowrap; }
.ia-fila .num { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ */
/* Tira de KPIs                                                        */
/* ------------------------------------------------------------------ */
#kpis {
  position: fixed; z-index: var(--z-overlay);
  top: calc(var(--topbar-h) + 16px); left: calc(var(--izq) + 16px); right: calc(var(--der) + 16px);
  display: grid; grid-template-columns: repeat(6, minmax(132px, 1fr)); gap: var(--gap);
  overflow-x: auto; overflow-y: visible; padding: 2px 2px 6px; margin: -2px -2px -6px;
  scrollbar-width: none;
  transition: right var(--t-ui) var(--ease), left var(--t-ui) var(--ease);
}
#kpis::-webkit-scrollbar { display: none; }
.kpi {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; min-width: 0;
  height: 88px; padding: 12px 14px 11px; border-radius: var(--r-14);
  background: var(--glass); -webkit-backdrop-filter: var(--blur-14); backdrop-filter: var(--blur-14);
  border: 1px solid var(--border); box-shadow: var(--shadow-card);
  transition: transform var(--t-hover) var(--ease), border-color var(--t-hover) var(--ease), box-shadow var(--t-hover) var(--ease), height var(--t-ui) var(--ease), padding var(--t-ui) var(--ease);
}
.kpi::after { content: ''; position: absolute; inset: -1px; border-radius: inherit; border: 1px solid var(--accent); opacity: 0; pointer-events: none; transition: opacity var(--t-num) var(--ease); }
.kpi.destello::after { opacity: 1; transition: none; }
.kpi:hover { transform: translateY(-2px); border-color: rgba(0, 103, 255, .5); }
.kpi.activo { border-color: var(--accent); box-shadow: var(--shadow-card), 0 0 0 3px rgba(0, 103, 255, .18); }
.kpi-f1 { display: flex; align-items: center; min-width: 0; }
.kpi-etiqueta { font-size: var(--fs-12); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.kpi-etiqueta .corta { display: none; }
.tendencia { flex: none; display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: var(--r-pill); font-size: var(--fs-11); color: var(--text-2); background: var(--field); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tendencia.sube { color: var(--green); background: rgba(34, 197, 94, .10); }
.kpi-f2 { display: flex; align-items: baseline; gap: 4px; line-height: 1; white-space: nowrap; min-width: 0; }
.kpi-f2 .tendencia { margin-left: auto; align-self: center; }
.kpi-valor { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-28); font-variant-numeric: tabular-nums; color: var(--text-strong); letter-spacing: -.02em; transition: font-size var(--t-ui) var(--ease); }
.kpi-unidad { font-size: var(--fs-14); color: var(--text-2); font-family: var(--font-display); font-weight: 500; }
.kpi-f3 { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; min-width: 0; }
.kpi-sub { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-11); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.kpi-sub.verde { color: var(--green); }
.kpi-canal { display: inline-flex; align-items: center; gap: 3px; font-variant-numeric: tabular-nums; color: var(--text-2); }
.kpi-canal + .kpi-canal { margin-left: 4px; }
.ico-12 { width: 12px; height: 12px; }
.kpi-canal .ico { color: var(--text-3); }
.kpi-spark { width: 56px; height: 20px; flex: none; display: block; }

/* modo compacto (drawer abierto) */
body.drawer-abierto #kpis { grid-template-columns: repeat(6, minmax(112px, 1fr)); }
body.drawer-abierto .kpi { height: 64px; padding: 10px 12px; }
body.drawer-abierto .kpi-valor { font-size: var(--fs-22); }
body.drawer-abierto .kpi-f3 { display: none; }
body.drawer-abierto .kpi-etiqueta .larga { display: none; }
body.drawer-abierto .kpi-etiqueta .corta { display: inline; }
body.drawer-abierto .kpi .tendencia { display: none; }

/* ------------------------------------------------------------------ */
/* Banner de momento                                                   */
/* ------------------------------------------------------------------ */
#banner {
  position: fixed; z-index: var(--z-banner); top: 172px;
  left: calc(var(--izq) + (100vw - var(--izq) - var(--der)) / 2);
  width: min(420px, calc(100vw - var(--izq) - var(--der) - 32px)); height: 48px; padding: 0 16px; border-radius: var(--r-14);
  display: flex; align-items: center; gap: 10px;
  background: var(--glass-strong); -webkit-backdrop-filter: var(--blur-16); backdrop-filter: var(--blur-16);
  border: 1px solid var(--border-2); box-shadow: var(--shadow-float);
  font-size: var(--fs-14); font-weight: 500; color: var(--text-strong);
  transform: translate(-50%, -8px); opacity: 0; pointer-events: none;
  transition: opacity 220ms var(--ease), transform 220ms var(--ease), left var(--t-ui) var(--ease), top var(--t-ui) var(--ease);
}
#banner.visible { opacity: 1; transform: translate(-50%, 0); }
#banner .punto { width: 8px; height: 8px; box-shadow: 0 0 12px var(--c); }
#banner .banner-texto { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.drawer-abierto #banner { top: 148px; }

/* ------------------------------------------------------------------ */
/* Drawer                                                              */
/* ------------------------------------------------------------------ */
#drawer {
  position: fixed; z-index: var(--z-drawer); top: var(--topbar-h); right: 0; bottom: 0; width: var(--drawer-w);
  background: var(--glass-strong); -webkit-backdrop-filter: var(--blur-24); backdrop-filter: var(--blur-24);
  border-left: 1px solid var(--border); box-shadow: -24px 0 60px rgba(0, 0, 0, .35);
  display: flex; flex-direction: column;
  opacity: 0; transform: translateX(24px); visibility: hidden; pointer-events: none;
  transition: opacity 180ms var(--ease), transform 180ms var(--ease), visibility 0s linear 180ms;
}
body.drawer-abierto #drawer { opacity: 1; transform: none; visibility: visible; pointer-events: auto; transition: opacity 240ms var(--ease), transform 240ms var(--ease), visibility 0s; }
.drawer-asa { display: none; }
.drawer-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 20px; }

.dr-cab { position: relative; display: grid; grid-template-columns: 36px 1fr; gap: 14px; min-height: 72px; padding-right: 40px; margin-bottom: 16px; }
.dr-icono { --c: var(--accent); width: 36px; height: 36px; border-radius: var(--r-10); display: grid; place-items: center; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); border: 1px solid color-mix(in srgb, var(--c) 22%, transparent); }
.dr-titulo { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-20); line-height: 1.2; color: var(--text-strong); letter-spacing: -.01em; margin-top: 4px; }
.dr-sub { margin-top: 4px; font-size: var(--fs-13); color: var(--text-2); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.dr-cerrar { position: absolute; top: 0; right: 0; width: 32px; height: 32px; border-radius: var(--r-8); display: grid; place-items: center; color: var(--text-2); transition: background var(--t-hover) var(--ease), color var(--t-hover) var(--ease); }
.dr-cerrar:hover { background: var(--hover); color: var(--text); }
.dr-estado { display: inline-flex; margin-top: 8px; }

.dr-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.dr-kpi { min-height: 76px; padding: 12px; border-radius: var(--r-12); background: var(--field); border: 1px solid var(--border); display: flex; flex-direction: column; justify-content: space-between; min-width: 0; }
.dr-kpi-et { font-size: var(--fs-12); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dr-kpi-v { display: flex; align-items: baseline; gap: 4px; line-height: 1.1; margin-top: 4px; min-width: 0; }
.dr-kpi-v .valor { font-family: var(--font-display); font-weight: 600; font-size: 24px; font-variant-numeric: tabular-nums; color: var(--text-strong); letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dr-kpi-v .valor.texto { font-size: 17px; letter-spacing: -.005em; }
.dr-kpi-v .unidad { font-size: var(--fs-13); color: var(--text-2); font-family: var(--font-display); }
.dr-kpi .tendencia { align-self: flex-start; margin-top: 6px; }

.dr-tarjeta { border-radius: var(--r-12); background: var(--field); border: 1px solid var(--border); padding: 12px; margin-bottom: 12px; }
.dr-tarjeta-cab { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.dr-tarjeta-titulo { font-size: var(--fs-12); color: var(--text-2); }
.dr-tarjeta-total { font-size: var(--fs-12); color: var(--text-3); font-variant-numeric: tabular-nums; }
.dr-graf { position: relative; height: 180px; }
.dr-graf canvas { width: 100%; height: 100%; display: block; }
.graf-tip {
  position: absolute; top: 0; z-index: 2; pointer-events: none; white-space: nowrap;
  padding: 5px 8px; border-radius: var(--r-8); font-size: var(--fs-12); color: var(--text); font-variant-numeric: tabular-nums;
  background: var(--glass-strong); border: 1px solid var(--border-2); box-shadow: var(--shadow-card);
  transform: translate(-50%, 0); opacity: 0; transition: opacity 120ms var(--ease);
}
.graf-tip.visible { opacity: 1; }

.dr-seccion { font-size: var(--fs-11); color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; margin: 18px 0 4px; }
.dr-lista { margin-bottom: 16px; }
.dr-fila { display: grid; grid-template-columns: 44px 6px 1fr; align-items: center; column-gap: 10px; min-height: 44px; padding: 7px 6px; margin: 0 -6px; border-radius: var(--r-8); width: calc(100% + 12px); text-align: left; }
.dr-fila + .dr-fila { box-shadow: inset 0 1px 0 var(--border); }
button.dr-fila { transition: background var(--t-hover) var(--ease); }
button.dr-fila:hover { background: var(--hover); }
.dr-fila.ayer, .con-ayer .dr-fila { grid-template-columns: 64px 6px 1fr; }
.dr-fila .hora { font-size: var(--fs-12); color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dr-fila.ayer .hora { font-size: var(--fs-11); }
.dr-fila .texto { font-size: var(--fs-13); color: var(--text); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dr-acciones { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 8px; }

.dr-vacio { padding: 18px; border-radius: var(--r-12); border: 1px dashed var(--border-2); color: var(--text-2); font-size: var(--fs-13); text-align: center; }
.esqueleto { border-radius: var(--r-8); background: linear-gradient(90deg, rgba(255,255,255,.04), rgba(255,255,255,.08), rgba(255,255,255,.04)); background-size: 200% 100%; animation: brillo 1.4s linear infinite; }
@keyframes brillo { to { background-position: -200% 0; } }

/* ------------------------------------------------------------------ */
/* Feed                                                                */
/* ------------------------------------------------------------------ */
#feed {
  position: fixed; z-index: var(--z-overlay); bottom: 16px; right: calc(var(--der) + 16px);
  width: min(380px, calc(100vw - var(--izq) - var(--der) - 32px)); border-radius: var(--r-14); overflow: hidden;
  background: var(--glass); -webkit-backdrop-filter: var(--blur-16); backdrop-filter: var(--blur-16);
  border: 1px solid var(--border); box-shadow: var(--shadow-card);
  transition: right var(--t-ui) var(--ease), width var(--t-ui) var(--ease);
}
.feed-cabecera { display: flex; align-items: center; gap: 10px; width: 100%; height: 40px; padding: 0 14px; font-size: var(--fs-13); font-weight: 600; color: var(--text); }
.feed-cabecera:hover { background: rgba(255, 255, 255, .025); }
.feed-titulo { flex: 1; }
.feed-contador { font-family: var(--font-display); font-size: var(--fs-11); font-weight: 600; color: #fff; background: var(--accent); border-radius: var(--r-pill); padding: 1px 7px; font-variant-numeric: tabular-nums; }
.feed-chev { color: var(--text-2); transition: transform var(--t-ui) var(--ease); transform: rotate(180deg); }
#feed.plegado .feed-chev { transform: rotate(0deg); }
.feed-lista { display: grid; max-height: 272px; overflow: hidden; padding: 0 0 8px; border-top: 1px solid var(--border); transition: max-height var(--t-ui) var(--ease), padding var(--t-ui) var(--ease), opacity var(--t-ui) var(--ease); }
#feed.plegado .feed-lista { max-height: 0; padding: 0; opacity: 0; border-top-color: transparent; }
.feed-fila { display: grid; grid-template-columns: 40px 16px 1fr; align-items: center; column-gap: 10px; height: 32px; padding: 0 14px; width: 100%; transition: background var(--t-hover) var(--ease); }
.feed-fila.ayer, .con-ayer .feed-fila { grid-template-columns: 64px 16px 1fr; }
.feed-fila:hover { background: var(--hover); }
.feed-fila .hora { font-size: var(--fs-12); color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.feed-fila.ayer .hora { font-size: var(--fs-11); }
.feed-fila .ico { color: var(--c, var(--text-2)); }
.feed-fila .texto { font-size: var(--fs-13); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.feed-fila.nueva { animation: fila-nueva 220ms var(--ease) both, fila-fondo 1.2s var(--ease) both; }
@keyframes fila-nueva { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes fila-fondo { from { background: var(--accent-soft); } to { background: transparent; } }
.feed-vacio { display: flex; align-items: center; gap: 10px; padding: 14px; font-size: var(--fs-13); color: var(--text-2); }

/* ------------------------------------------------------------------ */
/* Leyenda                                                             */
/* ------------------------------------------------------------------ */
#leyenda {
  position: fixed; z-index: var(--z-overlay); bottom: 16px; left: calc(var(--izq) + 16px);
  display: flex; align-items: center; gap: 14px; height: 36px; padding: 0 6px 0 4px; border-radius: var(--r-12);
  background: var(--glass); -webkit-backdrop-filter: var(--blur-14); backdrop-filter: var(--blur-14);
  border: 1px solid var(--border); box-shadow: var(--shadow-card);
  transition: left var(--t-ui) var(--ease);
}
.btn-vista { width: 28px; height: 28px; }
.leyenda-sep { width: 1px; height: 16px; background: var(--border-2); }
.leyenda-lista { display: flex; align-items: center; gap: 14px; }
.leyenda-lista li { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-12); color: var(--text-2); white-space: nowrap; }
.leyenda-lista .ico { color: var(--c); }
.chip-demo { height: 22px; font-size: var(--fs-11); border-color: var(--border-2); color: var(--text-2); }

/* Con el drawer abierto, la leyenda se queda en lo esencial para no chocar con el feed */
@media (max-width: 1719px) { body.drawer-abierto .leyenda-lista, body.drawer-abierto .leyenda-sep { display: none; } body.drawer-abierto #leyenda { gap: 8px; } }

/* ------------------------------------------------------------------ */
/* Móvil: barra inferior, hoja «Más», botón flotante                   */
/* ------------------------------------------------------------------ */
#barra-movil, .fab-noche, #hoja-mas { display: none; }

/* ------------------------------------------------------------------ */
/* Tablet 768-1279                                                     */
/* ------------------------------------------------------------------ */
@media (max-width: 1279px) {
  :root { --sidebar-w: 64px; --drawer-w: 60vw; }
  #sidebar { padding: 12px 10px; }
  .nav-item { justify-content: center; padding: 0; gap: 0; }
  .nav-item > span { display: none; }
  .nav-item.activo::before { left: -10px; }
  .nav-item[data-tip]:hover::after {
    content: attr(data-tip); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
    padding: 6px 10px; border-radius: var(--r-8); white-space: nowrap; font-size: var(--fs-12); color: var(--text); font-weight: 500;
    background: rgba(10, 14, 30, .97); border: 1px solid var(--border-2); box-shadow: var(--shadow-card); z-index: var(--z-menu);
    animation: aparecer 120ms var(--ease) both; pointer-events: none;
  }
  .nav-subitem { justify-content: center; padding: 0; }
  .nav-subitem .sub-nombre, .nav-subitem .sub-estado { display: none; }
  .nav-subitem .punto { width: 10px; height: 10px; }
  .nav-subitem[data-tip]:hover::after {
    content: attr(data-tip); position: absolute; left: calc(100% + 10px); padding: 6px 10px; border-radius: var(--r-8); white-space: nowrap;
    font-size: var(--fs-12); color: var(--text); background: var(--glass-strong); border: 1px solid var(--border-2); z-index: var(--z-menu); pointer-events: none;
  }
  .nav-subitem { position: relative; }
  .sidebar-pie, .ia-estado { display: none; }
  .tb-marca { display: none; }
  .btn-salir-texto { display: none; }
  .btn-noche-texto { display: none; }
  .btn-noche { padding: 0 10px; }
  body.drawer-abierto .btn-noche-texto { display: none; }
  #feed { width: min(340px, calc(100vw - var(--izq) - var(--der) - 32px)); }
  body.drawer-abierto #leyenda { display: none; }
}
@media (min-width: 1280px) and (max-width: 1439px) {
  .btn-noche-texto { display: none; }
  .btn-noche { padding: 0 10px; }
}

/* ------------------------------------------------------------------ */
/* Móvil < 768                                                         */
/* ------------------------------------------------------------------ */
@media (max-width: 767px) {
  :root { --izq: 0px; --der: 0px; --drawer-w: 100vw; }
  body.drawer-abierto { --der: 0px; }

  #topbar { grid-template-columns: auto 1fr auto; gap: 10px; padding: 0 12px; }
  .tb-izq { gap: 8px; }
  .tb-marca, .selector-marca, .chip-horario, #velocidad, #btn-noche, .btn-salir-texto { display: none !important; }
  .tb-centro { justify-self: start; gap: 8px; }
  .horario-punto-movil { display: inline-block; width: 8px; height: 8px; }
  #reloj { font-size: 18px; }
  .vel-movil { display: block; }
  .btn-fantasma#btn-salir { padding: 0; width: 32px; justify-content: center; }

  #sidebar { display: none; }

  #kpis {
    top: 64px; left: 0; right: 0; margin: 0; padding: 0 16px 4px;
    display: flex; gap: 10px; scroll-snap-type: x mandatory; scroll-padding: 0 16px;
    -webkit-overflow-scrolling: touch;
  }
  .kpi, body.drawer-abierto .kpi { flex: 0 0 150px; height: 76px; padding: 10px 12px; scroll-snap-align: start; }
  .kpi:hover { transform: none; }
  .kpi-valor, body.drawer-abierto .kpi-valor { font-size: var(--fs-22); }
  .kpi-spark { display: none; }
  .kpi .tendencia { display: none; }
  .kpi-f3, body.drawer-abierto .kpi-f3 { display: flex; }
  .kpi-etiqueta .larga { display: none; }
  .kpi-etiqueta .corta { display: inline; }

  #banner, body.drawer-abierto #banner { top: 152px; left: 50%; width: calc(100vw - 32px); }
  #kpis { transition: opacity 180ms var(--ease); }
  body.drawer-abierto #kpis { opacity: 0; pointer-events: none; }

  #drawer {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 85dvh; max-height: 85vh;
    border-left: 0; border-top: 1px solid var(--border-2); border-radius: 16px 16px 0 0;
    transform: translateY(100%); opacity: 1; box-shadow: 0 -24px 60px rgba(0, 0, 0, .45);
    transition: transform 240ms var(--ease), visibility 0s linear 240ms;
  }
  body.drawer-abierto #drawer { transform: translateY(var(--arrastre, 0px)); transition: transform 280ms var(--ease), visibility 0s; }
  #drawer.arrastrando { transition: none !important; }
  .drawer-asa { display: flex; justify-content: center; align-items: center; height: 24px; flex: none; touch-action: none; cursor: grab; }
  .drawer-asa span { width: 36px; height: 4px; border-radius: var(--r-pill); background: var(--border-2); }
  .drawer-scroll { padding: 4px 16px calc(24px + env(safe-area-inset-bottom)); }

  #feed { left: 16px; right: 16px; bottom: calc(64px + env(safe-area-inset-bottom)); width: auto; }
  #feed .feed-lista { max-height: 200px; }

  #leyenda { left: 16px; bottom: calc(128px + env(safe-area-inset-bottom)); gap: 8px; padding: 0 6px 0 4px; }
  #leyenda .leyenda-lista, #leyenda .leyenda-sep { display: none; }
  body.drawer-abierto #leyenda { display: flex; }

  .fab-noche:not([hidden]) {
    display: grid; place-items: center; position: fixed; z-index: var(--z-overlay); right: 16px; bottom: calc(128px + env(safe-area-inset-bottom));
    width: 48px; height: 48px; border-radius: 50%; background: var(--accent); color: #fff; box-shadow: var(--shadow-primary);
  }
  .fab-noche:disabled { background: #0B4CC0; }
  .fab-noche.activo { background: conic-gradient(#fff calc(var(--p, 0) * 1turn), #0B4CC0 0); }
  .fab-noche.activo .ico { color: #fff; filter: drop-shadow(0 0 2px #0B4CC0); }

  #barra-movil {
    display: grid; grid-template-columns: repeat(6, 1fr); position: fixed; z-index: var(--z-sidebar); left: 0; right: 0; bottom: 0;
    height: calc(56px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--glass-side); -webkit-backdrop-filter: var(--blur-14); backdrop-filter: var(--blur-14); border-top: 1px solid var(--border);
  }
  .bm-item { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--text-2); font-size: 10px; font-weight: 500; }
  .bm-item .ico { width: 20px; height: 20px; }
  .bm-item.activo { color: var(--text-strong); }
  .bm-item.activo .ico { color: var(--accent); }
  .bm-item.activo::after { content: ''; position: absolute; bottom: 4px; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }

  #hoja-mas:not([hidden]) { display: block; position: fixed; inset: 0; z-index: calc(var(--z-drawer) + 2); }
  .hoja-mas-velo { position: absolute; inset: 0; background: rgba(7, 6, 20, .55); animation: fundido 180ms var(--ease) both; }
  .hoja-mas-caja {
    position: absolute; left: 0; right: 0; bottom: 0; padding: 0 12px calc(16px + env(safe-area-inset-bottom)); border-radius: 16px 16px 0 0;
    background: var(--glass-strong); -webkit-backdrop-filter: var(--blur-24); backdrop-filter: var(--blur-24); border-top: 1px solid var(--border-2);
    animation: hoja-in 240ms var(--ease) both; display: grid; gap: 2px;
  }
  .hoja-mas-caja .nav-item { height: 48px; }
  .hoja-mas-caja .nav-item.activo::before { display: none; }
  .hoja-mas-titulo { font-size: var(--fs-12); color: var(--text-2); padding: 4px 12px 8px; }
  .hoja-mas-caja .sidebar-pie { padding: 12px 12px 0; }
  @keyframes hoja-in { from { transform: translateY(100%); } to { transform: none; } }

  .login-card { width: calc(100vw - 32px); padding: 28px 24px; }
  .login-datos { display: none; }
  .login-centro { transform: translateY(-2vh); }
  .login-demo { max-width: calc(100vw - 32px); border-radius: var(--r-12); padding: 8px 12px; line-height: 1.9; flex-direction: column; gap: 6px; }
  .login-demo { line-height: 1.5; }
  .login-demo-sep { display: none; }

  #sin3d { top: 50%; }
}

/* Alturas bajas */
@media (max-height: 640px) and (min-width: 768px) {
  .feed-lista { max-height: 160px; }
  #sidebar { overflow-y: auto; }
  .ia-estado, #leyenda, .kpi-spark { display: none; }
  .kpi, body.drawer-abierto .kpi { height: 64px; padding: 10px 12px; }
  .kpi-valor { font-size: var(--fs-22); }
  .kpi-f3 { display: none; }
}

/* ------------------------------------------------------------------ */
/* Calidad media y baja del 3D: sin desenfoque de fondo (se recalculaba en cada fotograma del canvas)   */
/* ------------------------------------------------------------------ */
:root[data-calidad="media"], :root[data-calidad="baja"] {
  --glass: rgba(15, 23, 42, .9); --glass-strong: rgba(10, 14, 30, .94); --glass-bar: rgba(7, 6, 20, .9); --glass-side: rgba(7, 6, 20, .92);
}
[data-calidad="baja"] *, [data-calidad="baja"] *::before, [data-calidad="baja"] *::after,
[data-calidad="media"] .kpi, [data-calidad="media"] #feed, [data-calidad="media"] #leyenda, [data-calidad="media"] .cn-et {
  -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
}

/* ------------------------------------------------------------------ */
/* Movimiento reducido                                                 */
/* ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0ms !important; animation-iteration-count: 1 !important; transition-duration: 0ms !important; scroll-behavior: auto !important; }
  #login, #login::before, .login-card, #drawer, #banner, body.entrando-rapido #panel { transition: opacity 120ms linear !important; }
  .punto-vivo, .chip-horario.fuera .punto, .horario-punto-movil.fuera { animation: none !important; }
  .kpi:hover { transform: none; }
  #drawer { transform: none !important; }
  @media (max-width: 767px) { #drawer { transform: translateY(100%) !important; } body.drawer-abierto #drawer { transform: none !important; } }
}

.noscript { position: fixed; inset: 0; display: grid; place-items: center; z-index: 200; background: var(--bg); color: var(--text-2); font-size: var(--fs-14); }
