:root {
    --verde-escuro: #315E54;
    --verde-darker: #2D544C;
    --verde-nav: #18342E;
    --verde-vibrante: #1AD69A;
    --verde-claro: #E6F9F2;
    --laranja: #F5793B;
    --laranja-claro: #FEF0E7;
    --cinza: #6C757D;
    --cinza-escuro: #1F2937;
    --cinza-claro: #E5E7EB;
    --bg: #F5F7FA;
    --vermelho: #E74C3C;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: hidden; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--cinza-escuro);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, system-ui, sans-serif;
    font-feature-settings: "tnum" 1;
    overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(135deg, var(--verde-escuro), var(--verde-darker) 58%, var(--verde-vibrante));
}
.login-card {
    width: min(420px, 100%);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 18px 60px rgba(0,0,0,.18);
    padding: 30px;
}
.login-brand { display: flex; align-items: center; justify-content: space-between; gap: 20px; color: var(--cinza); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.login-brand img { height: 38px; max-width: 160px; }
.login-card h1 { margin: 24px 0 6px; color: var(--verde-escuro); }
.login-card p { margin: 0 0 22px; color: var(--cinza); font-size: 14px; }
.login-form { display: grid; gap: 14px; }
.login-form label { display: grid; gap: 6px; font-size: 12px; font-weight: 700; color: #334155; }
.login-form input { width: 100%; border: 1px solid var(--cinza-claro); border-radius: 8px; padding: 12px; outline: none; }
.login-form input:focus { border-color: var(--verde-vibrante); box-shadow: 0 0 0 3px rgba(26,214,154,.16); }
.login-form button, .top-actions button {
    border: 0;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--verde-escuro), var(--verde-darker) 58%, var(--verde-vibrante));
    color: #fff;
    font-weight: 700;
    padding: 11px 14px;
    cursor: pointer;
}
.alert { background: #fff1f1; border: 1px solid #ffd0d0; color: #b91c1c; padding: 10px; border-radius: 8px; font-size: 13px; }
.login-hint { margin-top: 18px; color: var(--cinza); font-size: 12px; }

.app-shell { display: flex; min-height: 100vh; width: 100%; overflow-x: hidden; }
.mobile-menu-toggle {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.mobile-menu-button {
    display: none;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    place-items: center;
    border: 1px solid var(--cinza-claro);
    border-radius: 10px;
    background: #fff;
    color: var(--verde-escuro);
    cursor: pointer;
}
.mobile-menu-button svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}
.mobile-menu-backdrop {
    display: none;
}
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 230px;
    min-width: 230px;
    height: 100vh;
    background: var(--verde-nav);
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 20;
}
.sidebar-logo {
    height: 58px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--cinza-claro);
}
.sidebar-logo img { max-height: 34px; max-width: 170px; }
.sidebar-label { padding: 14px 20px; border-bottom: 1px solid rgba(255,255,255,.10); }
.sidebar-label span { display: block; color: rgba(255,255,255,.40); font-size: 10px; text-transform: uppercase; letter-spacing: .15em; }
.sidebar-label strong { display: block; margin-top: 4px; color: rgba(255,255,255,.86); font-size: 12px; }
.sidebar nav { padding: 10px 0; flex: 1; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 38px;
    padding: 8px 20px;
    color: rgba(255,255,255,.62);
    font-size: 13px;
    font-weight: 600;
    border-left: 3px solid transparent;
}
.sidebar nav a svg {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.sidebar nav a span {
    line-height: 1.25;
}
.sidebar nav a:hover, .sidebar nav a.active {
    color: #fff;
    background: rgba(26,214,154,.12);
    border-left-color: var(--verde-vibrante);
}
.version { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.10); color: rgba(255,255,255,.34); font-size: 10px; }

.main { flex: 1; min-width: 0; margin-left: 230px; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
    min-height: 58px;
    background: #fff;
    border-bottom: 1px solid var(--cinza-claro);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 28px;
}
.topbar > div:first-child { min-width: 0; }
.topbar-title {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.topbar-title > div,
.topbar-title strong,
.topbar-title small {
    min-width: 0;
}
.topbar strong { display: block; font-size: 15px; }
.topbar small { display: block; margin-top: 3px; color: var(--cinza); font-size: 12px; overflow-wrap: anywhere; }
.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-wrap: wrap; min-width: 0; }
.month { padding: 8px 12px; border-radius: 8px; background: var(--bg); color: var(--cinza); font-weight: 700; font-size: 12px; }
.month-filter {
    position: relative;
    display: flex;
    align-items: center;
}
.month-icon {
    position: absolute;
    left: 13px;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    color: var(--verde-escuro);
    pointer-events: none;
}
.month-filter select {
    min-width: 132px;
    height: 36px;
    padding: 8px 32px 8px 34px;
    border: 1px solid rgba(26,214,154,.38);
    border-radius: 999px;
    background: #E6F9F2;
    color: var(--verde-escuro);
    font-weight: 700;
    font-size: 12px;
    outline: none;
    cursor: pointer;
}
.month-filter select:focus {
    box-shadow: 0 0 0 3px rgba(26,214,154,.18);
}
.top-actions .pdf-button {
    height: 36px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border-radius: 999px;
    background: var(--laranja);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    padding: 0 16px;
    box-shadow: none;
}
.top-actions .pdf-button svg,
.month-icon svg {
    flex: 0 0 auto;
}
.user-chip { display: flex; align-items: center; gap: 10px; color: var(--cinza); font-size: 11px; }
.user-meta {
    display: grid;
    gap: 2px;
    text-align: right;
}
.user-meta strong {
    color: var(--cinza-escuro);
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
}
.user-meta span {
    color: var(--cinza);
    font-size: 11px;
}
.user-avatar {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: #CBF7EA;
    color: var(--verde-escuro);
    font-size: 13px;
    font-weight: 800;
}
.user-chip form {
    margin: 0;
}
.user-chip button { background: #fff; color: var(--verde-escuro); border: 1px solid var(--cinza-claro); padding: 8px 10px; }

.content { flex: 1; min-width: 0; overflow-y: auto; overflow-x: hidden; padding: 24px 28px; }
.hero-card {
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 28px;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    background: linear-gradient(135deg, var(--verde-escuro), var(--verde-darker) 55%, var(--verde-vibrante));
    color: #fff;
    min-width: 0;
}
.hero-card > div:first-child {
    min-width: 0;
    flex: 1 1 auto;
}
.hero-pill { display: inline-block; background: rgba(255,255,255,.20); padding: 6px 10px; border-radius: 999px; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; }
.hero-card h1 { margin: 12px 0 6px; font-size: clamp(24px, 3vw, 34px); }
.hero-card p { margin: 0; max-width: 720px; color: rgba(255,255,255,.86); font-size: 14px; }
.hero-stats { display: grid; grid-template-columns: repeat(3, minmax(82px, 1fr)); gap: 18px; text-align: center; align-content: start; min-width: 0; flex: 0 1 420px; }
.hero-stats small { display: block; color: rgba(255,255,255,.72); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.hero-stats strong { display: block; margin-top: 4px; font-size: 20px; }
.hero-stats span { font-size: 12px; font-weight: 600; color: rgba(255,255,255,.80); }

.section-block {
    margin-top: 24px;
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
    border-top: 3px solid var(--verde-vibrante);
    min-width: 0;
}
.section-block.or { border-top-color: var(--laranja); }
.sec-title { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 2px solid var(--verde-claro); }
.sec-title h2 { margin: 0; color: var(--verde-escuro); font-size: 22px; }
.sec-bar { width: 6px; height: 28px; background: var(--verde-vibrante); border-radius: 3px; }
.sec-bar.or { background: var(--laranja); }

.kpi-grid { display: grid; gap: 14px; min-width: 0; }
.cols-5 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.cols-4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.kpi-card {
    background: #fff;
    border-radius: 10px;
    border-left: 4px solid var(--verde-vibrante);
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    padding: 16px;
    min-height: 104px;
}
.kpi-card.or { border-left-color: var(--laranja); }
.kpi-card.red { border-left-color: var(--vermelho); }
.kpi-label { color: var(--cinza); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { margin-top: 8px; font-size: 24px; font-weight: 800; color: var(--cinza-escuro); line-height: 1.1; }
.kpi-value span { font-size: 12px; font-weight: 600; color: var(--cinza); }
.kpi-hint { margin-top: 8px; color: var(--cinza); font-size: 12px; }

.card {
    margin-top: 16px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    padding: 20px;
    overflow: auto;
    min-width: 0;
}
.card h3 {
    margin: 0 0 14px;
    color: var(--cinza);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
}
.chart-card { min-height: 330px; }
.chart-card canvas { max-height: 280px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.mt { margin-top: 16px; }

.creditos-section {
    padding: 22px;
    border-top-width: 4px;
}
.creditos-section .sec-title {
    margin-bottom: 14px;
}
.creditos-section .sec-title h2 {
    font-size: 21px;
}
.creditos-subtitle {
    margin: 4px 0 10px;
    color: #64748B;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
}
.creditos-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}
.credito-metric {
    min-height: 74px;
    padding: 15px 16px;
    border-radius: 10px;
    border: 1px solid #EEF2F7;
    border-left: 4px solid var(--verde-vibrante);
    box-shadow: 0 1px 5px rgba(15, 23, 42, .04);
    background: #fff;
}
.credito-metric.or {
    border-left-color: var(--laranja);
}
.credito-metric span {
    display: block;
    color: #64748B;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
}
.credito-metric strong {
    display: block;
    margin-top: 7px;
    color: #111827;
    font-size: 21px;
    line-height: 1;
}
.credito-metric small {
    color: #64748B;
    font-size: 12px;
    font-weight: 700;
}
.creditos-chart-card {
    min-height: 286px;
    padding: 18px;
    border-radius: 10px;
}
.creditos-chart-card canvas {
    max-height: 230px;
}

table { width: 100%; min-width: 680px; border-collapse: collapse; font-size: 13px; }
th { background: var(--verde-darker); color: #fff; padding: 10px 14px; font-size: 12px; text-align: center; }
td { padding: 10px 14px; border-bottom: 1px solid var(--cinza-claro); text-align: center; }
td:first-child { text-align: left; font-weight: 600; }
tr:nth-child(even) td { background: var(--bg); }
.pill { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.pill-g { background: var(--verde-claro); color: var(--verde-darker); }
.pill-or { background: var(--laranja-claro); color: var(--laranja); }
.progress { height: 8px; min-width: 90px; border-radius: 999px; background: var(--bg); overflow: hidden; margin-bottom: 5px; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--verde-vibrante), var(--verde-escuro)); }
.investor-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.investor-head strong, .investor-head small { display: block; }
.investor-head small { margin-top: 4px; color: var(--cinza); }

@media (max-width: 1100px) {
    .app-shell { height: auto; overflow-x: hidden; }
    .mobile-menu-button { display: grid; }
    .sidebar {
        display: flex;
        width: min(280px, 84vw);
        min-width: 0;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: 20px 0 60px rgba(15,23,42,.26);
    }
    .mobile-menu-toggle:checked ~ .sidebar {
        transform: translateX(0);
    }
    .mobile-menu-backdrop {
        position: fixed;
        inset: 0;
        z-index: 15;
        background: rgba(15, 23, 42, .42);
    }
    .mobile-menu-toggle:checked ~ .mobile-menu-backdrop {
        display: block;
    }
    .main { overflow: visible; width: 100%; margin-left: 0; }
    .content { overflow-x: hidden; overflow-y: visible; padding: 18px; width: 100%; }
    .topbar { height: auto; align-items: flex-start; gap: 14px; padding: 16px 18px; flex-direction: column; }
    .top-actions { width: 100%; justify-content: flex-start; }
    .hero-card { flex-direction: column; justify-content: flex-start; gap: 18px; }
    .hero-card > div:first-child { flex: 0 1 auto; }
    .hero-stats { min-width: 0; grid-template-columns: repeat(2, 1fr); }
    .cols-5, .cols-4, .grid-2, .creditos-metrics { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
    .content { padding: 12px; }
    .topbar { padding: 12px; }
    .top-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        align-items: stretch;
        gap: 10px;
    }
    .month-filter,
    .month-filter select,
    .top-actions .pdf-button {
        width: 100%;
    }
    .user-chip {
        grid-column: 1 / -1;
        width: 100%;
        justify-content: space-between;
    }
    .user-meta { text-align: left; min-width: 0; }
    .user-meta span { overflow-wrap: anywhere; }
    .hero-card,
    .section-block {
        border-radius: 10px;
        padding: 18px;
    }
    .hero-card {
        gap: 16px;
    }
    .hero-pill {
        padding: 5px 9px;
        font-size: 9px;
    }
    .hero-card h1 {
        font-size: 24px;
        margin-top: 10px;
    }
    .hero-card p {
        font-size: 13px;
    }
    .hero-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px 10px;
        text-align: left;
        width: 100%;
        flex: 0 1 auto;
    }
    .hero-stats strong {
        font-size: 18px;
    }
    .sec-title h2 {
        font-size: 20px;
    }
    .card {
        padding: 16px;
    }
    .chart-card {
        min-height: 300px;
    }
}

@media (max-width: 430px) {
    .top-actions {
        grid-template-columns: 1fr;
    }
    .user-chip {
        display: grid;
        grid-template-columns: 1fr auto;
    }
    .user-chip form {
        grid-column: 1 / -1;
    }
    .user-chip button {
        width: 100%;
    }
    .hero-stats {
        grid-template-columns: 1fr;
        text-align: left;
        gap: 12px;
    }
    .kpi-value {
        font-size: 22px;
    }
    table {
        min-width: 600px;
    }
}

@media print {
    @page { size: A4; margin: 12mm; }
    body { background: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .no-print { display: none !important; }
    .app-shell, .main, .content { display: block; height: auto; overflow: visible; padding: 0; }
    .section-block, .hero-card { break-inside: avoid; box-shadow: none; border: 1px solid var(--cinza-claro); margin-bottom: 14px; }
    .card { box-shadow: none; border: 1px solid var(--cinza-claro); }
}
