:root {
    /* PREMIUM LIGHT THEME TOKENS */
    --bg-page: #f4f6fb;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f8fafc;

    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    --border-subtle: #e2e8f0;
    --border-strong: #cbd5e1;

    --brand-primary: #3b82f6;
    --brand-primary-light: #eff6ff;

    --color-success: #10b981;
    --color-success-bg: #d1fae5;
    --color-warning: #f59e0b;
    --color-warning-bg: #fef3c7;
    --color-danger: #ef4444;
    --color-danger-bg: #fee2e2;
    --color-gold: #d97706;
    --color-forge: #6366f1;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.02);
    --shadow-glass: 0 8px 32px rgba(15, 23, 42, 0.04);

    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-full: 9999px;

    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --sidebar-width: 250px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-page);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 10;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: -0.5px;
    color: var(--text-main);
}

.env-switcher {
    padding: 1.5rem 1.5rem 0.5rem;
}

.env-label {
    display: block;
    font-size: 0.65rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.env-select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-page);
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-main);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px;
    transition: all 0.2s ease;
}

.env-select:hover {
    border-color: var(--brand-primary);
}

.env-select:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-primary-light);
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-group {
    font-size: 0.65rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-light);
    margin: 1rem 0 0.5rem 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.nav-item:hover {
    background: var(--bg-surface-hover);
    color: var(--text-main);
}

.nav-item.active {
    background: var(--brand-primary-light);
    color: var(--brand-primary);
    font-weight: 600;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-subtle);
}

.back-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--text-main);
}

/* MAIN CONTENT */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 70px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 5;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#page-title {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.env-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.env-badge.prod {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.env-badge.preprod {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.env-badge.recette {
    background: var(--brand-primary-light);
    color: var(--brand-primary);
}

.env-badge.int {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.env-badge.dev {
    background: #f1f5f9;
    color: var(--text-muted);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.live-dot {
    width: 8px;
    height: 8px;
    background: var(--color-success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.time-display {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.dashboard-container {
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.dashboard-view {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.dashboard-view.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* BENTO GRID */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: minMax(120px, auto);
    gap: 1.5rem;
}

.bento-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.bento-card:hover {
    box-shadow: var(--shadow-glass);
    border-color: var(--border-strong);
    transform: translateY(-2px);
}

.bento-card.double-width {
    grid-column: span 2;
}

.bento-card.full-width {
    grid-column: span 4;
}

/* CARDS SPECIALIZATION */
.kpi-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
}

.kpi-value {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-main);
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.kpi-value .unit {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-light);
}

.trend {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-md);
    margin-left: auto;
}

.trend.up {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.trend.down {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
}

.badge.primary {
    background: var(--brand-primary-light);
    color: var(--brand-primary);
}

/* MOCK CHART */
.chart-placeholder {
    height: 180px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding-top: 1rem;
}

.mock-chart {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 100%;
    width: 100%;
}

.mock-chart .bar {
    flex: 1;
    background: var(--brand-primary-light);
    border-radius: 4px 4px 0 0;
    transition: background 0.3s;
}

.mock-chart .bar:hover {
    background: var(--brand-primary);
}

/* TERMINAL LIGHT */
.terminal-light {
    background: #f8fafc;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.6;
    height: 180px;
    overflow-y: auto;
}

.term-line {
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
    padding: 2px 0;
}

.term-time {
    color: var(--text-light);
    margin-right: 0.5rem;
}

.term-info {
    color: var(--brand-primary);
    font-weight: 600;
}

.term-success {
    color: var(--color-success);
    font-weight: 600;
}

.term-warn {
    color: var(--color-warning);
    font-weight: 600;
}

.term-error {
    color: var(--color-danger);
    font-weight: 600;
}

/* MATRIX TABLE */
.matrix-table-container {
    overflow-x: auto;
}

.matrix-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.matrix-table th,
.matrix-table td {
    padding: 0.85rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.85rem;
    transition: background-color 0.2s;
}

.matrix-table tbody tr {
    transition: all 0.2s ease;
}

.matrix-table tbody tr:hover td {
    background-color: var(--bg-surface-hover);
}

.matrix-table tbody tr:hover .component-name {
    color: var(--brand-primary);
}

.matrix-table th {
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.component-name {
    font-weight: 600;
    color: var(--text-main);
}

.v-badge {
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
}

.v-badge.prod {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.v-badge.preprod {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.v-badge.int {
    background: var(--brand-primary-light);
    color: var(--brand-primary);
}

.v-badge.dev {
    background: #f1f5f9;
    color: var(--text-muted);
}

.v-badge.out-of-sync {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

/* QUOTAS */
.quota-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.quota-item {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.quota-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.quota-meta span:last-child {
    color: var(--text-muted);
    font-weight: 500;
}

.progress-bar {
    height: 8px;
    background: var(--border-subtle);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar .fill {
    height: 100%;
    background: var(--brand-primary);
    border-radius: var(--radius-full);
}

.progress-bar .fill.warn {
    background: var(--color-warning);
}

.progress-bar .fill.danger {
    background: var(--color-danger);
}

/* ACTIVITY LIST */
.activity-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.activity-list li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-main);
}

.activity-list .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.activity-list .dot.success {
    background: var(--color-success);
    box-shadow: 0 0 0 3px var(--color-success-bg);
}

.activity-list .dot.warn {
    background: var(--color-warning);
    box-shadow: 0 0 0 3px var(--color-warning-bg);
}

.activity-list .time {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-light);
}