:root{
    --bg:#07111f;
    --card:#0f1c30;
    --card2:#0b1829;
    --line:#223754;
    --text:#f7f9fc;
    --muted:#94a7bf;
    --brand:#765cff;
    --green:#32d394;
    --yellow:#f2ba4d;
    --red:#ef5f72;
    --sidebar-width:258px;
    --mobile-nav-height:72px;
}

*{
    box-sizing:border-box;
}

html{
    min-width:0;
    background:var(--bg);
}

body{
    margin:0;
    min-width:0;
    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    background:
        radial-gradient(
            circle at 20% 0,
            rgba(118,92,255,.12),
            transparent 30%
        ),
        var(--bg);
    color:var(--text);
}

body.sidebar-open{
    overflow:hidden;
}

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

button,
input,
select,
textarea{
    font:inherit;
}

button{
    -webkit-tap-highlight-color:transparent;
}

img{
    max-width:100%;
}

.btn{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:7px;
    min-height:42px;
    padding:9px 15px;
    border:1px solid transparent;
    border-radius:11px;
    background:var(--brand);
    color:#fff;
    font-weight:850;
    cursor:pointer;
}

.btn.secondary{
    background:#12223a;
    border-color:#2a4160;
}

.btn.danger{
    background:#341821;
    border-color:#6d3042;
    color:#ffbdc8;
}

.btn.warning{
    background:#322817;
    border-color:#65501f;
    color:#ffd57f;
}

.btn.full{
    width:100%;
}

.btn.small{
    min-height:34px;
    padding:6px 10px;
    font-size:12px;
}

.muted{
    color:var(--muted);
}

.mini{
    font-size:11px;
    color:#7085a0;
}

.flash{
    margin:0 0 14px;
    padding:12px 14px;
    border:1px solid #294361;
    border-radius:11px;
    background:#11223a;
}

.flash.success{
    background:#112d22;
    border-color:#296749;
}

.flash.error{
    background:#311820;
    border-color:#713144;
}

.support-mode{
    position:relative;
    z-index:2000;
    display:flex;
    justify-content:center;
    gap:10px;
    padding:10px 14px;
    background:#4a3512;
    border-bottom:1px solid #765b25;
    color:#ffe4a4;
    font-size:12px;
}

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

.sidebar{
    position:fixed;
    inset:0 auto 0 0;
    z-index:1200;

    width:var(--sidebar-width);
    height:100dvh;

    display:flex;
    flex-direction:column;

    padding:16px 12px 12px;

    overflow:hidden;

    background:
        linear-gradient(
            180deg,
            #07111f,
            #081423
        );

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

    box-shadow:
        18px 0 50px
        rgba(0,0,0,.10);
}

.sidebar-head{
    flex:0 0 auto;
    display:flex;
    align-items:center;
    gap:8px;
    padding:2px 3px 10px;
}

.brand{
    min-width:0;
    flex:1;
    display:flex;
    align-items:center;
    gap:10px;
}

.brand-mark{
    flex:0 0 auto;
    width:37px;
    height:37px;
    display:grid;
    place-items:center;
    border-radius:11px;
    background:
        linear-gradient(
            135deg,
            #806cff,
            #4f39dd
        );
    color:#fff;
    font-size:15px;
    font-weight:950;
    box-shadow:
        0 9px 22px
        rgba(118,92,255,.22);
}

.brand-copy{
    min-width:0;
    display:grid;
}

.brand-copy strong{
    overflow:hidden;
    white-space:nowrap;
    text-overflow:ellipsis;
    font-size:17px;
    font-weight:950;
}

.brand-copy small{
    margin-top:2px;
    overflow:hidden;
    white-space:nowrap;
    text-overflow:ellipsis;
    color:#69809a;
    font-size:9px;
}

.sidebar-close{
    display:none;
    width:36px;
    height:36px;
    border:1px solid #29415f;
    border-radius:10px;
    background:#102038;
    color:#c6d3e2;
    font-size:20px;
    cursor:pointer;
}

.sidebar-nav{
    flex:1 1 auto;
    min-height:0;
    overflow-y:auto;
    overflow-x:hidden;
    overscroll-behavior:contain;

    display:grid;
    align-content:start;
    gap:3px;

    padding:4px 2px 12px;

    scrollbar-width:thin;
    scrollbar-color:#2b4160 transparent;
}

.sidebar-section-title{
    margin:13px 9px 5px;
    color:#506984;
    font-size:8px;
    font-weight:950;
    text-transform:uppercase;
    letter-spacing:.11em;
}

.sidebar-nav a,
.sidebar-bottom a{
    display:flex;
    align-items:center;
    gap:10px;

    min-height:41px;

    padding:9px 11px;

    border:
        1px solid
        transparent;

    border-radius:10px;

    color:#aebed1;

    font-size:12px;
    font-weight:760;

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

.sidebar-nav a:hover,
.sidebar-nav a.active{
    color:#fff;
    background:#102039;
}

.sidebar-nav a.active{
    border-color:
        rgba(118,92,255,.34);

    background:
        linear-gradient(
            90deg,
            rgba(118,92,255,.20),
            rgba(118,92,255,.05)
        );
}

.nav-icon{
    flex:0 0 23px;
    min-width:23px;
    text-align:center;
    font-size:13px;
    font-weight:950;
}

.sidebar-bottom{
    flex:0 0 auto;

    padding:10px 2px 1px;

    border-top:
        1px solid
        rgba(94,117,145,.16);

    background:#081423;
}

.logout-link{
    color:#ffb6c0!important;
}

.mobile-topbar,
.mobile-nav,
.sidebar-overlay{
    display:none;
}

/* ========================================================================
   MAIN
   ======================================================================== */

.main{
    margin-left:var(--sidebar-width);
    min-width:0;
    min-height:100vh;
    padding:25px 27px 80px;
}

.dashboard-main{
    width:auto;
    overflow-x:hidden;
}

.toolbar{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:15px;
    margin-bottom:18px;
}

.toolbar h1{
    margin:0;
    font-size:29px;
    letter-spacing:-.035em;
}

.toolbar-actions{
    display:flex;
    flex-wrap:wrap;
    gap:8px;
}

.grid{
    display:grid;
    grid-template-columns:
        repeat(12,minmax(0,1fr));
    gap:14px;
}

.card{
    grid-column:span 4;
    min-width:0;
    background:
        linear-gradient(
            180deg,
            #101f35,
            #0c192b
        );
    border:1px solid var(--line);
    border-radius:16px;
    padding:18px;
}

.form{
    max-width:760px;
    background:#0f1d31;
    padding:20px;
    border:1px solid var(--line);
    border-radius:16px;
}

.form-clean{
    display:grid;
    gap:13px;
}

.field{
    display:grid;
    gap:6px;
    margin-bottom:12px;
    min-width:0;
}

.field label{
    font-size:12px;
    font-weight:800;
}

.field input,
.field select,
.field textarea,
.form-clean input{
    width:100%;
    min-width:0;
    min-height:44px;
    padding:10px 12px;
    border:1px solid #2a4261;
    border-radius:10px;
    background:#091626;
    color:#fff;
}

.field textarea{
    min-height:95px;
}

.table{
    width:100%;
    border-collapse:collapse;
    background:#0d1a2d;
}

.table th,
.table td{
    padding:12px;
    border-bottom:1px solid #1d304b;
    text-align:left;
    font-size:12px;
}

.table th{
    font-size:10px;
    color:#7d92ad;
    text-transform:uppercase;
}

.table-wrap{
    width:100%;
    max-width:100%;
    overflow:auto;
    -webkit-overflow-scrolling:touch;
    border:1px solid var(--line);
    border-radius:13px;
}

.badge{
    display:inline-flex;
    padding:4px 8px;
    border-radius:999px;
    border:1px solid #304864;
    background:#14253d;
    font-size:10px;
    font-weight:850;
}

.badge.ok{
    background:#123024;
    border-color:#2b694b;
    color:#86f2bb;
}

.badge.warn{
    background:#312817;
    border-color:#66501f;
    color:#ffd47b;
}

.badge.danger{
    background:#341821;
    border-color:#713144;
    color:#ffbdca;
}

.dash-grid{
    display:grid;
    grid-template-columns:
        repeat(4,minmax(0,1fr));
    gap:13px;
}

.dash-card,
.panel{
    min-width:0;
    background:
        linear-gradient(
            180deg,
            #101f35,
            #0c192b
        );
    border:1px solid var(--line);
    border-radius:16px;
    padding:18px;
}

.dash-card .label{
    font-size:12px;
    color:#8fa3bc;
}

.dash-card .value{
    margin-top:8px;
    font-size:29px;
    font-weight:950;
    letter-spacing:-.035em;
}

.panel-grid{
    display:grid;
    grid-template-columns:
        minmax(0,1.4fr)
        minmax(280px,.6fr);
    gap:14px;
    margin-top:14px;
}

.panel-head{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:12px;
    margin-bottom:13px;
}

.panel-head h2,
.panel-head h3{
    margin:0;
}

.quick-actions{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:9px;
}

.quick-action{
    min-width:0;
    min-height:88px;
    padding:13px;
    border:1px solid #243a58;
    border-radius:12px;
    background:#101f35;
    display:flex;
    flex-direction:column;
    justify-content:space-between;
}

.quick-action:hover{
    border-color:#3a5577;
    background:#13243b;
}

.quick-action span{
    margin-top:5px;
    font-size:11px;
    color:#7f94af;
}

.subscription-banner{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:16px;
    margin-bottom:16px;
    padding:15px 17px;
    border:
        1px solid
        rgba(118,92,255,.42);
    background:
        linear-gradient(
            90deg,
            rgba(118,92,255,.18),
            #101e33
        );
    border-radius:15px;
}

.subscription-banner p{
    margin:4px 0 0;
    font-size:12px;
    color:#9cafc6;
}

.choice-card{
    display:flex;
    gap:10px;
    padding:12px;
    border:1px solid #29405f;
    border-radius:11px;
    background:#0b1829;
}

.choice-card.featured{
    border-color:#765cff;
}

.choice-card input{
    width:auto!important;
    min-height:auto!important;
}

.choice-card span{
    display:grid;
}

.choice-card small,
.checkbox-line{
    font-size:11px;
    color:#8296af;
}

.checkbox-line{
    display:flex;
    gap:8px;
}

.checkbox-line input{
    width:auto!important;
    min-height:auto!important;
}

.slots{
    display:flex;
    flex-wrap:wrap;
    gap:8px;
}

.slot{
    padding:9px 12px;
    border:1px solid #314a68;
    border-radius:9px;
    background:#102039;
    color:#fff;
}

.slot.selected{
    background:var(--brand);
}

.public-wrap{
    max-width:900px;
    margin:auto;
    padding:28px 16px;
}

/* ========================================================================
   PAYMENT DASHBOARD
   ======================================================================== */

.payment-strip{
    display:grid;
    grid-template-columns:
        repeat(4,minmax(0,1fr));
    gap:10px;
    margin-top:14px;
}

.payment-stat{
    min-width:0;
    padding:13px;
    border:1px solid #233b58;
    border-radius:12px;
    background:#0b192a;
}

.payment-stat small{
    display:block;
    color:#7288a2;
    font-size:9px;
}

.payment-stat strong{
    display:block;
    margin-top:5px;
    font-size:18px;
}

.integration-card{
    border-color:
        rgba(0,158,227,.32);
}

.integration-card.ok{
    border-color:
        rgba(50,211,148,.32);
}

/* ========================================================================
   TABLET
   ======================================================================== */

@media(max-width:1100px){

    .dash-grid,
    .payment-strip{
        grid-template-columns:
            repeat(2,minmax(0,1fr));
    }

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

/* ========================================================================
   MOBILE / APP MODE
   ======================================================================== */

@media(max-width:820px){

    :root{
        --sidebar-width:292px;
    }

    .mobile-topbar{
        position:sticky;
        top:0;
        z-index:900;

        min-height:58px;

        display:grid;
        grid-template-columns:44px 1fr 44px;
        align-items:center;

        padding:
            max(6px,env(safe-area-inset-top))
            10px
            6px;

        background:
            rgba(7,17,31,.91);

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

        backdrop-filter:
            blur(18px);
    }

    .mobile-menu-button,
    .mobile-public-link{
        width:40px;
        height:40px;

        display:grid;
        place-items:center;

        border:
            1px solid
            #29415f;

        border-radius:11px;

        background:#102039;
        color:#dce7f2;

        cursor:pointer;
    }

    .mobile-public-link:empty{
        border-color:transparent;
        background:transparent;
    }

    .mobile-brand{
        min-width:0;
        overflow:hidden;
        white-space:nowrap;
        text-overflow:ellipsis;
        text-align:center;
        font-size:15px;
        font-weight:950;
    }

    .sidebar{
        width:292px;
        max-width:88vw;

        transform:
            translateX(-102%);

        transition:
            transform .20s ease;

        box-shadow:
            30px 0 70px
            rgba(0,0,0,.45);
    }

    .sidebar-open .sidebar{
        transform:
            translateX(0);
    }

    .sidebar-close{
        display:grid;
        place-items:center;
    }

    .sidebar-overlay{
        position:fixed;
        inset:0;
        z-index:1100;

        width:100%;
        height:100%;

        border:0;

        background:
            rgba(2,7,14,.70);

        backdrop-filter:
            blur(3px);

        opacity:0;
        visibility:hidden;

        transition:
            opacity .18s ease,
            visibility .18s ease;
    }

    .sidebar-open .sidebar-overlay{
        display:block;
        opacity:1;
        visibility:visible;
    }

    .main{
        margin-left:0;

        padding:
            16px
            12px
            calc(
                var(--mobile-nav-height)
                + env(safe-area-inset-bottom)
                + 22px
            );
    }

    .mobile-nav{
        position:fixed;
        left:8px;
        right:8px;
        bottom:
            max(
                7px,
                env(safe-area-inset-bottom)
            );
        z-index:950;

        min-height:
            var(--mobile-nav-height);

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

        padding:6px;

        border:
            1px solid
            rgba(70,95,128,.50);

        border-radius:18px;

        background:
            rgba(8,20,35,.94);

        box-shadow:
            0 18px 50px
            rgba(0,0,0,.42);

        backdrop-filter:
            blur(18px);
    }

    .mobile-nav a,
    .mobile-nav button{
        min-width:0;
        display:flex;
        flex-direction:column;
        align-items:center;
        justify-content:center;
        gap:3px;

        border:0;
        border-radius:12px;

        background:transparent;
        color:#7f95ae;

        cursor:pointer;
    }

    .mobile-nav a.active{
        color:#fff;
        background:
            rgba(118,92,255,.15);
    }

    .mobile-nav span{
        font-size:16px;
        font-weight:900;
    }

    .mobile-nav small{
        max-width:100%;
        overflow:hidden;
        white-space:nowrap;
        text-overflow:ellipsis;
        font-size:8px;
        font-weight:800;
    }

    .mobile-nav-main span{
        width:31px;
        height:31px;

        display:grid;
        place-items:center;

        border-radius:10px;

        background:var(--brand);
        color:#fff;
    }

    .toolbar{
        align-items:flex-start;
        flex-direction:column;
    }

    .toolbar h1{
        font-size:25px;
    }

    .toolbar-actions{
        width:100%;
    }

    .toolbar-actions .btn{
        flex:1;
    }

    .subscription-banner{
        align-items:flex-start;
        flex-direction:column;
    }

    .subscription-banner .btn{
        width:100%;
    }

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

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

    .grid>.card{
        grid-column:auto;
    }

    .card{
        margin-bottom:0;
    }

    .table{
        min-width:680px;
    }
}

@media(max-width:560px){

    .dash-grid,
    .payment-strip{
        grid-template-columns:1fr 1fr;
        gap:8px;
    }

    .dash-card,
    .panel{
        padding:14px;
        border-radius:14px;
    }

    .dash-card .value{
        font-size:23px;
    }

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

    .quick-action{
        min-height:72px;
    }

    .panel-head{
        align-items:flex-start;
        flex-direction:column;
    }

    .panel-head .btn{
        width:100%;
    }
}


/* ========================================================================
   KAVAGA V13 - PRESERVAÇÃO DOS MÓDULOS + CORREÇÕES DE NAVEGAÇÃO
   ======================================================================== */

.sidebar-user{
    display:flex;
    align-items:center;
    gap:9px;
    min-width:0;
    margin-bottom:6px;
    padding:9px 8px;
    border:1px solid rgba(72,96,126,.22);
    border-radius:11px;
    background:rgba(11,25,43,.62);
}

.sidebar-user-avatar{
    flex:0 0 auto;
    width:31px;
    height:31px;
    display:grid;
    place-items:center;
    border-radius:9px;
    background:linear-gradient(135deg,#765cff,#4f3bdd);
    color:#fff;
    font-size:11px;
    font-weight:950;
}

.sidebar-user-copy{
    min-width:0;
    display:grid;
}

.sidebar-user-copy strong,
.sidebar-user-copy small{
    overflow:hidden;
    white-space:nowrap;
    text-overflow:ellipsis;
}

.sidebar-user-copy strong{
    font-size:10px;
}

.sidebar-user-copy small{
    margin-top:2px;
    color:#687f9a;
    font-size:8px;
}

.sidebar-nav a[href*="#pagamento-agendamentos"]{
    border-color:rgba(0,158,227,.20);
    background:rgba(0,158,227,.055);
}

.sidebar-nav a[href*="#pagamento-agendamentos"]:hover{
    border-color:rgba(0,158,227,.42);
    background:rgba(0,158,227,.11);
}

.dashboard-section{
    margin-top:14px;
}

.dashboard-section-title{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:12px;
    margin-bottom:12px;
}

.dashboard-section-title h2,
.dashboard-section-title h3{
    margin:0;
}

.dashboard-section-title p{
    margin:4px 0 0;
    color:#8196af;
    font-size:11px;
}

.metric-subgrid{
    display:grid;
    grid-template-columns:repeat(4,minmax(0,1fr));
    gap:10px;
}

.metric-mini-card{
    min-width:0;
    padding:13px;
    border:1px solid #243b59;
    border-radius:12px;
    background:#0b192a;
}

.metric-mini-card small{
    display:block;
    color:#748aa4;
    font-size:9px;
}

.metric-mini-card strong{
    display:block;
    margin-top:5px;
    font-size:18px;
    letter-spacing:-.025em;
}

.payment-method-badge{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    min-width:50px;
    padding:4px 7px;
    border:1px solid #2e4765;
    border-radius:999px;
    background:#12243a;
    font-size:9px;
    font-weight:900;
}

.payment-method-badge.pix{
    border-color:rgba(50,188,173,.35);
    background:rgba(50,188,173,.08);
    color:#9ceade;
}

.payment-method-badge.card{
    border-color:rgba(0,158,227,.35);
    background:rgba(0,158,227,.08);
    color:#a5ddf7;
}

.dashboard-empty{
    padding:22px 14px;
    color:#7187a1;
    text-align:center;
    font-size:11px;
}

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

@media(max-width:820px){
    .sidebar-user{
        margin-top:3px;
    }

    .sidebar-bottom{
        padding-bottom:
            max(
                4px,
                env(safe-area-inset-bottom)
            );
    }

    .sidebar-nav{
        padding-bottom:8px;
    }

    .sidebar-nav a,
    .sidebar-bottom a{
        min-height:43px;
    }

    .dashboard-section-title{
        flex-direction:column;
    }

    .dashboard-section-title .btn{
        width:100%;
    }
}

@media(max-width:520px){
    .metric-subgrid{
        grid-template-columns:1fr 1fr;
        gap:8px;
    }

    .metric-mini-card{
        padding:11px;
    }

    .metric-mini-card strong{
        font-size:16px;
    }
}
