/* Panel de la plataforma. Marca B · Cielo (docs/maquetas/base.css), con modo oscuro como relayd
   Colores de texto con contraste AA (4,5:1) sobre fondo y tarjetas; el cielo de la marca (#4c6fff) queda para rellenos y adornos */
:root {
  --bg: #f4f7ff; --surface: #fff; --text: #14213d; --muted: #5d6987; --border: #dce4ff; --soft: #eef2ff;
  --accent: #3d5af1; --relleno: #3d5af1; --relleno-hover: #2f4bdc; --cielo: #4c6fff; --accent-2: #7c4ddb;
  --ok: #1a7f45; --warn: #8f5e0a; --danger: #c0392b; --sobre-warn: #fff;
  --sombra-s: 0 1px 2px #14213d0a, 0 1px 3px #14213d0d; --sombra: 0 10px 30px -12px #14213d2e; --foco: 0 0 0 3px #4c6fff59;
  --radio: 14px; --menu-ancho: 244px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1424; --surface: #161e33; --text: #e8ecf8; --muted: #98a2bd; --border: #26304a; --soft: #1c2640;
    --accent: #7d93ff; --relleno: #3d5af1; --relleno-hover: #4c6fff; --accent-2: #a78bfa;
    --ok: #3ccf7a; --warn: #f0b44c; --danger: #ff6b5e; --sobre-warn: #14213d;
    --sombra-s: 0 1px 2px #0006; --sombra: 0 12px 32px -12px #000a; --foco: 0 0 0 3px #7d93ff66;
    color-scheme: dark;
  }
}
/* Manrope servida desde el propio panel: sin peticiones a Google (RGPD). Licencia OFL en fuentes/ */
@font-face {
  font-family: Manrope; font-weight: 400 800; font-display: swap;
  src: url(/fuentes/manrope-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: Manrope; font-weight: 400 800; font-display: swap;
  src: url(/fuentes/manrope-latin.woff2) format('woff2');
  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;
}

* { box-sizing: border-box; margin: 0; }
body { font: 14px/1.5 Manrope, system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
h1 { font-size: 26px; line-height: 1.2; font-weight: 800; letter-spacing: -.025em; }
h2 { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: 14px; font-weight: 700; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.peq { font-size: 12px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.brand img { width: 28px; }

/* --- Estructura: menú a la izquierda (azul tinta, como una consola de control; elegido por Ángel el 27/10), contenido a la derecha --- */
.menu {
  position: fixed; inset: 0 auto 0 0; width: var(--menu-ancho); overflow-y: auto; z-index: 5;
  background: #14213d; border-right: 1px solid #14213d; padding: 18px 12px; display: flex; flex-direction: column; gap: 4px;
  --text: #fff; --muted: #a9b3cf; --soft: #ffffff14; --border: #ffffff1f; --accent: #9fb0ff; --foco: 0 0 0 3px #9fb0ff66;
  color: var(--text); color-scheme: dark; scrollbar-width: thin; scrollbar-color: #ffffff26 transparent;
}
@media (prefers-color-scheme: dark) { .menu { background: #0a0f1d; border-right-color: #1c2640; } }
.menu .brand { margin: 0 8px 14px; }
.menu .cliente { display: flex; flex-direction: column; gap: 4px; margin: 0 4px 10px; font-size: 12px; }
.menu .cliente select { padding: 8px 10px; border-radius: 10px; border: 1px solid #ffffff26; background: #ffffff14; color: #fff; font-weight: 700; font-size: 14px; }
.menu .cliente select option { background: #14213d; }
.menu .grupo { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.menu .titulo-grupo { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 12px 4px; }
.menu a { padding: 8px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 600; display: flex; gap: 10px; align-items: center; transition: background .15s, color .15s; }
.menu a:hover { color: var(--text); background: var(--soft); }
.menu a.on { background: linear-gradient(100deg, #4c6fff, #8b5cf6); color: #fff; font-weight: 700; box-shadow: 0 6px 16px -8px #4c6fffcc; }
.menu a.on .i { color: #fff; }
.menu .btn { background: transparent; color: #fff; border-color: #ffffff33; box-shadow: none; }
.menu .btn:hover { background: #ffffff14; border-color: #ffffff59; }
.cuenta { background: var(--warn); color: var(--sobre-warn); border-radius: 99px; font-size: 11px; padding: 0 7px; font-weight: 800; }
.menu .cuenta { background: #f0b44c; color: #14213d; }
.menu .pie { margin-top: auto; padding: 12px 4px 0; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.menu .pie .sp { display: flex; flex-direction: column; min-width: 0; font-size: 13px; line-height: 1.3; }
.menu .pie .sp b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu .cerrar-menu { display: none; }
main { margin-left: var(--menu-ancho); padding: 26px 28px 40px; display: flex; flex-direction: column; gap: 18px; max-width: calc(var(--menu-ancho) + 1240px); }
main:focus { outline: none; }
.abajo, .arriba { display: none; }

/* --- Piezas --- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radio); padding: 18px; box-shadow: var(--sombra-s); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); font-weight: 700; font-size: 13px; color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap;
  min-height: 36px; box-shadow: var(--sombra-s); transition: background .15s, border-color .15s, box-shadow .15s, transform .1s;
}
.btn:hover { border-color: var(--accent); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--relleno); border-color: var(--relleno); color: #fff; }
.btn.primary:hover { background: var(--relleno-hover); border-color: var(--relleno-hover); }
.btn.peligro { color: var(--danger); }
.btn.peq { padding: 5px 10px; font-size: 12px; min-height: 30px; }
.btn.icono-solo { padding: 0; width: 34px; min-height: 34px; box-shadow: none; }
.i { width: 18px; height: 18px; flex: none; }
.pill { font-size: 12px; padding: 2px 9px; border-radius: 99px; border: 1px solid currentColor; font-weight: 600; white-space: nowrap; }
.working { color: var(--accent); } .waiting { color: var(--warn); } .off { color: var(--muted); } .ok { color: var(--ok); } .danger { color: var(--danger); } .accent2 { color: var(--accent-2); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none; background: #c8d2ee; color: #14213d; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.entre { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 10px; }
.sp { flex: 1; }
.bar { height: 6px; border-radius: 99px; background: var(--border); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar.alta i { background: var(--warn); }
.cabecera { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.cabecera p { margin-top: 2px; }
.vacio { padding: 40px 20px; text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.vacio > p.muted { max-width: 440px; }
.card.vacio { border-style: dashed; box-shadow: none; background: transparent; }
.estado-pagina { margin: 8vh auto 0; max-width: 520px; width: 100%; border-style: solid !important; background: var(--surface) !important; }
.estado-pagina h1 { font-size: 21px; }
.cargando { padding: 40px; }

/* Pantalla dibujada (hasta que haya miniaturas en directo) */
.screen { border-radius: 10px; height: 92px; background: linear-gradient(160deg, #1d2742, #2b3a63); position: relative; overflow: hidden; flex: none; }
.screen::before { content: ''; position: absolute; inset: 12px 40% 30px 12px; background: #e8ecf8; border-radius: 4px; opacity: .9; }
.screen::after { content: ''; position: absolute; left: 62%; top: 14px; right: 12px; height: 8px; background: #5aa9ff; border-radius: 4px; box-shadow: 0 16px 0 #8b5cf6, 0 32px 0 #3a4a75; }
.screen.grande { height: auto; aspect-ratio: 16 / 9; }
.screen.apagada { filter: grayscale(1) brightness(.45); }
.screen .app { position: absolute; left: 10px; bottom: 8px; font-size: 11px; font-weight: 700; color: #c9d1ea; z-index: 1; }
.screen .cursor { position: absolute; left: 38%; top: 50%; width: 0; height: 0; border-left: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 14px solid #fff; transform: rotate(-30deg); filter: drop-shadow(0 1px 2px #000); z-index: 1; animation: mover 6s ease-in-out infinite alternate; }
.screen .tuyo { position: absolute; inset: auto 8px 8px auto; background: var(--accent-2); color: #fff; font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 6px; z-index: 1; }
@keyframes mover { 0% { left: 30%; top: 55%; } 50% { left: 55%; top: 35%; } 100% { left: 72%; top: 48%; } }
@media (prefers-reduced-motion: reduce) { .screen .cursor { animation: none; } }

/* Formularios */
.campo { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }
input[type=text], input[type=number], input[type=search], input[type=email], input[type=password], input[type=time], input[type=date], input:not([type]), select, textarea {
  padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-weight: 500;
}
textarea { min-height: 70px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: #c3cff7; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--foco); }
/* Foco con teclado visible en todo lo que se pulsa */
:is(a, button, summary, [tabindex], .opcion, .fila-opcion):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }

/* Pestañas */
.pestanas { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.pestanas a, .pestanas button { padding: 10px 12px; color: var(--muted); text-decoration: none; font-weight: 700; white-space: nowrap; border: 0; background: none; border-bottom: 2px solid transparent; cursor: pointer; }
.pestanas .on { color: var(--text); border-bottom-color: var(--accent); }
.filtros { display: flex; gap: 6px; flex-wrap: wrap; }
.filtros a, .filtros button { padding: 6px 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); font-weight: 700; font-size: 12px; text-decoration: none; cursor: pointer; }
.filtros .on { background: var(--relleno); border-color: var(--relleno); color: #fff; }

/* Tablas */
.tabla { width: 100%; border-collapse: collapse; }
.tabla td, .tabla th { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tabla th { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.tabla tr:last-child td { border-bottom: 0; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }

/* Cifras */
.cifras { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.cifras .card { display: flex; flex-direction: column; gap: 4px; }
.cifras .card > span:first-child { font-size: 13px; font-weight: 600; }
.cifras .card b { display: block; font-size: 26px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.cifras.cinco { grid-template-columns: repeat(5, 1fr); }
.aviso-parada { margin: 0; padding: 10px 12px; border-left: 4px solid var(--danger); border-radius: 8px; background: color-mix(in srgb, var(--danger) 8%, transparent); }
.dos { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.rejilla { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.lista > * + * { border-top: 1px solid var(--border); }
.lista > * { padding: 10px 0; }

/* Bandeja: avisos */
.avisos { display: flex; flex-direction: column; gap: 12px; }
.aviso { display: flex; flex-direction: column; gap: 10px; border-left: 4px solid var(--border); }
.aviso.permiso, .aviso.te_necesito { border-left-color: var(--warn); }
.aviso.atascado { border-left-color: var(--danger); }
.aviso.pregunta, .aviso.revisar { border-left-color: var(--accent); }
.aviso .tipo { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.aviso .cuerpo { display: flex; gap: 14px; align-items: flex-start; }
.aviso .cuerpo .screen { width: 150px; height: 84px; }
.aviso form { display: flex; gap: 8px; flex-wrap: wrap; }
.aviso form input { flex: 1; min-width: 140px; }
.aviso .codigo { letter-spacing: .3em; font-weight: 800; max-width: 180px; }
.tiras { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chip { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); white-space: nowrap; text-decoration: none; color: var(--text); }
.chip .bola { --t: 28px; }
.punto { width: 8px; height: 8px; border-radius: 99px; background: currentColor; display: inline-block; }

/* Equipo */
.emp { display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: var(--text); }
.emp:hover { border-color: var(--accent); }
.emp.alerta { border-color: var(--warn); box-shadow: 0 0 0 3px #c27c0e1f; }
.emp .ahora { min-height: 40px; }
.nuevo { border: 2px dashed var(--border); background: transparent; display: grid; place-items: center; text-align: center; color: var(--muted); text-decoration: none; min-height: 200px; }
.nuevo b { font-size: 32px; color: var(--accent); display: block; }

/* Tablero de tareas */
.tablero { display: grid; grid-template-columns: repeat(4, minmax(200px, 1fr)); gap: 12px; align-items: start; }
.columna { background: var(--soft); border-radius: var(--radio); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.columna h3 { display: flex; justify-content: space-between; padding: 2px 4px; }
.columna:not(:has(.tarea))::after { content: 'Nada por aquí'; color: var(--muted); font-size: 13px; text-align: center; padding: 18px 0; border: 1px dashed var(--border); border-radius: 10px; }
.tarea { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.tarea .row { gap: 6px; }

/* Conversación */
.hilo { display: flex; flex-direction: column; gap: 8px; max-height: 460px; overflow-y: auto; padding: 4px; }
.msg { max-width: 78%; padding: 8px 12px; border-radius: 14px; background: var(--soft); align-self: flex-start; }
.msg.persona { align-self: flex-end; background: var(--relleno); color: #fff; }
.msg .meta { font-size: 11px; opacity: .75; margin-top: 2px; }

/* Interruptor */
.interruptor { position: relative; width: 40px; height: 22px; flex: none; appearance: none; border-radius: 99px; background: var(--border); cursor: pointer; transition: background .15s; }
.interruptor::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 99px; background: #fff; transition: left .15s; }
.interruptor:checked { background: var(--accent); }
.interruptor:checked::after { left: 21px; }

/* Opciones grandes (Contratar, autonomía, potencia) */
.opciones { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.opcion { display: flex; flex-direction: column; gap: 4px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); cursor: pointer; }
.opcion:has(input:checked), .opcion.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.opcion input { position: absolute; opacity: 0; pointer-events: none; }
/* Cómo habla y cómo informa: bloques sin marco, trato en dos botones y un mensaje de ejemplo */
.bloque fieldset { border: 0; padding: 0; min-width: 0; }
.bloque legend { padding: 0; margin-bottom: 4px; }
.bloque + .bloque { border-top: 1px solid var(--border); padding-top: 14px; }
.segmento { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.segmento label { cursor: pointer; }
.segmento input { position: absolute; opacity: 0; pointer-events: none; }
.segmento span { display: block; padding: 8px 14px; font-weight: 600; }
.segmento input:checked + span { background: var(--accent); color: #fff; }
.segmento input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
.opcion:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.bloque .opciones { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.muestra { background: var(--soft); border-radius: 12px; padding: 12px; }
.muestra .msg { white-space: pre-line; max-width: 460px; background: var(--surface); border: 1px solid var(--border); }
.pasos { display: flex; gap: 6px; }
.pasos span { flex: 1; height: 5px; border-radius: 99px; background: var(--border); }
.pasos span.on { background: var(--accent); }

/* Sala de control: oscura, como videovigilancia */
body[data-pagina="sala-control"] { --bg: #0b1020; --surface: #161e33; --text: #e8ecf8; --muted: #98a2bd; --border: #1f2842; --soft: #1c2640; --accent: #7d93ff; color-scheme: dark; }
.directo { font-size: 12px; font-weight: 800; letter-spacing: .08em; color: #ff5a5a; display: inline-flex; align-items: center; gap: 6px; }
.directo::before { content: ''; width: 8px; height: 8px; border-radius: 99px; background: #ff5a5a; box-shadow: 0 0 0 4px #ff5a5a33; }
.camaras { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.cam { position: relative; border-radius: 12px; overflow: hidden; border: 2px solid var(--border); aspect-ratio: 16 / 10; }
.cam > a { position: absolute; inset: 0; }
.cam .screen { position: absolute; inset: 0; height: auto; border-radius: 0; }
.cam.alerta { border-color: #f0b44c; box-shadow: 0 0 0 3px #f0b44c33; }
.cam .arriba, .cam .abajo-cam { position: absolute; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: 8px 10px; font-size: 12px; z-index: 2; color: #e8ecf8; }
.cam .arriba { top: 0; background: linear-gradient(#0b1020cc, transparent); }
.cam .abajo-cam { bottom: 0; background: linear-gradient(transparent, #0b1020ee 40%); }
.cam .abajo-cam span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cam .t { margin-left: auto; font-variant-numeric: tabular-nums; color: #c9d1ea; }
.cam .bola { --t: 22px; }
.mini { padding: 4px 10px; border-radius: 8px; font-weight: 800; font-size: 11px; background: #ffffff1f; color: #fff; border: 0; cursor: pointer; text-decoration: none; }
.mini.y { background: #f0b44c; color: #14213d; }
.cinta { display: flex; gap: 28px; padding: 10px 0; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.cinta b { color: var(--text); }

/* Aviso flotante */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 700; transition: .2s; z-index: 20; max-width: calc(100vw - 32px); }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }

/* Tablet: el panel derecho baja */
@media (max-width: 1100px) {
  .dos { grid-template-columns: 1fr; }
  .tablero { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Móvil: menú abajo (Bandeja, Equipo, Control, Más), el menú completo se abre a pantalla entera */
@media (max-width: 760px) {
  main { margin-left: 0; padding: 18px 16px 90px; gap: 14px; }
  h1 { font-size: 21px; }
  .menu { display: none; width: auto; right: 0; z-index: 15; padding-bottom: 90px; }
  .menu-abierto .menu { display: flex; }
  .menu .cerrar-menu { display: inline-flex; position: absolute; top: 14px; right: 14px; }
  .abajo {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 16; background: var(--surface); border-top: 1px solid var(--border);
    justify-content: space-around; padding: 6px 4px calc(10px + env(safe-area-inset-bottom));
  }
  .abajo a, .abajo button { flex: 1; text-align: center; padding: 8px 4px; font-size: 13px; font-weight: 700; color: var(--muted); text-decoration: none; background: none; border: 0; }
  .abajo .on { color: var(--accent); }
  .cifras, .cifras.cinco { grid-template-columns: 1fr 1fr; gap: 8px; }
  .cifras .card { padding: 12px; }
  .cifras .card b { font-size: 18px; }
  .aviso { padding: 12px; }
  .aviso .cuerpo { flex-direction: column; }
  .aviso .cuerpo .screen { width: 100%; height: 120px; }
  .aviso .acciones .btn { flex: 1; }
  .tablero { grid-template-columns: 1fr; }
  .camaras { grid-template-columns: 1fr 1fr; gap: 8px; }
  .cam { aspect-ratio: 3 / 4; }
  .cam .arriba .muted, .cam .t, .cam .abajo-cam span { display: none; }
  .cam .abajo-cam .mini { flex: 1; text-align: center; }
  .cinta { display: none; }
  .ocultar-movil { display: none !important; }
  .tabla.apilable tr { display: flex; flex-wrap: wrap; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .tabla.apilable td { border: 0; padding: 0; }
  .tabla.apilable thead { display: none; }
  /* Al apilar: la celda .entera ocupa su fila y las que llevan data-et enseñan su título delante */
  .tabla.apilable td.entera { flex-basis: 100%; }
  .tabla.apilable td[data-et] { flex-basis: 100%; font-size: 13px; order: 1; }
  .tabla.apilable td[data-et]::before { content: attr(data-et) ': '; color: var(--muted); }
  .tabla.apilable tr { align-items: center; }
  .msg { max-width: 90%; }
}
.aviso .codigo:placeholder-shown { letter-spacing: normal; font-weight: 500; }

/* Entrada (sin sesión): sin menús, el formulario en el centro */
body.fuera .menu, body.fuera .abajo { display: none; }
body.fuera main { margin: 0 auto; min-height: 100vh; justify-content: center; align-items: center; padding: 24px 16px; }
.entrar { width: 100%; max-width: 380px; gap: 14px; }
.entrar .brand { margin-bottom: 6px; }
.error { color: var(--danger); font-weight: 600; }
.enlace { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; }
.enlace:hover { text-decoration: underline; }

/* Lo oculto con el atributo hidden se queda oculto aunque su clase lo haga flex */
[hidden] { display: none !important; }

/* Manual y memoria: Markdown dentro de una tarjeta */
.md { display: flex; flex-direction: column; gap: 8px; line-height: 1.55; overflow-wrap: anywhere; }
.md h2 { font-size: 19px; } .md h3 { font-size: 16px; margin-top: 6px; } .md h4, .md h5 { font-size: 14px; }
.md ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 3px; }
.md p { margin: 0; }
.md code { background: var(--soft); padding: 1px 5px; border-radius: 5px; font-size: .92em; }
textarea.largo { min-height: 320px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.5; }
.propuesta { display: flex; flex-direction: column; gap: 10px; border-left: 4px solid var(--accent-2); }
.norma { display: flex; gap: 12px; align-items: flex-start; }
.norma.pausada .texto { color: var(--muted); }
.norma .texto { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
details.version summary { cursor: pointer; list-style: none; display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
details.version summary::-webkit-details-marker { display: none; }
details.version[open] summary { margin-bottom: 8px; }

/* Accesos (Contratar › Accesos y gasto, Ficha › Herramientas, Herramientas y cuentas) */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff; flex: none; background: var(--muted); }
.s-microsoft { background: #2f6fde; } .s-google { background: #1f8a4c; } .s-elevenlabs { background: #14213d; } .s-holded { background: #e2574c; }
.s-caja { background: #6b7895; } .s-otro { background: var(--accent-2); } .s-pieza { background: var(--soft); color: var(--accent); }
.dato { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; overflow-wrap: anywhere; }

.pieza { border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.pieza-cab { display: flex; gap: 10px; align-items: flex-start; }
.pieza-cab p { margin-top: 1px; }
.modo { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 11px; background: var(--soft); align-self: flex-start; max-width: 100%; }
.modo label { position: relative; cursor: pointer; }
.modo input { position: absolute; opacity: 0; pointer-events: none; }
.modo span { display: block; padding: 6px 12px; border-radius: 8px; font-weight: 700; font-size: 13px; color: var(--muted); white-space: nowrap; }
.modo input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px #14213d26; }
.modo input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.modo label.apagada { cursor: not-allowed; opacity: .55; }
.pieza .si { display: none; flex-direction: column; gap: 8px; }
.pieza .si.visible,
.pieza:has(> .modo input[value="plataforma"]:checked) > .si[data-si="plataforma"],
.pieza:has(> .modo input[value="empresa"]:checked) > .si[data-si="empresa"],
.pieza:has(> .modo input[value="ninguno"]:checked) > .si[data-si="ninguno"] { display: flex; }
.fila-opcion { display: grid; grid-template-columns: 18px 1fr; gap: 10px; align-items: start; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.fila-opcion:has(input[type=radio]:checked) { border-color: var(--accent); background: var(--soft); }
.fila-opcion > input { margin: 3px 0 0; accent-color: var(--accent); }
.fila-opcion .tx { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fila-opcion .tx input[type=email] { max-width: 320px; }
.dir { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.dir input { width: 12ch; font: inherit; padding: 4px 8px; }

.permisos { display: flex; flex-direction: column; }
.perm { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.perm:last-child { border-bottom: 0; }
.perm .tx { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.perm .tx input { padding: 5px 8px; font-size: 12px; max-width: 340px; }
.perm select { font-size: 13px; padding: 6px 8px; }
.waiting b { color: var(--warn); }

.identidad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.idc { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.idc .k { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.idc .v { font-weight: 700; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13.5px; overflow-wrap: anywhere; }
.actividad { display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.actividad div { display: grid; grid-template-columns: 52px 1fr; gap: 10px; }
.actividad time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
details.cambiar summary, details.prestar summary { cursor: pointer; list-style: none; }
details.cambiar summary { display: flex; flex-direction: column; gap: 2px; }
details.cambiar summary::-webkit-details-marker, details.prestar summary::-webkit-details-marker { display: none; }
details.cambiar summary h2::after { content: ' ▾'; color: var(--muted); }
details.cambiar[open] summary h2::after { content: ' ▴'; }

.etiqueta { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--soft); color: var(--accent); }
.rejilla.conexiones { grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); align-items: start; }
.conexion .cab { align-items: flex-start; flex-wrap: wrap; }
.conexion .cab .sp { gap: 0; min-width: 0; overflow-wrap: anywhere; }
.conexion .usa { gap: 8px; text-decoration: none; color: var(--text); padding: 4px; margin: 0 -4px; border-radius: 8px; }
.conexion .usa:hover { background: var(--soft); }
.nueva-conexion { text-decoration: none; color: var(--text); gap: 12px; }
.nueva-conexion:hover, .nueva-conexion.resalta { border-color: var(--accent); }
.conectar { max-width: 760px; gap: 16px; }
.dos-igual { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.lista-si, .lista-no { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.lista-si li, .lista-no li { display: grid; grid-template-columns: 18px 1fr; gap: 8px; font-size: 13.5px; }
.lista-si li::before { content: '✓'; color: var(--ok); font-weight: 800; }
.lista-no li::before { content: '✕'; color: var(--danger); font-weight: 800; }

@media (max-width: 760px) {
  .identidad, .dos-igual { grid-template-columns: 1fr; }
  .perm { grid-template-columns: 30px minmax(0, 1fr); }
  .perm > select, .perm > form { grid-column: 2; justify-self: start; }
}

/* --- Carga: barra fina arriba mientras llegan los datos y esqueleto en la primera carga --- */
.progreso { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 30; pointer-events: none; opacity: 0; transition: opacity .2s; overflow: hidden; }
.progreso::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 40%; background: linear-gradient(90deg, #5aa9ff, #8b5cf6); border-radius: 99px; animation: progreso 1.1s ease-in-out infinite; }
/* Solo se ve si tarda: lo rápido no parpadea */
.progreso.activo { opacity: 1; transition-delay: .15s; }
@keyframes progreso { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.esqueleto { display: flex; flex-direction: column; gap: 14px; }
.esqueleto i { display: block; height: 18px; width: 40%; border-radius: 8px; background: linear-gradient(90deg, var(--soft), var(--border), var(--soft)); background-size: 200% 100%; animation: brillo 1.4s linear infinite; }
.esqueleto i:nth-child(2) { width: 100%; height: 96px; border-radius: var(--radio); }
.esqueleto i:nth-child(3) { width: 100%; height: 220px; border-radius: var(--radio); }
@keyframes brillo { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .progreso::before, .esqueleto i { animation: none; } }

/* Saltar al contenido (solo con teclado) */
.saltar { position: fixed; left: 12px; top: -60px; z-index: 40; background: var(--relleno); color: #fff; padding: 10px 14px; border-radius: 10px; font-weight: 700; text-decoration: none; }
.saltar:focus { top: 12px; }

/* Entrada: tarjeta centrada sobre un cielo suave */
body.fuera { background: radial-gradient(1200px 600px at 15% -10%, #5aa9ff33, transparent 60%), radial-gradient(900px 500px at 110% 110%, #8b5cf633, transparent 60%), var(--bg); }
.entrar { padding: 28px; box-shadow: var(--sombra); border-radius: 18px; }
.entrar h1 { font-size: 24px; margin-bottom: 4px; }
.entrar .btn.primary { min-height: 42px; font-size: 14px; }
.entrar input { padding: 10px 12px; }

/* Pestañas y filtros: foco y paso del ratón */
.pestanas a:hover, .pestanas button:hover { color: var(--text); }
.filtros a:hover, .filtros button:hover { color: var(--text); border-color: var(--accent); }
.filtros .on:hover { color: #fff; }

/* Móvil: cabecera con marca y empresa, menú de abajo con iconos */
@media (max-width: 760px) {
  .arriba {
    display: flex; position: sticky; top: 0; z-index: 14; align-items: center; gap: 10px; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
    background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
  }
  .arriba .brand { font-size: 17px; text-decoration: none; color: var(--text); }
  .arriba .brand img { width: 24px; }
  .arriba .empresa { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  body.fuera .arriba { display: none; }
  .abajo { background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); padding-top: 4px; }
  .abajo a, .abajo button { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; padding: 6px 4px; cursor: pointer; border-radius: 10px; }
  .ico-abajo { position: relative; display: grid; place-items: center; }
  .ico-abajo .i { width: 22px; height: 22px; }
  .ico-abajo .cuenta { position: absolute; top: -4px; left: 14px; font-size: 10px; padding: 0 5px; line-height: 16px; }
  .menu .brand { margin-right: 48px; }
  .entrar { padding: 22px; }
}

/* Botones y campos a tamaño de dedo en pantallas táctiles */
@media (pointer: coarse) {
  .btn { min-height: 40px; }
  .btn.peq { min-height: 34px; }
  input[type=text], input[type=number], input[type=search], input[type=email], input[type=password], input[type=time], input[type=date], input:not([type]), select { min-height: 40px; font-size: 16px; }
  textarea { font-size: 16px; }
}

/* --- Diálogos (confirmar): caja centrada en escritorio, hoja desde abajo en el móvil --- */
.btn.rojo { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.rojo:hover { filter: brightness(1.08); border-color: var(--danger); }
dialog.dialogo {
  margin: auto; width: min(440px, calc(100vw - 32px)); padding: 22px; border: 1px solid var(--border); border-radius: 18px;
  background: var(--surface); color: var(--text); box-shadow: 0 24px 60px -20px #0b1020a6;
  opacity: 0; transform: translateY(10px) scale(.97);
  transition: opacity .18s ease, transform .22s cubic-bezier(.2, .8, .2, 1), overlay .22s allow-discrete, display .22s allow-discrete;
}
dialog.dialogo[open] { opacity: 1; transform: none; }
@starting-style { dialog.dialogo[open] { opacity: 0; transform: translateY(10px) scale(.97); } }
dialog.dialogo::backdrop { background: #0b1020; opacity: 0; transition: opacity .2s, overlay .22s allow-discrete, display .22s allow-discrete; }
dialog.dialogo[open]::backdrop { opacity: .5; }
@starting-style { dialog.dialogo[open]::backdrop { opacity: 0; } }
.dialogo form { gap: 8px; }
.dialogo h2 { font-size: 18px; line-height: 1.3; }
.dialogo .botones { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
@media (max-width: 760px) {
  dialog.dialogo { width: 100%; max-width: none; margin: auto 0 0; border-radius: 20px 20px 0 0; border-bottom: 0; padding: 22px 16px calc(16px + env(safe-area-inset-bottom)); transform: translateY(100%); }
  @starting-style { dialog.dialogo[open] { transform: translateY(100%); } }
  .dialogo .botones { flex-direction: column-reverse; }
  .dialogo .botones .btn { min-height: 46px; }
}

/* --- Transiciones: cada página entra suave; el menú móvil se desliza --- */
main.entra > * { animation: entra .28s cubic-bezier(.2, .8, .2, 1) both; }
main.entra > :nth-child(2) { animation-delay: .03s; } main.entra > :nth-child(3) { animation-delay: .06s; } main.entra > :nth-child(n+4) { animation-delay: .09s; }
@keyframes entra { from { opacity: 0; transform: translateY(6px); } }
.card, .emp, .cam { transition: border-color .15s, box-shadow .15s, transform .15s; }
a.card:hover, a.emp:hover { box-shadow: var(--sombra); transform: translateY(-1px); }
@media (max-width: 760px) {
  .menu-abierto .menu { animation: menu-entra .24s cubic-bezier(.2, .8, .2, 1); }
  @keyframes menu-entra { from { opacity: 0; transform: translateY(12px); } }
}
@media (prefers-reduced-motion: reduce) {
  main.entra > *, .menu-abierto .menu { animation: none; }
  dialog.dialogo, dialog.dialogo::backdrop, .card, .emp { transition: none; }
}

/* Ficha › Ajustes › Imagen */
.imagen { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 18px; align-items: start; }
.imagen .vista { display: grid; place-items: center; width: 120px; height: 120px; border-radius: 24px; background: var(--soft); }
.imagen fieldset { border: 0; padding: 0; min-width: 0; }
.colores { display: flex; flex-wrap: wrap; gap: 6px; }
.colores label { position: relative; padding: 5px; border-radius: 50%; cursor: pointer; box-shadow: 0 0 0 2px transparent; transition: box-shadow .15s; }
.colores input { position: absolute; opacity: 0; pointer-events: none; }
.colores label:has(input:checked) { box-shadow: 0 0 0 2px var(--accent); }
.colores label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.imagen label.btn:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 760px) {
  .imagen { grid-template-columns: 1fr; justify-items: start; }
}

/* Grupos de campos (horario…): sin el recuadro del navegador */
fieldset.campo { border: 0; padding: 0; min-width: 0; }
fieldset.campo legend { padding: 0; margin-bottom: 4px; }

/* Entrada: a la izquierda la marca (tinta, como el menú) con tres bolas; a la derecha el formulario */
.entrada { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); width: min(960px, 100%); min-height: 540px; border-radius: 24px; overflow: hidden; box-shadow: var(--sombra); background: var(--surface); border: 1px solid var(--border); }
.entrada .entrar { box-shadow: none; border: 0; border-radius: 0; max-width: none; justify-content: center; padding: 48px; }
.entrada .entrar > * { width: 100%; max-width: 340px; margin-inline: auto; }
.entrada-marca { background: radial-gradient(500px 300px at 20% 10%, #4c6fff59, transparent 70%), radial-gradient(400px 300px at 90% 100%, #8b5cf659, transparent 70%), #14213d;
  color: #fff; padding: 36px; display: flex; flex-direction: column; justify-content: space-between; gap: 24px; }
.entrada-marca .brand { color: #fff; }
.entrada-marca h2 { font-size: 26px; line-height: 1.2; letter-spacing: -.02em; font-weight: 800; }
.entrada-marca p { color: #c9d1ea; margin-top: 8px; max-width: 34ch; }
.entrada-marca .bolas { position: relative; height: 220px; }
.entrada-marca .bola:nth-child(1) { --t: 150px; position: absolute; left: 12%; top: 10px; }
.entrada-marca .bola:nth-child(2) { --t: 76px; position: absolute; left: 62%; top: 0; }
.entrada-marca .bola:nth-child(3) { --t: 54px; position: absolute; left: 58%; top: 140px; }
.solo-movil { display: none; }
@media (max-width: 760px) {
  .entrada { grid-template-columns: 1fr; min-height: 0; border-radius: 20px; }
  .entrada-marca { display: none; }
  .entrada .entrar { padding: 24px; }
  .solo-movil { display: flex; }
}
@media (prefers-color-scheme: dark) {
  .entrada-marca { background-color: #0a0f1d; }
  .s-elevenlabs { background: #2b3550; }
}
.cam .arriba { background: linear-gradient(#0b1020ee, #0b102099 60%, transparent); }
@media (max-width: 760px) { .cabecera .bola.gr { --t: 72px; } }
