/* Agentic OS — capa común de diseño: tokens, controles, diálogos, avisos y navegación compartida.
   Sin fuentes externas (CSP): fuentes del sistema. Movimiento: solo transform y opacity, curvas fuertes,
   < 300 ms salvo el zoom de la esfera; con «reducir movimiento», fundidos suaves en vez de desplazamientos. */

:root {
  --fondo: #040507;
  --vidrio: rgba(12, 14, 20, 0.72);
  --vidrio-2: rgba(20, 23, 31, 0.86);
  --campo: rgba(255, 255, 255, 0.045);
  --campo-hover: rgba(255, 255, 255, 0.07);
  --linea: rgba(255, 255, 255, 0.1);
  --linea-2: rgba(255, 255, 255, 0.18);
  --texto: #f2f2f4;
  --texto-2: #a6a6b0;
  --texto-3: #7d7d88;
  --acento: #c070d0; /* lo mueve la interfaz: el tono deriva solo, como la esfera */
  --acento-rgb: 192, 112, 208;
  --menta: #5fe0c0;
  --menta-rgb: 95, 224, 192;
  --ambar: #e0a445;
  --ambar-rgb: 224, 164, 69;
  --rojo: #ff6b70;
  --rojo-rgb: 255, 107, 112;
  --azul: #6fb8ff;
  --display: "DIN Condensed", "Avenir Next Condensed", "Arial Narrow", sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --radio-s: 10px;
  --radio-m: 14px;
  --radio-l: 18px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --t-tap: 160ms;
  --t-ui: 220ms;
  --t-hoja: 320ms;
  --alto-tab: 64px;
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

/* Fundido entre páginas solo con ratón: en el teléfono la transición se aborta al cambiar de pestaña. */
@media (hover: hover) and (pointer: fine) { @view-transition { navigation: auto; } }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--fondo); }
body { margin: 0; background: var(--fondo); color: var(--texto); -webkit-tap-highlight-color: transparent; }
:where(button, input, select, textarea) { font: inherit; color: inherit; }
:where(a) { color: inherit; }
::selection { background: rgba(var(--acento-rgb), 0.4); }

/* Foco visible y consistente (solo teclado). */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid rgba(var(--acento-rgb), 0.95);
  outline-offset: 2px;
}

.sr { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[data-ico] { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ico-s { width: 15px; height: 15px; }
.ico-l { width: 22px; height: 22px; }
.etiqueta-mono { font: 600 11px/1.3 var(--mono); letter-spacing: 0.16em; text-transform: uppercase; color: var(--texto-2); }

/* ── Botones ─────────────────────────────────────────────────────────────────────────────────── */
.os-btn {
  --b-fondo: rgba(255, 255, 255, 0.055);
  --b-borde: var(--linea-2);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px;
  font: 600 14px/1 var(--sans); letter-spacing: 0.01em; color: var(--texto);
  background: var(--b-fondo); border: 1px solid var(--b-borde); border-radius: var(--radio-s);
  cursor: pointer; text-decoration: none; white-space: nowrap; user-select: none;
  transition: transform var(--t-tap) var(--ease-out), background-color var(--t-tap) ease, border-color var(--t-tap) ease, color var(--t-tap) ease;
}
.os-btn:active:not(:disabled) { transform: scale(0.97); }
.os-btn:disabled, .os-btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.os-btn.primario {
  --b-fondo: var(--acento);
  --b-borde: transparent;
  color: #0a0a0e;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 55%), var(--acento);
  box-shadow: 0 0 0 1px rgba(var(--acento-rgb), 0.6), 0 6px 22px -8px rgba(var(--acento-rgb), 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.os-btn.peligro { color: var(--rojo); --b-borde: rgba(var(--rojo-rgb), 0.4); --b-fondo: rgba(var(--rojo-rgb), 0.06); }
.os-btn.peligro-lleno { color: #12070a; --b-fondo: var(--rojo); --b-borde: transparent; }
.os-btn.fantasma { --b-fondo: transparent; --b-borde: transparent; color: var(--texto-2); }
.os-btn.chico { min-height: 32px; padding: 0 11px; font-size: 13px; gap: 6px; }
.os-btn.icono { width: 40px; padding: 0; }
.os-btn.icono.chico { width: 32px; }
.os-btn.ancho { width: 100%; }
@media (hover: hover) and (pointer: fine) {
  .os-btn:hover:not(:disabled) { --b-fondo: rgba(255, 255, 255, 0.09); --b-borde: rgba(var(--acento-rgb), 0.55); }
  .os-btn.primario:hover:not(:disabled) { --b-borde: transparent; filter: brightness(1.08); }
  .os-btn.peligro:hover:not(:disabled) { --b-fondo: rgba(var(--rojo-rgb), 0.12); --b-borde: rgba(var(--rojo-rgb), 0.7); }
  .os-btn.fantasma:hover:not(:disabled) { --b-fondo: rgba(255, 255, 255, 0.06); --b-borde: transparent; color: var(--texto); }
}
/* Cargando: el texto se queda (el ancho no salta) y una barra recorre el borde inferior. */
.os-btn[aria-busy="true"] { cursor: progress; }
.os-btn[aria-busy="true"]::after {
  content: ""; position: absolute; left: 10%; right: 10%; bottom: 3px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, currentColor, transparent);
  animation: os-barrido 900ms linear infinite;
}
@keyframes os-barrido { from { transform: translateX(-40%); opacity: 0.4; } 50% { opacity: 1; } to { transform: translateX(40%); opacity: 0.4; } }

/* ── Campos ──────────────────────────────────────────────────────────────────────────────────── */
.os-campo { display: grid; gap: 7px; margin: 0 0 16px; }
.os-campo > span:first-child, .os-leyenda { font-size: 13px; font-weight: 500; color: var(--texto-2); }
.os-ayuda { font-size: 13px; line-height: 1.45; color: var(--texto-3); margin: 0; }
.os-input, .os-select, .os-area,
.os-campo input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), .os-campo select, .os-campo textarea {
  display: block; width: 100%; min-height: 44px; margin: 0; padding: 10px 13px;
  font: 16px/1.4 var(--sans); color: var(--texto);
  background: var(--campo); border: 1px solid var(--linea); border-radius: var(--radio-s);
  transition: border-color var(--t-tap) ease, background-color var(--t-tap) ease;
}
.os-area, .os-campo textarea { resize: vertical; min-height: 88px; line-height: 1.5; }
:is(.os-input, .os-select, .os-area, .os-campo input, .os-campo select, .os-campo textarea)::placeholder { color: var(--texto-3); }
:is(.os-input, .os-select, .os-area, .os-campo input, .os-campo select, .os-campo textarea):focus-visible {
  outline: none; border-color: rgba(var(--acento-rgb), 0.9); background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 3px rgba(var(--acento-rgb), 0.22);
}
:is(.os-input, .os-select, .os-area, .os-campo input, .os-campo select, .os-campo textarea):disabled { opacity: 0.5; cursor: not-allowed; }
@media (hover: hover) and (pointer: fine) {
  :is(.os-input, .os-select, .os-area, .os-campo input, .os-campo select, .os-campo textarea):hover:not(:disabled):not(:focus) { border-color: var(--linea-2); }
}
.os-select, .os-campo select {
  appearance: none; -webkit-appearance: none; padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a6a6b0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
.os-select option, .os-campo select option { background: #12141b; color: var(--texto); }
.os-campo input[type="number"] { font-variant-numeric: tabular-nums; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
.os-campo input[type="file"] { display: block; width: 100%; font-size: 14px; color: var(--texto-2); padding: 8px; border: 1px dashed var(--linea-2); border-radius: var(--radio-s); background: var(--campo); }
.os-campo input[type="file"]::file-selector-button {
  margin-right: 12px; padding: 8px 14px; font: 600 13px var(--sans); color: var(--texto);
  background: rgba(255, 255, 255, 0.08); border: 1px solid var(--linea-2); border-radius: 8px; cursor: pointer;
}
.os-busqueda { position: relative; display: flex; align-items: center; }
.os-busqueda .ico { position: absolute; left: 12px; color: var(--texto-3); pointer-events: none; }
.os-busqueda input { padding-left: 38px !important; }

/* Casillas y radios */
.os-check {
  appearance: none; -webkit-appearance: none; flex: none; width: 20px; height: 20px; margin: 0;
  border: 1.5px solid var(--linea-2); border-radius: 6px; background: var(--campo); cursor: pointer;
  display: inline-grid; place-content: center;
  transition: background-color var(--t-tap) ease, border-color var(--t-tap) ease;
}
.os-check::after {
  content: ""; width: 12px; height: 12px; transform: scale(0.6); opacity: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230a0a0e' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: transform var(--t-tap) var(--ease-out), opacity var(--t-tap) var(--ease-out);
}
.os-check:checked { background: var(--acento); border-color: var(--acento); }
.os-check:checked::after { transform: none; opacity: 1; }
.os-check:disabled { opacity: 0.4; cursor: not-allowed; }

/* Interruptor (role="switch") */
.os-switch {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 44px; height: 26px; margin: 0;
  border-radius: 99px; background: rgba(255, 255, 255, 0.1); border: 1px solid var(--linea-2); cursor: pointer;
  transition: background-color var(--t-ui) ease, border-color var(--t-ui) ease;
}
.os-switch::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: #d9d9e0; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  transition: transform var(--t-ui) var(--ease-out), background-color var(--t-ui) ease;
}
.os-switch:checked { background: rgba(var(--acento-rgb), 0.85); border-color: transparent; }
.os-switch:checked::before { transform: translateX(18px); background: #fff; }
.os-switch:active:not(:disabled)::before { transform: scaleX(1.12); }
.os-switch:checked:active:not(:disabled)::before { transform: translateX(16px) scaleX(1.12); }
.os-switch:disabled { opacity: 0.4; cursor: not-allowed; }
.os-fila-switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 48px; padding: 6px 0; cursor: pointer; }
.os-fila-switch > span { display: grid; gap: 2px; font-size: 15px; color: var(--texto); }
.os-fila-switch small { font-size: 13px; color: var(--texto-3); line-height: 1.4; }

/* Control segmentado (radios) */
.os-segmentos { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border: 1px solid var(--linea); border-radius: 12px; background: rgba(255, 255, 255, 0.03); max-width: 100%; }
.os-segmentos label { position: relative; display: block; cursor: pointer; }
.os-segmentos input, .os-segmentos input:disabled { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.os-segmentos span {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 0 13px; border-radius: 8px;
  font: 500 14px var(--sans); color: var(--texto-2); white-space: nowrap;
  transition: background-color var(--t-tap) ease, color var(--t-tap) ease, transform var(--t-tap) var(--ease-out);
}
.os-segmentos input:checked + span { background: rgba(var(--acento-rgb), 0.2); color: var(--texto); box-shadow: inset 0 0 0 1px rgba(var(--acento-rgb), 0.65); }
.os-segmentos input:focus-visible + span { outline: 2px solid rgba(var(--acento-rgb), 0.95); outline-offset: 1px; }
.os-segmentos label:active span { transform: scale(0.97); }
.os-segmentos input:disabled + span { opacity: 0.4; cursor: not-allowed; }
@media (hover: hover) and (pointer: fine) { .os-segmentos label:hover input:not(:checked):not(:disabled) + span { color: var(--texto); background: rgba(255, 255, 255, 0.05); } }
.os-segmentos.ancho { display: flex; }
.os-segmentos.ancho label { flex: 1; }

/* Opciones como pastillas (casillas múltiples) */
.os-opciones { display: flex; flex-wrap: wrap; gap: 8px; }
.os-opciones label {
  display: inline-flex; align-items: center; gap: 9px; min-height: 40px; padding: 6px 14px 6px 10px; margin: 0;
  border: 1px solid var(--linea); border-radius: 99px; background: rgba(255, 255, 255, 0.03);
  font-size: 14px; color: var(--texto); cursor: pointer;
  transition: border-color var(--t-tap) ease, background-color var(--t-tap) ease, transform var(--t-tap) var(--ease-out);
}
.os-opciones label:has(input:checked) { border-color: rgba(var(--acento-rgb), 0.7); background: rgba(var(--acento-rgb), 0.12); }
.os-opciones label:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }
.os-opciones label:active { transform: scale(0.98); }
.os-opciones label.sensible { color: var(--ambar); }
.os-opciones .os-check { width: 18px; height: 18px; border-radius: 5px; }

/* ── Superficies ────────────────────────────────────────────────────────────────────────────── */
.os-vidrio {
  position: relative; border: 1px solid var(--linea); border-radius: var(--radio-m);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0) 40%), var(--vidrio);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
/* Esquinas de HUD (como las del centro de mando) */
.os-esquinas::before, .os-esquinas::after { content: ""; position: absolute; width: 12px; height: 12px; border: 0 solid rgba(var(--acento-rgb), 0.75); pointer-events: none; }
.os-esquinas::before { top: -1px; left: -1px; border-width: 1px 0 0 1px; border-top-left-radius: var(--radio-m); }
.os-esquinas::after { bottom: -1px; right: -1px; border-width: 0 1px 1px 0; border-bottom-right-radius: var(--radio-m); }

.os-chip { display: inline-flex; align-items: center; gap: 5px; min-height: 22px; padding: 0 9px; border-radius: 99px; border: 1px solid var(--linea-2); font: 500 12px/1 var(--sans); color: var(--texto-2); white-space: nowrap; }
.os-chip.bien { color: var(--menta); border-color: rgba(var(--menta-rgb), 0.4); background: rgba(var(--menta-rgb), 0.07); }
.os-chip.atencion, .os-chip.alta { color: var(--ambar); border-color: rgba(var(--ambar-rgb), 0.45); background: rgba(var(--ambar-rgb), 0.07); }
.os-chip.roto, .os-chip.urgente { color: var(--rojo); border-color: rgba(var(--rojo-rgb), 0.45); background: rgba(var(--rojo-rgb), 0.07); }
.os-chip.acento { color: var(--texto); border-color: rgba(var(--acento-rgb), 0.6); background: rgba(var(--acento-rgb), 0.12); }
.os-punto { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--menta); box-shadow: 0 0 8px var(--menta); flex: none; }
.os-punto.vivo { animation: os-latir 1.6s ease-in-out infinite; }
.os-punto.ambar { background: var(--ambar); box-shadow: 0 0 8px var(--ambar); }
.os-punto.rojo { background: var(--rojo); box-shadow: 0 0 8px var(--rojo); }
.os-punto.apagado { background: var(--texto-3); box-shadow: none; }
@keyframes os-latir { 50% { opacity: 0.35; } }

.os-vacio { display: grid; justify-items: center; gap: 8px; padding: 22px 12px; text-align: center; color: var(--texto-3); font-size: 14px; }
.os-vacio .ico { width: 26px; height: 26px; opacity: 0.7; }

/* Esqueleto de carga */
.os-esqueleto { position: relative; overflow: hidden; border-radius: var(--radio-s); background: rgba(255, 255, 255, 0.05); min-height: 64px; }
.os-esqueleto::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent); animation: os-brillo 1.4s ease-in-out infinite; }
@keyframes os-brillo { to { transform: translateX(100%); } }

/* ── Diálogos: centrados en escritorio; hoja inferior en el teléfono ─────────────────────────── */
dialog.os-dialogo {
  width: min(640px, calc(100vw - 32px)); max-height: min(86dvh, 900px); padding: 0; margin: auto;
  color: var(--texto); background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0) 30%), #0d0f15;
  border: 1px solid var(--linea-2); border-radius: var(--radio-l);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(var(--acento-rgb), 0.12);
  overflow: hidden; overscroll-behavior: contain;
  opacity: 1; transform: none;
  transition: opacity var(--t-ui) var(--ease-out), transform var(--t-ui) var(--ease-out), overlay var(--t-ui) allow-discrete, display var(--t-ui) allow-discrete;
}
dialog.os-dialogo:not([open]) { opacity: 0; transform: scale(0.96); transition-duration: 150ms; }
@starting-style { dialog.os-dialogo[open] { opacity: 0; transform: scale(0.96); } }
dialog.os-dialogo::backdrop {
  background: rgba(2, 3, 6, 0.62); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  opacity: 1; transition: opacity var(--t-ui) var(--ease-out), overlay var(--t-ui) allow-discrete, display var(--t-ui) allow-discrete;
}
dialog.os-dialogo:not([open])::backdrop { opacity: 0; transition-duration: 150ms; }
@starting-style { dialog.os-dialogo[open]::backdrop { opacity: 0; } }
.os-dialogo-marco { display: flex; flex-direction: column; max-height: inherit; }
.os-dialogo-cab { display: flex; align-items: flex-start; gap: 12px; padding: 18px 18px 12px 22px; border-bottom: 1px solid var(--linea); }
.os-dialogo-cab h2 { flex: 1; margin: 6px 0 0; font: 600 19px/1.3 var(--sans); overflow-wrap: anywhere; }
.os-dialogo-cuerpo { padding: 18px 22px; overflow-y: auto; overscroll-behavior: contain; }
.os-dialogo-pie { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 14px 18px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--linea); background: rgba(255, 255, 255, 0.02); }
.os-dialogo.chico { width: min(440px, calc(100vw - 32px)); }
.os-dialogo.amplio { width: min(780px, calc(100vw - 32px)); }
.os-confirmar p { margin: 0; font-size: 15px; line-height: 1.5; color: var(--texto-2); }

@media (max-width: 760px) {
  dialog.os-dialogo, dialog.os-dialogo.amplio, dialog.os-dialogo.chico {
    width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: var(--radio-l) var(--radio-l) 0 0; border-bottom: 0;
    transition-duration: var(--t-hoja); transition-timing-function: var(--ease-drawer);
  }
  dialog.os-dialogo:not([open]) { opacity: 1; transform: translateY(100%); transition-duration: 200ms; }
  @starting-style { dialog.os-dialogo[open] { opacity: 1; transform: translateY(100%); } }
  .os-dialogo-cab::before { content: ""; position: absolute; top: 7px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 4px; background: rgba(255, 255, 255, 0.2); }
}

/* ── Avisos (toasts) ────────────────────────────────────────────────────────────────────────── */
.os-avisos { position: fixed; z-index: 60; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: 8px; width: min(520px, calc(100vw - 32px)); pointer-events: none; }
.os-aviso {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; pointer-events: auto;
  font: 14px/1.45 var(--sans); color: var(--texto);
  background: rgba(16, 18, 26, 0.94); border: 1px solid var(--linea-2); border-left: 2px solid var(--acento); border-radius: 12px;
  box-shadow: 0 12px 40px -12px rgba(0, 0, 0, 0.8);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  opacity: 1; transform: none;
  transition: opacity 300ms ease, transform 300ms ease;
}
@starting-style { .os-aviso { opacity: 0; transform: translateY(12px); } }
.os-aviso.saliendo { opacity: 0; transform: translateY(6px); transition-duration: 160ms; }
.os-aviso.error { border-left-color: var(--rojo); }
.os-aviso.bien { border-left-color: var(--menta); }
.os-aviso .ico { margin-top: 1px; color: var(--acento); }
.os-aviso.error .ico { color: var(--rojo); }
.os-aviso.bien .ico { color: var(--menta); }
.os-aviso p { flex: 1; margin: 0; overflow-wrap: anywhere; }
.os-aviso button { flex: none; margin: -4px -6px -4px 0; }

/* ── Navegación compartida ──────────────────────────────────────────────────────────────────── */
.os-nav { display: flex; align-items: center; gap: 2px; padding: 4px; border: 1px solid var(--linea); border-radius: 99px; background: rgba(10, 11, 16, 0.75); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.os-nav a {
  position: relative; display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 15px; border-radius: 99px;
  font: 500 13px/1 var(--sans); color: var(--texto-2); text-decoration: none; white-space: nowrap;
  transition: color var(--t-tap) ease, transform var(--t-tap) var(--ease-out);
}
.os-nav a:active { transform: scale(0.97); }
.os-nav a > * { position: relative; z-index: 1; }
.os-nav a[aria-current="page"] { color: #0a0a0e; }
.os-nav a[aria-current="page"]::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; z-index: 0;
  background: linear-gradient(180deg, #fff, #dcdce2); box-shadow: 0 0 18px -4px rgba(var(--acento-rgb), 0.8);
}
/* La píldora que viaja entre páginas, solo con ratón: en el teléfono la transición se aborta. */
@media (hover: hover) and (pointer: fine) { .os-nav a[aria-current="page"]::before { view-transition-name: os-nav-activo; } }
@media (hover: hover) and (pointer: fine) { .os-nav a:not([aria-current="page"]):hover { color: var(--texto); background: rgba(255, 255, 255, 0.06); } }
html[data-modo="mac"] .os-nav [data-servidor], html[data-modo="desconocido"] .os-nav [data-servidor] { display: none; }
::view-transition-group(os-nav-activo) { animation-duration: 280ms; animation-timing-function: var(--ease-in-out); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 180ms; }

/* Barra superior de las páginas de trabajo (tablero, agentes, dispositivos) */
.os-barra {
  position: relative; z-index: 10; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 16px;
  padding: max(12px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 12px max(20px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--linea); background: rgba(4, 5, 7, 0.82); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.os-marca { display: flex; align-items: center; gap: 12px; min-width: 0; text-decoration: none; }
.os-marca canvas { width: 34px; height: 34px; flex: none; }
.os-marca-texto { display: grid; min-width: 0; }
.os-marca b { font: 700 22px/1 var(--display); letter-spacing: 0.22em; white-space: nowrap; }
.os-marca small { font: 500 11px/1.4 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--texto-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.os-barra-der { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-width: 0; }

/* Tableta: la marca se queda en la esfera y la navegación usa las etiquetas cortas para no pisar nada. */
@media (min-width: 761px) and (max-width: 1080px) {
  .os-barra .os-marca-texto { display: none; }
  .os-nav a { padding: 0 11px; }
}
/* Pantalla táctil: los controles llegan a 44 px. */
@media (pointer: coarse) {
  .os-btn, .os-nav a { min-height: 44px; }
}

/* Teléfono: la navegación baja a una barra de pestañas fija (con zona segura). */
@media (max-width: 760px) {
  /* Sin desenfoque aquí: un `backdrop-filter` haría que la barra de pestañas (fija) se pegara a la cabecera. */
  .os-barra { grid-template-columns: minmax(0, 1fr) auto; padding: max(10px, env(safe-area-inset-top)) 16px 10px; -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(4, 5, 7, 0.96); }
  .os-marca small { display: none; }
  .os-marca b { font-size: 20px; }
  .os-nav.os-nav-movil {
    position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; justify-content: space-around; gap: 0;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border: 0; border-top: 1px solid var(--linea); border-radius: 0;
    background: rgba(6, 7, 10, 0.92);
  }
  .os-nav.os-nav-movil a { flex: 1 1 0; flex-direction: column; justify-content: center; gap: 4px; min-height: 52px; padding: 0 2px; border-radius: 12px; font-size: 11px; }
  .os-nav.os-nav-movil a[aria-current="page"] { color: var(--texto); }
  .os-nav.os-nav-movil a[aria-current="page"]::before { inset: 4px 14%; background: rgba(var(--acento-rgb), 0.18); box-shadow: inset 0 0 0 1px rgba(var(--acento-rgb), 0.55); }
  .os-nav.os-nav-movil .ico { width: 21px; height: 21px; }
  body.con-tabs { padding-bottom: calc(var(--alto-tab) + env(safe-area-inset-bottom)); }
  .os-avisos { bottom: calc(var(--alto-tab) + 12px + env(safe-area-inset-bottom)); }
}

/* ── Movimiento reducido: sin desplazamientos, solo fundidos ─────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  dialog.os-dialogo, dialog.os-dialogo:not([open]) { transform: none !important; }
  @starting-style { dialog.os-dialogo[open] { transform: none; } }
  .os-aviso, .os-aviso.saliendo { transform: none; }
  @starting-style { .os-aviso { transform: none; } }
  .os-btn:active:not(:disabled), .os-segmentos label:active span, .os-opciones label:active, .os-nav a:active { transform: none; }
  .os-punto.vivo, .os-esqueleto::after { animation: none; }
  .os-btn[aria-busy="true"]::after { animation: none; transform: none; opacity: 0.8; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation-duration: 120ms !important; }
}
