/* ── Design tokens (light default, dark override) ───────────────────────── */
:root {
    --color-bg:              #f6f7fb;
    --color-bg-deep:         #eef0f6;
    --color-surface:         #ffffff;
    --color-surface-alt:     #f1f3f9;
    --color-border:          #e3e6ee;
    --color-text:            #1c2130;
    --color-text-muted:      #6b7280;
    --color-text-dim:        #8a93a8;
    --color-primary:         #005ea9;
    --color-primary-tint:    #e7f2fb;
    --color-auth-gradient-1: #e7f2fb;
    --color-auth-gradient-2: #f6f7fb;
    --radius:                10px;
    --radius-lg:             12px;
    --shadow-md:             0 4px 12px rgba(16,24,40,.08);
    /* legacy tokens kept for non-topbar components */
    --brand-primary:      #3fa9ff;
    --brand-primary-hover:#6cb8ff;
    --brand-underline:    #129de1;
    --brand-dark:         #0d3f73;
    --bar-bg:             #060d1a;
    --bar-border:         #1a2540;
}

[data-theme="dark"] {
    --color-bg:              #12141c;
    --color-bg-deep:         #0f172a;
    --color-surface:         #1b1e29;
    --color-surface-alt:     #1e293b;
    --color-border:          #2e3244;
    --color-text:            #e7e9f2;
    --color-text-muted:      #9198ad;
    --color-text-dim:        #64748b;
    --color-primary:         #3fa9ff;
    --color-primary-tint:    rgba(63,169,255,.16);
    --color-auth-gradient-1: #1b1e29;
    --color-auth-gradient-2: #12141c;
    --shadow-md:             0 4px 14px rgba(0,0,0,.45);
}

body {
    font-family: Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Topbar (matches SiteSnap structure exactly) ────────────────────────── */
.topbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 20;
    flex-shrink: 0;
}

.topbar-inner {
    padding: 18px 28px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
}

/* Left */
.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.hamburger-btn {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--color-text);
}

.hamburger-btn svg {
    width: 22px;
    height: 22px;
    display: block;
}

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 4px;
    text-decoration: none;
}

.brand-lockup .hex {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
}

.brand-lockup .product-name {
    font-family: 'Aldrich', sans-serif;
    font-weight: 400;
    letter-spacing: 2.4px;
    color: var(--color-primary);
    font-size: 26px;
    line-height: 1;
    text-transform: uppercase;
    -webkit-text-stroke: 0.6px currentColor;
}

/* Shared btn-ghost (used elsewhere) */
.btn-ghost {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    border-radius: var(--radius);
    transition: background .15s, color .15s;
    line-height: 1;
}
.btn-ghost:hover {
    background: var(--color-primary-tint);
    color: var(--color-primary);
}

/* Nav dropdown */
.nav-dropdown {
    display: none;
    position: absolute;
    top: 40px;
    left: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: .4rem;
    min-width: 180px;
    box-shadow: var(--shadow-md);
    z-index: 200;
}

.nav-dropdown.open { display: block; }

.nav-dropdown a {
    display: block;
    padding: .6rem .85rem;
    border-radius: 8px;
    font-size: .9rem;
    color: var(--color-text);
    text-decoration: none;
    transition: background .12s;
}

.nav-dropdown a:hover { background: var(--color-bg-deep); }
.nav-dropdown a.signout-link { color: #f87171; }

.nav-dropdown hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 6px 0;
}

/* Center brand */
.topbar-center {
    display: flex;
    justify-content: center;
    text-decoration: none;
}

.apex-brand-topbar { --brand-width: 238px !important; }

/* Right: topbar-right */
.topbar-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.user-badge {
    border: 1px solid var(--color-primary);
    color: var(--color-primary);
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.theme-toggle-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    color: var(--color-text-muted);
    transition: border-color .15s, color .15s;
    flex-shrink: 0;
}

.theme-toggle-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.theme-toggle-btn svg {
    width: 16px;
    height: 16px;
}

/* ── Theme toggle menu ─────────────────────────────────────────── */
.theme-toggle-wrap { position: relative; }
.theme-toggle-trigger {
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; padding: 0;
}
.theme-toggle-menu {
    position: absolute; top: calc(100% + 6px); right: 0; z-index: 500;
    min-width: 140px; padding: 4px;
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg, 10px);
    box-shadow: 0 8px 24px rgba(0,0,0,.16);
    display: flex; flex-direction: column; gap: 2px;
}
.theme-toggle-option {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 10px; border: none; background: transparent;
    border-radius: calc(var(--radius-lg, 10px) - 2px);
    color: var(--color-text); font-size: 13px; font-weight: 600;
    cursor: pointer; text-align: left; width: 100%;
    transition: background .12s;
}
.theme-toggle-option:hover { background: var(--color-bg-deep); }
.theme-toggle-option.active { background: var(--color-primary-tint); color: var(--color-primary); }
.theme-toggle-icon { display: inline-flex; width: 16px; height: 16px; }

.user-info {
    text-align: right;
    line-height: 1.2;
}

.user-info .name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-text);
}

.user-info .role {
    font-size: 0.7rem;
    color: var(--color-text-muted);
}

.topbar-right .signout {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    text-decoration: none;
    transition: color .15s;
    white-space: nowrap;
}

.topbar-right .signout:hover { color: var(--color-text); }

/* ── Light mode overrides (data-theme="light") ──────────────────────────── */
[data-theme="light"] body { background: var(--color-bg); color: var(--color-text); }
[data-theme="light"] .dashboard-card,
[data-theme="light"] .settings-panel,
[data-theme="light"] .site-row-item,
[data-theme="light"] .stat-card,
[data-theme="light"] .protect-card,
[data-theme="light"] .issues-panel { background: var(--color-surface); border-color: var(--color-border); }
[data-theme="light"] .site-card,
[data-theme="light"] .device-card { background: #f8fafc; border-color: var(--color-border); }
[data-theme="light"] input,
[data-theme="light"] textarea { background: var(--color-surface); border-color: var(--color-border); color: var(--color-text); }
[data-theme="light"] .dropdown-menu { background: var(--color-surface); border-color: var(--color-border); }
[data-theme="light"] .dropdown-item { color: var(--color-text-muted); }
[data-theme="light"] .dropdown-item:hover { background: var(--color-primary-tint); }
[data-theme="light"] .sites-table th,
[data-theme="light"] .sites-table td { border-bottom-color: var(--color-border); }

/* ── Apex Brand lockup (spec from Apex Core reference) ─────────────────── */
.apex-brand {
    --brand-width: 180px;
    display: flex;
    align-items: center;
}

.apex-brand-mark {
    display: block;
    width: var(--brand-width);
    height: auto;
    flex-shrink: 0;
}

.apex-brand-text {
    display: flex;
    flex-direction: column;
}

.apex-brand-technology {
    display: flex;
    justify-content: space-between;
    width: var(--brand-width);
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    line-height: 1;
    text-transform: uppercase;
}

/* Login variant — column layout, 10px TECHNOLOGY */
.apex-brand-login {
    --brand-width: 220px;
    flex-direction: column;
}
.apex-brand-login .apex-brand-text {
    align-items: stretch;
    margin-top: -30px;
}
.apex-brand-login .apex-brand-technology {
    font-size: 10px;
    color: #aeb1bc;
}

/* Header variant — row, 96px mark, 6px TECHNOLOGY */
.apex-brand-header {
    --brand-width: 96px;
    gap: 10px;
}

/* ── Login page ────────────────────────────────────────────────────────── */

/* Override container for login — full viewport, gradient background */
.login-container {
    max-width: 100% !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 100vh !important;
    background: linear-gradient(135deg, var(--color-auth-gradient-1), var(--color-auth-gradient-2)) !important;
    position: relative !important;
}

/* Theme toggle positioned in corner */
.auth-theme-toggle {
    position: absolute;
    top: 20px;
    right: 24px;
}

/* Card — matches Core exactly */
.auth-card {
    background: var(--color-surface);
    padding: 36px;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    width: 360px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    border: none;
}

/* Brand section inside card */
.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 14px;
}

/* Subtitle */
.auth-subtitle {
    margin: 0 0 8px;
    color: var(--color-text-muted);
    font-size: 13px;
    text-align: center;
}

/* Label + input — matches Core */
.auth-card label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
}

.auth-card input {
    padding: 9px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 14px;
    outline: none;
    transition: border-color .15s;
}

.auth-card input:focus {
    border-color: var(--color-primary);
}

/* Primary button */
.btn-primary {
    background: var(--color-primary);
    color: #fff;
    padding: 9px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s;
    width: 100%;
}

.btn-primary:hover { opacity: .88; }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

/* ── Apex Brand — product mark (MONITORING) ────────────────────────────── */
.apex-brand-core {
    display: flex;
    align-items: center;
    font-family: 'Aldrich', sans-serif !important;
    font-weight: 400;
    line-height: 1;
    text-transform: uppercase;
    -webkit-text-stroke: 0.6px currentColor;
}

.apex-brand-core .core-mark {
    flex-shrink: 0;
}

.apex-brand-ore {
    display: flex;
}

.apex-brand-core-line {
    border-radius: 10px;
    background: #129de1;
}

/* Login variant */
.apex-brand-login .apex-brand-core {
    display: grid;
    grid-template-columns: 80px 1fr;
    align-items: center;
    margin-top: 22px;
    font-size: 31px;
    color: #3fa9ff;
    width: var(--brand-width);
}

.apex-brand-login .apex-brand-core .core-mark {
    width: 80px;
    height: 80px;
}

.apex-brand-login .apex-brand-ore {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 18px;
    width: 100%;
}

.apex-brand-login .apex-brand-core-line {
    width: 84px;
    height: 3px;
    margin-top: 12px;
}

/* Header variant */
.apex-brand-header .apex-brand-core {
    margin-top: 2px;
    font-size: 14px;
    gap: 4px;
    color: var(--brand-primary);
}

.apex-brand-header .apex-brand-ore {
    gap: 1px;
}

.apex-brand-header .apex-brand-core .core-mark {
    width: 18px;
    height: 18px;
}

.apex-brand-header .apex-brand-core-line {
    display: none;
}


/* ── Main container ────────────────────────────────────────────────────── */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
    box-sizing: border-box;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.dashboard-card {
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

input {
    padding: 0.8rem;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    background: var(--color-bg-deep);
    color: var(--color-text);
}

button {
    padding: 0.9rem;
    border: none;
    border-radius: 8px;
    background: #2563eb;
    color: white;
    cursor: pointer;
}

button:hover {
    background: #1d4ed8;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dashboard-header a {
    color: #93c5fd;
    text-decoration: none;
}

.flash-wrapper {
    margin-top: 1rem;
}

.flash {
    padding: 0.8rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.flash-error {
    background: #7f1d1d;
    color: #fecaca;
}
.button-link {
    display: inline-block;
    padding: 0.7rem 1rem;
    border-radius: 8px;
    background: #2563eb;
    color: white;
    text-decoration: none;
    margin-left: 0.5rem;
}

.button-link.secondary {
    background: #475569;
}

.sites-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.sites-table th,
.sites-table td {
    text-align: left;
    padding: 0.8rem;
    border-bottom: 1px solid var(--color-border);
}

textarea {
    padding: 0.8rem;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    background: var(--color-bg-deep);
    color: var(--color-text);
    resize: vertical;
}

.checkbox-group {
    flex-direction: row;
    align-items: center;
    gap: 0.6rem;
}

.flash-success {
    background: #14532d;
    color: #bbf7d0;
}
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
    box-sizing: border-box;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.form-card {
    max-width: 760px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

input,
textarea {
    padding: 0.8rem;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    background: var(--color-bg-deep);
    color: var(--color-text);
    resize: vertical;
}

button,
.primary-button {
    padding: 0.9rem 1rem;
    border: none;
    border-radius: 8px;
    background: #2563eb;
    color: white;
    cursor: pointer;
    text-decoration: none;
}

button:hover,
.primary-button:hover {
    background: #1d4ed8;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.header-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.button-link {
    display: inline-block;
    padding: 0.7rem 1rem;
    border-radius: 8px;
    background: #2563eb;
    color: white;
    text-decoration: none;
    border: none;
    cursor: pointer;
}

.button-link.secondary {
    background: #475569;
}

.button-link.danger {
    background: #b91c1c;
}

.button-link.small {
    padding: 0.45rem 0.8rem;
    font-size: 0.9rem;
}

.dashboard-header a {
    color: white;
    text-decoration: none;
}

.flash-wrapper {
    margin-top: 1rem;
}

.flash {
    padding: 0.8rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.flash-error {
    background: #7f1d1d;
    color: #fecaca;
}

.flash-success {
    background: #14532d;
    color: #bbf7d0;
}

.sites-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.sites-table th,
.sites-table td {
    text-align: left;
    padding: 0.9rem 0.8rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
}

.table-link {
    color: #93c5fd;
    text-decoration: none;
    font-weight: bold;
}

.link-button {
    background: transparent;
    border: none;
    color: #f8fafc;
    padding: 0;
    cursor: pointer;
    font: inherit;
}

.link-button:hover {
    color: #93c5fd;
    background: transparent;
}

.link-button.danger:hover {
    color: #fca5a5;
}

.status-badge {
    display: inline-block;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: bold;
}

.status-badge.active {
    background: #14532d;
    color: #bbf7d0;
}

.status-badge.inactive {
    background: #7f1d1d;
    color: #fecaca;
}

.checkbox-group {
    flex-direction: row;
    align-items: center;
    gap: 0.6rem;
}

.secrets-box {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-bg-deep);
}

.secret-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--color-border);
}

.secret-row:last-of-type {
    border-bottom: none;
}

.secret-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.secret-status {
    color: #cbd5e1;
    font-size: 0.95rem;
}

.helper-text {
    margin-top: 0.8rem;
    color: #94a3b8;
    font-size: 0.9rem;
}
.settings-summary {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.setting-item {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.site-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.site-card {
    background: var(--color-bg-deep);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1rem;
}

.site-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.8rem;
    padding-right: 2.5rem;
}

.site-card h3 {
    margin: 0;
}

.secret-status-row {
    margin-bottom: 0.5rem;
}
.sync-site-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sync-site-item {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    background: var(--color-bg-deep);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1rem;
    cursor: pointer;
}

.sync-site-checkbox {
    padding-top: 0.3rem;
}

.sync-site-content h3 {
    margin: 0 0 0.6rem 0;
}

.sync-site-content p {
    margin: 0.2rem 0;
}

.sync-actions {
    margin-top: 1.5rem;
    display: flex;
    justify-content: flex-end;
}
.site-card {
    position: relative;
    background: var(--color-bg-deep);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1rem;
}

.site-card-menu {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
}

.dropdown {
    position: relative;
}

.dropdown summary {
    list-style: none;
    cursor: pointer;
    font-size: 1.3rem;
    color: #cbd5e1;
    user-select: none;
}

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

.dropdown-menu {
    position: absolute;
    right: 0;
    top: 1.8rem;
    min-width: 140px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 0.4rem;
    box-shadow: var(--shadow-md);
    z-index: 10;
}

.dropdown-menu form {
    margin: 0;
}

.dropdown-item {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    color: var(--color-text);
    padding: 0.7rem 0.8rem;
    border-radius: 8px;
    cursor: pointer;
}

.dropdown-item:hover {
    background: var(--color-primary-tint);
}

.dropdown-item.danger {
    color: #fca5a5;
}

.dropdown-item.danger:hover {
    background: #7f1d1d;
    color: #fff;
}

.health-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.health-dot.healthy {
    background: #22c55e;
}

.health-dot.warning {
    background: #facc15;
}

.health-dot.down {
    background: #ef4444;
}

.health-dot.inactive {
    background: #64748b;
}

.subtle-text {
    color: #94a3b8;
    margin-top: 0.25rem;
}

.site-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.device-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.device-card {
    background: var(--color-bg-deep);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1rem;
}

.device-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.8rem;
}

.device-card h3 {
    margin: 0;
}
.site-card-main {
    cursor: pointer;
}

.site-card-main:hover {
    opacity: 0.96;
}
.device-card {
    position: relative;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 1rem;
}

.device-card-menu {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    z-index: 20;
}

.device-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.8rem;
    padding-right: 2.5rem;
}
.module-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.module-card {
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: 18px;
    padding: 2rem;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.module-card:hover {
    transform: translateY(-2px);
    border-color: #3b82f6;
}

.module-card h2 {
    margin-bottom: 1rem;
    font-size: 2rem;
}

.module-card p {
    margin-bottom: 0.8rem;
    color: var(--color-text);
}
.warning-text {
    color: #facc15;
    font-weight: 600;
}
.site-card-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mute-form {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin: 0;
}

.mute-label {
    font-size: 1.3rem;
    font-weight: 600;
    color: #e5e7eb;
}

.mute-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.mute-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.mute-slider {
    position: absolute;
    inset: 0;
    cursor: pointer;
    background-color: #374151;
    border-radius: 999px;
    transition: background-color 0.2s ease;
}

.mute-slider::before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    left: 4px;
    top: 4px;
    background-color: #ffffff;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.mute-switch input:checked + .mute-slider {
    background-color: #5f2a2a;
}

.mute-switch input:checked + .mute-slider::before {
    transform: translateX(20px);
}

/* ─── STAT CARD CLICKEABLE ──────────────────────────────────── */
.stat-card.clickable {
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.stat-card.clickable:hover {
    border-color: #475569;
    background: #263347;
}

.stat-card.clickable.active {
    border-color: #3b82f6;
}

/* ─── ISSUES PANEL ──────────────────────────────────────────── */
.issues-panel {
    display: none;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 1.25rem;
    animation: fadeSlideIn 0.2s ease;
}

.issues-panel.open { display: block; }

.issues-panel-header {
    padding: .75rem 1.1rem;
    font-size: .82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
}

.issue-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1.1rem;
    border-bottom: 1px solid var(--color-border);
    transition: background 0.1s;
    color: inherit;
}

.issue-row:last-child { border-bottom: none; }
.issue-row:hover { background: var(--color-primary-tint); cursor: pointer; }

.issue-row-name {
    font-size: .9rem;
    font-weight: 600;
    color: var(--color-text);
    min-width: 0;
}

.issue-row-site {
    font-size: .8rem;
    color: #64748b;
    margin-top: 2px;
}

.issue-row-status {
    margin-left: auto;
    font-size: .75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    flex-shrink: 0;
}

.issue-row-status.offline {
    background: rgba(239,68,68,.12);
    color: #fca5a5;
    border: 1px solid rgba(239,68,68,.25);
}

.issue-row-status.interrupted {
    background: rgba(250,204,21,.1);
    color: #fde047;
    border: 1px solid rgba(250,204,21,.2);
}

.issue-row-alert-time {
    font-size: .75rem;
    color: #475569;
    flex-shrink: 0;
}

/* ─── ALERT TOOLTIP ─────────────────────────────────────────── */
.alert-tooltip {
    position: absolute;
    right: 0;
    top: 100%;
    z-index: 100;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: .75rem 1rem;
    font-size: .78rem;
    color: var(--color-text-muted);
    white-space: pre;
    line-height: 1.6;
    min-width: 280px;
    max-width: 380px;
    display: none;
    pointer-events: none;
    box-shadow: var(--shadow-md);
}

.issue-row:hover .alert-tooltip { display: block; }

/* ─── SELECT LIST (sync sites / select NVRs) ────────────────── */
.select-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.select-item {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 0.85rem 1.1rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    user-select: none;
}

.select-item:hover { border-color: #475569; }

.select-item.is-selected {
    border-color: #3b82f6;
    background: var(--color-primary-tint);
}

.select-item.is-imported {
    opacity: 0.55;
    cursor: default;
}

.select-item-checkbox {
    display: none;
}

.select-item-indicator {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    border: 2px solid #475569;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s;
    position: relative;
}

.select-item.is-selected .select-item-indicator,
.select-item.is-imported .select-item-indicator {
    background: #3b82f6;
    border-color: #3b82f6;
}

.select-item.is-selected .select-item-indicator::after,
.select-item.is-imported .select-item-indicator::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 0px;
    width: 5px;
    height: 9px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
}

.select-item-body {
    flex: 1;
    min-width: 0;
}

.select-item-name {
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.select-item-meta {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.imported-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    background: rgba(34,197,94,0.12);
    color: #86efac;
    border: 1px solid rgba(34,197,94,0.25);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.select-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

/* ─── SYNC RUNNING BANNER ───────────────────────────────────── */
.sync-running-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #0c2a44;
    border: 1px solid #1e4a6e;
    border-radius: 10px;
    padding: 0.75rem 1.1rem;
    margin-bottom: 1rem;
    font-size: 0.88rem;
    color: #93c5fd;
    animation: fadeSlideIn 0.3s ease;
}

.sync-banner-close {
    margin-left: auto;
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0 0.25rem;
    line-height: 1;
}

.sync-banner-close:hover { color: #94a3b8; background: none; }

/* ─── ANIMATIONS ────────────────────────────────────────────── */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
    from { opacity: 1; max-height: 80px; margin-bottom: 1rem; padding: 0.8rem 1rem; }
    to   { opacity: 0; max-height: 0;    margin-bottom: 0;    padding: 0; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

.flash {
    animation: fadeSlideIn 0.25s ease;
}

.flash.dismissing {
    animation: fadeOut 0.4s ease forwards;
    overflow: hidden;
    pointer-events: none;
}

/* ─── SPINNER ────────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
    flex-shrink: 0;
}

.btn-loading {
    opacity: 0.8;
    pointer-events: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ─── MODULE HEALTH DOT (home) ──────────────────────────────── */
.module-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.module-health {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
}

.module-health .health-dot {
    width: 10px;
    height: 10px;
}

.module-health.pulse-dot .health-dot.down {
    animation: pulse 1.5s ease-in-out infinite;
}

/* ─── SCHEDULER STATUS ──────────────────────────────────────── */
.scheduler-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.scheduler-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    animation: pulse 2s ease-in-out infinite;
    flex-shrink: 0;
}

/* ─── LAST SYNC BADGE ───────────────────────────────────────── */
.sync-badge {
    font-size: 0.75rem;
    color: #475569;
    white-space: nowrap;
}

/* ─── SITE DETAIL (rediseño) ────────────────────────────────── */
.detail-info-bar {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    align-items: center;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 1rem 1.5rem;
    margin-bottom: 1.25rem;
}

.detail-info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-info-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}

.detail-info-value {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--color-text);
}

/* ─── MODULE TAG ────────────────────────────────────────────── */
.module-tag {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
}

.module-tag.net {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.module-tag.prot {
    background: rgba(34, 197, 94, 0.12);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, 0.25);
}

.module-tag.upt {
    background: rgba(249, 115, 22, 0.12);
    color: #fdba74;
    border: 1px solid rgba(249, 115, 22, 0.25);
}

/* ─── PAGE HEADER (nuevo estilo) ────────────────────────────── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding-top: 0.5rem;
}

.page-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.page-header h1 {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 700;
}

.page-header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* ─── SETTINGS PANEL COLAPSABLE ─────────────────────────────── */
.settings-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    margin-bottom: 1.25rem;
    overflow: hidden;
}

.settings-panel summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text-muted);
    user-select: none;
    transition: background 0.15s;
}

.settings-panel summary::-webkit-details-marker { display: none; }

.settings-panel summary:hover {
    background: var(--color-primary-tint);
    color: var(--color-text);
}

.settings-panel summary .chevron {
    font-size: 1.1rem;
    transition: transform 0.2s ease;
}

.settings-panel[open] summary .chevron {
    transform: rotate(180deg);
}

.settings-panel-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    padding: 1rem 1.25rem 1.25rem;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg-deep);
}

.setting-row {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.setting-row-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}

.setting-row-value {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.ok { background: #22c55e; }
.status-dot.err { background: #ef4444; }
.status-dot.warn { background: #facc15; }

.setting-row-action {
    margin-top: 0.2rem;
    font-size: 0.82rem;
    color: #60a5fa;
    text-decoration: none;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
}

.setting-row-action:hover { color: #93c5fd; text-decoration: underline; }

/* ─── STATS ROW ─────────────────────────────────────────────── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
}

.stat-card-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    margin-bottom: 0.4rem;
}

.stat-card-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    color: var(--color-text);
}

.stat-card-value.alert { color: #ef4444; }
.stat-card-value.ok { color: #22c55e; }
.stat-card-value.muted { color: #64748b; }

/* ─── SITE CARD (nuevo diseño) ──────────────────────────────── */
.site-row {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.site-row-item {
    position: relative;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 0.9rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    transition: border-color 0.15s;
}

.site-row-item:hover { border-color: #475569; }

.site-row-item.is-down { border-left: 3px solid #ef4444; }
.site-row-item.is-warning { border-left: 3px solid #facc15; }
.site-row-item.is-healthy { border-left: 3px solid #22c55e; }
.site-row-item.is-inactive { border-left: 3px solid #475569; }

.site-row-dot { flex-shrink: 0; }

.site-row-main {
    flex: 1;
    cursor: pointer;
    min-width: 0;
}

.site-row-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.site-row-meta {
    font-size: 0.82rem;
    color: #64748b;
    margin-top: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.site-row-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.site-row-menu {
    position: relative;
}

/* ─── CAMERA / NVR CARDS (Protect) ──────────────────────────── */
.protect-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.75rem;
}

.protect-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1rem 1.1rem;
    position: relative;
}

.protect-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.6rem;
    padding-right: 1.5rem;
}

.protect-card-name {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.protect-card-meta {
    font-size: 0.82rem;
    color: #94a3b8;
    margin-top: 0.15rem;
}

.protect-card-field {
    display: flex;
    gap: 0.4rem;
    font-size: 0.83rem;
    margin-top: 0.4rem;
    color: #94a3b8;
}

.protect-card-field strong {
    color: #cbd5e1;
    min-width: 40px;
}

.protect-card-menu {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
}

.section-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    margin: 1.25rem 0 0.75rem;
}

.last-sync-note {
    font-size: 0.8rem;
    color: #475569;
    margin-top: 0.5rem;
    text-align: right;
}

/* ─── SITE GROUP (networking dashboard) ─────────────────────── */
.site-group-section {
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: .5rem;
}

.site-group-header {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .75rem 1rem;
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    user-select: none;
    transition: background .12s;
}

.site-group-section[open] .site-group-header {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom: none;
}

.site-group-header::-webkit-details-marker { display: none; }
.site-group-header::marker { display: none; }

.site-group-header:hover { background: var(--color-primary-tint); }

.site-group-name {
    font-weight: 600;
    font-size: .9rem;
    color: var(--color-text);
    flex: 1;
}

.site-group-badge {
    font-size: .72rem;
    font-weight: 700;
    padding: .15rem .55rem;
    border-radius: 999px;
    background: var(--color-primary-tint);
    color: var(--color-primary);
    flex-shrink: 0;
}

.site-group-chevron {
    font-size: .85rem;
    color: var(--color-text-muted);
    transition: transform .2s ease;
    flex-shrink: 0;
}

.site-group-section[open] .site-group-chevron {
    transform: rotate(180deg);
}

.site-group-body {
    border: 1px solid var(--color-border);
    border-top: none;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    padding: .4rem;
    background: var(--color-bg);
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

/* ─── MINI STAT BOX (home dashboard inside module cards) ──────── */
.mini-stat-box {
    background: var(--color-bg-deep);
    border-radius: 10px;
    padding: .75rem 1rem;
}

.mini-stat-box .mini-stat-label {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--color-text-muted);
    margin-bottom: .3rem;
}

.mini-stat-box .mini-stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--color-text);
}

/* ─── CARD ROW (users page) ─────────────────────────────────── */
.card-row {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: .85rem 1rem;
    display: flex;
    align-items: center;
    gap: .85rem;
}

.card-panel {
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
}

/* ─── FILTER BUTTON (networking) ────────────────────────────── */
.dash-filter-btn {
    font-size: .75rem;
    font-weight: 600;
    padding: .3rem .8rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all .15s;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-muted);
}

.dash-filter-btn.active {
    border-color: var(--color-primary);
    background: var(--color-primary-tint);
    color: var(--color-primary);
}