:root{
    --bg:#f3f6fb;
    --bg-soft:#eef4ff;
    --card:#ffffff;
    --text:#0f172a;
    --muted:#64748b;
    --line:#e2e8f0;
    --line-soft:#edf2f7;

    --primary:#2563eb;
    --primary-dark:#1d4ed8;
    --primary-soft:#dbeafe;

    --success:#16a34a;
    --success-bg:#dcfce7;
    --success-text:#166534;

    --warning:#d97706;
    --warning-bg:#fef3c7;
    --warning-text:#92400e;

    --danger:#dc2626;
    --danger-bg:#fee2e2;
    --danger-text:#991b1b;

    --sidebar:#0f172a;
    --sidebar-2:#111827;
    --sidebar-text:#e5e7eb;
    --sidebar-muted:#94a3b8;

    --shadow:0 10px 30px rgba(15,23,42,.08);
    --shadow-soft:0 8px 24px rgba(15,23,42,.05);

    --radius:18px;
    --radius-sm:12px;
    --radius-xs:10px;
}

*{
    margin:0;
    padding:0;
    box-sizing:border-box;
}

html,
body{
    width:100%;
    min-height:100%;
}

body{
    font-family:Arial, Helvetica, sans-serif;
    background:var(--bg);
    color:var(--text);
    -webkit-font-smoothing:antialiased;
    -moz-osx-font-smoothing:grayscale;
}

a{
    text-decoration:none;
    color:inherit;
}

img{
    max-width:100%;
    display:block;
}

.app-shell{
    min-height:100vh;
    display:flex;
}

/* SIDEBAR */
.sidebar{
    width:270px;
    background:linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
    color:var(--sidebar-text);
    padding:22px 16px;
    position:sticky;
    top:0;
    height:100vh;
    overflow-y:auto;
    overflow-x:hidden;
    flex-shrink:0;
    box-shadow:inset -1px 0 0 rgba(255,255,255,.04);
    scrollbar-width:thin;
    scrollbar-color: rgba(255,255,255,.28) transparent;
}

.sidebar::-webkit-scrollbar{
    width:10px;
}

.sidebar::-webkit-scrollbar-track{
    background:rgba(255,255,255,.03);
    border-radius:999px;
}

.sidebar::-webkit-scrollbar-thumb{
    background:rgba(255,255,255,.22);
    border-radius:999px;
    border:2px solid transparent;
    background-clip:padding-box;
}

.sidebar::-webkit-scrollbar-thumb:hover{
    background:rgba(255,255,255,.38);
    border:2px solid transparent;
    background-clip:padding-box;
}

.brand{
    display:flex;
    align-items:center;
    gap:12px;
    padding:6px 8px 18px 8px;
    margin-bottom:12px;
    border-bottom:1px solid rgba(255,255,255,.08);
}

.brand-mark{
    width:46px;
    height:46px;
    border-radius:14px;
    background:linear-gradient(135deg, #3b82f6, #1d4ed8);
    color:#fff;
    display:flex;
    align-items:center;
    justify-content:center;
    font-weight:700;
    font-size:18px;
    box-shadow:0 8px 24px rgba(37,99,235,.35);
}

.brand-logo-wrap{
    width:46px;
    height:46px;
    border-radius:14px;
    background:#fff;
    display:flex;
    align-items:center;
    justify-content:center;
    overflow:hidden;
    box-shadow:0 8px 24px rgba(37,99,235,.18);
    flex-shrink:0;
}

.brand-logo{
    width:100%;
    height:100%;
    object-fit:cover;
}

.brand strong{
    display:block;
    font-size:15px;
    color:#fff;
    line-height:1.2;
}

.brand small{
    display:block;
    margin-top:4px;
    color:var(--sidebar-muted);
    font-size:12px;
}

.menu{
    display:flex;
    flex-direction:column;
    gap:8px;
    margin-top:14px;
}

.menu-section-title{
    margin:18px 14px 6px;
    font-size:11px;
    text-transform:uppercase;
    letter-spacing:.08em;
    color:rgba(255,255,255,.45);
    font-weight:700;
}

.menu a{
    display:block;
    padding:12px 14px;
    border-radius:12px;
    color:#dbeafe;
    font-size:14px;
    transition:.2s ease;
    border:1px solid transparent;
}

.menu a:hover{
    background:rgba(255,255,255,.06);
    border-color:rgba(255,255,255,.06);
    color:#fff;
    transform:translateX(2px);
}

.menu a.active{
    background:linear-gradient(135deg, rgba(37,99,235,.28), rgba(29,78,216,.28));
    border-color:rgba(96,165,250,.25);
    color:#fff;
    font-weight:700;
    box-shadow:0 8px 20px rgba(37,99,235,.12);
}

/* CONTEÚDO */
.main-content{
    flex:1;
    padding:24px;
    min-width:0;
}

.topbar{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:16px;
    margin-bottom:24px;
    background:var(--card);
    border:1px solid var(--line);
    border-radius:var(--radius);
    padding:20px 22px;
    box-shadow:var(--shadow);
}

.topbar h1{
    font-size:28px;
    line-height:1.2;
    color:var(--text);
    margin-bottom:4px;
}

.topbar p{
    font-size:14px;
    color:var(--muted);
}

/* ALERTAS */
.alert{
    padding:14px 16px;
    border-radius:14px;
    margin-bottom:18px;
    font-size:14px;
    font-weight:700;
    border:1px solid transparent;
    box-shadow:var(--shadow-soft);
}

.alert.success{
    background:var(--success-bg);
    color:var(--success-text);
    border-color:#bbf7d0;
}

.alert.error{
    background:var(--danger-bg);
    color:var(--danger-text);
    border-color:#fecaca;
}

.alert.warning{
    background:var(--warning-bg);
    color:var(--warning-text);
    border-color:#fde68a;
}

/* GRID */
.grid{
    display:grid;
    gap:20px;
}

.grid-2{
    grid-template-columns:repeat(2, minmax(0, 1fr));
}

.grid-3{
    grid-template-columns:repeat(3, minmax(0, 1fr));
}

.grid-4{
    grid-template-columns:repeat(4, minmax(0, 1fr));
}

/* CARDS / KPI */
.card,
.kpi{
    background:var(--card);
    border:1px solid var(--line);
    border-radius:var(--radius);
    padding:20px;
    box-shadow:var(--shadow);
}

.card h2,
.card h3,
.card h4{
    color:var(--text);
    margin-bottom:14px;
}

.kpi{
    position:relative;
    overflow:hidden;
}

.kpi::after{
    content:"";
    position:absolute;
    top:0;
    right:0;
    width:70px;
    height:70px;
    background:radial-gradient(circle, rgba(37,99,235,.08), transparent 70%);
    pointer-events:none;
}

.kpi span{
    display:block;
    font-size:13px;
    color:var(--muted);
    margin-bottom:10px;
}

.kpi strong{
    display:block;
    font-size:28px;
    color:var(--text);
    line-height:1.2;
}

.kpi .sub{
    display:block;
    margin-top:8px;
    font-size:12px;
    color:var(--muted);
}

/* SEÇÕES */
.section-title{
    font-size:20px;
    font-weight:700;
    color:var(--text);
    margin:0 0 12px;
}

.page-subtitle{
    font-size:14px;
    color:var(--muted);
    margin-top:4px;
}

/* HERO */
.hero{
    background:linear-gradient(180deg, #ffffff, #f8fbff);
    border:1px solid var(--line);
    border-radius:24px;
    padding:24px;
    box-shadow:var(--shadow);
}

.hero h1{
    font-size:34px;
    line-height:1.1;
    margin-bottom:10px;
}

.hero p{
    color:var(--muted);
    font-size:15px;
    line-height:1.5;
}

/* PAGE WRAP */
.page-wrap{
    display:flex;
    flex-direction:column;
    gap:20px;
}

/* MENU RÁPIDO */
.quick-menu{
    display:grid;
    grid-template-columns:repeat(auto-fit,minmax(180px,1fr));
    gap:14px;
}

.quick-link{
    display:block;
    background:#0f172a;
    color:#fff;
    border-radius:16px;
    padding:16px;
    min-height:108px;
    transition:.18s ease;
    box-shadow:0 8px 20px rgba(15,23,42,.08);
}

.quick-link:hover{
    transform:translateY(-2px);
    opacity:.97;
}

.quick-link small{
    display:block;
    color:rgba(255,255,255,.72);
    margin-bottom:6px;
    font-size:12px;
    line-height:1.4;
}

.quick-link strong{
    display:block;
    font-size:16px;
    margin-top:6px;
}

/* MÉTRICAS */
.metric-list{
    display:flex;
    flex-direction:column;
    gap:12px;
}

.metric-row{
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    gap:14px;
    padding:10px 0;
    border-bottom:1px solid var(--line-soft);
}

.metric-row:last-child{
    border-bottom:0;
}

.metric-row span{
    color:var(--muted);
    font-size:14px;
}

.metric-row strong{
    color:var(--text);
    font-size:14px;
    text-align:right;
}

.dre-highlight{
    margin-top:14px;
    padding:16px;
    border-radius:16px;
    background:#f8fafc;
    border:1px solid var(--line);
}

.info-note{
    font-size:13px;
    color:var(--muted);
    margin-top:10px;
    line-height:1.5;
}

/* GRÁFICOS */
.chart-box{
    min-height:220px;
}

.chart-title{
    font-size:16px;
    font-weight:700;
    color:var(--text);
    margin-bottom:14px;
}

.chart-fake{
    width:100%;
    height:150px;
    border-radius:14px;
    border:1px dashed #bfdbfe;
    background:
        linear-gradient(180deg, rgba(219,234,254,.8), rgba(239,246,255,.9)),
        repeating-linear-gradient(
            90deg,
            rgba(37,99,235,.08) 0px,
            rgba(37,99,235,.08) 16px,
            transparent 16px,
            transparent 32px
        );
}

/* FORMULÁRIOS */
.form-card{
    background:var(--card);
    border:1px solid var(--line);
    border-radius:var(--radius);
    padding:22px;
    box-shadow:var(--shadow);
}

.form-grid{
    display:grid;
    grid-template-columns:repeat(2, minmax(0, 1fr));
    gap:16px;
}

.form-grid-modern{
    display:grid;
    grid-template-columns:repeat(auto-fit, minmax(220px, 1fr));
    gap:16px;
}

.form-group{
    display:flex;
    flex-direction:column;
    gap:6px;
}

.form-group.full{
    grid-column:1 / -1;
}

label{
    font-size:14px;
    font-weight:700;
    color:var(--text);
}

input,
select,
textarea{
    width:100%;
    border:1px solid #cbd5e1;
    background:#fff;
    color:var(--text);
    border-radius:12px;
    padding:12px 14px;
    font-size:14px;
    outline:none;
    transition:border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

input:focus,
select:focus,
textarea:focus{
    border-color:#60a5fa;
    box-shadow:0 0 0 4px rgba(96,165,250,.15);
    background:#fff;
}

textarea{
    min-height:120px;
    resize:vertical;
}

::placeholder{
    color:#94a3b8;
}

.actions{
    display:flex;
    align-items:end;
    gap:10px;
    flex-wrap:wrap;
}

/* BOTÕES */
.btn,
button,
input[type="submit"]{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:8px;
    padding:12px 18px;
    border:none;
    border-radius:12px;
    background:var(--primary);
    color:#fff;
    font-size:14px;
    font-weight:700;
    cursor:pointer;
    transition:.2s ease;
}

.btn:hover,
button:hover,
input[type="submit"]:hover{
    background:var(--primary-dark);
    transform:translateY(-1px);
}

.btn-primary{
    background:var(--primary);
    color:#fff;
}

.btn-primary:hover{
    background:var(--primary-dark);
}

.btn-save{
    background:var(--primary);
    color:#fff;
}

.btn-save:hover{
    background:var(--primary-dark);
}

.btn-secondary{
    background:#e2e8f0;
    color:#0f172a;
}

.btn-secondary:hover{
    background:#cbd5e1;
}

.btn-danger{
    background:var(--danger);
    color:#fff;
}

.btn-danger:hover{
    background:#b91c1c;
}

/* TABELAS */
.table-wrap,
.table-wrap-modern{
    width:100%;
    overflow:auto;
    background:#fff;
    border:1px solid var(--line);
    border-radius:var(--radius);
    box-shadow:var(--shadow);
}

table,
.tbl{
    width:100%;
    border-collapse:collapse;
    min-width:760px;
}

thead th,
.tbl thead th{
    background:#f8fafc;
    color:#334155;
    text-align:left;
    padding:14px 16px;
    font-size:13px;
    border-bottom:1px solid var(--line);
    white-space:nowrap;
}

tbody td,
.tbl tbody td{
    padding:14px 16px;
    font-size:14px;
    border-bottom:1px solid var(--line-soft);
    color:#0f172a;
    vertical-align:top;
}

tbody tr:hover,
.tbl tbody tr:hover{
    background:#f8fbff;
}

/* BADGES */
.badge,
.tag,
.score-badge,
.badge-score{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    padding:5px 10px;
    border-radius:999px;
    color:#fff;
    font-size:12px;
    font-weight:700;
    line-height:1.2;
}

.tag{
    background:#e2e8f0;
    color:#0f172a;
}

.muted{
    color:var(--muted);
    font-size:12px;
    line-height:1.5;
}

/* STATUS AUXILIARES */
.status-success{
    background:var(--success-bg);
    color:var(--success-text);
    border:1px solid #bbf7d0;
}

.status-warning{
    background:var(--warning-bg);
    color:var(--warning-text);
    border:1px solid #fde68a;
}

.status-danger{
    background:var(--danger-bg);
    color:var(--danger-text);
    border:1px solid #fecaca;
}

/* LOGIN / SEM SIDEBAR */
.auth-page{
    max-width:520px;
    margin:40px auto;
    width:100%;
}

.auth-page .card,
.auth-page .form-card{
    margin-top:40px;
}

/* UTILITÁRIOS */
.text-right{ text-align:right; }
.text-center{ text-align:center; }
.mb-0{ margin-bottom:0 !important; }
.mb-8{ margin-bottom:8px !important; }
.mb-12{ margin-bottom:12px !important; }
.mb-16{ margin-bottom:16px !important; }
.mb-20{ margin-bottom:20px !important; }
.mt-0{ margin-top:0 !important; }
.w-full{ width:100% !important; }

/* RESPONSIVO */
@media (max-width: 1200px){
    .grid-4{
        grid-template-columns:repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 980px){
    .sidebar{
        width:240px;
    }

    .hero h1{
        font-size:28px;
    }

    .topbar h1{
        font-size:24px;
    }
}

@media (max-width: 860px){
    .app-shell{
        flex-direction:column;
    }

    .sidebar{
        width:100%;
        height:auto;
        position:relative;
        border-radius:0 0 20px 20px;
    }

    .main-content{
        padding:18px;
    }

    .grid-2,
    .grid-3,
    .grid-4,
    .form-grid,
    .form-grid-modern,
    .quick-menu{
        grid-template-columns:1fr;
    }

    .topbar{
        padding:18px;
    }

    .topbar h1{
        font-size:22px;
    }

    .hero{
        padding:20px;
    }

    .hero h1{
        font-size:24px;
    }

    table,
    .tbl{
        min-width:680px;
    }
}

@media (max-width: 560px){
    .main-content{
        padding:14px;
    }

    .card,
    .kpi,
    .hero,
    .topbar,
    .form-card{
        padding:16px;
        border-radius:16px;
    }

    .brand{
        padding-left:4px;
        padding-right:4px;
    }

    .menu a{
        padding:11px 12px;
    }

    .kpi strong{
        font-size:24px;
    }
}