:root {
    --primary-red: #D91A21;
    /* Adjusted for visual match */
    --light-pink: #FDECEC;
    --bg-gray: #E6E6E6;
    --text-dark: #333333;
    --text-gray: #666666;
    --white: #FFFFFF;

    --radius-large: 24px;
    --radius-medium: 12px;

    --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Google Sans Flex', sans-serif;
    background-color: var(--bg-gray);
    color: var(--text-dark);
    height: 100vh;
    overflow: hidden;
    /* Main container handles scroll */
}

.dashboard-container {
    display: flex;
    height: 100vh;
    padding: 24px;
    gap: 24px;
}

/* --- Sidebar --- */
.sidebar {
    width: 260px;
    background-color: var(--white);
    border-radius: var(--radius-large);
    display: flex;
    flex-direction: column;
    padding: 30px 20px;
    box-shadow: var(--shadow-soft);
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.logo-area {
    margin-bottom: 40px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-box {
    display: flex;
    align-items: center;
    width: 100%;
}

.logo-img {
    max-width: 100%;
    height: auto;
    max-height: 60px;
    /* Adjust based on sidebar padding */
    display: block;
}


.nav-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.nav-label {
    font-size: 12px;
    color: var(--text-gray);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    font-weight: 600;
}

.nav-item {
    text-decoration: none;
    color: var(--text-gray);
    padding: 10px 16px;
    border-radius: 20px;
    /* Pill shape */
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-item:hover {
    background-color: #f5f5f5;
    color: var(--primary-red);
}

.nav-item.active {
    background-color: var(--primary-red);
    color: var(--white);
    font-weight: 600;
    box-shadow: 0 4px 8px rgba(217, 26, 33, 0.3);
}

.goal-card {
    background-color: var(--light-pink);
    border-radius: var(--radius-large);
    padding: 24px;
    text-align: center;
    margin-top: 20px;
    border: 1px solid #fecaca;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.goal-icon-circle {
    display: none;
    /* Icon not strictly needed if simpler */
}

.goal-label {
    color: #444;
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 4px;
}

.goal-value {
    color: var(--primary-red);
    font-size: 32px;
    font-weight: 800;
    line-height: 1.2;
}

.goal-sub {
    color: var(--text-dark);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    gap: 24px;
    /* Hide scrollbar for cleaner look */
    scrollbar-width: none;
}

.main-content::-webkit-scrollbar {
    display: none;
}

.top-header h1 {
    font-size: 20px;
    color: #595959;
    font-weight: 600;
    margin-bottom: 1px;
}

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1.5fr;
    gap: 24px;
    min-height: 160px;
    /* Fixed height for uniformity */
}

.kpi-card {
    border-radius: var(--radius-large);
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-soft);
    background-color: var(--white);
    position: relative;
    overflow: hidden;
}

.big-red {
    background-color: var(--primary-red);
    color: var(--white);
}

.kpi-content-main {
    text-align: center;
    display: flex;
    flex-direction: row;
    /* Side by side number and text? Image shows inline-ish */
    align-items: center;
    gap: 16px;
}

.kpi-value-large {
    font-size: 56px;
    font-weight: 700;
}

.kpi-label-large {
    text-align: left;
    font-size: 13px;
    font-weight: 500;
    opacity: 0.9;
    line-height: 1.2;
}

.stat-value {
    font-size: 42px;
    font-weight: 800;
    margin-right: 16px;
}

.text-red {
    color: var(--primary-red);
}

.stat-label {
    font-size: 11px;
    color: var(--text-gray);
    font-weight: 600;
    text-transform: uppercase;
    line-height: 1.3;
}

/* Chart Section */
.chart-container {
    background-color: var(--white);
    border-radius: var(--radius-large);
    padding: 24px 32px;
    box-shadow: var(--shadow-soft);
    min-height: 250px;
}

.chart-header {
    margin-bottom: 10px;
}

.chart-header h2 {
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.chart-wrapper {
    position: relative;
    height: 180px;
    width: 100%;
}

/* Units Grid */
.units-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.unit-card {
    background-color: var(--white);
    border-radius: 16px;
    /* Slightly less round */
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-soft);
    height: 90px;
}

.unit-name {
    font-weight: 600;
    color: #444;
    font-size: 15px;
}

.unit-separator {
    color: #ddd;
    font-weight: 300;
    margin: 0 10px;
}

.unit-value {
    color: var(--primary-red);
    font-weight: 700;
    font-size: 20px;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.unit-value small {
    font-size: 9px;
    color: #888;
    font-weight: 600;
    text-transform: uppercase;
}

/* Mobile Header e Botão Hambúrguer */
.mobile-header {
    display: none !important;
    /* Force hide on desktop */
    align-items: center;
    justify-content: space-between;
    background-color: var(--white);
    padding: 12px 20px;
    border-radius: var(--radius-large);
    box-shadow: var(--shadow-soft);
    margin: 16px 16px 0 16px;
    /* Added margin for better look when outside container */
    z-index: 1000;
}

.mobile-logo-img {
    height: 32px !important;
    width: auto !important;
    max-width: 150px;
}

.hamburger-btn {
    background: none;
    border: none;
    color: var(--primary-red);
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 8px;
}

.close-menu-btn {
    display: none;
    position: absolute;
    top: 20px;
    right: 20px;
    background: #f5f5f5;
    border: none;
    color: var(--text-gray);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
}

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 1500;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.menu-overlay.active {
    display: block;
    opacity: 1;
}

/* --- Responsiveness --- */

/* Tablet e Mobile (Ajuste para Drawer) */
@media (max-width: 1024px) {
    body {
        overflow: auto;
        height: auto;
    }

    .dashboard-container {
        flex-direction: column;
        padding: 16px;
        height: auto;
        gap: 0;
    }

    .mobile-header {
        display: flex !important;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -300px;
        width: 280px;
        height: 100vh;
        z-index: 2000;
        border-radius: 0 24px 24px 0;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        margin: 0;
    }

    .sidebar.active {
        left: 0;
    }

    .close-menu-btn {
        display: flex;
    }

    .main-content {
        padding-top: 8px;
    }

    .kpi-grid {
        grid-template-columns: 1fr;
        height: auto;
        gap: 16px;
    }

    .kpi-card:first-child {
        grid-column: span 1;
    }

    .kpi-value-large {
        font-size: 48px;
    }

    .stat-value {
        font-size: 36px;
    }

    .units-grid {
        grid-template-columns: 1fr;
    }
}

/* Tablet específico (dois cards lado a lado onde couber) */
@media (min-width: 600px) and (max-width: 1024px) {
    .kpi-grid {
        grid-template-columns: 1fr 1fr;
    }

    .kpi-card:first-child {
        grid-column: span 2;
    }

    .units-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Gauge Chart for Units */
.unit-gauge {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    /* Default: 0% progress */
    background: conic-gradient(var(--primary-red) 0deg, #E6E6E6 0deg);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin: 0 12px;
    flex-shrink: 0;
}

.unit-gauge::after {
    content: attr(data-percent);
    position: absolute;
    background: var(--white);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: #444;
}

/* History Section Styles */
.history-container {
    background-color: var(--white);
    border-radius: var(--radius-large);
    padding: 24px 32px;
    box-shadow: var(--shadow-soft);
}

.history-header {
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 20px;
    font-weight: 600;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background-color: #FAFAFA;
    border-radius: 12px;
    font-size: 14px;
    transition: background-color 0.2s;
}

.history-item:hover {
    background-color: #F0F0F0;
}

.history-date {
    color: var(--primary-red);
    font-weight: 600;
    font-size: 12px;
}

/* Optional dotted line if needed, but flex space-between is cleaner */
.history-line {
    flex: 1;
    margin: 0 20px;
    /* border-bottom: 1px dashed #ddd; can enable if desired */
}

.history-value {
    color: var(--primary-red);
    text-align: right;
    display: flex;
    align-items: baseline;
    gap: 4px;
}

/* --- Preloader --- */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: var(--white);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.6s ease, visibility 0.6s;
}

#preloader.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loader-logo {
    width: 120px;
    height: auto;
    margin-bottom: 20px;
    animation: pulse-logo 2s infinite ease-in-out;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-red);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes pulse-logo {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}