:root {
    --bg: #f0f4f8;
    --bg-strong: #dce6f0;
    --panel: rgba(255, 255, 255, 0.92);
    --panel-strong: #ffffff;
    --text: #343a40;
    --muted: #6c757d;
    --accent: #258ccd;
    --accent-2: #63a7da;
    --border: rgba(31, 41, 51, 0.08);
    --success: #23846b;
    --danger: #c23b3b;
    --disabled: #6c757d;
    --shadow: 0 24px 80px rgba(37, 140, 205, 0.12);
}

* {
    box-sizing: border-box;
}

/* ── Loading overlay ────────────────────────────────────────────────────── */
#loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 25, 35, 0.72);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#snmp-test-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(15, 25, 35, 0.78);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

#switch-sync-overlay {
    position: fixed;
    inset: 0;
    z-index: 10002;
    background: rgba(15, 25, 35, 0.78);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

#mac-ip-resolve-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: rgba(15, 25, 35, 0.82);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.snmp-test-card {
    width: min(640px, 100%);
    background: #fff;
    border-radius: 24px;
    border: 1px solid rgba(31, 41, 51, 0.1);
    box-shadow: 0 30px 80px rgba(15, 25, 35, 0.35);
    padding: 24px;
}

.snmp-test-card.is-loading {
    border-color: rgba(13, 110, 110, 0.25);
}

.snmp-test-card.is-success {
    border-color: rgba(35, 132, 107, 0.45);
}

.snmp-test-card.is-error {
    border-color: rgba(194, 59, 59, 0.45);
}

.mac-ip-resolve-card.is-loading {
    border-color: rgba(13, 110, 110, 0.3);
}

.mac-ip-resolve-card.is-error {
    border-color: rgba(194, 59, 59, 0.5);
}

#poe-restart-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: rgba(15, 25, 35, 0.82);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

#port-save-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: rgba(15, 25, 35, 0.82);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.poe-restart-card.is-loading {
    border-color: rgba(217, 111, 50, 0.35);
}

.poe-restart-card.is-success {
    border-color: rgba(35, 132, 107, 0.45);
}

.port-save-card.is-loading {
    border-color: rgba(13, 110, 110, 0.35);
}

.snmp-test-spinner {
    margin-bottom: 12px;
    color: var(--accent);
}

.snmp-test-details {
    white-space: pre-wrap;
    background: #f8f9fb;
    border: 1px solid rgba(31, 41, 51, 0.1);
    border-radius: 14px;
    padding: 12px;
    font-size: 0.88rem;
    max-height: 220px;
    overflow: auto;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Manrope', sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(37, 140, 205, 0.08), transparent 28%),
        radial-gradient(circle at bottom right, rgba(99, 167, 218, 0.06), transparent 28%),
        linear-gradient(135deg, #f0f4f8 0%, #e8f1f8 100%);
}

.app-shell {
    display: grid;
    grid-template-columns: 290px 1fr;
}

.app-shell.is-guest {
    display: block;
}

.app-shell.is-guest .main-panel {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 32px 16px;
}

.sidebar {
    min-height: 100vh;
    padding: 32px 24px;
    background: #258ccd;
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: sticky;
    top: 0;
}

.brand-mark {
    color: #fff;
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    text-decoration: none;
}

.brand-copy,
.muted-copy {
    color: var(--muted);
    max-width: 60ch;
}

.sidebar .brand-copy {
    color: rgba(255, 255, 255, 0.76);
    margin-top: 12px;
}

.sidebar .nav-link {
    color: rgba(255, 255, 255, 0.84);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 12px 14px;
}

.sidebar .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar .nav-link.active {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.22);
}

.sidebar-tree-group {
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 16px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.03);
}

.sidebar-tree-group > summary {
    cursor: pointer;
    list-style: none;
    color: rgba(255, 255, 255, 0.92);
    font-weight: 700;
    padding: 6px 8px;
}

.sidebar-tree-group > summary::-webkit-details-marker {
    display: none;
}

.sidebar-tree-children {
    margin-top: 6px;
    display: grid;
    gap: 8px;
    padding-left: 10px;
    border-left: 1px dashed rgba(255, 255, 255, 0.22);
}

.sidebar-tree-children .nav-link {
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 0.92rem;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.main-panel {
    padding: 32px;
}

.hero-panel,
.panel-card,
.metric-card,
.login-card,
.stack-item {
    background: var(--panel);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: 28px;
    box-shadow: var(--shadow);
}

.hero-panel,
.page-head {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: end;
}

.hero-panel {
    padding: 30px;
}

.page-head {
    margin-bottom: 24px;
}

.display-title {
    font-size: clamp(2rem, 4vw, 3.5rem);
    line-height: 0.95;
    letter-spacing: -0.05em;
    margin: 8px 0 12px;
}

.eyebrow {
    color: var(--accent);
    font-size: 0.84rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.stats-grid,
.content-grid {
    display: grid;
    gap: 20px;
}

.stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.content-grid {
    grid-template-columns: 1.1fr 1fr;
}

.metric-card {
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.metric-card span {
    color: var(--muted);
}

.metric-card strong {
    font-size: 2.4rem;
    letter-spacing: -0.05em;
}

.metric-card.accent {
    background: linear-gradient(145deg, rgba(13, 110, 110, 0.15), rgba(217, 111, 50, 0.08));
}

.panel-card {
    padding: 24px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.section-head h2,
.page-head h1,
.port-status-subtitle {
    margin: 0;
    font-size: 1.5rem;
    letter-spacing: -0.04em;
}

.port-status-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.port-status-sections {
    display: grid;
    gap: 18px;
}

.port-status-section {
    display: grid;
    gap: 10px;
}

.port-status-subtitle {
    font-weight: 600;
    color: inherit;
    text-transform: none;
}

.port-status-grid .port-status-item {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
    min-height: 78px;
    height: 100%;
    line-height: 1.35;
    padding: 14px 15px;
    border: 1px solid rgba(31, 41, 51, 0.1);
    border-radius: 16px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(249, 243, 234, 0.92));
    box-shadow:
        0 8px 20px rgba(31, 41, 51, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.port-status-grid .port-status-label {
    margin: 0;
    flex: 0 0 auto;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.port-status-grid .port-status-item > span {
    min-width: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.port-status-grid .port-status-item--action {
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s, border-color 0.15s;
    border-color: rgba(37, 140, 205, 0.28);
    background:
        linear-gradient(180deg, rgba(240, 247, 253, 0.92), rgba(220, 235, 248, 0.88));
}

.port-status-grid .port-status-item--action:hover,
.port-status-grid .port-status-item--action:focus-visible {
    border-color: rgba(37, 140, 205, 0.6);
    box-shadow:
        0 8px 24px rgba(37, 140, 205, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.75);
    outline: none;
}

.port-status-grid .port-status-item--action:active {
    background:
        linear-gradient(180deg, rgba(220, 235, 248, 0.95), rgba(195, 220, 242, 0.92));
}

.port-status-grid .port-status-item--action[disabled],
.port-status-grid .port-status-item--action.is-busy {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

.port-status-grid .port-status-item--action > span {
    color: var(--accent-2) !important;
}

.port-status-grid.is-compact .port-status-item {
    min-height: 62px;
    padding: 10px 12px;
}

.port-status-grid.is-compact .port-status-item > span {
    font-size: 0.95rem;
}

@media (max-width: 1200px) {
    .port-status-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 767px) {
    .port-status-grid {
        grid-template-columns: 1fr;
    }
}

.switch-list,
.log-list,
.stack-list {
    display: grid;
    gap: 14px;
}

.debug-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    align-items: end;
}

.debug-probe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    align-items: end;
}

.debug-filter-actions {
    display: flex;
    gap: 8px;
    align-items: end;
    flex-wrap: wrap;
}

.debug-table {
    table-layout: fixed;
}

.debug-oid-cell {
    word-break: break-all;
    max-width: 260px;
}

.switch-row,
.log-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    color: inherit;
}

.stack-item {
    padding: 18px 20px;
}

.stack-item summary {
    list-style: none;
    display: flex;
    justify-content: space-between;
    gap: 14px;
    cursor: pointer;
}

.pill {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.82rem;
    background: rgba(37, 140, 205, 0.1);
    color: var(--accent);
    font-weight: 700;
}

.pill.connected,
.port-tile.connected {
    background: rgba(35, 132, 107, 0.16);
    color: var(--success);
}

.pill.disconnected,
.port-tile.disconnected {
    background: rgba(217, 111, 50, 0.16);
    color: var(--accent-2);
}

.pill.disabled,
.port-tile.disabled {
    background: rgba(108, 117, 125, 0.22);
    color: var(--disabled);
}

.port-map {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 14px;
}

.module-group {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
}

.module-group-title {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    color: var(--muted);
}

.port-tile {
    text-decoration: none;
    color: inherit;
    min-height: 120px;
    border-radius: 24px;
    padding: 16px;
    display: grid;
    gap: 8px;
    border: 1px solid rgba(31, 41, 51, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.port-tile:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 32px rgba(31, 41, 51, 0.12);
}

.port-number {
    width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.7);
    font-weight: 800;
}

.vlan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

.vlan-option {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.78);
    padding: 12px 14px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.login-screen {
    min-height: 0;
    display: grid;
    place-items: center;
    width: min(760px, 100%);
}

.login-card {
    width: min(680px, 100%);
    padding: 36px;
}

.login-options {
    display: grid;
    gap: 20px;
}

.login-local-form,
.login-federated-block {
    border: 1px solid rgba(31, 41, 51, 0.08);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.55);
    padding: 20px;
}

.login-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.78rem;
    font-weight: 700;
}

.login-divider::before,
.login-divider::after {
    content: '';
    height: 1px;
    flex: 1;
    background: rgba(31, 41, 51, 0.12);
}

.log-json {
    margin: 0;
    white-space: pre-wrap;
    max-width: 420px;
}

.trap-live-table td,
.trap-live-table th {
    vertical-align: top;
}

.trap-live-payload {
    margin: 0;
    white-space: pre-wrap;
    max-width: 360px;
    max-height: 130px;
    overflow: auto;
    font-size: 0.78rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #1d6ea2);
    border: none;
    box-shadow: 0 12px 26px rgba(37, 140, 205, 0.28);
}

.form-control,
.form-select {
    min-height: 48px;
    border-radius: 16px;
    border-color: rgba(31, 41, 51, 0.12);
}

@media (max-width: 1100px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        min-height: auto;
    }

    .stats-grid,
    .content-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .main-panel {
        padding: 18px;
    }

    .hero-panel,
    .page-head {
        flex-direction: column;
        align-items: stretch;
    }

    .stats-grid,
    .content-grid {
        grid-template-columns: 1fr;
    }
}
