:root {
    --m360-bg: #080f1f;
    --m360-bg-soft: #0f172a;
    --m360-sidebar: rgba(15, 23, 42, .94);
    --m360-card: rgba(15, 23, 42, .84);
    --m360-card-soft: rgba(30, 41, 59, .72);
    --m360-border: rgba(148, 163, 184, .16);
    --m360-text: #f8fafc;
    --m360-muted: #94a3b8;
    --m360-primary: #38bdf8;
    --m360-success: #22c55e;
    --m360-warning: #f59e0b;
    --m360-danger: #ef4444;
    --m360-purple: #8b5cf6;
    --m360-shadow: 0 20px 60px rgba(0, 0, 0, .22);
}

html[data-theme="light"] {
    --m360-bg: #f5f7fb;
    --m360-bg-soft: #ffffff;
    --m360-sidebar: rgba(255, 255, 255, .94);
    --m360-card: rgba(255, 255, 255, .9);
    --m360-card-soft: rgba(248, 250, 252, .94);
    --m360-border: rgba(15, 23, 42, .12);
    --m360-text: #0f172a;
    --m360-muted: #64748b;
    --m360-primary: #2563eb;
    --m360-success: #16a34a;
    --m360-warning: #d97706;
    --m360-danger: #dc2626;
    --m360-purple: #7c3aed;
    --m360-shadow: 0 20px 60px rgba(15, 23, 42, .08);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden !important;
}

body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at top left, rgba(56, 189, 248, .18), transparent 32%),
        radial-gradient(circle at 80% 10%, rgba(139, 92, 246, .18), transparent 28%),
        linear-gradient(135deg, #020617 0%, #0f172a 50%, #111827 100%);
    color: var(--m360-text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-text-size-adjust: 100%;
}

html[data-theme="light"] body,
html[data-theme="light"] body.bg-light {
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, .12), transparent 32%),
        radial-gradient(circle at 80% 10%, rgba(124, 58, 237, .10), transparent 28%),
        linear-gradient(135deg, #f8fafc 0%, #eef2ff 52%, #f1f5f9 100%) !important;
}

img,
svg,
video,
canvas {
    max-width: 100%;
}

img {
    height: auto;
}

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

/* ==============================
   ESTRUTURA
============================== */

.app-shell {
    display: flex;
    width: 100%;
    min-height: 100vh;
    min-width: 0;
    overflow-x: clip;
}

.sidebar {
    width: 280px;
    max-width: 280px;
    background: var(--m360-sidebar);
    border-right: 1px solid var(--m360-border);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1000;
    padding: 22px 18px;
    display: flex;
    flex-direction: column;
    overflow: hidden !important;
}

.main {
    margin-left: 280px;
    width: calc(100% - 280px);
    min-width: 0;
    padding: 22px;
}

/* ==============================
   LOGO / MARCA
============================== */

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 8px 10px 24px;
    overflow: hidden !important;
}

.brand-logo-link {
    width: 52px !important;
    min-width: 52px !important;
    max-width: 52px !important;
    height: 52px !important;
    min-height: 52px !important;
    max-height: 52px !important;
    flex: 0 0 52px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden !important;
    text-decoration: none;
}

.brand-logo {
    display: block !important;
    width: 52px !important;
    min-width: 0 !important;
    max-width: 52px !important;
    height: 52px !important;
    min-height: 0 !important;
    max-height: 52px !important;
    object-fit: contain !important;
    position: static !important;
    inset: auto !important;
    transform: none !important;
    z-index: auto !important;
    margin: 0 !important;
    padding: 0 !important;
}

.brand-text {
    min-width: 0;
    overflow: hidden;
}

.brand-title {
    display: block;
    max-width: 100%;
    overflow: hidden;
    color: var(--m360-text);
    font-size: 1.12rem;
    font-weight: 850;
    letter-spacing: .2px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-subtitle {
    max-width: 100%;
    overflow: hidden;
    color: var(--m360-muted);
    font-size: .78rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 16px;
    background: linear-gradient(135deg, #38bdf8, #8b5cf6);
    display: grid;
    place-items: center;
    box-shadow: 0 14px 40px rgba(56, 189, 248, .25);
    color: #fff;
    flex: 0 0 auto;
}

.brand-icon i {
    font-size: 22px;
}

/* ==============================
   MENU LATERAL
============================== */

.menu-label {
    color: var(--m360-muted);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    padding: 16px 12px 8px;
}

.nav-link-m360 {
    color: color-mix(in srgb, var(--m360-text) 76%, var(--m360-muted));
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 13px;
    border-radius: 14px;
    margin-bottom: 4px;
    transition: .2s ease;
    font-size: .94rem;
    min-width: 0;
}

.nav-link-m360 span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-link-m360:hover,
.nav-link-m360.active {
    background: rgba(56, 189, 248, .12);
    color: var(--m360-text);
}

.nav-link-m360.active {
    border: 1px solid rgba(56, 189, 248, .22);
}

.sidebar-status-card {
    margin-top: auto;
    background: var(--m360-card);
    border: 1px solid var(--m360-border);
    border-radius: 22px;
    box-shadow: var(--m360-shadow);
    padding: 16px;
    overflow: hidden;
}

/* ==============================
   TOPO
============================== */

.topbar {
    width: 100%;
    min-width: 0;
    min-height: 72px;
    background: rgba(15, 23, 42, .62);
    border: 1px solid var(--m360-border);
    border-radius: 24px;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
    box-shadow: var(--m360-shadow);
    overflow: hidden;
}

html[data-theme="light"] .topbar {
    background: rgba(255, 255, 255, .72);
}

.topbar-info {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    flex: 1 1 auto;
}

.page-heading {
    min-width: 0;
    max-width: 100%;
}

.page-title {
    color: var(--m360-text);
    font-size: 1.35rem;
    font-weight: 850;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.page-subtitle,
.section-subtitle,
.text-secondary,
.text-muted {
    color: var(--m360-muted) !important;
}

.page-subtitle {
    margin-top: 3px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex: 0 0 auto;
    min-width: 0;
}

.mobile-toggle {
    display: none;
    flex: 0 0 auto;
}

/* ==============================
   CARDS / COMPONENTES
============================== */

.glass-card,
.card {
    background: var(--m360-card);
    border: 1px solid var(--m360-border) !important;
    border-radius: 24px;
    box-shadow: var(--m360-shadow);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    color: var(--m360-text);
}

.card-header,
.card-footer {
    background: transparent;
    border-color: var(--m360-border);
}

.hero {
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.hero::after {
    content: "";
    position: absolute;
    width: 260px;
    height: 260px;
    right: -80px;
    top: -80px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(56, 189, 248, .22), transparent 70%);
    pointer-events: none;
}

.health-number {
    font-size: clamp(2.5rem, 5vw, 4.6rem);
    font-weight: 900;
    letter-spacing: -0.06em;
    line-height: 1;
}

.health-label {
    color: var(--m360-muted);
    font-size: .94rem;
}

.kpi-card {
    padding: 18px;
    height: 100%;
    transition: .22s ease;
    position: relative;
    overflow: hidden;
}

.kpi-card:hover,
.platform-card:hover {
    transform: translateY(-3px);
    border-color: rgba(56, 189, 248, .32) !important;
}

.kpi-icon {
    width: 42px;
    height: 42px;
    border-radius: 15px;
    display: grid;
    place-items: center;
    background: rgba(56, 189, 248, .12);
    color: var(--m360-primary);
    font-size: 1.25rem;
}

.kpi-title {
    color: var(--m360-muted);
    font-size: .82rem;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 850;
    letter-spacing: -0.04em;
}

.kpi-foot {
    font-size: .78rem;
    color: var(--m360-muted);
}

.section-title {
    font-weight: 850;
    font-size: 1rem;
    margin: 0;
    color: var(--m360-text);
}

.platform-card {
    padding: 17px;
    height: 100%;
    transition: .22s ease;
}

.platform-logo {
    width: 42px;
    height: 42px;
    border-radius: 15px;
    background: rgba(255,255,255,.06);
    display: grid;
    place-items: center;
    color: var(--m360-text);
    font-weight: 850;
}

html[data-theme="light"] .platform-logo {
    background: rgba(37, 99, 235, .08);
}

.soft-badge {
    border-radius: 999px;
    padding: 5px 10px;
    font-size: .74rem;
    font-weight: 750;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.soft-badge.success { color: #86efac; background: rgba(34, 197, 94, .12); border-color: rgba(34, 197, 94, .20); }
.soft-badge.warning { color: #fcd34d; background: rgba(245, 158, 11, .12); border-color: rgba(245, 158, 11, .22); }
.soft-badge.danger { color: #fca5a5; background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .22); }
.soft-badge.primary { color: #7dd3fc; background: rgba(56, 189, 248, .12); border-color: rgba(56, 189, 248, .22); }
.soft-badge.info { color: #67e8f9; background: rgba(6, 182, 212, .12); border-color: rgba(6, 182, 212, .22); }

html[data-theme="light"] .soft-badge.success { color: #15803d; }
html[data-theme="light"] .soft-badge.warning { color: #b45309; }
html[data-theme="light"] .soft-badge.danger { color: #b91c1c; }
html[data-theme="light"] .soft-badge.primary { color: #1d4ed8; }
html[data-theme="light"] .soft-badge.info { color: #0e7490; }

/* ==============================
   TABELAS
============================== */

.table {
    color: var(--m360-text);
    --bs-table-bg: transparent;
    --bs-table-color: var(--m360-text);
    --bs-table-hover-bg: rgba(56, 189, 248, .06);
    --bs-table-hover-color: var(--m360-text);
    border-color: var(--m360-border);
}

.table th,
.table-m360 thead th {
    color: var(--m360-muted);
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    border-bottom: 1px solid var(--m360-border);
    font-weight: 850;
    padding: 14px 16px;
    background: transparent;
}

.table td,
.table-m360 tbody td {
    border-bottom: 1px solid rgba(148, 163, 184, .10);
    padding: 14px 16px;
    vertical-align: middle;
    font-size: .88rem;
}

.table-m360 {
    color: var(--m360-text);
    margin: 0;
}

/* ==============================
   TIMELINE
============================== */

.timeline {
    position: relative;
    padding-left: 8px;
}

.timeline-item {
    display: flex;
    gap: 12px;
    margin-bottom: 18px;
}

.timeline-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-top: 5px;
    flex: 0 0 auto;
    box-shadow: 0 0 0 6px rgba(255,255,255,.04);
}

.timeline-dot.success { background: var(--m360-success); }
.timeline-dot.warning { background: var(--m360-warning); }
.timeline-dot.danger { background: var(--m360-danger); }
.timeline-dot.primary { background: var(--m360-primary); }

.timeline-time { color: var(--m360-muted); font-size: .76rem; }
.timeline-title { font-weight: 750; font-size: .9rem; }
.timeline-desc { color: var(--m360-muted); font-size: .8rem; }

/* ==============================
   BOTÕES / FORMULÁRIOS
============================== */

.btn {
    border-radius: 12px;
}

.btn-m360 {
    border-radius: 14px;
    font-weight: 750;
    padding: 10px 14px;
}

.btn-glow {
    background: linear-gradient(135deg, #38bdf8, #2563eb);
    color: #fff;
    border: none;
    box-shadow: 0 14px 30px rgba(37, 99, 235, .25);
}

.btn-glow:hover {
    color: #fff;
    transform: translateY(-1px);
}

html[data-theme="light"] .btn-outline-light,
html[data-theme="light"] .btn-outline-dark,
html[data-theme="light"] .btn-outline-secondary {
    border-color: rgba(15, 23, 42, .18);
    color: #0f172a;
}

html[data-theme="light"] .btn-outline-light:hover,
html[data-theme="light"] .btn-outline-dark:hover,
html[data-theme="light"] .btn-outline-secondary:hover {
    background: #0f172a;
    color: #fff;
}

.form-control,
.form-select {
    background-color: rgba(15, 23, 42, .82);
    border-color: var(--m360-border);
    color: var(--m360-text);
    border-radius: 14px;
}

.form-control:focus,
.form-select:focus {
    background-color: rgba(15, 23, 42, .92);
    color: var(--m360-text);
    border-color: rgba(56, 189, 248, .5);
    box-shadow: 0 0 0 .25rem rgba(56, 189, 248, .08);
}

.form-control::placeholder {
    color: #64748b;
}

html[data-theme="light"] .form-control,
html[data-theme="light"] .form-select {
    background-color: rgba(255, 255, 255, .92);
    border-color: rgba(15, 23, 42, .12);
    color: #0f172a;
}

html[data-theme="light"] .form-control:focus,
html[data-theme="light"] .form-select:focus {
    background-color: #fff;
    color: #0f172a;
}

/* ==============================
   MODAL / DROPDOWN / LOG
============================== */

.modal-content,
.offcanvas {
    background: var(--m360-bg-soft);
    color: var(--m360-text);
    border: 1px solid var(--m360-border);
}

.modal-header,
.modal-footer {
    border-color: var(--m360-border);
}

html[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

.dropdown-menu {
    background: var(--m360-bg-soft);
    border-color: var(--m360-border);
    box-shadow: var(--m360-shadow);
}

.dropdown-item,
.dropdown-item-text {
    color: var(--m360-text);
}

.dropdown-item:hover {
    background: rgba(56, 189, 248, .10);
    color: var(--m360-text);
}

.log-pre,
.json-box {
    max-height: 420px;
    overflow: auto;
    font-size: .82rem;
    white-space: pre-wrap;
    word-break: break-word;
    background: #020617;
    border: 1px solid var(--m360-border);
    border-radius: 18px;
    padding: 16px;
    color: #cbd5e1;
}

html[data-theme="light"] .log-pre,
html[data-theme="light"] .json-box {
    background: #f8fafc;
    color: #334155;
}

/* ==============================
   LOGIN
============================== */

.login-shell {
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow: hidden;
}

.login-card {
    max-width: 430px;
    width: 100%;
    overflow: hidden !important;
}

.login-logo-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    overflow: hidden !important;
}

.login-logo {
    display: block !important;
    width: 260px !important;
    min-width: 0 !important;
    max-width: min(78vw, 260px) !important;
    height: auto !important;
    max-height: 120px !important;
    object-fit: contain !important;
    object-position: center !important;
    position: static !important;
    inset: auto !important;
    transform: none !important;
    z-index: auto !important;
    margin: 0 auto !important;
    padding: 0 !important;
}

.login-brand-icon {
    width: 56px;
    height: 56px;
    border-radius: 20px;
    background: linear-gradient(135deg, #38bdf8, #8b5cf6);
    display: grid;
    place-items: center;
    color: #fff;
    margin: 0 auto 14px;
    box-shadow: 0 14px 40px rgba(56, 189, 248, .25);
}

.login-brand-icon i {
    font-size: 28px;
}

/* ==============================
   FOOTER
============================== */

.footer-m360,
.app-footer {
    margin-top: 24px;
    padding: 16px 8px 4px;
    color: var(--m360-muted);
    font-size: .82rem;
    text-align: center;
}

/* ==============================
   TEMA LIGHT AUXILIAR
============================== */

html[data-theme="light"] .text-white {
    color: var(--m360-text) !important;
}

html[data-theme="light"] .bg-dark {
    background-color: #f8fafc !important;
}

html[data-theme="light"] .text-light {
    color: #334155 !important;
}

/* ==============================
   RESPONSIVO
============================== */

@media (max-width: 991px) {
    .sidebar {
        width: 280px !important;
        max-width: min(280px, 86vw) !important;
        transform: translate3d(-105%, 0, 0);
        visibility: hidden;
        pointer-events: none;
        transition: transform .25s ease, visibility .25s ease;
        overflow: hidden !important;
    }

    .sidebar.show {
        transform: translate3d(0, 0, 0);
        visibility: visible;
        pointer-events: auto;
    }

    .main {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 14px !important;
    }

    .brand-logo-link {
        width: 44px !important;
        min-width: 44px !important;
        max-width: 44px !important;
        height: 44px !important;
        min-height: 44px !important;
        max-height: 44px !important;
        flex-basis: 44px !important;
    }

    .brand-logo {
        width: 44px !important;
        max-width: 44px !important;
        height: 44px !important;
        max-height: 44px !important;
    }

    .topbar {
        display: grid !important;
        grid-template-columns: 1fr;
        align-items: stretch;
        gap: 14px;
        min-height: 0;
        padding: 16px !important;
        border-radius: 22px !important;
        overflow: hidden !important;
    }

    .topbar-info {
        display: grid !important;
        grid-template-columns: 44px minmax(0, 1fr);
        align-items: flex-start;
        gap: 12px;
        width: 100%;
        min-width: 0;
    }

    .mobile-toggle {
        display: inline-flex !important;
        width: 44px;
        height: 44px;
        align-items: center;
        justify-content: center;
        padding: 0 !important;
    }

    .page-heading {
        min-width: 0;
        width: 100%;
    }

    .page-title {
        font-size: 1.22rem !important;
        line-height: 1.18 !important;
        margin: 0 !important;
    }

    .page-subtitle {
        font-size: .9rem !important;
        line-height: 1.35 !important;
        margin-top: 6px;
    }

    .topbar-actions {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 10px;
        width: 100%;
        min-width: 0;
        justify-content: stretch;
    }

    .topbar-actions .btn,
    .topbar-actions .dropdown,
    .topbar-actions .dropdown > .btn {
        width: 100%;
        min-width: 0;
    }

    .topbar-actions .btn {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .login-logo {
        width: 210px !important;
        max-width: 74vw !important;
        max-height: 95px !important;
    }
}

@media (max-width: 575px) {
    .main {
        padding: 12px !important;
    }

    .topbar {
        padding: 14px !important;
        gap: 12px;
    }

    .page-title {
        font-size: 1.12rem !important;
    }

    .page-subtitle {
        font-size: .84rem !important;
    }

    .topbar-actions {
        grid-template-columns: 1fr;
    }

    .btn-m360 {
        padding: 9px 10px;
        font-size: .88rem;
    }

    .login-shell {
        padding: 18px;
    }

    .login-logo {
        width: 180px !important;
        max-width: 70vw !important;
        max-height: 82px !important;
    }

    .brand-logo-link {
        width: 40px !important;
        min-width: 40px !important;
        max-width: 40px !important;
        height: 40px !important;
        min-height: 40px !important;
        max-height: 40px !important;
        flex-basis: 40px !important;
    }

    .brand-logo {
        width: 40px !important;
        max-width: 40px !important;
        height: 40px !important;
        max-height: 40px !important;
    }
}


/* =====================================================
   SIDEBAR RETRÁTIL / RESPONSIVA
   Desktop: recolhe/expande.
   Mobile: abre/fecha como gaveta com backdrop.
===================================================== */

:root {
    --m360-sidebar-width: 280px;
    --m360-sidebar-collapsed-width: 86px;
}

.sidebar,
.main,
.brand,
.brand-text,
.brand-logo-link,
.brand-logo,
.nav-link-m360,
.nav-link-m360 span,
.menu-label,
.sidebar-status-card,
.sidebar-tools,
.sidebar-collapse-btn,
.sidebar-close-btn {
    transition: width .25s ease, max-width .25s ease, min-width .25s ease,
                margin .25s ease, padding .25s ease, opacity .18s ease,
                visibility .18s ease, transform .25s ease, background .2s ease,
                border-color .2s ease;
}

.sidebar-tools {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    min-height: 34px;
    margin-bottom: 6px;
}

.sidebar-collapse-btn,
.sidebar-close-btn {
    width: 34px;
    height: 34px;
    border: 1px solid var(--m360-border);
    border-radius: 12px;
    background: var(--m360-card-soft);
    color: var(--m360-text);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    line-height: 1;
}

.sidebar-collapse-btn:hover,
.sidebar-close-btn:hover {
    background: rgba(56, 189, 248, .12);
    border-color: rgba(56, 189, 248, .35);
}

.sidebar-backdrop {
    display: none;
}

/* Estado retraído no desktop */
@media (min-width: 992px) {
    body.sidebar-collapsed .sidebar {
        width: var(--m360-sidebar-collapsed-width) !important;
        max-width: var(--m360-sidebar-collapsed-width) !important;
        padding-left: 14px !important;
        padding-right: 14px !important;
    }

    body.sidebar-collapsed .main {
        margin-left: var(--m360-sidebar-collapsed-width) !important;
        width: calc(100% - var(--m360-sidebar-collapsed-width)) !important;
    }

    body.sidebar-collapsed .sidebar-tools {
        justify-content: center;
    }

    body.sidebar-collapsed .brand {
        justify-content: center;
        gap: 0;
        padding-left: 0;
        padding-right: 0;
    }

    body.sidebar-collapsed .brand-logo-link {
        width: 48px !important;
        min-width: 48px !important;
        max-width: 48px !important;
        height: 48px !important;
        min-height: 48px !important;
        max-height: 48px !important;
        flex: 0 0 48px !important;
    }

    body.sidebar-collapsed .brand-logo {
        width: 48px !important;
        max-width: 48px !important;
        height: 48px !important;
        max-height: 48px !important;
    }

    body.sidebar-collapsed .brand-text,
    body.sidebar-collapsed .nav-link-m360 span,
    body.sidebar-collapsed .menu-label,
    body.sidebar-collapsed .sidebar-status-card {
        opacity: 0 !important;
        visibility: hidden !important;
        width: 0 !important;
        max-width: 0 !important;
        height: 0 !important;
        max-height: 0 !important;
        overflow: hidden !important;
        padding: 0 !important;
        margin: 0 !important;
        border: 0 !important;
    }

    body.sidebar-collapsed .nav-link-m360 {
        justify-content: center;
        gap: 0;
        padding: 12px 0 !important;
    }

    body.sidebar-collapsed .nav-link-m360 i {
        font-size: 1.12rem;
    }

    body.sidebar-collapsed .sidebar-collapse-btn i {
        transform: rotate(180deg);
    }
}

/* Mobile: menu lateral como gaveta */
@media (max-width: 991px) {
    .sidebar-tools {
        justify-content: flex-end;
    }

    .sidebar-collapse-btn {
        display: none !important;
    }

    .sidebar-close-btn {
        display: inline-flex !important;
    }

    .sidebar {
        transform: translate3d(-105%, 0, 0);
        visibility: hidden;
        pointer-events: none;
    }

    .sidebar.show {
        transform: translate3d(0, 0, 0);
        visibility: visible;
        pointer-events: auto;
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 999;
        background: rgba(2, 6, 23, .52);
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
        display: none;
    }

    .sidebar-backdrop.show {
        display: block;
    }

    body.mobile-menu-open {
        overflow: hidden !important;
        touch-action: none;
    }

    body.sidebar-collapsed .sidebar {
        width: 280px !important;
        max-width: min(280px, 86vw) !important;
        padding: 22px 18px !important;
    }

    body.sidebar-collapsed .main {
        margin-left: 0 !important;
        width: 100% !important;
    }

    body.sidebar-collapsed .brand-text,
    body.sidebar-collapsed .nav-link-m360 span,
    body.sidebar-collapsed .menu-label,
    body.sidebar-collapsed .sidebar-status-card {
        opacity: 1 !important;
        visibility: visible !important;
        width: auto !important;
        max-width: none !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        padding: revert-layer;
        margin: revert-layer;
        border: revert-layer;
    }
}

/* Melhor leitura dos botões no mobile */
@media (max-width: 575px) {
    .topbar-actions {
        grid-template-columns: 1fr !important;
    }
}

/* =====================================================
   CORREÇÃO DROPDOWN USUÁRIO / LOGOUT
===================================================== */

.topbar {
    overflow: visible !important;
}

.topbar-actions,
.dropdown {
    position: relative;
    overflow: visible !important;
}

.dropdown-menu {
    z-index: 3000 !important;
    border-radius: 16px;
    padding: 8px;
    min-width: 220px;
}

.dropdown-menu-end {
    right: 0;
    left: auto;
}

/* Mobile */
@media (max-width: 991px) {
    .topbar {
        overflow: visible !important;
    }

    .topbar-actions {
        overflow: visible !important;
    }

    .dropdown-menu {
        width: 100%;
        min-width: 100%;
    }
}

/* =====================================================
   CORREÇÃO CAMADA DROPDOWN USUÁRIO
===================================================== */

.topbar {
    position: relative;
    z-index: 2500 !important;
    overflow: visible !important;
}

.topbar-actions,
.topbar-actions .dropdown {
    position: relative;
    z-index: 2600 !important;
    overflow: visible !important;
}

.user-dropdown-menu,
.dropdown-menu {
    z-index: 5000 !important;
}

.main {
    position: relative;
    z-index: 1;
}

.glass-card,
.card,
.hero,
.kpi-card,
.platform-card {
    position: relative;
    z-index: 1;
}

/* =====================================================
   MODAL MODERNO DE EXECUÇÃO / CONFIRMAÇÃO
   Uso global: M360UI.loading(), success(), error(), confirm()
===================================================== */

.m360-feedback-modal .modal-dialog {
    max-width: min(760px, calc(100vw - 28px));
}

.m360-feedback-modal .modal-content {
    overflow: hidden;
    border-radius: 28px;
    background:
        radial-gradient(circle at top left, rgba(56, 189, 248, .13), transparent 34%),
        var(--m360-bg-soft);
    border: 1px solid var(--m360-border);
    box-shadow: 0 28px 90px rgba(0, 0, 0, .36);
}

html[data-theme="light"] .m360-feedback-modal .modal-content {
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, .10), transparent 34%),
        #ffffff;
    box-shadow: 0 28px 90px rgba(15, 23, 42, .16);
}

.m360-feedback-modal .modal-header {
    padding: 20px 22px 14px;
    border-bottom: 1px solid var(--m360-border);
    align-items: flex-start;
    gap: 14px;
}

.m360-feedback-modal .modal-body {
    padding: 20px 22px 22px;
}

.m360-feedback-modal .modal-footer {
    padding: 14px 22px 20px;
    border-top: 1px solid var(--m360-border);
    gap: 10px;
}

.m360-feedback-head {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    min-width: 0;
    flex: 1 1 auto;
}

.m360-feedback-icon {
    width: 48px;
    height: 48px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    flex: 0 0 48px;
    font-size: 1.35rem;
    color: #fff;
    box-shadow: 0 16px 36px rgba(15, 23, 42, .18);
}

.m360-feedback-icon.loading {
    background: linear-gradient(135deg, #38bdf8, #2563eb);
}

.m360-feedback-icon.success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.m360-feedback-icon.error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.m360-feedback-icon.warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.m360-feedback-icon.info {
    background: linear-gradient(135deg, #38bdf8, #8b5cf6);
}

.m360-feedback-title-wrap {
    min-width: 0;
}

.m360-feedback-title {
    color: var(--m360-text);
    font-weight: 850;
    font-size: 1.12rem;
    line-height: 1.2;
    margin: 2px 0 3px;
}

.m360-feedback-subtitle {
    color: var(--m360-muted);
    font-size: .86rem;
    line-height: 1.35;
    margin: 0;
    overflow-wrap: anywhere;
}

.m360-feedback-message {
    color: var(--m360-text);
    background: var(--m360-card);
    border: 1px solid var(--m360-border);
    border-radius: 20px;
    padding: 16px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.m360-feedback-message.success {
    border-color: rgba(34, 197, 94, .28);
    background: rgba(34, 197, 94, .10);
}

.m360-feedback-message.error {
    border-color: rgba(239, 68, 68, .30);
    background: rgba(239, 68, 68, .10);
}

.m360-feedback-message.warning {
    border-color: rgba(245, 158, 11, .30);
    background: rgba(245, 158, 11, .10);
}

.m360-feedback-message.info,
.m360-feedback-message.loading {
    border-color: rgba(56, 189, 248, .26);
    background: rgba(56, 189, 248, .10);
}

.m360-feedback-loader {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--m360-muted);
    margin-top: 12px;
    font-size: .88rem;
}

.m360-feedback-spinner {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    border: 3px solid rgba(148, 163, 184, .25);
    border-top-color: var(--m360-primary);
    animation: m360spin .8s linear infinite;
}

@keyframes m360spin {
    to {
        transform: rotate(360deg);
    }
}

.m360-feedback-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.m360-feedback-meta-item {
    background: var(--m360-card);
    border: 1px solid var(--m360-border);
    border-radius: 16px;
    padding: 10px 12px;
    min-width: 0;
}

.m360-feedback-meta-label {
    color: var(--m360-muted);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 800;
    margin-bottom: 4px;
}

.m360-feedback-meta-value {
    color: var(--m360-text);
    font-weight: 800;
    font-size: .9rem;
    overflow-wrap: anywhere;
}

.m360-feedback-technical {
    margin-top: 14px;
}

.m360-feedback-technical-toggle {
    width: 100%;
    border: 1px solid var(--m360-border);
    background: var(--m360-card-soft);
    color: var(--m360-text);
    border-radius: 16px;
    padding: 11px 13px;
    font-size: .88rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.m360-feedback-technical-toggle:hover {
    background: rgba(56, 189, 248, .10);
    border-color: rgba(56, 189, 248, .28);
}

.m360-feedback-technical pre {
    margin: 10px 0 0;
    max-height: 340px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    background: #020617;
    color: #cbd5e1;
    border: 1px solid var(--m360-border);
    border-radius: 18px;
    padding: 14px;
    font-size: .78rem;
}

html[data-theme="light"] .m360-feedback-technical pre {
    background: #f8fafc;
    color: #334155;
}

.m360-feedback-modal .btn {
    border-radius: 14px;
    font-weight: 800;
}

.m360-feedback-modal .btn-primary {
    background: linear-gradient(135deg, #38bdf8, #2563eb);
    border: 0;
    box-shadow: 0 14px 30px rgba(37, 99, 235, .20);
}

.m360-feedback-modal .btn-success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border: 0;
}

.m360-feedback-modal .btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border: 0;
}

@media (max-width: 575px) {
    .m360-feedback-modal .modal-dialog {
        margin: 12px;
        max-width: calc(100vw - 24px);
    }

    .m360-feedback-modal .modal-header,
    .m360-feedback-modal .modal-body,
    .m360-feedback-modal .modal-footer {
        padding-left: 16px;
        padding-right: 16px;
    }

    .m360-feedback-head {
        gap: 11px;
    }

    .m360-feedback-icon {
        width: 42px;
        height: 42px;
        flex-basis: 42px;
        border-radius: 16px;
        font-size: 1.15rem;
    }

    .m360-feedback-meta {
        grid-template-columns: 1fr;
    }

    .m360-feedback-modal .modal-footer {
        display: grid;
        grid-template-columns: 1fr;
    }

    .m360-feedback-modal .modal-footer .btn {
        width: 100%;
    }
}

/* =========================================================
   MODAL M360 - CORREÇÃO RESPONSIVO / MOBILE
   ========================================================= */

.m360-modal-backdrop {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(15, 23, 42, 0.62);
    backdrop-filter: blur(4px);
    z-index: 99998 !important;
    display: none;
}

.m360-modal-backdrop.show {
    display: block !important;
}

.m360-modal {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 99999 !important;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.m360-modal.show {
    display: flex !important;
}

.m360-modal-card {
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: var(--m360-card-bg, #ffffff);
    color: var(--m360-text, #0f172a);
    border-radius: 22px;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.30);
    position: relative;
    z-index: 100000 !important;
    animation: m360ModalIn .18s ease-out;
}

@keyframes m360ModalIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.m360-modal-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 22px 24px 12px;
}

.m360-modal-icon {
    width: 44px;
    height: 44px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    font-size: 22px;
}

.m360-modal-icon.success {
    background: rgba(34, 197, 94, .14);
    color: #16a34a;
}


.m360-modal-icon.warning {
    background: rgba(245, 158, 11, .16);
    color: #d97706;
}

.m360-modal-icon.error {
    background: rgba(239, 68, 68, .14);
    color: #dc2626;
}

.m360-modal-icon.loading {
    background: rgba(59, 130, 246, .14);
    color: #2563eb;
}

.m360-modal-title {
    margin: 0;
    font-size: 1.08rem;
    font-weight: 800;
}

.m360-modal-subtitle {
    margin: 3px 0 0;
    color: var(--m360-muted, #64748b);
    font-size: .9rem;
}

.m360-modal-body {
    padding: 8px 24px 18px;
}

.m360-modal-message {
    margin: 0;
    color: var(--m360-text, #0f172a);
    line-height: 1.5;
}

.m360-modal-tech {
    margin-top: 16px;
    border: 1px solid rgba(148, 163, 184, .35);
    border-radius: 14px;
    overflow: hidden;
}

.m360-modal-tech summary {
    cursor: pointer;
    padding: 12px 14px;
    font-size: .88rem;
    font-weight: 700;
    color: var(--m360-text, #0f172a);
    background: rgba(148, 163, 184, .10);
}

.m360-modal-tech pre {
    margin: 0;
    padding: 14px;
    max-height: 260px;
    overflow: auto;
    font-size: .78rem;
    white-space: pre-wrap;
    word-break: break-word;
    background: rgba(15, 23, 42, .04);
    color: var(--m360-text, #0f172a);
}

.m360-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 0 24px 22px;
}

.m360-modal-btn {
    border: 0;
    border-radius: 14px;
    padding: 10px 16px;
    font-weight: 800;
    cursor: pointer;
    background: #2563eb;
    color: #ffffff;
}

.m360-modal-btn:hover {
    filter: brightness(.96);
}

.m360-modal-close {
    margin-left: auto;
    border: 0;
    background: transparent;
    font-size: 24px;
    line-height: 1;
    color: var(--m360-muted, #64748b);
    cursor: pointer;
}

/* Spinner loading */
.m360-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid rgba(37, 99, 235, .20);
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: m360Spin .75s linear infinite;
}

@keyframes m360Spin {
    to {
        transform: rotate(360deg);
    }
}

/* Bloqueia scroll do fundo */
body.m360-modal-open {
    overflow: hidden !important;
    touch-action: none;
}

/* Ajuste especial mobile */
@media (max-width: 768px) {
    .m360-modal {
        align-items: flex-end;
        padding: 12px;
    }

    .m360-modal-card {
        max-width: 100%;
        max-height: calc(100vh - 24px);
        border-radius: 22px 22px 18px 18px;
    }

    .m360-modal-header {
        padding: 20px 18px 10px;
    }

    .m360-modal-body {
        padding: 8px 18px 16px;
    }

    .m360-modal-footer {
        padding: 0 18px 18px;
    }

    .m360-modal-btn {
        width: 100%;
        padding: 13px 16px;
    }
}

/* Tema dark */
[data-theme="dark"] .m360-modal-card {
    background: #111827;
    color: #f8fafc;
}

[data-theme="dark"] .m360-modal-message,
[data-theme="dark"] .m360-modal-title,
[data-theme="dark"] .m360-modal-tech summary,
[data-theme="dark"] .m360-modal-tech pre {
    color: #f8fafc;
}

[data-theme="dark"] .m360-modal-subtitle,
[data-theme="dark"] .m360-modal-close {
    color: #94a3b8;
}

[data-theme="dark"] .m360-modal-tech {
    border-color: rgba(148, 163, 184, .22);
}

[data-theme="dark"] .m360-modal-tech summary {
    background: rgba(148, 163, 184, .10);
}

[data-theme="dark"] .m360-modal-tech pre {
    background: rgba(15, 23, 42, .55);
}

.empresa-switch-form {
    margin: 0;
}

.empresa-switch-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.empresa-switch-label {
    font-size: 12px;
    color: var(--m360-muted, #94a3b8);
    margin: 0;
    white-space: nowrap;
}

.empresa-switch-select {
    min-width: 260px;
    max-width: 360px;
    background-color: var(--m360-card, #111827);
    color: var(--m360-text, #e5e7eb);
    border-color: var(--m360-border, rgba(148, 163, 184, 0.25));
}

.empresa-switch-select:focus {
    box-shadow: 0 0 0 .2rem rgba(13, 110, 253, .15);
}

@media (max-width: 991px) {
    .topbar-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 8px;
    }

    .empresa-switch-form {
        width: 100%;
        order: 3;
    }

    .empresa-switch-wrap {
        width: 100%;
        align-items: stretch;
        flex-direction: column;
        gap: 4px;
    }

    .empresa-switch-select {
        width: 100%;
        max-width: 100%;
        min-width: 100%;
    }
}