/*
 * Panel admin. Tokens en :root (claro) y [data-theme="dark"] / prefers-color-scheme (oscuro).
 * Criterio: neutros sobrios, un solo acento para selección y foco, botón principal monocromo,
 * bordes finos y sombras solo en lo que flota (modales, toasts).
 */

:root {
  color-scheme: light;
  --bg: #f6f6f7;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --surface-3: #f1f1f3;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-2: #3f3f46;
  --muted: #71717a;
  --faint: #a1a1aa;
  --accent: #0f62fe;
  --accent-text: #0043ce;
  --accent-soft: rgba(15, 98, 254, .08);
  --focus: rgba(15, 98, 254, .35);
  --primary-bg: #18181b;
  --primary-fg: #ffffff;
  --primary-hover: #3f3f46;
  --ok: #15803d;
  --ok-soft: rgba(21, 128, 61, .09);
  --warn: #b45309;
  --warn-soft: rgba(180, 83, 9, .09);
  --danger: #b91c1c;
  --danger-soft: rgba(185, 28, 28, .07);
  --overlay: rgba(9, 9, 11, .42);
  --shadow-pop: 0 1px 2px rgba(0, 0, 0, .06), 0 12px 32px rgba(0, 0, 0, .12);
  --code-bg: #18181b;
  --code-fg: #e4e4e7;
  --radius: 8px;
  --radius-sm: 6px;
  --sidebar-w: 236px;
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0b0d;
  --surface: #121215;
  --surface-2: #16161a;
  --surface-3: #1d1d22;
  --border: #26262c;
  --border-strong: #3a3a42;
  --text: #ececef;
  --text-2: #c4c4cc;
  --muted: #8d8d97;
  --faint: #5e5e68;
  --accent: #4589ff;
  --accent-text: #78a9ff;
  --accent-soft: rgba(69, 137, 255, .14);
  --focus: rgba(69, 137, 255, .45);
  --primary-bg: #ececef;
  --primary-fg: #121215;
  --primary-hover: #c4c4cc;
  --ok: #4cc27a;
  --ok-soft: rgba(76, 194, 122, .13);
  --warn: #e2a84a;
  --warn-soft: rgba(226, 168, 74, .13);
  --danger: #f07474;
  --danger-soft: rgba(240, 116, 116, .13);
  --overlay: rgba(0, 0, 0, .62);
  --shadow-pop: 0 0 0 1px rgba(255, 255, 255, .06), 0 16px 40px rgba(0, 0, 0, .55);
  --code-bg: #08080a;
  --code-fg: #d4d4d8;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0b0d;
    --surface: #121215;
    --surface-2: #16161a;
    --surface-3: #1d1d22;
    --border: #26262c;
    --border-strong: #3a3a42;
    --text: #ececef;
    --text-2: #c4c4cc;
    --muted: #8d8d97;
    --faint: #5e5e68;
    --accent: #4589ff;
    --accent-text: #78a9ff;
    --accent-soft: rgba(69, 137, 255, .14);
    --focus: rgba(69, 137, 255, .45);
    --primary-bg: #ececef;
    --primary-fg: #121215;
    --primary-hover: #c4c4cc;
    --ok: #4cc27a;
    --ok-soft: rgba(76, 194, 122, .13);
    --warn: #e2a84a;
    --warn-soft: rgba(226, 168, 74, .13);
    --danger: #f07474;
    --danger-soft: rgba(240, 116, 116, .13);
    --overlay: rgba(0, 0, 0, .62);
    --shadow-pop: 0 0 0 1px rgba(255, 255, 255, .06), 0 16px 40px rgba(0, 0, 0, .55);
    --code-bg: #08080a;
    --code-fg: #d4d4d8;
  }
}

/* ── Base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1;
}
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 20px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 13.5px; font-weight: 600; }
p { margin: 0 0 8px; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--accent-soft); }

.icon { display: inline-flex; flex: none; line-height: 0; }
.icon svg { display: block; }

.boot, .page-error { padding: 48px; color: var(--muted); }
.page-error h2 { color: var(--text); margin-bottom: 8px; }

/* ── Botones ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 13px; border: 1px solid transparent; border-radius: var(--radius-sm);
  font: inherit; font-weight: 550; white-space: nowrap; cursor: pointer; text-decoration: none !important;
  transition: background-color .12s, border-color .12s, color .12s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--primary-bg); color: var(--primary-fg); }
.btn--primary:not(:disabled):hover { background: var(--primary-hover); }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn--secondary:not(:disabled):hover { background: var(--surface-3); }
.btn--ghost { background: transparent; color: var(--text-2); }
.btn--ghost:not(:disabled):hover { background: var(--surface-3); color: var(--text); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger-text { color: var(--danger); }
.btn--danger-text:not(:disabled):hover { background: var(--danger-soft); color: var(--danger); }
.btn--sm { height: 28px; padding: 0 9px; font-size: 13px; }
.btn--block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:not(:disabled):hover { background: var(--surface-3); color: var(--text); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn--danger:not(:disabled):hover { background: var(--danger-soft); color: var(--danger); }

/* ── Formularios ────────────────────────────────────────── */
input, select, textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form--inline { flex-direction: row; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.form--inline .field { flex: 1 1 220px; }
.form__row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form__section { margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--border); }
/* Campos que se muestran u ocultan juntos (ej. según el destino del QR) */
.form__group { display: flex; flex-direction: column; gap: 14px; }
.form__label, .field__label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field__hint { font-size: 12px; color: var(--muted); }
.form-error { padding: 8px 12px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 8px; margin-right: 16px; cursor: pointer; }
.check-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.input-group { display: flex; gap: 8px; }
.option { display: flex; flex-direction: column; gap: 2px; }
.option + .option { margin-top: 10px; }
.option .field__hint { padding-left: 24px; }

/* Selector de equipos (widget de fútbol) */
.team-picker__bar { display: flex; align-items: center; gap: 10px; }
.team-picker__search { flex: 0 1 220px; }
.team-picker__summary { flex: 1; min-width: 0; overflow: hidden; color: var(--text-2); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.team-picker__list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 4px 12px;
  max-height: 196px; overflow-y: auto; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
}
.team-picker__list > p { grid-column: 1 / -1; margin: 0; }
.team-picker__item { margin: 0; font-size: 13px; }
.team-picker__item:has(input:disabled) { color: var(--faint); cursor: default; }
/* Encabezado de grupo dentro de la lista (región de las ligas, tipo de cotización) */
.team-picker__list > .picker-group { margin-top: 6px; color: var(--text-2); font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.team-picker__list > .picker-group:first-child { margin-top: 0; }

/* Colores del QR */
.qr-colors { display: flex; gap: 20px; }
.qr-colors__item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.qr-colors__item input[type="color"] { width: 40px; height: 30px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); cursor: pointer; }

/* ── Layout de la app ───────────────────────────────────── */
.app {
  display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh;
  /* El fondo dibuja la columna lateral entera, así sigue hasta abajo en páginas más altas que la ventana. */
  background: linear-gradient(to right, var(--surface-2) calc(var(--sidebar-w) - 1px), var(--border) calc(var(--sidebar-w) - 1px) var(--sidebar-w), var(--bg) var(--sidebar-w));
}
.sidebar {
  position: sticky; top: 0; display: flex; flex-direction: column; height: 100vh;
  padding: 16px 12px; border-right: 1px solid var(--border); background: var(--surface-2);
}
.brand { display: flex; align-items: center; gap: 9px; padding: 4px 8px 20px; font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }
.brand__mark { display: inline-flex; color: var(--text); line-height: 0; }
.brand--large { padding: 0 0 2px; font-size: 19px; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav__link {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 7px 10px;
  border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; text-decoration: none !important;
}
.nav__link .icon { color: var(--muted); }
.nav__link:hover { background: var(--surface-3); color: var(--text); }
.nav__link.is-active { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border); }
.nav__link.is-active .icon { color: var(--accent); }
.nav__tenant { display: flex; flex-direction: column; gap: 1px; margin: 14px 0 8px; padding: 0 10px; }
.nav__tenant strong { font-weight: 600; }
.nav__caption { font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); }

/* Uso del plan (barra lateral y tabla de clientes) */
.plan-meter { display: flex; flex-direction: column; gap: 3px; margin: 0 4px 10px; padding: 9px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--muted); font-size: 12px; }
.plan-meter:empty { display: none; }
.plan-meter__title { margin-bottom: 2px; color: var(--text-2); font-weight: 600; }
.usage-row { display: flex; justify-content: space-between; gap: 8px; white-space: nowrap; }
.usage-row.is-full { color: var(--warn); font-weight: 550; }
.usage-bar { height: 4px; margin: 1px 0 3px; overflow: hidden; border-radius: 2px; background: var(--surface-3); }
.usage-bar__fill { height: 100%; border-radius: 2px; background: var(--accent); }
.usage-bar.is-full .usage-bar__fill { background: var(--warn); }
.usage-cell { display: flex; flex-direction: column; gap: 1px; min-width: 150px; font-size: 12.5px; }
.nav__switch { font-size: 12px; }
.sidebar__footer { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 12px 4px 0; border-top: 1px solid var(--border); }
.sidebar__user { overflow: hidden; padding: 0 6px; color: var(--muted); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__role { display: block; margin-top: 1px; color: var(--muted); font-size: 11.5px; opacity: .8; }
.sidebar__logout { justify-content: flex-start; }

.more-sheet { display: flex; flex-direction: column; gap: 12px; }
.more-sheet .nav__tenant { margin: 0; }
.more-sheet .sidebar__footer { margin-top: 0; }
.theme-switch { display: inline-flex; align-self: flex-start; gap: 2px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.theme-switch__btn { display: grid; place-items: center; width: 28px; height: 24px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); cursor: pointer; }
.theme-switch__btn:hover { color: var(--text); }
.theme-switch__btn[aria-checked="true"] { background: var(--surface-3); color: var(--text); }

.main { min-width: 0; }
.page-header {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 64px; padding: 12px 28px; border-bottom: 1px solid var(--border); background: var(--bg);
}
.page-header__subtitle { margin-top: 3px; color: var(--muted); font-size: 13px; }
.page-header__actions { display: flex; align-items: center; gap: 8px; }
.main__content { display: flex; flex-direction: column; gap: 20px; max-width: 1480px; padding: 24px 28px 56px; }
.page-note { margin: 0; color: var(--muted); font-size: 13px; }

/* ── Componentes ────────────────────────────────────────── */
.card { padding: 18px 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.card__title { margin-bottom: 14px; }

/* Estado: punto de color + texto, sin píldoras rellenas */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 550; white-space: nowrap; color: var(--text-2); }
.badge::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.badge--ok::before { background: var(--ok); }
.badge--warn::before { background: var(--warn); }
.badge--error::before { background: var(--danger); }
.badge--muted { margin-right: 8px; color: var(--muted); }
.badge--muted::before { display: none; }

.callout { padding: 10px 14px; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-2); font-size: 13px; }
.callout--warn { border-left-color: var(--warn); background: var(--warn-soft); }
.empty { display: flex; flex-direction: column; align-items: flex-start; padding: 28px; border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--text-2); }
.list { margin: 0 0 8px; padding-left: 18px; }

.table { width: 100%; border-collapse: separate; border-spacing: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table th { padding: 9px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 550; text-align: left; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.is-muted td { opacity: .5; }
.table td.nowrap { white-space: nowrap; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.pager__buttons { display: flex; gap: 8px; }
.table__actions { text-align: right; white-space: nowrap; }
.table__actions .btn { margin-left: 4px; }

.segmented { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.segmented__btn { padding: 4px 11px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 550; cursor: pointer; }
.segmented__btn:hover { color: var(--text); }
.segmented__btn.is-active { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border); }

.secret { display: flex; align-items: center; gap: 8px; margin: 8px 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--code-bg); }
.secret code { flex: 1; overflow-wrap: anywhere; color: var(--code-fg); }
.secret .btn { color: var(--code-fg); }
.secret .btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.code-block { position: relative; margin: 8px 0 16px; border-radius: var(--radius-sm); background: var(--code-bg); }
.code-block pre { margin: 0; padding: 14px 16px; overflow-x: auto; color: var(--code-fg); font: 12.5px/1.6 var(--mono); white-space: pre-wrap; word-break: break-all; }
.code-block .btn { position: absolute; top: 8px; right: 8px; color: var(--code-fg); }
.code-block .btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.docs h3 { margin-top: 18px; }

/* ── Estados de carga, menú "⋯", vacíos ─────────────────── */
/* Botón esperando al server: deshabilitado pero legible, con spinner (busy() en ui.ts) */
.btn.is-busy, .btn.is-busy:disabled { opacity: .85; cursor: progress; }
.spinner { flex: none; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.menu { position: relative; display: inline-flex; }
.menu__toggle { padding: 0 8px; }
.menu__list {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 40; display: flex; flex-direction: column; min-width: 220px; max-width: min(320px, calc(100vw - 32px));
  padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-pop);
}
.menu__item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 9px 12px; border: 0; border-radius: 4px; background: transparent; color: var(--text); font: inherit; font-weight: 550; text-align: left; cursor: pointer; }
.menu__item:not(:disabled):hover { background: var(--surface-3); }
.menu__item--danger { color: var(--danger); }
.menu__item:disabled { color: var(--muted); cursor: default; }
.menu__note { color: var(--muted); font-size: 12px; font-weight: 400; white-space: normal; }

.empty__title { margin: 0; color: var(--text); font-weight: 600; }
.empty__text { margin: 4px 0 0; max-width: 62ch; color: var(--muted); }
.empty__action { margin-top: 14px; }
.empty__buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.callout--action { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }

/* Opciones que casi nadie necesita (identificador, URL de la pantalla), plegadas */
.advanced > summary, .install-details > summary { color: var(--text-2); font-size: 13px; font-weight: 550; cursor: pointer; }
.advanced[open] > summary { margin-bottom: 12px; }
.install-details { padding-top: 10px; border-top: 1px solid var(--border); }
.install-details[open] { display: flex; flex-direction: column; gap: 8px; }
.install-details p { margin: 0; }

/* ── Login ──────────────────────────────────────────────── */
.login { position: relative; display: grid; place-items: center; min-height: 100vh; padding: 24px; background: var(--bg); }
.login-card { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 360px; padding: 28px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.login-card__lead { margin: -6px 0 6px; color: var(--muted); }
.login__theme { position: absolute; top: 16px; right: 16px; }

/* ── Modal y toasts ─────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; background: var(--overlay); animation: fade .12s; }
.modal { display: flex; flex-direction: column; width: 100%; max-width: 500px; max-height: calc(100vh - 48px); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-pop); }
.modal--wide { max-width: 960px; }
.modal__header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal__body { padding: 18px; overflow-y: auto; }
.modal__footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
/* Una acción destructiva al principio (ej. Desvincular) queda separada, a la izquierda */
.modal__footer .btn--danger:first-child { margin-right: auto; }
@keyframes fade { from { opacity: 0; } }

/* Los avisos solo informan: los toques pasan a lo que está debajo (no tapan un botón mientras duran) */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: 400px; pointer-events: none; }
.toast {
  padding: 11px 14px 11px 16px; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop);
  animation: toast-in .16s ease-out; transition: opacity .25s, transform .25s;
}
.toast--success { border-left-color: var(--ok); }
.toast--error { border-left-color: var(--danger); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ── Pantallas ──────────────────────────────────────────── */
.screen-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; }
.screen-card { display: flex; flex-direction: column; gap: 12px; }
.screen-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.screen-card__meta { font-size: 13px; }
.screen-card__actions { display: flex; flex-wrap: wrap; gap: 6px; }
/* Dispositivos de la pantalla: reproductores (tope del plan) y vistas previas */
.device-list { display: flex; flex-direction: column; gap: 2px; padding-top: 10px; border-top: 1px solid var(--border); }
.device-list__head { display: flex; justify-content: space-between; margin-top: 4px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.device-list__head .is-full { color: var(--warn); }
.device-row { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 4px 0; font-size: 13px; }
.device-row .badge { flex: none; gap: 0; }
.device-row__main { display: flex; flex: 1 1 auto; flex-direction: column; min-width: 0; }
.device-row__label { font-weight: 550; overflow-wrap: anywhere; }
.device-row__state { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.device-row > .btn { flex: none; }
.device-list__empty { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
.screens-note { display: flex; flex-direction: column; gap: 10px; }
.screens-note:empty { display: none; }
.device-row.is-preview .device-row__label { color: var(--muted); }
/* Código que muestra el TV en /tv (Vincular TV) */
.input--code { font-family: var(--mono); font-size: 22px !important; letter-spacing: .15em; text-transform: uppercase; }
.input--code.is-invalid { border-color: var(--danger); }
.code-hint { color: var(--muted); font-size: 13px; }
.code-hint--error { color: var(--danger); }
.code-hint--ok { color: var(--ok); font-weight: 600; }
.url-row { display: flex; align-items: center; gap: 4px; padding: 4px 4px 4px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.url-row__url { flex: 1; overflow: hidden; color: var(--text-2); text-overflow: ellipsis; white-space: nowrap; }

/* ── Editor de playlist ─────────────────────────────────── */
.editor { display: flex; flex-direction: column; gap: 18px; }
.editor-subtitle { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.back-link { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); }
.back-link:hover { color: var(--text); text-decoration: none; }
.editor-status { display: inline-flex; align-items: center; gap: 12px; }
.editor-status__sync { display: inline-flex; align-items: center; gap: 5px; color: var(--text-2); font-size: 12.5px; }
.editor-status__sync.is-ok { color: var(--ok); }
.save-bar { display: flex; align-items: center; gap: 8px; }
.save-bar__dirty { display: inline-flex; align-items: center; gap: 6px; color: var(--warn); font-size: 13px; font-weight: 550; }
.save-bar__dirty::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.layout-picker { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.layout-option {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text-2);
  font: inherit; font-weight: 550; text-align: left; cursor: pointer; transition: border-color .12s;
}
.layout-option:not(:disabled):hover { border-color: var(--border-strong); }
.layout-option:disabled { cursor: default; }
.layout-option:disabled:not(.is-active) { opacity: .5; }
.layout-option.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); color: var(--text); }
.layout-thumb { display: grid; flex: none; width: 64px; aspect-ratio: 16 / 9; gap: 2px; padding: 2px; border-radius: 3px; background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--border); }
.layout-thumb__zone { border-radius: 1px; background: var(--border-strong); }
.layout-option.is-active .layout-thumb__zone { background: var(--accent); opacity: .7; }

.editor__body { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(400px, 1fr); gap: 18px; align-items: start; }
.editor__preview { position: sticky; top: 88px; }
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }

/* Vista previa: misma grilla (LAYOUT_GEOMETRY) y mismo object-fit que el player. Siempre oscura: es el TV. */
.preview { display: grid; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 4px; background: #000; box-shadow: 0 0 0 5px #1a1a1d, 0 0 0 6px var(--border); }
.preview--portrait { width: auto; height: min(70vh, 640px); aspect-ratio: 9 / 16; margin: 0 auto; }
.preview-zone { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #000; cursor: pointer; container-type: size; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); }
.preview-zone:hover { box-shadow: inset 0 0 0 2px rgba(120, 169, 255, .55); }
.preview-zone.is-selected { box-shadow: inset 0 0 0 2px #78a9ff; }
.preview-zone.is-drop-target { box-shadow: inset 0 0 0 2px #4cc27a; }
.preview-zone.is-disabled .preview-media, .preview-zone.is-disabled .pw,
.preview-zone.is-off-schedule .preview-media, .preview-zone.is-off-schedule .pw { opacity: .3; }
.preview-media { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; pointer-events: none; }
.preview-zone__empty { display: grid; place-items: center; width: 100%; height: 100%; color: #52525b; font-size: 12px; background: repeating-linear-gradient(45deg, #0c0c0e, #0c0c0e 8px, #111114 8px, #111114 16px); }
.preview-zone__label { position: absolute; left: 6px; bottom: 6px; display: flex; gap: 6px; max-width: calc(100% - 12px); padding: 2px 7px; border-radius: 4px; background: rgba(9, 9, 11, .8); color: #e4e4e7; font-size: 11px; white-space: nowrap; pointer-events: none; }
/* El nombre se recorta con "…"; las medidas nunca (un "480×54" recortado parecería otro número). */
.preview-zone__label > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.preview-zone__label > .preview-zone__px, .preview-zone__label > .preview-zone__count { flex-shrink: 0; }
.preview-zone__px { color: #a1a1aa; font-family: var(--mono); }
.preview-zone__count { color: #e2a84a; }
.preview-zone__notice { position: absolute; top: 6px; left: 6px; right: 6px; display: flex; align-items: center; justify-content: center; gap: 5px; padding: 4px 8px; border-radius: 4px; background: rgba(9, 9, 11, .85); color: #f2c98a; font-size: 11px; font-weight: 550; text-align: center; pointer-events: none; }
.preview-note { margin: 12px 0 0; color: var(--muted); font-size: 12.5px; }

/* Maquetas de widgets (tamaños en cq* como en el player) */
.pw { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; overflow: hidden; color: #fff; pointer-events: none; }
.pw--clock { flex-direction: column; background: linear-gradient(160deg, #1f2937, #0b0f17); }
.pw-clock__time { font-size: 28cqmin; font-weight: 700; line-height: 1; }
.pw-clock__date { margin-top: 3cqmin; font-size: 7cqmin; opacity: .7; }
.pw--weather { flex-direction: column; background: linear-gradient(160deg, #12345c, #0b1424); }
.pw-weather__now { display: flex; align-items: center; gap: 3cqmin; }
.pw-weather__icon { display: block; width: 30cqmin; height: 30cqmin; }
.pw-weather__icon svg { display: block; width: 100%; height: 100%; }
.pw-weather__temp { font-size: 26cqmin; font-weight: 700; line-height: 1; }
.pw-weather__place { margin-top: 3cqmin; font-size: 8cqmin; font-weight: 600; }
.pw--ticker { justify-content: flex-start; padding: 0 2cqw; background: #111; }
.pw-ticker__text { font-size: 9cqmin; font-weight: 600; white-space: nowrap; }
.pw--football { flex-direction: column; align-items: stretch; justify-content: flex-start; padding: 4cqmin 5cqmin; background: #0b1220; font-size: 5cqmin; }
.pw-fb__head { display: flex; align-items: baseline; justify-content: space-between; gap: 1em; margin-bottom: .5em; padding-bottom: .4em; border-bottom: 1px solid rgba(255, 255, 255, .16); white-space: nowrap; }
.pw-fb__head b { overflow: hidden; font-size: 1.25em; text-overflow: ellipsis; }
.pw-fb__rows { display: flex; flex-direction: column; }
.pw-fb__row { display: flex; gap: .6em; padding: .4em 0; border-bottom: 1px solid rgba(255, 255, 255, .07); white-space: nowrap; }
.pw-fb__team { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.pw-fb__team--home { text-align: right; }
.pw-fb__muted { color: #9ca3af; }
.pw-fb__card { display: flex; flex-direction: column; margin-top: .3em; font-size: 1.6em; font-weight: 600; }
.pw-fb__card span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pw--qr { flex-direction: column; padding: 4cqmin; background: #0b1220; text-align: center; }
.pw-qr__code { display: block; width: 62cqmin; height: 62cqmin; }
.pw-qr__code svg { display: block; width: 100%; height: 100%; border-radius: 1.5cqmin; }
.pw-qr__title { margin-bottom: 3cqmin; font-size: 8cqmin; font-weight: 700; line-height: 1.15; }
.pw-qr__caption { margin-top: 3cqmin; color: #d1d5db; font-size: 6cqmin; line-height: 1.2; }
@container (min-aspect-ratio: 3 / 1) {
  .pw--clock { background: #111827; }
  .pw-clock__time { font-size: 56cqh; }
  .pw-clock__time:only-child { font-size: 70cqh; }
  .pw-clock__date { margin-top: 4cqh; font-size: 24cqh; line-height: 1.1; }
  .pw-weather__icon { width: 70cqh; height: 70cqh; }
  .pw-weather__temp { font-size: 60cqh; }
  .pw--weather { flex-direction: row; gap: 2cqw; }
  .pw-weather__place { margin: 0; font-size: 40cqh; }
  .pw-ticker__text { font-size: 50cqh; }
  .pw--football { flex-direction: row; align-items: center; padding: 0 2cqw; font-size: 38cqh; }
  .pw-fb__head { flex-direction: column; gap: 0; margin: 0 1em 0 0; padding: 0 1em 0 0; border-bottom: 0; border-right: 1px solid rgba(255, 255, 255, .2); }
  .pw-fb__head b { font-size: .9em; }
  .pw-fb__head span { font-size: .6em; }
  .pw-fb__rows { flex-direction: row; gap: 1.5em; }
  .pw-fb__row { padding: 0; border: 0; }
  .pw-fb__team { flex: none; }
  .pw--qr { flex-direction: row; justify-content: flex-start; gap: 1.2cqw; padding: 6cqh 1.5cqw; text-align: left; }
  .pw-qr__code { flex: none; width: 88cqh; height: 88cqh; }
  .pw-qr__title { margin: 0; font-size: 38cqh; white-space: nowrap; }
  .pw-qr__caption { margin: 0; font-size: 26cqh; white-space: nowrap; }
}

/* Panel de zona */
.zone-panel { display: flex; flex-direction: column; gap: 14px; transition: box-shadow .15s; }
.zone-panel.is-drop-target { box-shadow: 0 0 0 2px var(--ok); }
.zone-tabs { display: flex; flex-wrap: wrap; gap: 2px; margin: -4px 0 0; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.zone-tab { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 550; cursor: pointer; }
.zone-tab:hover { background: var(--surface-3); color: var(--text); }
.zone-tab.is-active { background: var(--accent-soft); color: var(--accent-text); }
.zone-tab__count { min-width: 18px; padding: 0 5px; border-radius: 4px; background: var(--surface-3); color: var(--muted); font-size: 11px; text-align: center; }
.zone-tab.is-active .zone-tab__count { background: transparent; color: inherit; }
.zone-toolbar { display: flex; flex-direction: column; gap: 10px; }
.zone-toolbar__actions { display: flex; flex-wrap: wrap; gap: 6px; }

.item-list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.item-row {
  position: relative; display: grid; grid-template-columns: 14px 88px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 10px 10px 10px 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer;
}
.item-row .thumb { width: 88px; }
/* Solo lectura: sin columna de arrastre */
.item-row--readonly { grid-template-columns: 88px minmax(0, 1fr) auto; }
.item-row:hover { border-color: var(--border-strong); }
.item-row.is-focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.item-row.is-disabled .thumb, .item-row.is-disabled .item-row__info { opacity: .45; }
.item-row.has-error { border-color: var(--danger); background: var(--danger-soft); }
.item-row.is-dragging { opacity: .4; }
.item-row.drop-before::before, .item-row.drop-after::after { content: ""; position: absolute; left: 0; right: 0; height: 2px; border-radius: 2px; background: var(--accent); }
.item-row.drop-before::before { top: -4px; }
.item-row.drop-after::after { bottom: -4px; }
.item-row__handle { display: grid; place-items: center; color: var(--faint); cursor: grab; }
.item-row__info { min-width: 0; }
.item-row__title { overflow: hidden; font-weight: 550; text-overflow: ellipsis; white-space: nowrap; }
.item-row__meta { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.item-row__details { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 7px; }
.item-row__duration { display: inline-flex; align-items: center; gap: 5px; }
.item-row__controls { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.item-row__actions { display: flex; }
.duration-input { width: 62px; padding: 3px 6px; text-align: right; }
.duration-input.is-invalid { border-color: var(--danger); background: var(--danger-soft); }
.duration-input:disabled { border-color: transparent; background: transparent; color: var(--text); -moz-appearance: textfield; }
.duration-input:disabled::-webkit-inner-spin-button { display: none; }

.thumb { position: relative; width: 72px; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 4px; background: #000; }
.thumb img, .thumb video { display: block; width: 100%; height: 100%; object-fit: contain; }
.thumb--large { width: 100%; }
.thumb--widget { display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.thumb__badge { position: absolute; right: 3px; bottom: 3px; display: inline-flex; align-items: center; padding: 1px 4px; border-radius: 3px; background: rgba(0, 0, 0, .72); color: #fff; font-size: 10px; }

/* Ajuste (bandas) */
.fit { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11.5px; font-weight: 550; white-space: nowrap; }
.fit::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.fit--exact { color: var(--ok); }
.fit--pillarbox, .fit--letterbox { color: var(--warn); }
.fit--minor { color: var(--muted); }

/* Dayparting */
.sched {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 7px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: transparent;
  color: var(--muted); font: inherit; font-size: 11.5px; font-weight: 550; white-space: nowrap; cursor: pointer;
}
.sched:not(:disabled):hover { border-color: var(--border-strong); color: var(--text); }
.sched:disabled { cursor: default; }
.sched--on { border-color: transparent; background: var(--accent-soft); color: var(--accent-text); }
.sched--off { border-color: var(--border); background: var(--surface-3); color: var(--muted); }
.schedule-mode { display: flex; flex-direction: column; gap: 8px; }
.schedule-details { display: flex; flex-direction: column; gap: 14px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.day-chips { display: flex; gap: 6px; }
.day-chip { width: 34px; height: 34px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-2); font: inherit; font-weight: 600; cursor: pointer; }
.day-chip:hover { border-color: var(--text-2); }
.day-chip[aria-pressed="true"] { border-color: var(--primary-bg); background: var(--primary-bg); color: var(--primary-fg); }
.day-presets { display: flex; gap: 4px; margin-top: 8px; }
.schedule-summary { margin: 0; color: var(--text-2); font-weight: 550; }
.schedule-summary.is-invalid { color: var(--danger); }

.switch-field { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; cursor: pointer; }
.switch { position: relative; display: inline-block; flex: none; width: 34px; height: 20px; cursor: pointer; }
.switch input { position: absolute; width: 0; height: 0; opacity: 0; }
.switch:has(input:disabled) { cursor: default; opacity: .6; }
.switch__track { position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong); transition: background .15s; }
.switch__track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch input:checked + .switch__track { background: var(--ok); }
.switch input:checked + .switch__track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--focus); outline-offset: 2px; }

.dropzone { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 24px 18px; border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--text-2); }

.uploads { display: flex; flex-direction: column; gap: 6px; }
.uploads:empty { display: none; }
.upload { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 4px 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.upload__head { display: flex; gap: 6px; min-width: 0; }
.upload__name { overflow: hidden; font-weight: 550; text-overflow: ellipsis; white-space: nowrap; }
.upload__state { color: var(--muted); font-size: 12px; }
.upload--error { border-color: var(--danger); background: var(--danger-soft); }
.upload--error .upload__state { grid-column: 1 / 3; color: var(--danger); }
.upload--done .upload__state { color: var(--ok); }
.progress { grid-column: 1 / 3; height: 4px; overflow: hidden; border-radius: 999px; background: var(--surface-3); }
.progress__bar { height: 100%; border-radius: inherit; background: var(--accent); transition: width .2s; }
.upload--processing .progress__bar { background: linear-gradient(90deg, var(--accent) 0 40%, var(--accent-soft) 40% 60%, var(--accent) 60%); background-size: 200% 100%; animation: indeterminate 1s linear infinite; }
.upload--done .progress__bar { background: var(--ok); }
@keyframes indeterminate { to { background-position: -200% 0; } }

/* Biblioteca */
.library__toolbar { display: flex; gap: 12px; margin-bottom: 14px; }
.library__toolbar input { max-width: 280px; }
.library { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.library__card { display: flex; flex-direction: column; gap: 4px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); }
.library__name { overflow: hidden; font-size: 13px; font-weight: 550; text-overflow: ellipsis; white-space: nowrap; }
.library__actions { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }

/* ── Playlists compartidas ──────────────────────────────── */
.playlist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.playlist-card { display: flex; flex-direction: column; gap: 12px; }
.playlist-card__head { display: flex; align-items: center; gap: 12px; }
.playlist-card__head h3 { margin: 0 0 2px; font-size: 15px; }
.playlist-card__screens, .screen-card__source { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.screen-card__source .icon { color: var(--muted); }
.board-card__usage { display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.library__usage { margin-top: 2px; }
.source-card { display: flex; flex-direction: column; gap: 10px; }
.source-card .card__title { margin-bottom: 0; }
.source-card__controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.source-card__controls select { flex: 1 1 240px; min-width: 0; font-weight: 550; }
.source-card__controls .btn { flex: none; }
.source-card__help { margin: 0; }
.editor__source { display: flex; flex-direction: column; gap: 10px; }
.editor__source:empty { display: none; }

/* ── Placas ─────────────────────────────────────────────── */
/* Vista previa: iframe con el lienzo de la plantilla, escalado por JS (boardPreview.ts) dentro del contenedor */
.board-frame { position: relative; width: 100%; height: 100%; overflow: hidden; background: #000; }
.board-frame__doc { position: absolute; top: 0; left: 0; border: 0; background: #000; transform-origin: 0 0; pointer-events: none; }
.board-frame--card { aspect-ratio: 16 / 9; height: auto; border-radius: 4px; }
.board-stage { width: 100%; max-height: 70vh; margin: 0 auto; overflow: hidden; border-radius: 4px; box-shadow: 0 0 0 5px #1a1a1d, 0 0 0 6px var(--border); }
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.board-card { display: flex; flex-direction: column; gap: 10px; padding: 12px; }
.board-zoom { position: fixed; inset: 0; z-index: 150; display: flex; align-items: center; justify-content: center; background: #000; animation: fade .12s; }
.board-zoom__stage { flex: none; background: #000; }
.board-zoom__close { position: absolute; bottom: calc(16px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); }
.board-card__actions { flex-wrap: wrap; }
.board-card__preview { display: block; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 4px; background: #000; }
.board-card__info h3 { margin: 0 0 2px; font-size: 15px; }
.board-card__actions { display: flex; gap: 6px; }
.templates-card { margin-top: 18px; }
.templates-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.templates-card__head .card__title { margin-bottom: 2px; }
.template-list { display: flex; flex-direction: column; gap: 6px; }
.template-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.template-row__info { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.library__card--pick { background: var(--surface); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.library__card--pick:hover { border-color: var(--accent); }

/* Formulario del cliente */
.board-form { gap: 16px; }
.board-image { display: flex; align-items: center; gap: 8px; }
.board-image .thumb { width: 96px; }
.board-image--compact .thumb { width: 48px; }
.board-image__empty { display: grid; place-items: center; height: 100%; color: #a1a1aa; font-size: 11px; }
.board-color { display: flex; align-items: center; gap: 8px; }
.board-color input[type="color"] { width: 44px; height: 32px; padding: 2px; }
.board-qr { display: flex; flex-direction: column; gap: 8px; }
.board-qr__group { display: flex; flex-wrap: wrap; gap: 8px; }
.board-qr__group > * { flex: 1 1 160px; }
.board-list { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.board-list__head { display: flex; align-items: baseline; justify-content: space-between; }
.board-list__rows { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.board-list__row { display: flex; align-items: center; gap: 8px; }
.board-list__index { flex: 0 0 18px; text-align: right; }
.board-list__cells { display: flex; flex: 1; flex-wrap: wrap; gap: 6px; min-width: 0; }
.board-list__cell { flex: 1 1 120px; min-width: 0; }
.board-list__caption { display: block; margin-bottom: 3px; color: var(--muted); font-size: 11.5px; font-weight: 550; }
.board-list__cell--color, .board-list__cell--image { flex: 0 0 auto; }
.board-list__actions { display: flex; flex: none; }
.board-list__add { align-self: flex-start; }

/* Editor de plantillas (superadmin) */
.template-editor__left { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.code-input { min-height: 320px; font: 12.5px/1.55 var(--mono); tab-size: 2; white-space: pre; overflow-wrap: normal; overflow-x: auto; }
.size-row { display: flex; align-items: center; gap: 8px; }
.size-row select { flex: 1; }
.size-row input { flex: 0 0 90px; }
.tf-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.tf-group { display: flex; flex-direction: column; gap: 8px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
/* clave · nombre · tipo · valor inicial (o máx. de filas) · acciones */
.tf-row { display: grid; grid-template-columns: 118px minmax(110px, 1.3fr) 116px minmax(90px, 1fr) auto; align-items: center; gap: 6px; }
.tf-row > * { min-width: 0; }
.tf-row input[type="color"] { width: 44px; height: 32px; padding: 2px; }
.tf-row__max { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.tf-row__max input { width: 58px; }
.tf-row__actions { display: flex; }
.tf-columns { display: flex; flex-direction: column; gap: 6px; padding-left: 18px; border-left: 2px solid var(--border); }
.template-problems { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.template-problem { padding: 7px 10px; border-radius: var(--radius-sm); font-size: 12.5px; }
.template-problem--error { background: var(--danger-soft); color: var(--danger); }
.template-problem--warn { background: var(--warn-soft); color: var(--warn); }
.template-problem--ok { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); }

/* ── Alertas ────────────────────────────────────────────── */
.two-columns { display: grid; grid-template-columns: minmax(340px, 440px) minmax(0, 1fr); gap: 18px; align-items: start; }
.alert-preview { display: flex; justify-content: center; padding: 20px; border-radius: var(--radius-sm); background: #1b1b1f; }
.alert-preview__toast { min-width: 70%; padding: 12px 16px; border-left: 5px solid #3b82f6; border-radius: 8px; background: rgba(15, 23, 42, .95); color: #fff; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); }
.alert-preview__toast--success { border-left-color: #22c55e; }
.alert-preview__toast--warning { border-left-color: #f59e0b; }
.alert-preview__toast--critical { border-left-color: #fecaca; background: rgba(185, 28, 28, .96); }
.alert-preview__title { font-size: 18px; font-weight: 700; }
.alert-preview__subtitle { margin-top: 2px; opacity: .85; }
.type-dot { display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: #3b82f6; vertical-align: middle; }
.type-dot--success { background: #22c55e; }
.type-dot--warning { background: #f59e0b; }
.type-dot--critical { background: #dc2626; }

@media (max-width: 1180px) {
  .editor__body, .two-columns { grid-template-columns: minmax(0, 1fr); }
  .editor__preview { position: static; }
  .layout-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* Placa: en una sola columna, primero se ve cómo queda */
  .board-editor .editor__preview { order: -1; }
}

/* ── Menú inferior (solo celular) ───────────────────────── */
.bottom-nav { display: none; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; background: var(--bg); }
  .sidebar { display: none; }
  .main { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .page-header { position: static; flex-direction: column; align-items: stretch; gap: 12px; min-height: 0; padding: 14px 16px 12px; }
  .page-header__actions { flex-wrap: wrap; }
  .page-header__actions > .btn { flex: 1 1 auto; }
  .main__content { gap: 16px; padding: 16px 16px 24px; }
  .screen-grid, .playlist-grid, .board-grid { grid-template-columns: minmax(0, 1fr); }
  .item-row { grid-template-columns: 72px minmax(0, 1fr); }
  .item-row__handle { display: none; }
  .item-row__controls { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; }

  .bottom-nav {
    position: fixed; right: 0; bottom: 0; left: 0; z-index: 60; display: flex;
    padding: 4px 4px env(safe-area-inset-bottom); border-top: 1px solid var(--border); background: var(--surface);
  }
  .bottom-nav__link {
    display: flex; flex: 1 1 0; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 0; min-height: 56px;
    padding: 4px 2px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted);
    font: inherit; font-size: 11px; font-weight: 550; text-decoration: none !important; cursor: pointer;
  }
  .bottom-nav__link span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bottom-nav__link.is-active { color: var(--accent-text); }
  .bottom-nav__link.is-active .icon { color: var(--accent); }

  /* Editores: la barra de guardar ocupa el lugar del menú inferior (una sola barra abajo) */
  .app.has-dock .bottom-nav { display: none; }
  .app.has-dock .page-header__actions {
    position: fixed; right: 0; bottom: 0; left: 0; z-index: 60;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--surface); box-shadow: 0 -6px 16px rgba(0, 0, 0, .12);
  }
  .app.has-dock .save-bar { width: 100%; }
  .app.has-dock .save-bar__state { flex: 1 1 auto; min-width: 0; }
  .app.has-dock .save-bar .btn--primary { flex: 0 1 auto; }

  /* Toasts arriba de la barra de abajo, a lo ancho */
  .toasts { right: 12px; bottom: calc(80px + env(safe-area-inset-bottom)); left: 12px; max-width: none; }

  /* Modales: casi a pantalla completa; "Más" sale desde abajo */
  .modal-backdrop { padding: 12px; }
  .modal { max-height: calc(100vh - 24px); }
  .modal__footer { flex-wrap: wrap; }
  .modal-backdrop--sheet { place-items: end stretch; padding: 0; }
  .modal--sheet { max-width: none; border-radius: 14px 14px 0 0; padding-bottom: env(safe-area-inset-bottom); }

  /* En el celular no hay hover: la explicación del botón va escrita */
  .screen-card__actions > .btn:first-child { flex: 1 1 auto; }
  .board-card__actions > .btn:first-child { flex: 1 1 auto; }

  /* Letra de 16 px en los campos: con menos, el iPhone hace zoom al tocarlos */
  input, select, textarea { font-size: 16px; }
  .duration-input { width: 72px; }
}

/* Pantallas táctiles: todo lo que se toca, de al menos ~44 px */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn--sm { min-height: 40px; padding: 0 12px; }
  .icon-btn { width: 40px; height: 40px; }
  .nav__link { padding: 11px 10px; }
  input, select { min-height: 44px; }
  input[type="checkbox"], input[type="radio"] { min-height: 0; width: 20px; height: 20px; }
  .segmented__btn { padding: 9px 13px; }
  .sched { padding: 6px 9px; }
  .switch-field { min-height: 40px; }
  .day-chip { width: 42px; height: 42px; }
  .menu__item { padding: 12px 14px; }
}
