@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Space+Grotesk:wght@500;700&display=swap');

:root {
    --bg-main: #090B0E;
    --bg-card: #11151E;
    --bg-card-hover: #171D2A;
    --bg-card-header: #151A26;
    
    --orange-primary: #FF6500;
    --orange-glow: rgba(255, 101, 0, 0.35);
    --orange-light: #FF8D3D;
    --orange-subtle: rgba(255, 101, 0, 0.12);
    
    --text-white: #FFFFFF;
    --text-muted: #94A3B8;
    --text-dim: #64748B;
    
    --border-color: rgba(255, 255, 255, 0.08);
    --border-orange: rgba(255, 101, 0, 0.3);
    
    --co2-low: #10B981;
    --co2-med: #F59E0B;
    --co2-high: #EF4444;
    
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-glow: 0 0 25px rgba(255, 101, 0, 0.18);
    --transition-fast: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-white);
    line-height: 1.5;
    min-height: 100vh;
    padding: 0;
    overflow-x: hidden;
}

/* Background Glowing Accents */
.bg-glow {
    position: fixed;
    top: -150px;
    right: -150px;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--orange-glow) 0%, rgba(0,0,0,0) 70%);
    pointer-events: none;
    z-index: 0;
}

.bg-glow-bottom {
    position: fixed;
    bottom: -200px;
    left: -200px;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(255, 101, 0, 0.15) 0%, rgba(0,0,0,0) 70%);
    pointer-events: none;
    z-index: 0;
}

.app-container {
    position: relative;
    z-index: 1;
    max-width: 1440px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header Navbar */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.75rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1.25rem;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #FF8D3D 0%, #FF6500 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px var(--orange-glow);
    flex-shrink: 0;
}

.brand-icon svg {
    width: 26px;
    height: 26px;
    fill: #FFFFFF;
}

.brand-title h1 {
    font-size: 1.65rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(180deg, #FFFFFF 30%, #E2E8F0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.2;
}

.brand-title p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Status Indicator Pill */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.85rem;
    border-radius: 50px;
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: #10B981;
    border-radius: 50%;
    box-shadow: 0 0 10px #10B981;
    animation: pulse-green 2s infinite;
    flex-shrink: 0;
}

@keyframes pulse-green {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Action Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.15rem;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    border: none;
    outline: none;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--orange-light) 0%, var(--orange-primary) 100%);
    color: #FFFFFF;
    box-shadow: 0 4px 15px var(--orange-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 101, 0, 0.45);
}

.btn-outline {
    background: var(--bg-card);
    color: var(--text-white);
    border: 1px solid var(--border-color);
}

.btn-outline:hover {
    border-color: var(--orange-primary);
    color: var(--orange-light);
}

/* KPI Cards Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2.25rem;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    position: relative;
    overflow: hidden;
    transition: var(--transition-fast);
}

.kpi-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-orange);
    box-shadow: var(--shadow-glow);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--orange-primary);
    opacity: 0.8;
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.kpi-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.kpi-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: var(--orange-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--orange-primary);
    flex-shrink: 0;
}

.kpi-value-container {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
}

.kpi-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2.1rem;
    font-weight: 700;
    color: var(--text-white);
    line-height: 1.1;
}

.kpi-unit {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 500;
}

.kpi-subtext {
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-top: 0.4rem;
}

/* Badge styling for CO2 Status */
.badge-co2 {
    display: inline-block;
    padding: 0.2rem 0.75rem;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.88rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-low {
    background: rgba(16, 185, 129, 0.15);
    color: var(--co2-low);
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-medium {
    background: rgba(245, 158, 11, 0.15);
    color: var(--co2-med);
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-high {
    background: rgba(239, 68, 68, 0.15);
    color: var(--co2-high);
    border: 1px solid rgba(239, 68, 68, 0.4);
    animation: alert-blink 1s infinite alternate;
}

@keyframes alert-blink {
    from { opacity: 1; }
    to { opacity: 0.5; }
}

/* Charts Section */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2.25rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 0.75rem;
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.card-title svg {
    color: var(--orange-primary);
    flex-shrink: 0;
}

.chart-wrapper {
    position: relative;
    height: 320px;
    width: 100%;
}

/* Table Section */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-md);
    -webkit-overflow-scrolling: touch;
}

/* Scrollbar styling for touch table */
.table-responsive::-webkit-scrollbar {
    height: 6px;
}
.table-responsive::-webkit-scrollbar-track {
    background: var(--bg-main);
}
.table-responsive::-webkit-scrollbar-thumb {
    background: var(--border-orange);
    border-radius: 4px;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    white-space: nowrap;
}

.custom-table th {
    background-color: var(--bg-card-header);
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.85rem 1.1rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.custom-table td {
    padding: 0.85rem 1.1rem;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-white);
}

.custom-table tr:hover td {
    background-color: var(--bg-card-hover);
}

.custom-table tr:last-child td {
    border-bottom: none;
}

/* Footer */
.footer {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-dim);
    font-size: 0.82rem;
}

.footer a {
    color: var(--orange-light);
    text-decoration: none;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--orange-primary);
    color: var(--text-white);
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5), var(--shadow-glow);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    animation: slide-up 0.3s ease-out forwards;
}

@keyframes slide-up {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ======================================================
   MOBILE & TABLET RESPONSIVE ADAPTATIONS
   ====================================================== */

@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 1rem 0.85rem;
    }

    .header {
        flex-direction: column;
        align-items: stretch;
        padding-bottom: 1.25rem;
        margin-bottom: 1.5rem;
        gap: 1rem;
    }

    .brand-section {
        justify-content: flex-start;
    }

    .brand-title h1 {
        font-size: 1.4rem;
    }

    .brand-title p {
        font-size: 0.78rem;
    }

    .header-controls {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.6rem;
    }

    .header-controls .status-pill {
        grid-column: 1 / -1;
        justify-content: center;
    }

    .header-controls label {
        grid-column: 1 / -1;
        justify-content: center;
        padding: 0.4rem;
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-sm);
    }

    .header-controls .btn {
        width: 100%;
        font-size: 0.82rem;
        padding: 0.65rem 0.75rem;
    }

    /* KPI Grid 2 columns on mobile */
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        margin-bottom: 1.5rem;
    }

    /* Make 5th item take full width on 2-col grid */
    .kpi-card:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }

    .kpi-card {
        padding: 1rem;
    }

    .kpi-value {
        font-size: 1.75rem;
    }

    .card {
        padding: 1rem;
        border-radius: var(--radius-md);
    }

    .chart-wrapper {
        height: 240px;
    }

    #toast-container {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }

    .toast {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .header-controls {
        grid-template-columns: 1fr;
    }

    .kpi-value {
        font-size: 1.9rem;
    }
}
