:root {
    --bg: #eef2f5;
    --surface: #ffffff;
    --surface-soft: #f7f9fb;
    --text: #17212b;
    --muted: #6b7785;
    --line: #d9e1e8;
    --primary: #0f8f83;
    --primary-dark: #087268;
    --danger: #c0392b;
    --warning: #a66a00;
    --shadow: 0 16px 40px rgba(26, 38, 52, .10);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, Helvetica, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary-dark); text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
input, select, textarea, button { font: inherit; }

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #0d2b36 0%, #17645d 48%, #f2b84b 100%);
    padding: 24px;
}
.login-card {
    width: min(980px, 100%);
    min-height: 520px;
    display: grid;
    grid-template-columns: 1.1fr .9fr;
    background: rgba(255,255,255,.94);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.login-copy { padding: 58px; background: #10232b; color: #fff; display: flex; flex-direction: column; justify-content: center; }
.login-copy h1 { font-size: 44px; line-height: 1.05; margin-bottom: 18px; letter-spacing: 0; }
.login-copy p { color: #c8d5db; font-size: 17px; line-height: 1.6; max-width: 460px; }
.login-form { padding: 58px 44px; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.login-form h2 { font-size: 26px; }
.login-form input { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; }
.sidebar { background: #111d27; color: #dce6ec; padding: 22px; }
.brand { color: #fff; display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 28px; }
.brand-mark { background: var(--primary); color: #fff; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 6px; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav a { color: #dce6ec; padding: 11px 12px; border-radius: 6px; }
.sidebar nav a:hover { background: rgba(255,255,255,.08); }
.nav-section { color: #8da0ae; font-size: 12px; text-transform: uppercase; margin: 18px 12px 6px; }
.main { min-width: 0; padding: 24px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px 18px; }
.topbar span { color: var(--muted); margin-left: 8px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.router-pill { border: 1px solid var(--line); background: var(--surface-soft); border-radius: 999px; padding: 7px 12px; color: var(--text) !important; }

.page-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 18px; }
.page-heading h1 { font-size: 30px; letter-spacing: 0; margin-bottom: 0; }
.eyebrow { display: block; color: var(--primary-dark); text-transform: uppercase; font-size: 12px; font-weight: 700; letter-spacing: .08em; margin-bottom: 7px; }
.muted { color: var(--muted); }

.panel, .stat, .router-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 22px rgba(28, 41, 56, .05);
}
.panel { padding: 20px; margin-bottom: 20px; }
.panel-header { display: flex; justify-content: space-between; gap: 18px; align-items: center; margin-bottom: 14px; }
.panel-header p { color: var(--muted); margin-bottom: 0; }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { padding: 18px; }
.stat span { color: var(--muted); display: block; margin-bottom: 8px; }
.stat strong { font-size: 30px; }
.split { display: grid; grid-template-columns: minmax(300px, .75fr) minmax(420px, 1.25fr); gap: 20px; align-items: start; }
.router-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.router-card { padding: 18px; display: grid; gap: 10px; text-align: left; }
.router-card.is-selected { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 143, 131, .13); }

.form-grid { display: grid; gap: 13px; }
.form-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.form-grid input, .form-grid select, .search-form input {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    background: #fff;
    color: var(--text);
    min-width: 0;
}
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.checkbox-grid label { border: 1px solid var(--line); border-radius: 6px; padding: 12px; background: var(--surface-soft); }
.checkbox-grid small { display: block; color: var(--muted); margin-left: 22px; }

.button { border: 0; border-radius: 6px; padding: 10px 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; min-height: 40px; }
.button-primary { background: var(--primary); color: #fff; }
.button-primary:hover { background: var(--primary-dark); color: #fff; }
.button-light { background: var(--surface-soft); border: 1px solid var(--line); color: var(--text); }

.alert { border-radius: 6px; padding: 12px 14px; margin-bottom: 16px; border: 1px solid var(--line); background: #fff; }
.alert-success { border-color: #9ad9c2; background: #ebfbf4; color: #146b4d; }
.alert-danger { border-color: #efb2aa; background: #fff1ef; color: #912c20; }
.alert-warning { border-color: #f2d487; background: #fff8e3; color: var(--warning); }
.badge { display: inline-flex; border-radius: 999px; padding: 5px 9px; font-size: 12px; }
.badge.ok { background: #e6f7ef; color: #0d6b45; }
.badge.off { background: #f2f4f6; color: #66717e; }
.badge.warning { background: #fff8e3; color: var(--warning); }
.badge.danger { background: #fff1ef; color: var(--danger); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: 12px 13px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: var(--surface-soft); color: #465464; font-size: 13px; }
tr:last-child td { border-bottom: 0; }
.actions { display: flex; gap: 10px; align-items: center; white-space: nowrap; }
.actions form { margin: 0; }
.link-danger { background: transparent; border: 0; color: var(--danger); cursor: pointer; padding: 0; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { border: 1px solid var(--line); background: var(--surface-soft); border-radius: 999px; padding: 8px 12px; color: var(--text); }
.tabs a.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.search-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-bottom: 18px; }
.log-list { display: grid; gap: 8px; }
.log-list article { border: 1px solid var(--line); border-radius: 6px; padding: 12px; background: var(--surface-soft); display: grid; gap: 6px; }
.empty { padding: 18px; color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; background: var(--surface-soft); }

@media (max-width: 900px) {
    .app-shell, .login-card, .split { grid-template-columns: 1fr; }
    .sidebar { position: static; }
    .stats-grid { grid-template-columns: 1fr; }
    .topbar, .panel-header { align-items: flex-start; flex-direction: column; }
    .login-copy, .login-form { padding: 34px 26px; }
    .search-form { grid-template-columns: 1fr; }
}

body.theme-dark {
    --bg: #0f151c;
    --surface: #17212b;
    --surface-soft: #111a23;
    --text: #edf3f7;
    --muted: #a8b5c1;
    --line: #2a3947;
    --primary: #18b8a8;
    --primary-dark: #55d8cc;
    --danger: #ff7c6e;
    --warning: #f7c667;
    --shadow: 0 16px 40px rgba(0, 0, 0, .30);
}

body.theme-dark table,
body.theme-dark .login-form input,
body.theme-dark .form-grid input,
body.theme-dark .form-grid select,
body.theme-dark .search-form input {
    background: var(--surface);
    color: var(--text);
}

body.theme-dark th { color: var(--muted); }
body.theme-dark .sidebar { background: #0a1016; }
body.theme-dark .button-light { color: var(--text); }
body.theme-dark .alert { background: var(--surface); }

.theme-form { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface-soft); border-radius: 999px; padding: 5px 8px 5px 12px; }
.theme-form label { color: var(--muted); font-size: 12px; }
.theme-form select { border: 0; background: transparent; color: var(--text); outline: 0; }
.inline-form { margin: 0; }
.selected-row td { background: rgba(15, 143, 131, .08); }

.hotspot-form-panel { margin-bottom: 20px; }
.hotspot-create-grid { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)); gap: 13px; align-items: end; }
.hotspot-create-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.hotspot-create-grid input,
.hotspot-create-grid select { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; background: var(--surface); color: var(--text); min-width: 0; }
.hotspot-preview { border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); padding: 10px 12px; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; min-height: 78px; }
.hotspot-preview span { color: var(--muted); font-size: 12px; }
.hotspot-preview strong { word-break: break-word; }
.hotspot-table-wrap { max-height: 620px; }
.hotspot-table th { white-space: nowrap; }
.hotspot-table td { white-space: nowrap; }
.hotspot-table td:nth-child(8) { min-width: 220px; white-space: normal; }
.hotspot-actions { min-width: 220px; }
.link-button { background: transparent; border: 0; color: var(--primary-dark); cursor: pointer; padding: 0; }

@media (max-width: 1100px) {
    .hotspot-create-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

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

.hotspot-page-stats { display: none; }
.hotspot-summary-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 15px; }
.hotspot-summary { border-radius: 6px; padding: 12px 14px; border: 1px solid var(--line); }
.hotspot-summary.info { background: #eaf5ff; color: #205a83; border-color: #b7daf4; }
.hotspot-summary.success { background: #ebfbf4; color: #146b4d; border-color: #9ad9c2; }
.hotspot-summary.warning { background: #fff8e3; color: var(--warning); border-color: #f2d487; }
.hotspot-table-classic { font-size: 13px; }
.hotspot-table-classic th { background: var(--surface-soft); border-right: 1px solid var(--line); }
.hotspot-table-classic td { border-right: 1px solid var(--line); }
.hotspot-table-classic tbody tr:nth-child(even) td { background: rgba(115, 132, 150, .055); }
.hotspot-table-classic tbody tr:hover td { background: rgba(15, 143, 131, .09); }
.status-label { display: inline-flex; border-radius: 3px; padding: 4px 7px; font-size: 12px; font-weight: 700; }
.status-success { background: #1caf9a; color: #fff; }
.status-warning { background: #f6a821; color: #2d2100; }
.comment-cell { min-width: 220px; white-space: normal !important; }
.action-btn { border: 0; border-radius: 4px; padding: 5px 8px; font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; min-height: 28px; }
.action-edit { background: #f6a821; color: #2d2100; }
.action-enable { background: #1caf9a; color: #fff; }
.action-disable { background: var(--surface-soft); color: var(--text); border: 1px solid var(--line); }
.action-delete { background: #d9534f; color: #fff; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(7, 12, 18, .58); display: grid; place-items: center; z-index: 1000; padding: 16px; overflow-y: auto; }
.created-modal { width: min(560px, 100%); max-height: calc(100dvh - 32px); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.created-modal-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; padding: 18px 20px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.created-modal-header h2 { margin-bottom: 0; }
.modal-close { border: 1px solid var(--line); background: var(--surface-soft); color: var(--text); border-radius: 4px; padding: 7px 10px; cursor: pointer; }
.created-modal-body { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 20px; }
.created-modal-body div { border: 1px solid var(--line); border-radius: 6px; padding: 10px; background: var(--surface-soft); }
.created-modal-body span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.created-modal-body strong { word-break: break-word; }
.created-modal-body .wide { grid-column: 1 / -1; }
.created-modal-footer { padding: 14px 20px; border-top: 1px solid var(--line); text-align: right; }
body.theme-dark .hotspot-summary.info { background: #102638; color: #acd8f7; border-color: #27465d; }
body.theme-dark .hotspot-summary.success { background: #0f3029; color: #b7f2df; border-color: #1d5b4d; }
body.theme-dark .hotspot-summary.warning { background: #37280f; color: #f7d68a; border-color: #684d1b; }
@media (max-width: 800px) {
    .hotspot-summary-row, .created-modal-body { grid-template-columns: 1fr; }
}
[hidden] { display: none !important; }
.hotspot-panel-header { align-items: flex-end; }
.table-tools { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.table-search, .table-page-size { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.table-search input, .table-page-size select {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 9px 10px;
    background: var(--surface);
    color: var(--text);
    min-height: 38px;
}
.table-search input { width: min(360px, 58vw); }
.hotspot-panel-classic { overflow: hidden; }
.hotspot-table-wrap { max-height: none; width: 100%; }
.hotspot-table-classic { table-layout: auto; min-width: 920px; }
.hotspot-table-classic th, .hotspot-table-classic td { padding: 10px 11px; }
.hotspot-table-classic th:nth-child(1) { width: 118px; }
.hotspot-table-classic th:nth-child(2) { width: 150px; }
.hotspot-table-classic th:nth-child(3) { width: 140px; }
.hotspot-table-classic th:nth-child(4) { width: 140px; }
.hotspot-table-classic th:nth-child(5) { width: 120px; }
.hotspot-table-classic th:nth-child(7) { width: 238px; }
.sort-button {
    width: 100%;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0;
    font-weight: 700;
    text-align: left;
}
.sort-button::after { content: "sort"; color: var(--muted); font-size: 11px; }
.sort-button[data-direction="asc"]::after { content: "asc"; color: var(--primary-dark); }
.sort-button[data-direction="desc"]::after { content: "desc"; color: var(--primary-dark); }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 14px; color: var(--muted); flex-wrap: wrap; }
.pagination-controls { display: flex; align-items: center; gap: 10px; }
.pagination-controls .button:disabled { opacity: .45; cursor: not-allowed; }
.empty-table-cell { color: var(--muted); text-align: center; padding: 22px !important; }

@media (max-width: 1250px) {
    .hotspot-table-classic { min-width: 840px; }
    .hotspot-actions { min-width: 190px; gap: 6px; flex-wrap: wrap; }
}

@media (max-width: 760px) {
    .main { padding: 16px; }
    .page-heading { align-items: stretch; flex-direction: column; gap: 12px; }
    .table-tools { width: 100%; justify-content: stretch; }
    .table-search { width: 100%; }
    .table-search input { width: 100%; }
    .table-page-size { min-width: 120px; }
    .hotspot-table-wrap { border: 0; overflow: visible; }
    .hotspot-table-classic { min-width: 0; background: transparent; }
    .hotspot-table-classic thead { display: none; }
    .hotspot-table-classic, .hotspot-table-classic tbody, .hotspot-table-classic tr, .hotspot-table-classic td { display: block; width: 100%; }
    .hotspot-table-classic tbody tr {
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--surface);
        margin-bottom: 12px;
        overflow: hidden;
    }
    .hotspot-table-classic td {
        border-right: 0;
        display: grid;
        grid-template-columns: 120px minmax(0, 1fr);
        gap: 12px;
        white-space: normal;
    }
    .hotspot-table-classic td::before {
        content: attr(data-label);
        color: var(--muted);
        font-weight: 700;
        font-size: 12px;
    }
    .hotspot-actions { min-width: 0; white-space: normal; align-items: flex-start; }
    .hotspot-actions::before { align-self: center; }
    .table-footer, .pagination-controls { align-items: stretch; flex-direction: column; width: 100%; }
    .pagination-controls .button { width: 100%; }
}
.users-layout { grid-template-columns: minmax(320px, .72fr) minmax(520px, 1.28fr); }
.user-actions { flex-wrap: wrap; gap: 8px; }
.permissions-form { display: grid; gap: 16px; }
.permission-mode { display: flex; gap: 12px; flex-wrap: wrap; }
.permission-mode label {
    border: 1px solid var(--line);
    background: var(--surface-soft);
    border-radius: 6px;
    padding: 10px 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.permissions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.permissions-grid label {
    border: 1px solid var(--line);
    background: var(--surface-soft);
    border-radius: 8px;
    padding: 13px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
}
.permissions-grid label:has(input:checked) {
    border-color: var(--primary);
    background: rgba(15, 143, 131, .10);
}
.permissions-grid span { font-weight: 700; }
body.theme-dark .permissions-grid label:has(input:checked) { background: rgba(24, 184, 168, .15); }

@media (max-width: 900px) {
    .users-layout { grid-template-columns: 1fr; }
}
/* Ajuste final de tablas: evita anchos rigidos y se adapta antes a pantallas medianas. */
.table-wrap { max-width: 100%; }
.hotspot-table-wrap { overflow-x: auto; }
.hotspot-table-classic { min-width: 0; width: 100%; table-layout: fixed; }
.hotspot-table-classic th:nth-child(1),
.hotspot-table-classic th:nth-child(2),
.hotspot-table-classic th:nth-child(3),
.hotspot-table-classic th:nth-child(4),
.hotspot-table-classic th:nth-child(5),
.hotspot-table-classic th:nth-child(7) { width: auto; }
.hotspot-table-classic th, .hotspot-table-classic td { white-space: normal; overflow-wrap: anywhere; word-break: normal; }
.hotspot-table-classic th:nth-child(1), .hotspot-table-classic td:nth-child(1) { width: 116px; }
.hotspot-table-classic th:nth-child(7), .hotspot-table-classic td:nth-child(7) { width: 230px; }
.hotspot-actions { min-width: 0; flex-wrap: wrap; white-space: normal; }
.router-diagnostic { display: grid; gap: 4px; max-width: 420px; }
.router-diagnostic strong { display: inline-flex; width: fit-content; border-radius: 999px; padding: 4px 8px; font-size: 12px; }
.router-diagnostic.is-ok strong { background: #e6f7ef; color: #0d6b45; }
.router-diagnostic.is-error strong { background: #fff1ef; color: #912c20; }
.router-diagnostic span, .router-diagnostic small { color: var(--muted); overflow-wrap: anywhere; }

@media (max-width: 1100px) {
    .hotspot-table-wrap { border: 0; overflow: visible; }
    .hotspot-table-classic { min-width: 0; background: transparent; table-layout: auto; }
    .hotspot-table-classic thead { display: none; }
    .hotspot-table-classic, .hotspot-table-classic tbody, .hotspot-table-classic tr, .hotspot-table-classic td { display: block; width: 100%; }
    .hotspot-table-classic tbody tr {
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--surface);
        margin-bottom: 12px;
        overflow: hidden;
    }
    .hotspot-table-classic td {
        border-right: 0;
        display: grid;
        grid-template-columns: 132px minmax(0, 1fr);
        gap: 12px;
        white-space: normal;
    }
    .hotspot-table-classic td::before {
        content: attr(data-label);
        color: var(--muted);
        font-weight: 700;
        font-size: 12px;
    }
    .hotspot-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, max-content)); align-items: center; }
}

@media (max-width: 520px) {
    .hotspot-table-classic td { grid-template-columns: 1fr; gap: 6px; }
    .hotspot-actions { grid-template-columns: 1fr; }
    .action-btn, .hotspot-actions form, .hotspot-actions a { width: 100%; justify-content: center; }
}
.connection-guide .guide-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.connection-guide article { border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); padding: 14px; }
.connection-guide strong { display: block; margin-bottom: 8px; }
.connection-guide p { color: var(--muted); margin-bottom: 0; line-height: 1.45; }
.connection-guide code { color: var(--primary-dark); overflow-wrap: anywhere; }
@media (max-width: 1000px) { .connection-guide .guide-grid { grid-template-columns: 1fr; } }
/* Tema unificado claro/oscuro */
:root {
    --bg: #edf1f5;
    --surface: #ffffff;
    --surface-soft: #f5f7fa;
    --surface-strong: #e8eef3;
    --text: #17212b;
    --muted: #667486;
    --line: #d7e0e8;
    --primary: #0f8f83;
    --primary-dark: #087268;
    --primary-soft: #e6f7f4;
    --success-bg: #e8f7ef;
    --success-text: #126b46;
    --success-line: #9fd7bd;
    --info-bg: #e9f4ff;
    --info-text: #245b82;
    --info-line: #b8d8f0;
    --warning-bg: #fff7e3;
    --warning-text: #8a5b00;
    --warning-line: #ebcf7b;
    --danger-bg: #fff0ee;
    --danger-text: #913126;
    --danger-line: #efb0a7;
    --table-row-alt: rgba(80, 105, 130, .055);
    --table-row-hover: rgba(15, 143, 131, .095);
    --sidebar-bg: #111d27;
    --sidebar-text: #dce6ec;
    --sidebar-muted: #8da0ae;
    --sidebar-hover: rgba(255, 255, 255, .08);
    --shadow: 0 16px 40px rgba(26, 38, 52, .10);
}

body.theme-dark {
    --bg: #0d131a;
    --surface: #151f29;
    --surface-soft: #101820;
    --surface-strong: #1e2b37;
    --text: #eef4f8;
    --muted: #a7b5c3;
    --line: #2b3a48;
    --primary: #18b8a8;
    --primary-dark: #70ddd3;
    --primary-soft: #123c39;
    --success-bg: #0f3029;
    --success-text: #b9f2dd;
    --success-line: #1e5d4d;
    --info-bg: #102638;
    --info-text: #acd8f7;
    --info-line: #274b64;
    --warning-bg: #37280f;
    --warning-text: #f7d68a;
    --warning-line: #684d1b;
    --danger-bg: #3a1717;
    --danger-text: #ffb8b0;
    --danger-line: #74302d;
    --table-row-alt: rgba(180, 200, 220, .045);
    --table-row-hover: rgba(24, 184, 168, .13);
    --sidebar-bg: #090f15;
    --sidebar-text: #dce8ef;
    --sidebar-muted: #8da2b2;
    --sidebar-hover: rgba(255, 255, 255, .075);
    --shadow: 0 16px 40px rgba(0, 0, 0, .34);
}

body { background: var(--bg); color: var(--text); }
a { color: var(--primary-dark); }
.sidebar { background: var(--sidebar-bg); color: var(--sidebar-text); }
.sidebar nav a { color: var(--sidebar-text); }
.sidebar nav a:hover { background: var(--sidebar-hover); }
.nav-section { color: var(--sidebar-muted); }
.brand, .brand:hover { color: #fff; }
.brand-mark { background: var(--primary); color: #fff; }
.panel, .stat, .router-card, .topbar, .created-modal { background: var(--surface); border-color: var(--line); box-shadow: var(--shadow); }
.router-pill, .button-light, .theme-form, .tabs a, .checkbox-grid label, .log-list article, .empty, .hotspot-preview, .permission-mode label, .permissions-grid label, .connection-guide article { background: var(--surface-soft); border-color: var(--line); color: var(--text); }
.form-grid input, .form-grid select, .search-form input, .table-search input, .table-page-size select, .hotspot-create-grid input, .hotspot-create-grid select, .login-form input, .theme-form select { background: var(--surface); color: var(--text); border-color: var(--line); }
.form-grid input::placeholder, .search-form input::placeholder, .table-search input::placeholder, .login-form input::placeholder { color: var(--muted); }
.topbar span, .muted, .panel-header p, .stat span, .form-grid label, .checkbox-grid small, .hotspot-preview span, .created-modal-body span, .table-footer, .table-search, .table-page-size, .router-diagnostic span, .router-diagnostic small, .connection-guide p { color: var(--muted); }
.eyebrow, .connection-guide code { color: var(--primary-dark); }

.alert { background: var(--surface); border-color: var(--line); color: var(--text); }
.alert-success, .badge.ok, .router-diagnostic.is-ok strong { background: var(--success-bg); color: var(--success-text); border-color: var(--success-line); }
.alert-danger, .router-diagnostic.is-error strong { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-line); }
.alert-warning { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-line); }
.badge.off { background: var(--surface-strong); color: var(--muted); }

.table-wrap { border-color: var(--line); background: var(--surface); }
table { background: var(--surface); color: var(--text); }
th { background: var(--surface-soft); color: var(--muted); border-color: var(--line); }
td { border-color: var(--line); }
.hotspot-table-classic th, .hotspot-table-classic td { border-color: var(--line); }
.hotspot-table-classic tbody tr:nth-child(even) td { background: var(--table-row-alt); }
.hotspot-table-classic tbody tr:hover td { background: var(--table-row-hover); }
.sort-button::after { color: var(--muted); }
.sort-button[data-direction="asc"]::after, .sort-button[data-direction="desc"]::after { color: var(--primary-dark); }
.selected-row td { background: var(--primary-soft); }

.hotspot-summary.info { background: var(--info-bg); color: var(--info-text); border-color: var(--info-line); }
.hotspot-summary.success { background: var(--success-bg); color: var(--success-text); border-color: var(--success-line); }
.hotspot-summary.warning { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-line); }
.status-success, .action-enable { background: #129b85; color: #fff; }
.status-warning, .action-edit { background: #e7a02d; color: #2d2100; }
.action-disable { background: var(--surface-soft); color: var(--text); border-color: var(--line); }
.action-delete { background: #c9504b; color: #fff; }
.link-danger { color: var(--danger-text); }
.modal-backdrop { background: rgba(3, 8, 13, .64); }
.created-modal-header, .created-modal-footer, .created-modal-body div { border-color: var(--line); }
.created-modal-body div { background: var(--surface-soft); }

.permissions-grid label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
body.theme-dark .permissions-grid label:has(input:checked) { background: var(--primary-soft); }
.login-card { background: var(--surface); }
.login-form { background: var(--surface); color: var(--text); }
.login-copy { background: #10232b; }

@media (max-width: 1100px) {
    .hotspot-table-classic tbody tr { background: var(--surface); border-color: var(--line); }
    .hotspot-table-classic tbody tr:nth-child(even) td { background: transparent; }
    .hotspot-table-classic tbody tr:hover td { background: transparent; }
}
.permission-profile-select { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.permission-profile-select select { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; background: var(--surface); color: var(--text); }
.active-hotspot-table th, .active-hotspot-table td { white-space: normal; overflow-wrap: anywhere; }
@media (max-width: 900px) {
    .active-hotspot-table thead { display: none; }
    .active-hotspot-table, .active-hotspot-table tbody, .active-hotspot-table tr, .active-hotspot-table td { display: block; width: 100%; }
    .active-hotspot-table tr { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 12px; overflow: hidden; background: var(--surface); }
    .active-hotspot-table td { border-bottom: 1px solid var(--line); }
}
/* Inicio con marca F&M */
.login-page-branded {
    background: radial-gradient(circle at 18% 18%, rgba(24, 184, 168, .24), transparent 28%), linear-gradient(135deg, #08131c 0%, #102b36 48%, #0f8f83 100%);
}
.login-card-branded {
    width: min(1040px, 100%);
    min-height: 560px;
    background: var(--surface);
}
.login-brand-panel {
    position: relative;
    gap: 12px;
    background: #061018;
    overflow: hidden;
}
.login-brand-panel::after {
    content: "";
    position: absolute;
    inset: auto -80px -120px auto;
    width: 280px;
    height: 280px;
    border: 1px solid rgba(112, 221, 211, .28);
    border-radius: 50%;
}
.login-logo {
    width: min(260px, 78%);
    max-height: 250px;
    object-fit: contain;
    align-self: flex-start;
    margin-bottom: 18px;
    filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .28));
}
.login-form-branded { gap: 13px; }
.login-form-heading h2 { margin-bottom: 0; }
.login-form-branded label { color: var(--muted); font-size: 13px; font-weight: 700; }
.login-help-row { display: flex; justify-content: flex-end; align-items: center; min-height: 22px; }
.login-help-row a { font-size: 13px; font-weight: 700; }
.login-credit { margin: 8px 0 0; font-size: 12px; text-align: center; }
.recovery-card { width: min(980px, 100%); }

@media (max-width: 900px) {
    .login-logo { width: min(210px, 70%); max-height: 190px; margin-bottom: 10px; }
    .login-card-branded { min-height: 0; }
    .login-help-row { justify-content: flex-start; }
}
/* Marca interna y menu colapsable */
.app-shell { grid-template-columns: 260px minmax(0, 1fr); transition: grid-template-columns .18s ease; }
.sidebar { min-width: 0; transition: padding .18s ease; }
.brand-with-logo { align-items: center; gap: 12px; margin-bottom: 26px; }
.brand-logo {
    width: 54px;
    height: 54px;
    flex: 0 0 54px;
    object-fit: contain;
    border-radius: 8px;
    padding: 5px;
    background: #050b10;
    border: 1px solid rgba(255, 255, 255, .12);
    box-shadow: 0 10px 24px rgba(0, 0, 0, .22);
}
.brand-text { display: grid; gap: 2px; min-width: 0; }
.brand-text strong { line-height: 1.05; }
.brand-text small { color: var(--sidebar-muted); font-size: 11px; font-weight: 700; letter-spacing: 0; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; min-height: 42px; }
.nav-icon {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    display: inline-grid;
    place-items: center;
    border-radius: 8px;
    color: #dff7f3;
    background: rgba(255, 255, 255, .07);
    transition: background .18s ease, color .18s ease, transform .18s ease;
}
.nav-icon svg { width: 19px; height: 19px; }
.nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sidebar nav a:hover .nav-icon { background: rgba(24, 184, 168, .22); color: #ffffff; transform: translateX(1px); }
body.theme-dark .nav-icon { background: rgba(255, 255, 255, .08); color: #bdf4ec; }
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-user { display: grid; gap: 2px; min-width: 0; }
.topbar-user span { margin-left: 0; }
.sidebar-toggle {
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--text);
    display: inline-grid;
    place-items: center;
    cursor: pointer;
    flex: 0 0 auto;
}
.sidebar-toggle span,
.sidebar-toggle::before,
.sidebar-toggle::after {
    content: "";
    display: block;
    width: 17px;
    height: 2px;
    border-radius: 99px;
    background: currentColor;
    transition: transform .18s ease, opacity .18s ease;
}
.sidebar-toggle span { margin: 4px 0; }
body.sidebar-collapsed .app-shell { grid-template-columns: 84px minmax(0, 1fr); }
body.sidebar-collapsed .sidebar { padding: 18px 12px; }
body.sidebar-collapsed .brand-with-logo { justify-content: center; margin-bottom: 22px; }
body.sidebar-collapsed .brand-logo { width: 48px; height: 48px; flex-basis: 48px; }
body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .nav-section,
body.sidebar-collapsed .sidebar nav a .nav-label { display: none; }
body.sidebar-collapsed .sidebar nav a { justify-content: center; padding: 7px; }
body.sidebar-collapsed .nav-icon { background: rgba(255, 255, 255, .09); }
body.sidebar-collapsed .sidebar nav a:hover .nav-icon { transform: none; }
body.sidebar-collapsed .sidebar-toggle::before { transform: translateY(6px) rotate(45deg); }
body.sidebar-collapsed .sidebar-toggle span { opacity: 0; }
body.sidebar-collapsed .sidebar-toggle::after { transform: translateY(-6px) rotate(-45deg); }
.login-credit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: fit-content;
    margin: 10px auto 0;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 12px;
    line-height: 1;
    text-align: center;
}
.login-credit strong { color: var(--text); font-size: 12px; }
.login-credit small {
    color: #fff;
    background: var(--primary);
    border-radius: 999px;
    padding: 4px 7px;
    font-size: 11px;
    font-weight: 800;
}

@media (max-width: 900px) {
    body.sidebar-collapsed .app-shell { grid-template-columns: 1fr; }
    body.sidebar-collapsed .sidebar { display: none; }
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { width: 100%; }
    .topbar-left, .topbar-actions { width: 100%; }
    .topbar-actions { flex-wrap: wrap; }
}

@media (max-width: 520px) {
    .login-credit { display: flex; width: 100%; flex-wrap: wrap; }
}

/* Credito discreto del login */
.login-byline {
    position: fixed;
    right: 18px;
    bottom: 16px;
    z-index: 5;
    color: rgba(255, 255, 255, .78);
    font-size: 12px;
    line-height: 1;
    padding: 8px 10px;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 999px;
    background: rgba(4, 12, 18, .42);
    backdrop-filter: blur(10px);
}
.login-byline strong { color: #fff; font-size: 12px; }

@media (max-width: 520px) {
    .login-byline { right: 12px; bottom: 10px; font-size: 11px; }
}
/* Submenus Hotspot */
.hotspot-process-tabs { align-items: center; }
.hotspot-process-tabs a { display: inline-flex; align-items: center; gap: 8px; }
.hotspot-process-tabs strong {
    min-width: 24px;
    height: 22px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    padding: 0 7px;
    background: var(--surface);
    color: var(--muted);
    font-size: 12px;
    line-height: 1;
}
.hotspot-process-tabs a.active strong { background: rgba(255, 255, 255, .22); color: #fff; }
.active-hotspot-wrap { margin-bottom: 12px; }
.active-hotspot-table .actions form { display: inline-flex; }

@media (max-width: 900px) {
    .active-hotspot-table td {
        display: grid;
        grid-template-columns: 132px minmax(0, 1fr);
        gap: 10px;
        white-space: normal;
    }
    .active-hotspot-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-weight: 700;
        font-size: 12px;
    }
    .active-hotspot-table .actions form,
    .active-hotspot-table .action-btn { width: 100%; justify-content: center; }
}

@media (max-width: 520px) {
    .active-hotspot-table td { grid-template-columns: 1fr; gap: 6px; }
    .hotspot-process-tabs a { width: 100%; justify-content: space-between; }
}

/* Pines comerciales Hotspot */
.commercial-hotspot-layout { grid-template-columns: minmax(320px, .85fr) minmax(420px, 1.15fr); }
.commercial-hotspot-grid { display: grid; grid-template-columns: minmax(320px, 460px) minmax(520px, 1fr); gap: 20px; align-items: start; }
.commercial-single-layout { display: grid; grid-template-columns: minmax(320px, 560px); align-items: start; margin-bottom: 20px; }
.commercial-main-panel { margin-bottom: 0; }
.commercial-plans-panel .actions { flex-wrap: wrap; }
.inline-fields { display: grid; grid-template-columns: minmax(90px, 1fr) minmax(120px, .8fr); gap: 10px; }
.pin-ticket-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}
.pin-ticket {
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    padding: 12px;
    display: grid;
    gap: 5px;
    min-height: 96px;
}
.pin-ticket span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    overflow-wrap: anywhere;
}
.pin-ticket strong {
    color: var(--text);
    font-size: 22px;
    letter-spacing: 0;
    overflow-wrap: anywhere;
}
.pin-ticket small { color: var(--muted); overflow-wrap: anywhere; }
.copy-source {
    position: fixed;
    left: -9999px;
    top: 0;
    width: 1px;
    height: 1px;
}
.app-modal[hidden] { display: none !important; }
.plan-modal { width: min(640px, 100%); }
.plan-modal-body {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 13px;
    padding: 20px;
    overflow-y: auto;
    min-height: 0;
}
.plan-modal-body label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.plan-modal-body .wide,
.plan-modal-body .compact-radio-row,
.plan-modal-body .checkbox-line,
.plan-modal-body .created-modal-footer { grid-column: 1 / -1; }
.plan-modal-body .checkbox-line { display: flex; align-items: center; gap: 9px; color: var(--text); }
.plan-modal-body .checkbox-line input { width: auto; }
.plan-modal-body .compact-radio-row { gap: 10px; }
.plan-modal-body .compact-radio-row label { color: var(--text); }
.plan-modal-body input,
.plan-modal-body select {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    background: var(--surface);
    color: var(--text);
    min-width: 0;
}
.plan-modal-body .created-modal-footer { margin: 4px -20px -20px; }

@media print {
    body { background: #fff; }
    .sidebar, .topbar, .page-heading, .commercial-hotspot-layout, .created-pins-panel .panel-header, .panel:not(.created-pins-panel) { display: none !important; }
    .app-shell { display: block; }
    .main { padding: 0; }
    .created-pins-panel { border: 0; box-shadow: none; padding: 0; margin: 0; }
    .pin-ticket-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
    .pin-ticket { break-inside: avoid; background: #fff; color: #111; }
}

@media (max-width: 900px) {
    .commercial-hotspot-layout, .commercial-hotspot-grid, .commercial-single-layout, .inline-fields { grid-template-columns: 1fr; }
    .plan-modal-body { grid-template-columns: 1fr; }
    .commercial-hotspot-layout,
    .commercial-hotspot-grid,
    .commercial-single-layout,
    .panel,
    .form-grid,
    .form-grid label,
    .form-grid input,
    .form-grid select,
    .alert,
    .panel-header,
    .panel-header > div { min-width: 0; max-width: 100%; }
    .commercial-hotspot-grid > *,
    .commercial-single-layout > * { min-width: 0; }
    .panel-header h2,
    .panel-header p,
    .alert { overflow-wrap: anywhere; }
}

@media (max-width: 520px) {
    .main { padding: 10px; }
    .panel { padding: 14px; border-radius: 6px; }
    .commercial-hotspot-grid { gap: 12px; }
    .form-grid { gap: 11px; }
    .form-grid input,
    .form-grid select,
    .button { width: 100%; }
    .panel-header p { line-height: 1.45; }
    .commercial-hotspot-grid .table-wrap,
    .commercial-plans-panel .table-wrap { border: 0; overflow: visible; }
    .commercial-hotspot-grid table,
    .commercial-hotspot-grid tbody,
    .commercial-hotspot-grid tr,
    .commercial-hotspot-grid td,
    .commercial-plans-panel table,
    .commercial-plans-panel tbody,
    .commercial-plans-panel tr,
    .commercial-plans-panel td { display: block; width: 100%; }
    .commercial-hotspot-grid thead,
    .commercial-plans-panel thead { display: none; }
    .commercial-hotspot-grid tr,
    .commercial-plans-panel tr {
        border: 1px solid var(--line);
        border-radius: 6px;
        background: var(--surface);
        margin-bottom: 10px;
        overflow: hidden;
    }
    .commercial-hotspot-grid td,
    .commercial-plans-panel td {
        border-bottom: 1px solid var(--line);
        padding: 10px 12px;
        white-space: normal;
        overflow-wrap: anywhere;
    }
    .commercial-hotspot-grid td::before,
    .commercial-plans-panel td::before {
        content: attr(data-label);
        display: block;
        color: var(--muted);
        font-size: 11px;
        font-weight: 700;
        margin-bottom: 4px;
        text-transform: uppercase;
    }
    .commercial-hotspot-grid td.actions,
    .commercial-plans-panel td.actions {
        align-items: stretch;
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .commercial-hotspot-grid td.actions form,
    .commercial-hotspot-grid td.actions .link-danger,
    .commercial-plans-panel td.actions form,
    .commercial-plans-panel td.actions .link-danger { width: 100%; }
    .commercial-hotspot-grid td.actions .link-danger,
    .commercial-plans-panel td.actions .link-danger {
        border: 1px solid var(--danger);
        border-radius: 6px;
        min-height: 38px;
    }
    .modal-backdrop { padding: 8px; place-items: stretch; }
    .created-modal { width: 100%; max-height: calc(100dvh - 16px); }
    .created-modal-header { padding: 14px 14px; }
    .plan-modal-body { padding: 14px; gap: 10px; }
    .plan-modal-body .created-modal-footer { margin: 2px -14px -14px; }
    .permission-mode label { width: 100%; justify-content: flex-start; }
}
