:root {
    --brand-navy: #0c1e42;
    --brand-blue: #1a3a6e;
    --bg: #f4f6fb;
    --bg-2: #f8fafc;
    --panel: #ffffff;
    --panel-2: #f1f5f9;
    --line: #e2e8f0;
    --line-soft: #e2e8f0;
    --text: #0f172a;
    --heading: #0c1e42;
    --muted: #64748b;
    --accent: #3ee0a0;
    --accent-hover: #2bd492;
    --accent-dim: rgba(62, 224, 160, 0.14);
    --accent-ink: #062016;
    --ok: #12b981;
    --ok-dim: rgba(18, 185, 129, 0.14);
    --amber: #b45309;
    --amber-dim: #fefce8;
    --danger: #b91c1c;
    --danger-dim: #fef2f2;
    --info: #3ee0a0;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12);
    --radius: 12px;
    --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
    --touch: 44px;
    --btn-h: 42px;
    --header-h: 52px;
    --header-bg: #0c1e42;
    --header-border: #1e3a5f;
    --header-chip-bg: #1a3a6e;
    --header-chip-border: #2a4a8b;
    --header-chip-hover: #234878;
    --nav-menu-bg: #122a52;
    --nav-menu-bg-2: #1a3a6e;
    --nav-active: rgba(62, 224, 160, 0.22);
    --focus-ring: rgba(62, 224, 160, 0.28);
    --btn-border: #cbd5e1;
    --btn-hover: #e2e8f0;
    --label: #334155;
    --input-border: #cbd5e1;
    --th-bg: #f1f5f9;
    --th-fg: #475569;
    --row-odd: #fafbfc;
    --row-hover: rgba(62, 224, 160, 0.08);
    --toolbar-bg: #f8fafc;
    --pill-bg: rgba(62, 224, 160, 0.12);
    --pill-fg: #0f766e;
    --pill-border: rgba(45, 212, 146, 0.35);
    --pill-on-bg: #dcfce7;
    --pill-on-fg: #166534;
    --pill-on-border: #86efac;
    --danger-border: #fecaca;
    --danger-hover: #fee2e2;
    --banner-ok-bg: #ecfdf5;
    --banner-ok-border: #86efac;
    --pending-bg: #fffbeb;
    --pending-border: #fde047;
    --preview-bg: #f8fafc;
    --invalid: #f87171;
    --safe-t: env(safe-area-inset-top, 0px);
    --safe-r: env(safe-area-inset-right, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-l: env(safe-area-inset-left, 0px);
    color-scheme: light;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --brand-navy: #eef3f8;
    --brand-blue: #161d28;
    --bg: #07090d;
    --bg-2: #0c1017;
    --panel: #10161f;
    --panel-2: #161d28;
    --line: #243041;
    --line-soft: rgba(255, 255, 255, 0.06);
    --text: #eef3f8;
    --heading: #f4f7fb;
    --muted: #9aa8b8;
    --accent: #3ee0a0;
    --accent-hover: #54e8ad;
    --accent-dim: rgba(62, 224, 160, 0.16);
    --accent-ink: #062016;
    --ok: #3ee0a0;
    --ok-dim: rgba(62, 224, 160, 0.16);
    --amber: #f0b429;
    --amber-dim: rgba(240, 180, 41, 0.16);
    --danger: #ff6b7a;
    --danger-dim: rgba(255, 107, 122, 0.16);
    --info: #3ee0a0;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    --header-bg: #0c1017;
    --header-border: #243041;
    --header-chip-bg: #161d28;
    --header-chip-border: #243041;
    --header-chip-hover: #1c2532;
    --nav-menu-bg: #10161f;
    --nav-menu-bg-2: #161d28;
    --nav-active: rgba(62, 224, 160, 0.18);
    --focus-ring: rgba(62, 224, 160, 0.28);
    --btn-border: #2a3545;
    --btn-hover: #1c2532;
    --label: #c5d0dc;
    --input-border: #2a3545;
    --th-bg: #0c1017;
    --th-fg: #9aa8b8;
    --row-odd: rgba(255, 255, 255, 0.025);
    --row-hover: rgba(62, 224, 160, 0.08);
    --toolbar-bg: #0c1017;
    --pill-bg: rgba(62, 224, 160, 0.14);
    --pill-fg: #3ee0a0;
    --pill-border: rgba(62, 224, 160, 0.28);
    --pill-on-bg: rgba(62, 224, 160, 0.16);
    --pill-on-fg: #3ee0a0;
    --pill-on-border: rgba(62, 224, 160, 0.35);
    --danger-border: rgba(255, 107, 122, 0.35);
    --danger-hover: rgba(255, 107, 122, 0.22);
    --banner-ok-bg: rgba(62, 224, 160, 0.12);
    --banner-ok-border: rgba(62, 224, 160, 0.32);
    --pending-bg: rgba(240, 180, 41, 0.14);
    --pending-border: rgba(240, 180, 41, 0.35);
    --preview-bg: #0c1017;
    --invalid: #ff6b7a;
    scrollbar-color: #2a3545 #0c1017;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
    font-size: 0.9375rem;
    transition: background-color 0.35s ease, color 0.25s ease;
}
body.nav-lock { overflow: hidden; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
img { max-width: 100%; height: auto; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
code { font-family: var(--mono); font-size: 0.92em; background: var(--panel-2); padding: 0.1em 0.35em; border-radius: 4px; }

.app { min-height: 100vh; min-height: 100dvh; }

.header {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: var(--header-h);
    padding: 6px max(14px, var(--safe-r)) 6px max(10px, var(--safe-l));
    padding-top: max(6px, var(--safe-t));
    background: var(--header-bg);
    color: #fff;
    width: 100%;
    border-bottom: 1px solid var(--header-border);
    box-shadow: var(--shadow);
    box-sizing: border-box;
}
.header__tools {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: auto;
}

.menu-toggle {
    display: inline-flex;
    appearance: none; border: 0; background: transparent;
    color: #fff; border-radius: 8px; cursor: pointer;
    align-items: center; justify-content: flex-start;
    gap: 8px;
    min-width: 40px; min-height: 40px;
    margin: 0; padding: 6px 10px;
    flex-shrink: 0;
    font: inherit; font-weight: 700; font-size: 15px;
    letter-spacing: 0.02em;
    -webkit-tap-highlight-color: transparent;
}
.menu-toggle__icon { width: 20px; height: 20px; flex-shrink: 0; }
.menu-toggle__label {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.menu-toggle .brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}
.menu-toggle:hover, .menu-toggle:focus-visible { background: rgba(255, 255, 255, 0.12); outline: none; }
.menu-toggle:active { background: rgba(255, 255, 255, 0.12); }

.nav-backdrop {
    position: fixed;
    top: var(--header-h);
    right: 0; bottom: 0; left: 0;
    z-index: 1090;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}
.nav-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.nav {
    flex: 1;
    min-width: 0;
}
.nav__list {
    display: flex;
    align-items: center;
    gap: 2px;
    list-style: none;
    margin: 0;
    padding: 0;
}
.nav__list > li { flex-shrink: 0; }

.nav-item,
.nav-group-toggle {
    display: flex;
    align-items: center;
    gap: 7px;
    box-sizing: border-box;
    min-height: 40px;
    padding: 8px 10px;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    white-space: nowrap;
    transition: background 0.2s ease, color 0.2s ease;
}
.nav-item svg,
.nav-group-toggle svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.92; }
.nav-item:hover,
.nav-group-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    text-decoration: none;
}
.nav-item.is-active,
.nav-group.has-active > .nav-group-toggle {
    background: var(--nav-active);
    color: #fff;
    box-shadow: inset 0 -2px 0 var(--accent);
}
.nav-item.is-active svg,
.nav-group.has-active > .nav-group-toggle svg { opacity: 1; }
.nav-item--exit { color: #fca5a5; }
.nav-item--exit:hover { background: rgba(239, 68, 68, 0.16); color: #fecaca; }

.nav-count {
    font-size: 11px; color: rgba(255, 255, 255, 0.75);
    background: rgba(255, 255, 255, 0.12); padding: 1px 7px; border-radius: 999px;
    min-width: 1.6em; text-align: center;
}
.nav-item.is-active .nav-count { color: var(--accent-ink); background: var(--accent); }

.nav-group { position: relative; }
.nav-group-toggle {
    width: 100%;
    margin: 0;
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.85);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-align: left;
    cursor: pointer;
}
.nav-group-toggle__main {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
}
.nav-group-toggle:hover,
.nav-group-toggle:focus-visible {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    outline: none;
}
.nav-group.is-open > .nav-group-toggle {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}
.nav-group-caret {
    width: 14px; height: 14px;
    opacity: 0.75;
    transition: transform 0.22s ease;
}
.nav-group.is-open .nav-group-caret { transform: rotate(180deg); }

.nav-subnav {
    list-style: none;
    margin: 0;
    padding: 8px;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 220px;
    z-index: 20;
    background: linear-gradient(180deg, var(--nav-menu-bg) 0%, var(--nav-menu-bg-2) 100%);
    border: 1px solid var(--header-chip-border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    visibility: hidden;
    opacity: 0;
    transform: translateY(6px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
}
.nav-group.is-open > .nav-subnav {
    visibility: visible;
    opacity: 1;
    transform: none;
    pointer-events: auto;
}
.nav-subnav .nav-item {
    width: 100%;
    margin: 2px 0;
    font-size: 0.875rem;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
}
.nav-subnav .nav-item.is-active {
    box-shadow: inset 3px 0 0 var(--accent);
}

.nav-status {
    display: inline-flex; align-items: center; gap: 7px;
    color: rgba(255, 255, 255, 0.85); font-size: 12px;
    background: var(--header-chip-bg); border: 1px solid var(--header-chip-border);
    border-radius: 999px; padding: 6px 10px;
    white-space: nowrap;
}
.live-dot {
    width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
    box-shadow: 0 0 0 0 rgba(62, 224, 160, 0.65);
    animation: pulse 1.8s infinite;
    flex-shrink: 0;
}
.live-dot.is-off { background: #ef4444; box-shadow: none; animation: none; }
@keyframes pulse {
    70% { box-shadow: 0 0 0 8px rgba(62, 224, 160, 0); }
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    padding: 0;
    border: 1px solid var(--header-chip-border);
    border-radius: 999px;
    background: var(--header-chip-bg);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.12s ease;
}
.theme-toggle:hover,
.theme-toggle:focus-visible {
    background: var(--header-chip-hover);
    border-color: var(--header-chip-border);
    outline: none;
}
.theme-toggle:active { transform: scale(0.96); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle__icon--light { display: none; }
html[data-theme="dark"] .theme-toggle__icon--dark { display: none; }
html[data-theme="dark"] .theme-toggle__icon--light { display: block; }
.theme-toggle--login {
    position: absolute;
    top: max(16px, var(--safe-t));
    right: max(16px, var(--safe-r));
    z-index: 2;
    border-color: var(--btn-border);
    background: var(--panel);
    color: var(--text);
    box-shadow: var(--shadow);
}
html[data-theme="dark"] .theme-toggle--login {
    background: var(--panel-2);
    border-color: var(--btn-border);
    color: var(--text);
}

.main {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: clip;
    padding-top: calc(var(--header-h) + 20px);
    padding-right: max(28px, var(--safe-r));
    padding-bottom: max(56px, calc(24px + var(--safe-b)));
    padding-left: max(28px, var(--safe-l));
}

.page-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 16px; flex-wrap: wrap;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--line);
}
.page-head h1 {
    margin: 0;
    font-size: clamp(1.25rem, 2.2vw, 1.6rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--heading);
}
.page-head__subtitle {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}
.page-head__actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.user-menu { position: relative; flex-shrink: 0; }
.user-chip {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--header-chip-bg); border: 1px solid var(--header-chip-border);
    border-radius: 999px; padding: 4px 10px 4px 4px;
    color: #fff; font: inherit; font-size: 0.82rem; font-weight: 500;
    max-width: 200px;
    cursor: pointer;
}
.user-chip:hover,
.user-chip:focus-visible {
    background: var(--header-chip-hover);
    outline: none;
}
.user-chip[aria-expanded="true"] {
    background: var(--header-chip-hover);
    border-color: rgba(255, 255, 255, 0.28);
}
.user-chip .user-name {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-chip .avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--accent); color: var(--accent-ink);
    font-size: 0.7rem; font-weight: 700;
    display: grid; place-items: center; flex-shrink: 0;
}
.user-menu__caret {
    width: 14px; height: 14px; flex-shrink: 0; opacity: 0.8;
    transition: transform 0.18s ease;
}
.user-chip[aria-expanded="true"] .user-menu__caret { transform: rotate(180deg); }
.user-menu__panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 1200;
    min-width: 200px;
    padding: 8px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}
.user-menu__panel[hidden] { display: none; }
.user-menu__meta {
    padding: 8px 10px 10px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 6px;
}
.user-menu__meta strong {
    display: block;
    color: var(--heading);
    font-size: 0.9rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-menu__meta span {
    color: var(--muted);
    font-size: 0.75rem;
}
.user-menu__logout {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--danger);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem;
}
.user-menu__logout svg { width: 16px; height: 16px; flex-shrink: 0; }
.user-menu__logout:hover,
.user-menu__logout:focus-visible {
    background: var(--danger-dim);
    color: var(--danger);
    text-decoration: none;
    outline: none;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}
.stat {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px 18px; position: relative; overflow: hidden;
    box-shadow: var(--shadow);
    transition: box-shadow .2s ease, transform .2s ease;
}
.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
a.stat-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    border-color: var(--banner-ok-border);
}
a.stat-link.is-live strong { color: var(--ok); }
a.stat-link:hover,
a.stat-link:focus-visible {
    border-color: var(--accent);
    outline: none;
}
.page-head__actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.panel-head .live-dot { margin-right: 2px; }
.stat span {
    display: block; color: var(--muted); font-size: 11px;
    letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600;
}
.stat strong {
    display: block; font-size: 26px; margin-top: 6px;
    letter-spacing: -0.03em; font-weight: 700; color: var(--heading);
}

.panel {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); overflow: hidden;
}
.panel-narrow { max-width: 820px; }
.panel-head, .toolbar {
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
    padding: 12px 16px; border-bottom: 1px solid var(--line);
    background: var(--toolbar-bg);
}
.panel-body { padding: 18px; }
.muted { color: var(--muted); }
.grow { flex: 1; min-width: 160px; }
.ms-auto { margin-left: auto; }
.stack-gap { margin-bottom: 18px; }
.w-select { max-width: 240px; }
.w-group { max-width: 280px; }

.btn, .icon-btn {
    appearance: none; border: 1px solid var(--btn-border); background: var(--panel-2);
    color: var(--text); border-radius: 10px; cursor: pointer;
    font: inherit; font-weight: 600;
    box-shadow: var(--shadow);
    transition: background .2s ease, border-color .2s ease, transform .12s ease, opacity .15s ease;
}
.btn {
    min-height: var(--btn-h); padding: 8px 16px;
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    text-decoration: none; line-height: 1.2; white-space: nowrap; font-size: 0.875rem;
}
.btn:hover { background: var(--btn-hover); text-decoration: none; color: var(--text); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent-hover); }
.btn-primary:hover { background: var(--accent-hover); color: var(--accent-ink); }
.btn-amber { background: #f59e0b; color: #fff; border-color: #d97706; }
.btn-danger { background: var(--danger-dim); color: var(--danger); border-color: var(--danger-border); }
.btn-danger:hover { background: var(--danger-hover); color: var(--danger); }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--panel-2); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.icon-btn {
    width: 40px; height: 40px; min-width: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0; font-size: 16px;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--btn-hover); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 0.85rem; color: var(--label); font-weight: 600; }
.field .hint, .hint { font-size: 12px; color: var(--muted); line-height: 1.45; }
.hint-row { padding-top: 0; }
.logo-assign { padding-top: 0; }
.logo-assign .field { margin-bottom: 8px; }
.logo-assign .btn { min-height: 40px; width: 100%; }
.input, select, textarea {
    width: 100%; background: var(--panel); color: var(--text);
    border: 1px solid var(--input-border); border-radius: 8px;
    padding: 11px 12px; font: inherit; font-size: 16px;
    min-height: var(--touch);
    color-scheme: inherit;
    transition: border-color .2s ease, box-shadow .2s ease;
}
select { min-height: var(--touch); }
textarea { min-height: 96px; resize: vertical; }
.input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--focus-ring);
}
.input.is-invalid, select.is-invalid { border-color: var(--invalid); }
.error { color: var(--danger); font-size: 13px; font-weight: 500; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-start { align-items: start; }
.check {
    display: flex; align-items: flex-start; gap: 10px;
    color: var(--text); font-size: 14px; line-height: 1.4;
    min-height: 24px;
}
.field .check { margin-top: 8px; }
.check input[type="checkbox"],
input[type="checkbox"] {
    width: 20px; height: 20px; min-width: 20px; margin: 1px 0 0;
    accent-color: var(--accent); cursor: pointer;
}

.table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.7rem 0.85rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th {
    font-size: 0.8rem; letter-spacing: 0.04em; text-transform: uppercase;
    color: var(--th-fg); font-weight: 600; background: var(--th-bg);
    position: sticky; top: 0; z-index: 1;
}
tr:nth-child(odd) td { background: var(--row-odd); }
tr:hover td { background: var(--row-hover); }
td[data-label="Estado"] {
    white-space: nowrap;
}
.mono { font-family: var(--mono); font-size: 12px; color: var(--muted); word-break: break-word; }
.url-cell {
    max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-family: var(--mono); font-size: 12px; color: var(--muted);
}
.channel { display: flex; align-items: center; gap: 12px; min-width: 0; }
.channel strong { font-weight: 600; display: block; word-break: break-word; color: var(--heading); }
.logo-thumb {
    width: 40px; height: 40px; border-radius: 10px; background: var(--bg-2);
    border: 1px solid var(--line); object-fit: contain; flex-shrink: 0;
}
.logo-thumb.is-empty {
    display: flex; align-items: center; justify-content: center;
    color: var(--muted); font-size: 11px;
}

.pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 999px;
    background: var(--pill-bg); color: var(--pill-fg);
    font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em;
    border: 1px solid var(--pill-border);
    flex-shrink: 0;
    white-space: nowrap;
    word-break: normal;
}
.pill-off { background: var(--danger-dim); color: var(--danger); border-color: var(--danger-border); }
.pill-on { background: var(--pill-on-bg); color: var(--pill-on-fg); border-color: var(--pill-on-border); }
.pill-on .live-dot, .pill-off .live-dot { width: 6px; height: 6px; }
.pill-pkg-a { background: var(--pill-on-bg); color: var(--pill-on-fg); border-color: var(--pill-on-border); }
.pill-pkg-b {
    background: rgba(59, 130, 246, 0.14);
    color: #1d4ed8;
    border-color: rgba(59, 130, 246, 0.35);
}
html[data-theme="dark"] .pill-pkg-b {
    background: rgba(96, 165, 250, 0.16);
    color: #93c5fd;
    border-color: rgba(96, 165, 250, 0.35);
}
.package-perms {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.activate-list-form {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    min-width: 180px;
}
.package-perms .input,
.activate-list-form .input {
    min-height: 36px;
    width: auto;
    max-width: 280px;
}

.row-actions {
    display: inline-flex; align-items: center; gap: 4px;
    flex-wrap: nowrap; background: var(--bg-2);
    border: 1px solid var(--line); border-radius: 10px; padding: 3px;
}
.row-actions .btn, .row-actions .icon-btn {
    border: 0; background: transparent; border-radius: 7px;
    height: 34px; min-height: 34px; min-width: 34px; padding: 0 8px; font-size: 12px;
    box-shadow: none;
}
.row-actions .icon-btn { width: 34px; }
.row-actions .btn:hover, .row-actions .icon-btn:hover { background: var(--btn-hover); }
.row-actions .btn-primary {
    background: var(--accent);
    color: var(--accent-ink);
}
.row-actions .btn-primary:hover {
    background: var(--accent-hover);
    color: var(--accent-ink);
}
.row-actions .btn-danger { color: var(--danger); }
.row-actions .btn-danger:hover { background: var(--danger-dim); color: var(--danger); }
.row-off td { opacity: 0.62; }
.row-off td.cell-actions { opacity: 1; }

.form-actions {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    margin-top: 6px;
}
.form-actions .btn { min-height: var(--touch); }

.empty { text-align: center; padding: 52px 20px; color: var(--muted); }
.empty h3 { color: var(--heading); margin: 0 0 8px; }
.empty .btn { margin: 6px 4px 0; }

.dropzone {
    border: 1.5px dashed var(--input-border); border-radius: var(--radius);
    padding: 36px 20px; text-align: center; background: var(--bg-2); cursor: pointer;
}
.dropzone.is-over { border-color: var(--accent); background: var(--accent-dim); }
.dropzone strong { display: block; margin-bottom: 6px; font-size: 16px; color: var(--heading); }
.formats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
.format-card {
    background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px;
    box-shadow: var(--shadow);
}
.format-card h3 { margin: 0 0 8px; font-size: 14px; color: var(--heading); }
.format-card pre {
    margin: 0; font-family: var(--mono); font-size: 11px; color: var(--muted);
    white-space: pre-wrap; word-break: break-word;
}

.logo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.logo-card {
    background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
    overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.logo-card .preview {
    height: 120px; display: flex; align-items: center; justify-content: center;
    background: var(--preview-bg); padding: 12px;
}
.logo-card .preview img { max-height: 96px; }
.logo-card .meta { padding: 12px; }
.logo-card .meta strong { display: block; font-size: 13px; word-break: break-all; color: var(--heading); }
.logo-card .actions { display: flex; gap: 8px; padding: 0 12px 12px; flex-wrap: wrap; }
.logo-card .actions .btn,
.logo-card .actions label.btn { flex: 1 1 auto; min-height: 40px; }

.toasts {
    position: fixed; right: max(16px, var(--safe-r)); top: max(16px, calc(var(--safe-t) + 60px));
    z-index: 1200;
    display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100% - 32px));
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--info);
    border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow-lg);
    animation: slidein .2s ease-out; font-size: 14px; font-weight: 500; color: var(--text);
}
.toast.success { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--amber); }
@keyframes slidein { from { transform: translateX(16px); opacity: 0; } }

.modal { position: fixed; inset: 0; z-index: 1300; display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(2, 6, 23, 0.62); }
.modal-dialog {
    position: relative; width: min(520px, 100%);
    background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
    box-shadow: var(--shadow-lg); max-height: min(90vh, 100%);
    display: flex; flex-direction: column; overflow: hidden;
}
.modal-header, .modal-footer { display: flex; align-items: center; gap: 10px; padding: 14px 16px; flex-shrink: 0; }
.modal-header { border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 1.05rem; flex: 1; color: var(--heading); font-weight: 700; }
.modal-footer { border-top: 1px solid var(--line); justify-content: flex-end; flex-wrap: wrap; }
.modal-footer .btn { min-height: var(--touch); }
.modal-body { padding: 16px; overflow: auto; }

.banner {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px;
    border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow);
}
.banner-lock { background: var(--danger-dim); border-color: var(--danger-border); }
.banner-ok { background: var(--banner-ok-bg); border-color: var(--banner-ok-border); }
.banner p { max-width: 640px; margin: 6px 0 0; }
.banner .btn { flex-shrink: 0; }

.copy-row { display: flex; gap: 8px; align-items: center; min-width: 0; width: 100%; }
.copy-row .input {
    font-family: var(--mono); font-size: 13px; padding: 8px 10px;
    min-height: 40px; min-width: 0; background: var(--bg-2);
}
.copy-row .btn { flex-shrink: 0; }
.preview-logo { width: 72px; height: 72px; object-fit: contain; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); }

.login {
    width: min(420px, 100%);
    box-shadow: var(--shadow-lg);
    border-radius: 20px;
    position: relative; overflow: hidden;
}
.login::before {
    content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover), var(--accent));
}
.login h1 { margin: 0 0 4px; font-size: 1.4rem; color: var(--heading); font-weight: 700; letter-spacing: -0.03em; }
.brand-mark {
    width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
    display: block;
    object-fit: contain;
    box-shadow: 0 4px 12px rgba(62, 224, 160, 0.28);
}
.login .brand-row { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.login-page {
    position: relative;
    min-height: 100vh; min-height: 100dvh;
    display: grid; place-items: center;
    padding: max(24px, var(--safe-t)) max(20px, var(--safe-r)) max(24px, var(--safe-b)) max(20px, var(--safe-l));
    background:
        radial-gradient(ellipse 80% 60% at 50% -10%, rgba(62, 224, 160, 0.22), transparent 55%),
        radial-gradient(ellipse 70% 50% at 100% 100%, rgba(18, 185, 129, 0.12), transparent 50%),
        var(--bg);
}
html[data-theme="dark"] .login-page {
    background:
        radial-gradient(ellipse 80% 60% at 50% -10%, rgba(62, 224, 160, 0.16), transparent 55%),
        radial-gradient(ellipse 70% 50% at 100% 100%, rgba(62, 224, 160, 0.08), transparent 50%),
        var(--bg);
}
html[data-theme="dark"] code {
    background: var(--bg-2);
    color: var(--accent);
    border: 1px solid var(--line);
}
.login .btn { width: 100%; min-height: 50px; font-size: 0.9375rem; }

.help-list { margin: 0; padding-left: 18px; color: var(--muted); }
.help-list li { margin: 8px 0; }
.page-title { margin: 0 0 8px; font-size: 18px; color: var(--heading); font-weight: 700; }

.public-page {
    position: relative;
    min-height: 100vh; min-height: 100dvh;
    display: grid; place-items: center;
    padding: max(24px, var(--safe-t)) max(20px, var(--safe-r)) max(24px, var(--safe-b)) max(20px, var(--safe-l));
    background: var(--bg);
}
.activate-card { width: min(640px, 100%); }
.activate-card h1 { margin: 0 0 8px; font-size: 1.6rem; color: var(--heading); font-weight: 700; }
.activate-card .facts {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; margin: 18px 0;
}
.activate-card .item span {
    display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
}
.activate-card .item strong { font-size: 16px; word-break: break-word; color: var(--heading); }
.activate-card .ok { color: var(--ok); }
.activate-card .err { color: var(--danger); }
.activate-card .btn { min-height: var(--touch); margin-top: 8px; }

.fab {
    display: none;
    position: fixed;
    right: max(16px, var(--safe-r));
    bottom: max(16px, var(--safe-b));
    z-index: 30;
    width: 56px; height: 56px; border-radius: 16px;
    background: var(--accent); color: var(--accent-ink);
    box-shadow: 0 8px 24px rgba(62, 224, 160, 0.35);
    align-items: center; justify-content: center;
    text-decoration: none; font-size: 28px; font-weight: 600; line-height: 1;
}
.fab:hover { background: var(--accent-hover); text-decoration: none; color: var(--accent-ink); }

.wrap-ua { max-width: 280px; word-break: break-word; }
.copy-row-next { margin-top: 6px; }
.pending-panel { border-color: var(--pending-border); background: var(--pending-bg); }
.online-panel { border-color: var(--banner-ok-border); }
.online-panel .panel-head strong {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.dropzone + .form-actions { margin-top: 16px; }
.btn, .icon-btn, .nav-item, .nav-group-toggle, .check, .fab, .menu-toggle, .theme-toggle, .user-chip { touch-action: manipulation; }
.btn:focus-visible, .icon-btn:focus-visible, .nav-item:focus-visible, .nav-group-toggle:focus-visible, .menu-toggle:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px;
}
body:has(.modal:not([hidden])) { overflow: hidden; }

@media (min-width: 1101px) {
    .menu-toggle { pointer-events: none; }
    .menu-toggle__icon { display: none; }
    .nav-group-toggle { gap: 6px; }
    .nav-item svg { width: 16px; height: 16px; }
}

@media (max-width: 1280px) and (min-width: 1101px) {
    .nav-item svg,
    .nav-group-toggle__main svg { display: none; }
    .nav-item, .nav-group-toggle { padding: 8px 9px; font-size: 13px; }
    .nav-group-toggle { font-size: 0.72rem; }
}

@media (max-width: 1100px) {
    .url-cell { max-width: 160px; }
    .stats, .formats, .grid-2 { grid-template-columns: 1fr 1fr; }
    .menu-toggle { display: inline-flex; }
    .nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0; right: 0;
        background: linear-gradient(180deg, var(--nav-menu-bg) 0%, var(--nav-menu-bg-2) 55%, var(--header-bg) 100%);
        border-bottom: 1px solid var(--header-border);
        box-shadow: 0 18px 40px rgba(9, 20, 40, 0.28);
        padding: 10px 12px 14px;
        padding-bottom: max(14px, var(--safe-b));
        max-height: min(78vh, calc(100dvh - var(--header-h)));
        overflow: auto;
        z-index: 45;
    }
    .header.nav-open .nav { display: block; }
    .nav__list {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
    }
    .nav__list > li { width: 100%; }
    .nav-item,
    .nav-group-toggle {
        min-height: var(--touch);
        font-size: 15px;
        padding: 11px 12px;
        width: 100%;
    }
    .nav-group-toggle { font-size: 0.78rem; justify-content: space-between; }
    .nav-item.is-active,
    .nav-group.has-active > .nav-group-toggle {
        box-shadow: inset 3px 0 0 var(--accent);
    }
    .nav-item svg,
    .nav-group-toggle svg { width: 20px; height: 20px; }
    .nav-count { margin-left: auto; }
    .nav-subnav {
        position: static;
        min-width: 0;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        visibility: visible;
        opacity: 1;
        transform: none;
        pointer-events: none;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.25s ease;
    }
    .nav-group.is-open > .nav-subnav {
        pointer-events: auto;
        max-height: 480px;
        padding: 0 0 6px;
    }
    .nav-subnav .nav-item { padding-left: 24px; }
    .hide-sm { display: none !important; }
    .nav-status-text { display: none; }
    .user-chip { padding-right: 8px; max-width: none; }
    .user-chip .user-name { display: none; }
    .main { padding-left: 16px; padding-right: max(16px, var(--safe-r)); }
    .app[data-page="canales"] .fab { display: flex; }
    .app[data-page="canales"] .main { padding-bottom: max(88px, calc(24px + var(--safe-b))); }
}

@media (max-width: 768px) {
    :root { --header-h: 50px; }
    .header {
        padding-left: max(10px, var(--safe-l));
        padding-right: max(10px, var(--safe-r));
        gap: 6px;
    }
    .menu-toggle {
        flex: 1 1 auto;
        justify-content: flex-start;
        overflow: hidden;
        min-height: 44px;
    }
    .w-select, .w-group { max-width: none; width: 100%; }
    .grow { min-width: 0; width: 100%; }
    .toolbar { align-items: stretch; }
    .toolbar .input,
    .toolbar select,
    .toolbar .btn { width: 100%; }
    .toolbar .check { width: 100%; }
    .ms-auto { margin-left: 0; width: 100%; text-align: left; }
    .panel-head { align-items: stretch; }
    .panel-head .btn, .panel-head form { width: 100%; }
    .panel-head form .btn { width: 100%; }
    .page-head { align-items: stretch; }
    .page-head__actions { width: 100%; }
    .page-head__actions .btn { flex: 1; }
    .banner { flex-direction: column; align-items: stretch; }
    .banner .btn { width: 100%; }
    .copy-row { flex-direction: column; align-items: stretch; }
    .copy-row .btn { width: 100%; }
    .form-actions .btn { flex: 1 1 100%; }

    .table-wrap { overflow: visible; }
    .table-wrap table,
    .table-wrap thead,
    .table-wrap tbody,
    .table-wrap th,
    .table-wrap td,
    .table-wrap tr { display: block; width: 100%; }
    .table-wrap thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
    .table-wrap tbody { padding: 12px; display: flex; flex-direction: column; gap: 12px; }
    .table-wrap tr {
        background: var(--panel) !important;
        border: 1px solid var(--line);
        border-radius: 12px;
        padding: 12px 14px;
        box-shadow: var(--shadow);
    }
    .table-wrap tr:nth-child(odd) td,
    .table-wrap tr:hover td { background: transparent; }
    .table-wrap td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        padding: 8px 0;
        border-bottom: 0;
        white-space: normal;
        min-width: 0;
        background: transparent !important;
    }
    .table-wrap td:last-child { white-space: normal; }
    .table-wrap td[data-label]::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        font-weight: 600;
        flex: 0 0 92px;
        padding-top: 3px;
    }
    .table-wrap td.cell-check {
        justify-content: flex-start;
        padding-top: 0;
        padding-bottom: 4px;
    }
    .table-wrap td.cell-check input { width: 22px; height: 22px; }
    .table-wrap td.cell-main { padding-top: 0; }
    .table-wrap td.cell-main .channel { width: 100%; }
    .table-wrap .url-cell {
        max-width: none;
        white-space: normal;
        word-break: break-all;
        text-align: right;
    }
    .table-wrap td.cell-actions,
    .table-wrap td[data-label="URL"] {
        display: block;
        padding-top: 12px;
        margin-top: 4px;
        border-top: 1px solid var(--line);
    }
    .table-wrap td[data-label="URL"]::before,
    .table-wrap td[data-label="Detalle"]::before {
        display: block;
        margin-bottom: 6px;
        flex: none;
    }
    .table-wrap td.cell-actions form { width: 100%; }
    .table-wrap td.cell-actions form .btn { width: 100%; }
    .wrap-ua { max-width: none; }
    .table-wrap td.cell-actions .row-actions,
    .row-actions {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
        background: transparent;
        border: 0;
        padding: 0;
        gap: 8px;
    }
    .table-wrap td.cell-actions .row-actions .btn,
    .table-wrap td.cell-actions .row-actions .icon-btn,
    .row-actions .btn,
    .row-actions .icon-btn {
        background: var(--panel-2);
        border: 1px solid var(--line);
        min-height: var(--touch);
        height: auto;
        min-width: var(--touch);
        padding: 0 12px;
        font-size: 13px;
    }
    .row-actions .btn { flex: 1 1 calc(50% - 8px); }
    .row-actions form { flex: 1 1 calc(50% - 8px); min-width: 0; }
    .row-actions form .btn { width: 100%; flex: 1 1 auto; }
    .row-off td { opacity: 1; }
    .row-off { opacity: 0.78; }

    .toasts {
        left: 12px; right: 12px; top: auto;
        bottom: max(16px, var(--safe-b));
        width: auto;
    }
    .app[data-page="canales"] .toasts { bottom: max(80px, calc(16px + var(--safe-b))); }

    .modal { padding: 0; place-items: end center; }
    .modal-dialog {
        width: 100%;
        border-radius: 20px 20px 0 0;
        max-height: min(92dvh, 100%);
    }
    .modal-footer .btn { flex: 1 1 calc(50% - 8px); }
}

@media (max-width: 380px) {
    .menu-toggle__label { max-width: 64px; }
}
@media (max-width: 340px) {
    .menu-toggle__label { display: none; }
}

@media (max-width: 640px) {
    .stats, .formats, .grid-2, .activate-card .facts { grid-template-columns: 1fr; }
    .page-head h1 { font-size: 1.25rem; }
    .stat strong { font-size: 22px; }
    .logo-grid { grid-template-columns: 1fr; }
    .login h1 { font-size: 1.25rem; }
    .activate-card h1 { font-size: 1.35rem; }
    .empty { padding: 36px 16px; }
    .empty .btn { display: flex; width: 100%; margin: 8px 0 0; }
}

@media (min-width: 981px) {
    .input, select, textarea { font-size: 14px; min-height: 40px; }
}
