/* ==========================================================================
   IG Nicho — sistema de diseño KEVHUG
   Monocromo (blanco/negro/gris) · Inter · controles en píldora (18px) · tarjetas de 24px.
   Claro por defecto; oscuro con <html class="dark"> (igual que KEVHUG).
   Layout: la página es fija; cabecera y menú no se mueven, solo scrollea el contenido.
   Ninguna barra de scroll nativa es visible (estándar de scroll de KEVHUG).
   ========================================================================== */

@font-face {
  font-family: "Inter Variable";
  src: url("/fonts/InterVariable-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* --- Tokens (valores de index.css de KEVHUG: --brand-*) ------------------- */
:root {
  color-scheme: light;

  --bg: #ffffff;
  --inset: #fafafa; /* sub-tarjeta: neutral-100 al 50 % sobre la superficie */
  --surface: #ffffff;
  --surface-subtle: #f5f5f5; /* neutral-100: hover y fila activa */
  --border: #e4e4e7;
  --border-strong: #a1a1a1;
  --field-bg: color-mix(in oklab, #e5e5e5 50%, transparent);
  --accent: #171717; /* neutral-900: botón primario */
  --accent-2: #171717;
  --accent-ink: #0a0a0a;
  --accent-fg: #fafafa;
  --text: #0a0a0a;
  --text-muted: #737373;
  --success: #15803d;
  --warning: #b45309;
  --danger: #e40014;

  /* Sin degradados: los usos antiguos de --gradient pasan a color sólido */
  --gradient: var(--accent);
  --nav-active: var(--surface-subtle);
  --page-glow: none;
  --sidebar-bg: var(--surface);
  --card-bg: var(--surface);

  --ring: rgb(163 163 163 / 0.3);
  --overlay: rgb(0 0 0 / 0.4);
  --shadow: 0 0 0 1px rgb(10 10 10 / 0.05), 0 1px 3px #0000001a, 0 1px 2px -1px #0000001a;
  --shadow-lg: 0 0 0 1px rgb(10 10 10 / 0.05), 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  /* Huecos */
  --gap-1: 6px;
  --gap-2: 10px;
  --gap-3: 14px;
  --gap-4: 24px;
  --gap-5: 56px;

  /* Radios de KEVHUG: píldora 18 · sub-tarjeta 18 · tarjeta 24 · menú 22 */
  --radius-sm: 6px;
  --radius-md: 18px;
  --radius-lg: 18px;
  --radius-card: 24px;
  --radius-pill: 18px;

  /* Tipografía */
  --font-sans: "Inter Variable", Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Medidas */
  --control-h: 32px;
  --control-h-sm: 28px;
  --rail-w: 240px;
}

html.dark {
  color-scheme: dark;

  --bg: #0a0a0a;
  --inset: #181818;
  --surface: #111111;
  --surface-subtle: #1f1f1f;
  --border: #262626;
  --border-strong: #404040;
  --field-bg: color-mix(in oklab, #2a2a2a 50%, transparent);
  --accent: #fafafa;
  --accent-2: #fafafa;
  --accent-ink: #fafafa;
  --accent-fg: #0a0a0a;
  --text: #fafafa;
  --text-muted: #a3a3a3;
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #f87171;

  --ring: rgb(115 115 115 / 0.4);
  --overlay: rgb(0 0 0 / 0.6);
  --shadow: 0 0 0 1px rgb(255 255 255 / 0.1);
  --shadow-lg: 0 0 0 1px rgb(255 255 255 / 0.1), 0 10px 15px -3px rgb(0 0 0 / 0.5);
}

/* --- Base ---------------------------------------------------------------- */
* {
  box-sizing: border-box;
}

/* ESTÁNDAR DE SCROLL de KEVHUG: ninguna barra nativa es visible (el scroll sigue funcionando). */
html,
body,
* {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

*::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden; /* la página es fija: solo scrollea #app-scroll */
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent-ink);
  text-underline-offset: 2px;
}

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

::selection {
  background: rgb(163 163 163 / 0.35);
}

/* Iconos (sprite en index.html) */
.ic {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- Estructura: la página es fija (100dvh) --------------------------------- */
.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

/* Riel izquierdo (escritorio): pegado al borde, esquina derecha redondeada */
.sidebar {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: var(--gap-2);
  width: var(--rail-w);
  height: 100%;
  padding: 6px 8px;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--sidebar-bg);
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 0 22px 22px 0;
}

/* Marca: botón-píldora como el BrandToggle de KEVHUG */
.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex: none;
  height: 40px;
  margin-bottom: 8px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg);
  color: var(--text);
}

.brand .logo-img {
  width: 28px;
  height: 28px;
  flex: none;
  object-fit: contain;
}

.brand strong {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

.brand small {
  display: none;
}

.brand .menu-close {
  display: none;
}

#nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  overflow-y: auto;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Etiqueta de grupo = botón que pliega/despliega sus páginas */
summary.nav-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-2);
  height: 32px;
  margin: 6px 0 0;
  padding: 0 12px;
  border-radius: 19.6px;
  color: color-mix(in oklab, var(--text) 70%, transparent);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  list-style: none;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.nav-section:first-child summary.nav-group {
  margin-top: 0;
}

summary.nav-group::-webkit-details-marker {
  display: none;
}

summary.nav-group::after {
  content: "";
  width: 7px;
  height: 7px;
  flex: none;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.15s;
  margin-bottom: 3px;
}

details.nav-section:not([open]) > summary.nav-group::after {
  transform: rotate(-45deg);
  margin-bottom: 0;
}

@media (hover: hover) {
  summary.nav-group:hover {
    background: var(--surface-subtle);
    color: var(--text);
  }
}

/* Fila de menú: 32px, píldora, activa = neutral-100 en negrita media */
.nav-item {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 32px;
  padding: 8px 12px 8px 10px;
  border: 0;
  border-radius: 19.6px;
  background: transparent;
  color: var(--text);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s;
}

@media (hover: hover) {
  .nav-item:hover {
    background: var(--surface-subtle);
  }
}

.nav-item:active {
  background: var(--surface-subtle);
  opacity: 0.6;
}

.nav-item.active {
  background: var(--surface-subtle);
  font-weight: 500;
}

.nav-item:focus-visible,
summary.nav-group:focus-visible {
  box-shadow: 0 0 0 3px #a3a3a3;
}

.sidebar-foot {
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--gap-2);
  margin-top: auto;
  padding: var(--gap-2) 12px 0;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
}

.sidebar-foot #conn-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-user {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px 4px 12px;
  color: var(--text-muted);
  font-size: 12px;
}

.panel-user[hidden] {
  display: none;
}

.panel-user-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.dot.on {
  background: var(--success);
}

.dot.off {
  background: var(--text-muted);
  opacity: 0.6;
}

/* Botón del menú (móvil) y fondo: ocultos en escritorio */
.menu-btn {
  display: none;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: transparent; /* KEVHUG: el menú móvil no oscurece la página */
}

.scrim[hidden] {
  display: none;
}

/* Zona principal: cabecera fija + contenido que scrollea */
.main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  height: 100%;
  padding: 12px;
}

.topbar {
  position: relative;
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-3);
  min-height: 36px;
}

.topbar h1 {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* Botón-icono de KEVHUG (.bd-icon): 32px, píldora */
.icon-btn {
  appearance: none;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s, opacity 0.15s;
}

@media (hover: hover) {
  .icon-btn:hover {
    background: var(--surface-subtle);
  }
}

.icon-btn:active {
  opacity: 0.6;
}

#app-scroll {
  flex: 1;
  min-height: 0;
  margin: -4px;
  padding: 4px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Palabras largas (usuarios, URLs) se parten en vez de salirse de la tarjeta */
#view {
  overflow-wrap: anywhere;
}

#app-scroll > * {
  max-width: 1280px;
  margin-right: auto;
  margin-left: auto;
}

/* --- Tarjeta ------------------------------------------------------------- */
.card {
  background: var(--card-bg);
  border: 0;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: var(--gap-3);
}

.card h2 {
  margin: 0 0 var(--gap-3);
  font-size: 16px;
  font-weight: 500;
  line-height: 24px;
  color: var(--text);
}

/* --- Botones ------------------------------------------------------------- */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap-1);
  height: var(--control-h);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 0 12px;
  border-radius: var(--radius-pill);
  box-shadow: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

@media (hover: hover) {
  .btn:hover {
    background: var(--surface-subtle);
    text-decoration: none;
  }
}

.btn:active {
  opacity: 0.6;
  translate: 0 1px;
}

@media (min-width: 768px) {
  .btn:active {
    opacity: 1;
  }
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 500;
}

@media (hover: hover) {
  .btn-primary:hover {
    border-color: transparent;
    background: color-mix(in oklab, var(--accent) 80%, transparent);
  }
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

.btn-ghost:hover {
  border-color: transparent;
}

.btn-mini {
  height: var(--control-h-sm);
  padding: 0 var(--gap-2);
  font-size: 13px;
}

/* --- Campos -------------------------------------------------------------- */
input,
select,
textarea {
  width: 100%;
  min-height: var(--control-h);
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--field-bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 20px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea {
  min-height: 100px;
  padding: 8px 10px;
  resize: none;
}

select {
  max-width: 100%;
  text-overflow: ellipsis;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px var(--ring);
}

/* Casilla = bd-check */
input[type="checkbox"],
input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  background: color-mix(in oklab, var(--border) 90%, transparent);
  box-shadow: none;
  cursor: pointer;
}

input[type="radio"] {
  border-radius: 50%;
}

input[type="checkbox"]:checked,
input[type="radio"]:checked {
  border-color: var(--accent);
  background: var(--accent);
}

input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent-fg);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/14px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/14px no-repeat;
}

input[type="radio"]:checked::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--accent-fg);
}

label {
  display: flex;
  flex-direction: column;
  gap: var(--gap-1);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap-2) var(--gap-3);
  margin-bottom: var(--gap-3);
}

.form-grid .full {
  grid-column: 1 / -1;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-2);
  margin-bottom: var(--gap-2);
}

.inline-form input {
  flex: 1 1 220px;
  min-width: 0;
}

.row {
  display: flex;
  align-items: center;
  gap: var(--gap-2);
  flex-wrap: wrap;
}

.check {
  flex-direction: row;
  align-items: center;
  gap: var(--gap-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 400;
  white-space: nowrap;
}

.check input[type="checkbox"],
.check input[type="radio"] {
  width: 16px;
}

.check input:not([type="checkbox"]):not([type="radio"]) {
  width: auto;
}

.check select {
  width: auto;
  min-width: 180px;
}

/* --- Plegables ----------------------------------------------------------- */
.details {
  margin-top: var(--gap-3);
  font-size: 13px;
  color: var(--text-muted);
}

.details summary {
  cursor: pointer;
  margin-bottom: var(--gap-2);
  font-weight: 500;
}

.details summary:hover {
  color: var(--text);
}

.details textarea {
  margin-bottom: var(--gap-2);
}

details.card {
  padding: 0;
}

details.card > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-2);
  padding: 18px var(--gap-4);
  list-style: none;
  cursor: pointer;
  user-select: none;
  border-radius: var(--radius-card);
  transition: background-color 0.15s;
}

details.card > summary::-webkit-details-marker {
  display: none;
}

details.card > summary h2 {
  margin: 0;
}

details.card > summary::after {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  margin-top: -4px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform 0.15s ease, margin-top 0.15s ease;
}

details.card[open] > summary::after {
  margin-top: 4px;
  transform: rotate(-135deg);
}

details.card > summary:hover {
  background: var(--surface-subtle);
}

details.card[open] > summary {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

details.card > .fold-body {
  padding: var(--gap-1) var(--gap-4) var(--gap-4);
}

details.fold-block {
  margin-top: var(--gap-3);
  padding-top: var(--gap-3);
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

details.fold-block > summary {
  display: flex;
  align-items: center;
  gap: var(--gap-2);
  list-style: none;
  cursor: pointer;
  user-select: none;
}

details.fold-block > summary::-webkit-details-marker {
  display: none;
}

details.fold-block > summary::before {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

details.fold-block[open] > summary::before {
  transform: rotate(45deg);
}

details.fold-block > summary strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}

/* --- Cifras y listas ----------------------------------------------------- */
.kv {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--gap-2);
  margin-bottom: var(--gap-3);
}

.kv > div {
  padding: 12px;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--inset);
}

.kv span {
  display: block;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-muted);
}

.kv strong {
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.list {
  display: flex;
  flex-direction: column;
  gap: var(--gap-1);
  margin-top: var(--gap-3);
}

.list-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--gap-2) var(--gap-3);
  padding: 12px;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--inset);
}

.list-main {
  display: flex;
  flex: 1 1 220px;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.row > select,
.list-row .row select,
.list-row > select {
  width: auto;
  min-width: 120px;
}

.list-label {
  margin: var(--gap-3) 0 var(--gap-1);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

/* --- Chips, insignias y etiquetas ---------------------------------------- */
.chips {
  display: flex;
  gap: var(--gap-1);
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  white-space: nowrap;
}

.chip.ok {
  border-color: color-mix(in srgb, var(--success) 45%, transparent);
  color: var(--success);
}

.chip.err {
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  color: var(--danger);
}

.chip.warn {
  border-color: color-mix(in srgb, var(--warning) 45%, transparent);
  color: var(--warning);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  white-space: nowrap;
}

.badge-ok {
  border-color: color-mix(in srgb, var(--success) 45%, transparent);
  color: var(--success);
}

.badge-warn {
  border-color: color-mix(in srgb, var(--warning) 45%, transparent);
  color: var(--warning);
}

.badge-muted {
  color: var(--text-muted);
}

/* --- Barra de herramientas y filtros ------------------------------------- */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--gap-2) var(--gap-3);
  margin-bottom: var(--gap-3);
  flex-wrap: wrap;
}

.filters {
  display: flex;
  align-items: center;
  gap: var(--gap-2);
  flex-wrap: wrap;
}

.filters select {
  width: auto;
  min-width: 180px;
}

/* --- Rejilla de vídeos --------------------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--gap-3);
}

.vcard {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.vcard.dim {
  opacity: 0.45;
}

.thumb {
  position: relative;
  aspect-ratio: 4 / 5;
  display: grid;
  place-items: center;
  background: var(--inset);
  color: var(--text-muted);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tag {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.65);
  color: #ffffff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.6;
  backdrop-filter: blur(4px);
}

.tag.new {
  left: auto;
  right: 8px;
  background: var(--accent);
  color: var(--accent-fg);
}

.tag.hot {
  top: auto;
  bottom: 8px;
  background: #fafafa;
  color: #0a0a0a;
}

.vbody {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--gap-2);
  padding: var(--gap-3);
}

.vhead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--gap-2);
}

.vhead {
  min-width: 0;
}

.vhead a {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.vhead a:hover {
  color: var(--accent-ink);
}

.caption {
  margin: 0;
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-1);
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.metrics span {
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
}

.filetag {
  color: var(--text-muted);
  font-size: 12px;
  word-break: break-all;
}

.analysis {
  margin-top: var(--gap-1);
  padding-top: var(--gap-2);
  border-top: 1px solid var(--border);
}

.analysis summary {
  cursor: pointer;
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 500;
}

/* --- Texto con formato (informes) ---------------------------------------- */
.md {
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
}

.md h2,
.md h3,
.md h4 {
  margin: var(--gap-3) 0 var(--gap-1);
  color: var(--text);
  font-weight: 800;
  line-height: 1.3;
}

.md h2 {
  font-size: 18px;
}

.md h3 {
  font-size: 16px;
}

.md h4 {
  font-size: 14px;
}

.md p {
  margin: var(--gap-1) 0;
}

.md ul {
  margin: var(--gap-1) 0 var(--gap-1) 18px;
  padding: 0;
}

.md li {
  margin: 3px 0;
}

.md li::marker {
  color: var(--text-muted);
}

.md strong {
  color: var(--text);
  font-weight: 700;
}

/* --- Tabla --------------------------------------------------------------- */
.table-wrap {
  scroll-behavior: smooth;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

th {
  height: 36px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  background: var(--surface);
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: var(--surface-subtle);
}

/* --- Informes ------------------------------------------------------------ */
.report-view {
  margin-top: var(--gap-3);
  padding-top: var(--gap-3);
  border-top: 1px solid var(--border);
}

.report-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--gap-2);
  flex-wrap: wrap;
}

/* --- Estados ------------------------------------------------------------- */
.empty {
  grid-column: 1 / -1;
  padding: var(--gap-5) var(--gap-4);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-card);
  text-align: center;
  color: var(--text-muted);
}

.status {
  margin-bottom: var(--gap-3);
  padding: var(--gap-2) var(--gap-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--inset);
  font-size: 14px;
}

.status.ok {
  border-color: color-mix(in srgb, var(--success) 45%, transparent);
  color: var(--success);
}

.status.warn {
  border-color: color-mix(in srgb, var(--warning) 45%, transparent);
  color: var(--warning);
}

.status.err {
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  color: var(--danger);
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: var(--gap-4);
  bottom: var(--gap-4);
  z-index: 50;
  max-width: 360px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: none;
}

.toast.ok {
  border-color: color-mix(in srgb, var(--success) 55%, transparent);
}

.toast.warn {
  border-color: color-mix(in srgb, var(--warning) 55%, transparent);
}

.toast.err {
  border-color: color-mix(in srgb, var(--danger) 55%, transparent);
}

/* --- Utilidades de texto ------------------------------------------------- */
.muted {
  color: var(--text-muted);
}

.small {
  font-size: 13px;
}

.err {
  color: var(--danger);
}

.ok {
  color: var(--success);
}

.warn {
  color: var(--warning);
}

/* --- Drawer (formularios): escritorio entra de derecha a izquierda; móvil sube de abajo (hoja inferior) --- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 51;
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: min(420px, calc(100vw - 16px));
  padding: 20px;
  overflow-y: auto;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  transform: translateX(calc(100% + 16px));
  visibility: hidden;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s linear 0.3s;
}

.drawer.open {
  transform: none;
  visibility: visible;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s;
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
}

.drawer-head h2,
.drawer-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  line-height: 24px;
}

.drawer .field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.drawer .field select,
.drawer .field input,
.drawer .field textarea {
  width: 100%;
}

.drawer .row {
  margin: 0;
}

.drawer .row .btn {
  flex: 1;
}

.link-preview {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text-muted);
}

/* --- Puntos de corte de KEVHUG: lg = 1024px (menú móvil por debajo) ---------- */
.hbar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  margin-top: 8px;
}

.hbar[hidden] {
  display: none;
}

.hbar button {
  appearance: none;
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 9999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.hbar button:hover:not(:disabled) {
  background: var(--surface-subtle);
}

.hbar button:disabled {
  opacity: 0.4;
  cursor: default;
}

.hbar-track {
  position: relative;
  flex: 1;
  height: 12px;
  border-radius: 9999px;
  background: var(--surface-subtle);
  cursor: pointer;
}

.hbar-thumb {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 9999px;
  background: var(--border-strong);
  cursor: grab;
  touch-action: none;
}

@media (max-width: 1023px) {
  :root {
    --rail-w: 288px;
  }

  .app {
    flex-direction: column;
  }

  /* Menú: tarjeta flotante a la izquierda (Sheet de KEVHUG) */
  .sidebar {
    position: fixed;
    inset: 8px auto 8px 8px;
    z-index: 50;
    width: min(288px, calc(100vw - 16px));
    height: auto;
    padding: 8px;
    border: 0;
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    overscroll-behavior: contain;
    transform: translateX(calc(-100% - 16px));
    visibility: hidden;
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s linear 0.3s;
  }

  .sidebar.open {
    transform: none;
    visibility: visible;
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s;
  }

  .brand {
    position: relative;
    justify-content: center;
    padding: 0 44px;
  }

  .brand .menu-close {
    position: absolute;
    top: 50%;
    right: 6px;
    display: inline-flex;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border: 0;
    background: var(--surface-subtle);
  }

  .nav-item {
    height: 40px;
    font-size: 15px;
  }

  summary.nav-group {
    height: 36px;
  }

  body.menu-open .main {
    pointer-events: none;
  }

  /* Cabecera móvil fija (MobileTopBar): botón de menú · título · acciones */
  .main {
    padding: 0;
    gap: 0;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 8px 10px;
    padding: max(10px, env(safe-area-inset-top)) 16px 10px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
  }

  /* Botón de menú = BrandToggle contraído: estrella + flecha */
  .menu-btn {
    appearance: none;
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .menu-btn .logo-img {
    width: 24px;
    height: 24px;
    object-fit: contain;
  }

  .menu-btn .ic {
    width: 12px;
    height: 12px;
    color: var(--text-muted);
  }

  .menu-btn:active {
    opacity: 0.6;
  }

  .topbar h1 {
    flex: 1;
    order: 1;
    font-size: 17px;
  }

  /* El tema va arriba a la derecha; los botones de acción, en su propia fila, SIEMPRE visibles */
  .top-actions {
    order: 3;
    flex: 0 0 100%;
    margin-left: 0;
  }

  #theme-btn {
    order: 2;
    width: 40px;
    height: 40px;
  }

  #pause-btn,
  #poll-btn {
    flex: 1 1 0;
    min-width: 0;
    height: 40px;
  }

  #pause-btn[hidden] {
    display: none;
  }

  /* El estado ya se ve en el texto del botón y en el pie del menú */
  #session-badge,
  #monitor-badge {
    display: none;
  }

  #app-scroll {
    margin: 0;
    padding: 12px 16px calc(24px + env(safe-area-inset-bottom));
  }

  .card {
    padding: 16px;
  }

  details.card > summary {
    padding: 14px 16px;
  }

  details.card > .fold-body {
    padding: 4px 16px 16px;
  }

  /* Objetivos táctiles de 40px y 16px de letra (evita el zoom de iOS) */
  .btn {
    height: 40px;
  }

  .btn-mini {
    height: 36px;
  }

  input,
  select,
  textarea {
    min-height: 40px;
    font-size: 16px;
  }

  input[type="checkbox"],
  input[type="radio"] {
    width: 20px;
    height: 20px;
    min-height: 0;
  }

  .check {
    min-height: 40px;
  }

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

  .filters,
  .toolbar {
    width: 100%;
  }

  /* Los desplegables ocupan el ancho disponible (su mínimo natural es el de su opción más larga) */
  #view select,
  #view .row > select,
  #view .list-row .row select,
  #view .list-row > select,
  #view .check select,
  #view .filters select {
    width: 100%;
    min-width: 0;
    flex: 1 1 100%;
  }

  .row {
    row-gap: 8px;
  }

  .toast {
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    left: 16px;
    max-width: none;
  }
}

/* Drawer del panel: hoja inferior en móvil (KEVHUG, < 768px) */
@media (max-width: 767px) {
  .drawer {
    top: auto;
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
    max-height: calc(100dvh - 16px);
    transform: translateY(calc(100% + 16px));
  }

  .drawer.open {
    transform: none;
  }
}

@media (max-width: 480px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .table-wrap {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* --- Métricas (estándar KEVHUGNUEVA: pages/Metricas.jsx) ------------------- */
:root {
  --chart-1: hsl(12 76% 61%);
  --chart-2: hsl(173 58% 39%);
  --chart-3: hsl(197 37% 24%);
  --chart-4: hsl(43 74% 66%);
  --chart-5: hsl(27 87% 67%);
}

.mt-page {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mt-header,
.mt-filters,
.mt-table-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mt-filters {
  justify-content: flex-start;
}

.mt-filters .mt-model,
.mt-header select {
  width: auto;
  min-width: 160px;
}

.mt-filters .mt-model {
  margin-left: auto;
}

.mt-chip {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  padding: 4px 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.mt-chip.on {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}

.mt-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 16px;
  min-width: 0;
}

.mt-kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.mt-highlights,
.mt-charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.mt-label {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
}

.mt-upper {
  font-weight: 500;
  text-transform: uppercase;
}

.mt-value {
  margin: 4px 0 0;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.mt-h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
}

.mt-card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
}

.mt-card-title.ok {
  color: #059669;
}

.mt-card-title.err {
  color: var(--danger);
}

.mt-card-body {
  margin-top: 12px;
}

.mt-post {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mt-post-text {
  min-width: 0;
  max-width: 260px;
}

.mt-post-title {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 500;
}

.mt-thumb {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
}

.mt-thumb-lg {
  width: 48px;
  height: 48px;
}

.mt-thumb-empty {
  display: inline-block;
  background: var(--surface-subtle);
}

.mt-svg {
  display: block;
  width: 100%;
  height: auto;
}

.mt-grid {
  stroke: var(--border);
  stroke-dasharray: 3 3;
}

.mt-tick {
  fill: var(--text-muted);
  font-size: 11px;
}

.mt-bar {
  fill: var(--text);
}

.mt-line {
  fill: none;
  stroke-width: 2;
}

.mt-hit {
  fill: transparent;
}

.mt-hit:hover {
  fill: var(--surface-subtle);
  opacity: 0.5;
}

.mt-c1 { stroke: var(--chart-1); background: var(--chart-1); }
.mt-c2 { stroke: var(--chart-2); background: var(--chart-2); }
.mt-c3 { stroke: var(--chart-3); background: var(--chart-3); }
.mt-c5 { stroke: var(--chart-5); background: var(--chart-5); }

.mt-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 6px;
  font-size: 12px;
}

.mt-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mt-legend-item i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.mt-table th {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
}

.mt-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.mt-table-head input[type="date"] {
  width: auto;
  height: 32px;
  font-size: 12px;
}

.mt-empty {
  padding: 24px 0;
  text-align: center;
}

@media (max-width: 1100px) {
  .mt-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .mt-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mt-highlights,
  .mt-charts {
    grid-template-columns: 1fr;
  }

  .mt-filters .mt-model {
    margin-left: 0;
  }
}

/* --- Zernio: perfiles por modelo (estándar ModelZernioForm) ---------------- */
.zn-profile {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.zn-profile.on {
  border-color: var(--text);
}

.zn-check {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
}

.zn-profile.on .zn-check {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}

/* ==========================================================================
   Drawers apilados (ui.js) · estándar de clave · tarjetas de cuenta
   ========================================================================== */
.bdw-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.bdw-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

body.bdw-open {
  overflow: hidden;
}

.bdw {
  position: fixed;
  top: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 61;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(420px, calc(100vw - 16px));
  padding: 20px;
  overflow: hidden;
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  transform: translateX(calc(100% + 16px));
  visibility: hidden;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s linear 0.3s;
}

.bdw.open {
  transform: none;
  visibility: visible;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s;
}

/* Segundo drawer: se abre a la izquierda del primero (pegado a su borde) */
@media (min-width: 900px) {
  .bdw.bdw-l2 {
    right: calc(8px + min(420px, calc(100vw - 16px)) + 8px);
    width: min(520px, calc(100vw - 452px));
  }
}

/* Con poco ancho el segundo drawer cubre al primero */
@media (max-width: 899px) {
  .bdw.bdw-l2 {
    z-index: 62;
    width: calc(100vw - 16px);
  }
}

.bdw-head {
  display: flex;
  flex: none;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.bdw-titles {
  min-width: 0;
}

.bdw-titles h2 {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 500;
  line-height: 24px;
}

.bdw-titles p {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.bdw-x {
  appearance: none;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-subtle);
  color: var(--text);
  cursor: pointer;
}

.bdw-x:active {
  opacity: 0.6;
}

.bdw-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  margin: 0 -20px;
  padding: 0 20px 4px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  overflow-wrap: anywhere;
}

/* Los bloques del drawer nunca se encogen: si no caben, el cuerpo hace scroll */
.bdw-body > * {
  flex: none;
}

.bdw select,
.bdw input,
.bdw textarea {
  flex: none;
  width: 100%;
}

.bdw-foot {
  flex: none;
}

.bdw-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bdw-form label {
  gap: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}

.bdw-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bdw-label {
  font-size: 14px;
  font-weight: 500;
}

.bdw-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.kf-danger {
  color: var(--danger);
}

/* Móvil: hoja inferior (los drawers suben desde abajo) */
@media (max-width: 767px) {
  .bdw {
    top: auto;
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
    max-height: calc(100dvh - 16px);
    height: min(88dvh, 760px);
    padding: 16px;
    transform: translateY(calc(100% + 16px));
  }

  .bdw.bdw-l2 {
    right: 8px;
    width: auto;
    height: calc(100dvh - 16px);
  }

  .bdw-body {
    margin: 0 -16px;
    padding: 0 16px 4px;
  }

  .bdw-x {
    width: 36px;
    height: 36px;
  }

  .bdw .btn {
    height: 40px;
  }
}

/* --- Estándar de clave de API ------------------------------------------------ */
.kf {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kf-label {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
}

.kf-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.kf-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

.kf-badge.on {
  border-color: color-mix(in srgb, var(--success) 45%, transparent);
  color: var(--success);
}

.kf-badge .ic {
  width: 12px;
  height: 12px;
}

.kf-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kf-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.kf-hint {
  margin: 0;
}

/* --- Tarjetas de cuenta ---------------------------------------------------------- */
.acc-add {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius-lg);
  background: var(--inset);
}

.acc-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.acc-h {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.acc-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.acc-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-lg);
  background: var(--inset);
}

.acc-card.is-off .acc-avatar {
  opacity: 0.55;
}

.acc-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.acc-id {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.acc-id strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.acc-avatar {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-subtle);
  box-shadow: 0 0 0 1px var(--border);
}

.acc-avatar.xl {
  width: 88px;
  height: 88px;
  font-size: 28px;
}

.acc-initials {
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.acc-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.acc-stats div {
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--surface);
}

.acc-stats dt {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
}

.acc-stats dd {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.acc-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
}

.acc-meta li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.acc-meta li.stack {
  flex-direction: column;
  gap: 2px;
}

.acc-meta li.stack b {
  text-align: left;
}

.acc-meta li span {
  flex: none;
  color: var(--text-muted);
}

.acc-meta li b {
  min-width: 0;
  font-weight: 500;
  text-align: right;
}

.acc-error {
  margin: 0;
}

.acc-actions {
  display: flex;
  gap: 8px;
}

.acc-photo {
  display: flex;
  align-items: center;
  gap: 16px;
}

.acc-photo-actions {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.acc-photo-actions p {
  flex: 0 0 100%;
  margin: 0;
}

.acc-upload {
  cursor: pointer;
}

.acc-profiles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* --- Links: cuentas agrupadas -------------------------------------------------- */
.lk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: var(--gap-3);
}

.lk-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.lk-sep {
  margin-left: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

.lk-group {
  margin-bottom: 28px;
}

.lk-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-lg);
  background: var(--inset);
}

.lk-title {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.lk-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.lk-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.lk-count {
  white-space: nowrap;
}

.lk-error {
  margin: 0 0 8px;
}

@media (max-width: 1023px) {
  .lk-head {
    flex-wrap: wrap;
  }

  .lk-tags {
    order: 3;
  }

  .lk-count {
    order: 4;
    margin-left: auto;
  }
}

/* --- Selección y visualizar -------------------------------------------------- */
.sel-note {
  margin: 0 0 var(--gap-3);
}

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

.sel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.sel-head .lk-title {
  flex: 1;
  min-width: 160px;
}

.sel-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fit-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  font-size: 13px;
}

.fit-box.ok b {
  color: var(--success);
}

.fit-box.err b {
  color: var(--danger);
}

.fit-box span {
  color: var(--text-muted);
}

@media (max-width: 1023px) {
  .sel-head .row {
    width: 100%;
  }

  .sel-head .row .btn {
    flex: 1;
  }
}

/* --- Correo de pruebas (generador + bandeja) --- */
.mail-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: var(--gap-3);
  align-items: start;
}

.mail-create {
  flex-wrap: wrap;
}

.mail-input {
  flex: 1 1 220px;
  min-width: 0;
}

.mail-head {
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--gap-2);
  flex-wrap: wrap;
}

.mail-head h2 {
  margin: 0;
}

.mail-main-title {
  min-width: 0;
}

.mail-inbox {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-subtle);
}

.mail-inbox.active {
  border-color: var(--border-strong);
  background: var(--inset);
}

.mail-inbox-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.mail-inbox-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.mail-inbox-title strong {
  overflow-wrap: anywhere;
}

.mail-inbox-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mail-msg-list {
  margin-top: var(--gap-2);
}

.mail-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.mail-msg:hover {
  background: var(--surface-subtle);
}

.mail-msg.unread {
  border-color: var(--border-strong);
  box-shadow: inset 3px 0 0 var(--accent);
}

.mail-msg-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--gap-2);
}

.mail-msg-top strong {
  overflow-wrap: anywhere;
}

.mail-msg-intro {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.mail-detail-subject {
  margin: 12px 0 6px;
  overflow-wrap: anywhere;
}

.mail-body {
  margin: var(--gap-3) 0;
  padding: 14px;
  border-radius: var(--radius-lg);
  background: var(--inset);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  font-size: 13px;
  line-height: 1.55;
}

.mail-html-block {
  margin-top: var(--gap-3);
}

.mail-html {
  width: 100%;
  min-height: 360px;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #fff;
}

.mail-attachments ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.mail-empty {
  padding: 24px 4px;
}

@media (max-width: 1023px) {
  .mail-layout {
    grid-template-columns: 1fr;
  }
}

/* --- Cuenta conectada ------------------------------------------------------------ */
.ses-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.ses-head .lk-title {
  flex: 1;
  min-width: 160px;
}

.ses-head h2 {
  margin: 0;
}

.ses-cookie {
  margin-top: 12px;
}

.watch-add {
  flex-direction: row;
  margin-bottom: 14px;
}

.watch-add input {
  flex: 1;
}

.acc-grid-wide {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

@media (max-width: 480px) {
  .watch-add {
    flex-direction: column;
  }
}

.lk-selects {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.lk-select {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 190px;
  font-size: 12px;
  color: var(--text-muted);
}

@media (max-width: 1023px) {
  .lk-selects,
  .lk-select {
    width: 100%;
  }
}

/* Parar monitor / Actualizar ahora: solo en Cuenta conectada */
body:not([data-view="session"]) #pause-btn,
body:not([data-view="session"]) #poll-btn {
  display: none !important;
}

/* --- Selección: vídeo visible en la tarjeta ---------------------------------------- */
.sel-video {
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 420px;
  object-fit: cover;
  background: var(--surface-subtle);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.sel-poster {
  position: relative;
  overflow: hidden;
}

.sel-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sel-poster .chip {
  position: absolute;
  left: 10px;
  bottom: 10px;
}

/* --- Aprobado ------------------------------------------------------------------------ */
.wf-ap {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 18px;
  align-items: start;
}

.wf-ap-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

@media (max-width: 1023px) {
  .wf-ap {
    grid-template-columns: 1fr;
  }
}

.sel-sections {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
}

.sel-sec b {
  display: block;
  margin-bottom: 2px;
  font-size: 12px;
  color: var(--text-muted);
}

.sel-sec .md p {
  margin: 0;
}

/* --- Selector estándar: lista flotante (ui.js, uiSelOpen) ------------------------------ */
select.ui-open {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px var(--ring);
}

.ui-select-list {
  position: fixed;
  z-index: 200;
  max-width: calc(100vw - 16px);
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.ui-select-group {
  padding: 8px 10px 4px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

.ui-select-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 10px;
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  line-height: 20px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.ui-select-opt.active {
  background: var(--surface-subtle);
}

.ui-select-opt.disabled {
  color: var(--text-muted);
  opacity: 0.6;
  cursor: not-allowed;
}

.ui-select-opt .ic {
  opacity: 0;
}

.ui-select-opt.on {
  font-weight: 600;
}

.ui-select-opt.on .ic {
  opacity: 1;
}


/* --- Actividad del monitor (Cuenta conectada) ---------------------------------------- */
.act-now {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.act-now-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.act-now-head b {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.act-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-muted);
  flex: none;
}

.act-dot.live {
  background: #22a06b;
  animation: actPulse 1.4s ease-in-out infinite;
}

@keyframes actPulse {
  50% {
    opacity: 0.25;
  }
}

.acc-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-subtle);
  overflow: hidden;
}

.acc-bar > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #5b8def, #22a06b);
  transition: width 0.6s ease;
}

.act-ig {
  margin: 0;
}

.act-accounts {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.act-acc {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.act-acc.is-analyzing {
  border-color: #5b8def;
  box-shadow: 0 0 0 1px #5b8def inset;
}

.act-acc-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.act-status {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.act-status.live::before,
.act-status.off::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
}

.act-status.live {
  color: #22a06b;
}

.act-status.live::before {
  background: #22a06b;
}

.act-acc-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.act-note {
  margin: 0;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
}

.act-recent {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.act-log {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 320px;
  overflow: auto;
}

.act-log-row {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 8px;
  align-items: baseline;
  font-size: 12.5px;
  padding: 3px 0;
  border-bottom: 1px dashed var(--border);
}

.act-log-row:last-child {
  border-bottom: 0;
}

.act-log-time {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.act-log-user {
  font-weight: 600;
}

.act-log-row.ok .act-log-msg {
  color: #22a06b;
}

.act-log-row.err .act-log-msg,
.act-log-row.warn .act-log-msg {
  color: #d9822b;
}


/* Programación por cuenta dentro del editor */
.acc-sched-daily {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.acc-sched-days .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
}

.acc-sched-days .check.small {
  white-space: nowrap;
}

/* «Una vez a la semana»: día y hora en una fila */
.acc-sched-weekly {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.acc-sched-note {
  margin: 0;
}

/* Añadir un vídeo por enlace (Selección de pruebas) */
.sel-linkform {
  align-items: stretch;
  flex-wrap: nowrap;
  gap: 8px;
}

.sel-linkform input {
  flex: 1 1 auto;
  min-width: 0;
}

.sel-linkbox .grid {
  margin-top: 12px;
}

.sel-title {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 500;
}

@media (max-width: 640px) {
  .sel-linkform {
    flex-wrap: wrap;
  }
}

/* Cuentas pausadas: plegadas debajo de las activas */
.acc-paused {
  margin-top: 12px;
}

.acc-paused-list {
  margin-top: 10px;
}
