* {
    box-sizing: border-box;
}

:root {
    --background: #0b0e13;
    --sidebar: #10141b;
    --surface: #151a22;
    --surface-hover: #1a202a;
    --border: #252c37;

    --text: #f4f6f8;
    --muted: #8893a3;

    --accent: #4c9fff;

    --success: #35c98a;
    --danger: #ef6672;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    min-height: 100vh;

    background: var(--background);

    color: var(--text);

    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

.app {
    min-height: 100vh;

    display: grid;

    grid-template-columns:
        250px minmax(0, 1fr);
}

.sidebar {
    position: fixed;

    top: 0;
    bottom: 0;
    left: 0;

    width: 250px;

    padding: 28px 18px 20px;

    display: flex;
    flex-direction: column;

    background: var(--sidebar);

    border-right: 1px solid var(--border);
}

.brand {
    padding:
        0 12px 30px;
}

.brand-name {
    font-size: 20px;

    font-weight: 800;

    letter-spacing: 0.13em;
}

.brand-description {
    margin-top: 5px;

    color: var(--muted);

    font-size: 12px;
}

.navigation {
    display: flex;

    flex-direction: column;

    gap: 5px;
}

.navigation-item {
    padding:
        13px 14px;

    border-radius: 10px;

    color: var(--muted);

    font-size: 14px;

    font-weight: 600;
}

.navigation-item.active {
    color: var(--text);

    background: rgba(76, 159, 255, 0.12);
}

.navigation-item:not(.disabled):hover {
    background: var(--surface-hover);

    color: var(--text);
}

.navigation-item.disabled {
    opacity: 0.45;

    cursor: default;
}

.sidebar-footer {
    margin-top: auto;

    padding-top: 18px;

    border-top: 1px solid var(--border);
}

.service-status {
    min-height: 34px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    color: var(--muted);

    font-size: 12px;
}

.status-dot {
    width: 8px;
    height: 8px;

    display: inline-block;

    border-radius: 50%;
}

.status-dot.online {
    background: var(--success);
}

.status-dot.offline {
    background: var(--danger);
}

.main {
    grid-column: 2;

    min-width: 0;
}

.topbar {
    min-height: 105px;

    padding:
        25px 34px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    border-bottom: 1px solid var(--border);
}

.topbar-label,
.section-label {
    color: var(--muted);

    font-size: 11px;

    font-weight: 700;

    letter-spacing: 0.12em;
}

.topbar h1 {
    margin:
        4px 0 0;

    font-size: 25px;
}

.system-status {
    display: flex;

    align-items: center;

    gap: 9px;

    padding:
        9px 13px;

    border: 1px solid var(--border);

    border-radius: 100px;

    background: var(--surface);

    color: var(--muted);

    font-size: 12px;
}

.content {
    padding:
        30px 34px 50px;
}

.dashboard {
    display: grid;

    gap: 22px;
}

.welcome-card {
    min-height: 180px;

    padding: 30px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    border: 1px solid var(--border);

    border-radius: 18px;

    background:
        radial-gradient(circle at 90% 10%,
            rgba(76, 159, 255, 0.17),
            transparent 35%),
        var(--surface);
}

.welcome-card h2 {
    margin:
        8px 0;

    font-size: 32px;
}

.welcome-card p {
    margin: 0;

    color: var(--muted);
}

.home-state {
    padding:
        10px 15px;

    border: 1px solid rgba(53, 201, 138, 0.24);

    border-radius: 100px;

    background: rgba(53, 201, 138, 0.09);

    color: var(--success);

    font-size: 13px;

    font-weight: 700;
}

.summary-grid {
    display: grid;

    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    gap: 18px;
}

.summary-card {
    padding: 22px;

    display: flex;

    flex-direction: column;

    border: 1px solid var(--border);

    border-radius: 16px;

    background: var(--surface);
}

.summary-label {
    color: var(--muted);

    font-size: 12px;

    font-weight: 600;
}

.summary-card strong {
    margin-top: 13px;

    font-size: 32px;
}

.summary-card strong.bridge-offline {
    color: var(--danger);

    font-size: 20px;
}

.summary-card small {
    margin-top: 5px;

    color: var(--muted);

    font-size: 12px;
}

.panel {
    padding: 24px;

    border: 1px solid var(--border);

    border-radius: 16px;

    background: var(--surface);
}

.panel-header {
    padding-bottom: 18px;
}

.panel-header h3 {
    margin:
        5px 0 0;
}

.services {
    display: flex;

    flex-direction: column;
}

.service {
    min-height: 72px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 20px;

    border-top: 1px solid var(--border);
}

.service:first-child {
    border-top: 0;
}

.service>div:first-child {
    display: flex;

    flex-direction: column;

    gap: 5px;
}

.service strong {
    font-size: 14px;
}

.service span {
    color: var(--muted);

    font-size: 12px;
}

.service-badge {
    padding:
        6px 10px;

    border-radius: 100px;

    font-size: 12px;

    font-weight: 700;
}

.service-badge.online {
    color: var(--success);

    background: rgba(53, 201, 138, 0.09);
}

.service-badge.offline {
    color: var(--danger);

    background: rgba(239, 102, 114, 0.09);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;

    padding: 0;

    border: 0;

    cursor: pointer;

    color: #8ea0ae;
    background: transparent;
}

.theme-toggle-track {
    position: relative;

    width: 38px;
    height: 21px;

    flex: 0 0 auto;

    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 20px;

    background: #263d50;

    transition:
        background 0.18s ease,
        border-color 0.18s ease;
}

.theme-toggle-knob {
    position: absolute;

    width: 15px;
    height: 15px;

    left: 2px;
    top: 2px;

    border-radius: 50%;

    background: #dce5eb;

    transition:
        transform 0.18s ease,
        background 0.18s ease;
}

.theme-toggle.light .theme-toggle-track {
    border-color: #ccd6dd;

    background: #dfe6eb;
}

.theme-toggle.light .theme-toggle-knob {
    transform: translateX(17px);

    background: #ffffff;

    box-shadow:
        0 2px 5px rgba(0, 0, 0, 0.16);
}

.theme-toggle-label {
    font-size: 11px;
    font-weight: 600;
}


/* TEMA CHIARO */

body.theme-light {
    color: #263746;
    background: #edf1f4;
}

body.theme-light .app {
    background: #edf1f4;
}

body.theme-light .sidebar {
    color: #263746;
    background: #ffffff;

    border-color: #dce3e8;
}

body.theme-light .brand-name {
    color: #263746;
}

body.theme-light .brand-description {
    color: #83919d;
}

body.theme-light .navigation-item {
    color: #687783;
}

body.theme-light .navigation-item:hover:not(.disabled) {
    color: #263746;
    background: #edf2f5;
}

body.theme-light .navigation-item.active {
    color: #ffffff;
    background: #4b6d85;
}

body.theme-light .navigation-item.disabled {
    color: #b0bac1;
}

body.theme-light .sidebar-footer {
    border-color: #e0e6ea;
}

body.theme-light .service-status {
    color: #74828d;
}

body.theme-light .main {
    background: #edf1f4;
}

body.theme-light .topbar {
    border-color: #dce3e8;

    background: rgba(255, 255, 255, 0.88);
}

body.theme-light .topbar-label {
    color: #7b8994;
}

body.theme-light .topbar h1 {
    color: #20313f;
}

body.theme-light .system-status {
    color: #65747f;
}

body.theme-light .content {
    color: #263746;
}

/* =========================================================
   TEMA CHIARO - TOPBAR
   ========================================================= */

body.theme-light .system-status {
    color: #4f6473;

    border: 1px solid #d5dfe5;
    background: #ffffff;

    box-shadow:
        0 3px 10px rgba(45, 65, 80, 0.05);
}


/* =========================================================
   TEMA CHIARO - DASHBOARD
   ========================================================= */

body.theme-light .dashboard {
    color: #253746;
}


/* PANORAMICA */

body.theme-light .welcome-card {
    border: 1px solid #d7e0e6;

    background:
        linear-gradient(135deg,
            #ffffff 0%,
            #f3f7f9 100%);

    box-shadow:
        0 7px 22px rgba(45, 65, 80, 0.07);
}

body.theme-light .welcome-card h2 {
    color: #223746;
}

body.theme-light .welcome-card p {
    color: #718390;
}

body.theme-light .welcome-card .section-label {
    color: #6889a0;
}

body.theme-light .home-state {
    color: #287b58;

    border-color: rgba(45, 159, 108, 0.22);

    background: rgba(45, 159, 108, 0.09);
}


/* CARD RIEPILOGO */

body.theme-light .summary-card {
    border: 1px solid #d7e0e6;

    background: #ffffff;

    box-shadow:
        0 5px 16px rgba(45, 65, 80, 0.06);
}

body.theme-light .summary-card:hover {
    border-color: #c4d1d9;

    box-shadow:
        0 8px 20px rgba(45, 65, 80, 0.09);
}

body.theme-light .summary-card .summary-label {
    color: #718390;
}

body.theme-light .summary-card strong {
    color: #263b4a;
}

body.theme-light .summary-card small {
    color: #82929d;
}

body.theme-light .summary-card .bridge-offline {
    color: #d6535f;
}


/* PANNELLO SERVIZI */

body.theme-light .panel {
    border: 1px solid #d7e0e6;

    background: #ffffff;

    box-shadow:
        0 6px 20px rgba(45, 65, 80, 0.06);
}

body.theme-light .panel-header {
    border-color: #e1e7eb;
}

body.theme-light .panel-header h3 {
    color: #263b4a;
}

body.theme-light .panel .section-label {
    color: #6889a0;
}


/* RIGHE SERVIZI */

body.theme-light .service {
    border-color: #e1e7eb;
}

body.theme-light .service strong {
    color: #304757;
}

body.theme-light .service span {
    color: #718390;
}


/* BADGE SERVIZI */

body.theme-light .service-badge.online {
    color: #237e58;

    background: rgba(46, 168, 113, 0.10);
}

body.theme-light .service-badge.offline {
    color: #c44e5b;

    background: rgba(202, 74, 88, 0.09);
}

.navigation-item {
    display: flex;
    align-items: center;
    gap: 11px;
}

.navigation-icon {
    width: 19px;
    height: 19px;

    flex: 0 0 19px;

    display: grid;
    place-items: center;
}

.navigation-icon svg {
    width: 18px;
    height: 18px;

    fill: none;
    stroke: currentColor;

    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;

    opacity: .82;
}

.navigation-item.active .navigation-icon svg {
    opacity: 1;
}


/* FOOTER SIDEBAR */

body.theme-light .sidebar-footer {
    border-color: #dce4e9;
}

body.theme-light .sidebar-footer .service-status {
    color: #6d7e8a;
}

/* ==========================================================
   SIDEBAR CON ICONE E COMPRESSIONE
   ========================================================== */

.sidebar {
    overflow: hidden;

    transition:
        width .18s ease,
        padding .18s ease;
}

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 12px;
}

.sidebar-toggle {
    width: 38px;
    height: 38px;

    flex: 0 0 38px;

    display: grid;
    place-items: center;

    padding: 0;

    border:
        1px solid rgba(127, 127, 127, .18);

    border-radius: 10px;

    color: #8ea0ae;

    background:
        rgba(127, 127, 127, .05);

    cursor: pointer;

    transition:
        color .15s ease,
        border-color .15s ease,
        background .15s ease;
}

.sidebar-toggle:hover {
    color: #d8e3ea;

    border-color:
        rgba(127, 127, 127, .30);

    background:
        rgba(127, 127, 127, .09);
}

.sidebar-toggle svg {
    width: 20px;
    height: 20px;

    fill: none;
    stroke: currentColor;

    stroke-width: 1.8;
    stroke-linecap: round;
}


/* NAV */

.navigation-item {
    display: flex;
    align-items: center;

    gap: 12px;

    min-width: 0;
}

.navigation-icon {
    width: 22px;
    height: 22px;

    flex: 0 0 22px;

    display: grid;
    place-items: center;
}

.navigation-icon svg {
    width: 20px;
    height: 20px;

    fill: none;
    stroke: currentColor;

    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.navigation-label {
    min-width: 0;

    overflow: hidden;

    white-space: nowrap;

    transition:
        opacity .12s ease;
}


/* FOOTER */

.service-status-label {
    white-space: nowrap;
}


/* ==========================================================
   SIDEBAR COMPRESSA
   ========================================================== */

.app.sidebar-collapsed {
    grid-template-columns:
        76px minmax(0, 1fr);
}

.app.sidebar-collapsed .sidebar {
    width: 76px;
}

.app.sidebar-collapsed .sidebar-head {
    justify-content: center;
}

.app.sidebar-collapsed .brand {
    display: none;
}

.app.sidebar-collapsed .sidebar-toggle {
    margin: 0 auto;
}

.app.sidebar-collapsed .navigation {
    align-items: center;
}

.app.sidebar-collapsed .navigation-item {
    width: 46px;
    height: 46px;

    margin-left: auto;
    margin-right: auto;

    padding: 0;

    justify-content: center;

    gap: 0;
}

.app.sidebar-collapsed .navigation-label {
    display: none;
}

.app.sidebar-collapsed .navigation-icon {
    width: 22px;
    height: 22px;

    flex-basis: 22px;
}

.app.sidebar-collapsed .sidebar-footer {
    align-items: center;
}

.app.sidebar-collapsed .service-status {
    width: 100%;

    justify-content: center;
}

.app.sidebar-collapsed .service-status-label {
    display: none;
}

.app.sidebar-collapsed .status-dot {
    margin: 0;
}


/* ==========================================================
   TEMA CHIARO
   ========================================================== */

body.theme-light .sidebar-toggle {
    color: #687783;

    border-color: #d7e0e6;

    background: #f5f7f8;
}

body.theme-light .sidebar-toggle:hover {
    color: #263746;

    border-color: #c4d1d9;

    background: #edf2f5;
}


/* ==========================================================
   MOBILE
   ========================================================== */

@media (max-width: 760px) {

    .app.sidebar-collapsed {
        display: grid;

        grid-template-columns:
            76px minmax(0, 1fr);
    }

    .app.sidebar-collapsed .sidebar {
        position: relative;

        width: 76px;
        min-height: 100vh;

        border-right:
            1px solid var(--border);

        border-bottom: 0;
    }

    .app.sidebar-collapsed .navigation {
        display: flex;
        flex-direction: column;

        grid-template-columns: none;
    }

    .app.sidebar-collapsed .main {
        min-width: 0;
    }

}

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

@media (max-width: 760px) {
    .app {
        display: block;
    }

    .sidebar {
        position: static;

        width: 100%;

        border-right: 0;

        border-bottom: 1px solid var(--border);
    }

    .sidebar-footer {
        display: none;
    }

    .navigation {
        display: grid;

        grid-template-columns:
            repeat(2, 1fr);
    }

    .main {
        display: block;
    }

    .topbar,
    .content {
        padding-left: 20px;

        padding-right: 20px;
    }

    .system-status {
        display: none;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }

    .welcome-card {
        align-items: flex-start;

        flex-direction: column;

        gap: 25px;
    }
}

/* ==========================================================
   SMARTPHONE / TABLET - SIDEBAR COMPRESSA
   Toggle dopo la navigazione, mai flottante sul contenuto
   ========================================================== */

@media (max-width: 1024px) {

    .app.sidebar-collapsed .sidebar {
        display: flex;
        flex-direction: column;
    }

    .app.sidebar-collapsed .navigation {
        order: 1;
    }

    .app.sidebar-collapsed .sidebar-head {
        order: 2;

        width: 100%;

        margin-top: 10px;

        justify-content: center;
    }

    .app.sidebar-collapsed .sidebar-footer {
        order: 3;
    }

    .app.sidebar-collapsed .sidebar-toggle {
        position: static;

        width: 32px;
        height: 32px;

        flex: 0 0 32px;

        margin: 0 auto;

        border-radius: 9px;

        transform: none;
    }

    .app.sidebar-collapsed .sidebar-toggle svg {
        display: none;
    }

    .app.sidebar-collapsed .sidebar-toggle::before {
        content: "›";

        display: block;

        font-size: 23px;
        font-weight: 400;
        line-height: 1;
    }

}
