:root {
    --bg-color: #F7F9FC;
    --card-bg: #FFFFFF;
    --sidebar-bg: #1C2A42;
    --text-main: #1C2A42;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --color-good: #259E8A;
    --color-bad: #E4574C;
    --color-warn: #E3A008;
    --font-ui: 'Space Grotesk', sans-serif;
    --font-data: 'IBM Plex Mono', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-ui);
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    padding: 20px;
    flex-shrink: 0;
    overflow: visible;
    z-index: 100;
}

.sidebar-header {
    margin-bottom: 24px;
}

.brand-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: contain;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-text h2 {
    font-weight: 700;
    font-size: 1.4rem;
    letter-spacing: 0.5px;
    color: #ffffff;
    line-height: 1.2;
}

.brand-subtitle {
    font-size: 0.75rem;
    color: #94a3b8;
    opacity: 0.7;
    font-weight: 400;
    letter-spacing: 0.3px;
}

.project-selector-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 28px;
    position: relative;
    overflow: visible;
    z-index: 200;
}

.project-selector-container label {
    font-size: 0.75rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Custom Dropdown */
.custom-dropdown {
    position: relative;
    width: 100%;
    z-index: 300;
}

.dropdown-selected {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid #334155;
    background: #0f172a;
    color: #ffffff;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    gap: 8px;
    min-height: 40px;
}

.dropdown-selected:hover,
.dropdown-selected.active {
    border-color: var(--color-good);
}

.dropdown-selected.active {
    box-shadow: 0 0 0 2px rgba(47, 182, 163, 0.2);
}

.dropdown-selected-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #94a3b8;
}

.dropdown-selected-text.selected {
    color: #ffffff;
}

.dropdown-arrow {
    font-size: 0.75rem;
    color: #94a3b8;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.dropdown-selected.active .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-options {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 6px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.35s ease, opacity 0.25s ease, border-color 0.3s ease;
    z-index: 400;
}

.dropdown-options.open {
    max-height: 240px;
    opacity: 1;
    border-color: var(--color-good);
    overflow-y: auto;
}

.dropdown-options::-webkit-scrollbar {
    width: 4px;
}

.dropdown-options::-webkit-scrollbar-track {
    background: transparent;
}

.dropdown-options::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 2px;
}

.dropdown-option {
    padding: 10px 12px;
    color: #cbd5e1;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.dropdown-option:hover {
    background: #334155;
    color: #ffffff;
}

.dropdown-option.selected {
    background: rgba(47, 182, 163, 0.15);
    color: var(--color-good);
    font-weight: 600;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    text-decoration: none;
    color: #cbd5e1;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.nav-item:hover,
.nav-item.active {
    background: #334155;
    color: #ffffff;
}

/* Sidebar Spacer - pushes user profile to bottom */
.sidebar-spacer {
    flex: 1;
}

/* User Profile Section */
.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 10px;
    border-top: 1px solid #334155;
    margin-top: 8px;
    flex-wrap: wrap;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #D97706;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.2;
}

.user-role {
    font-size: 0.7rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid #475569;
    border-radius: 6px;
    background: transparent;
    color: #94a3b8;
    font-family: var(--font-ui);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    margin-top: 6px;
    justify-content: center;
}

.logout-btn:hover {
    background: #334155;
    color: #ffffff;
    border-color: #E4574C;
}

.logout-btn svg {
    flex-shrink: 0;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 0 24px 24px 24px;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
    background: var(--bg-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

.top-bar h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 2px;
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.date-display {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: #e2e8f0;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
}

.dashboard-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(226, 232, 240, 0.8);
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    color: var(--text-main);
}

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.kpi-card {
    padding: 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.kpi-card h3 {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    font-weight: 600;
}

.kpi-card .value {
    font-family: var(--font-data);
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-main);
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.metric-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    padding-bottom: 6px;
    border-bottom: 1px dashed var(--border-color);
}

.metric-row:last-child {
    border-bottom: none;
}

.metric-row span {
    color: var(--text-muted);
    font-weight: 500;
}

.metric-row strong {
    font-family: var(--font-data);
    font-size: 1rem;
}

/* Status Colors */
.text-good {
    color: var(--color-good) !important;
}

.text-bad {
    color: var(--color-bad) !important;
}

.text-warn {
    color: var(--color-warn) !important;
}

/* Gauge Bars */
.gauge-bars {
    margin-top: 10px;
}

.gauge-row {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.8rem;
}

.gauge-label {
    width: 28px;
    font-weight: 600;
    color: var(--text-muted);
}

.gauge-track {
    flex: 1;
    height: 6px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.gauge-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.fill-good {
    background: var(--color-good);
}

.fill-warn {
    background: var(--color-warn);
}

.fill-bad {
    background: var(--color-bad);
}

/* Charts */
.chart-container {
    width: 100%;
}

/* Expandable Chart Cards - Swap Interaction */
.chart-expandable {
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
}

.chart-expandable:hover {
    border-color: var(--color-good);
    box-shadow: 0 4px 12px rgba(47, 182, 163, 0.15);
    transform: translateY(-2px);
}

/* When a trend chart is expanded (takes S-Curve position) */
.chart-expanded {
    border-color: var(--color-good) !important;
    box-shadow: 0 4px 20px rgba(47, 182, 163, 0.2) !important;
    animation: swapIn 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* When S-Curve is minimized (moved to grid position) */
.chart-minimized {
    border-color: #cbd5e1;
    opacity: 0.7;
    animation: swapOut 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.chart-minimized:hover {
    opacity: 0.9;
    border-color: var(--color-good);
}

@keyframes swapIn {
    from {
        opacity: 0.5;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes swapOut {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    to {
        opacity: 0.7;
        transform: scale(0.98) translateY(5px);
    }
}

/* Chart wrapper transition for height animation */
.chart-wrapper {
    transition: height 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

/* Chart header */
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.chart-header .section-title {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}

/* View Toggle Bar - Fixed Position */
.view-toggle-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--card-bg);
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.04);
}

.toggle-bar-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-right: 4px;
}

/* Toggle Switch */
.toggle-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: 0.3s;
    border-radius: 22px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--color-good);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

/* Tables */
.tables-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 1200px) {
    .tables-grid {
        grid-template-columns: 1fr;
    }
}

.table-scroll {
    overflow-x: auto;
    max-height: 280px;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th,
td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
}

#resourceTable th:last-child,
#resourceTable td:last-child {
    text-align: center;
    padding-left: 24px;
}

th {
    background: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 5;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

td {
    font-family: var(--font-ui);
    color: var(--text-main);
    font-weight: 500;
}

th.num-col,
td.num-col {
    text-align: right;
    font-family: var(--font-data);
}

/* Status Badges */
.status-badge {
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge-good {
    background: rgba(47, 182, 163, 0.15);
    color: var(--color-good);
}

.badge-bad {
    background: rgba(228, 87, 76, 0.15);
    color: var(--color-bad);
}
