/* ================================================================
   SentryAlert Admin — Design System
   ================================================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --sentry-red: #E53935;
    --sentry-red-hover: #C62828;
    --sentry-red-light: rgba(229, 57, 53, 0.15);
    --sentry-red-glow: rgba(229, 57, 53, 0.25);

    --bg-dark: #0f0f1a;
    --bg-card: #161625;
    --bg-card-hover: #1c1c30;
    --bg-sidebar: #12121f;
    --bg-input: #1a1a2e;

    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);

    --text-primary: #f0f0f5;
    --text-secondary: rgba(255, 255, 255, 0.55);
    --text-muted: rgba(255, 255, 255, 0.35);

    --sidebar-width: 260px;

    --gradient-red: linear-gradient(135deg, #E53935 0%, #FF6F61 100%);
    --gradient-blue: linear-gradient(135deg, #4285F4 0%, #69B4FF 100%);
    --gradient-green: linear-gradient(135deg, #34A853 0%, #5ED47A 100%);
    --gradient-yellow: linear-gradient(135deg, #FBBC04 0%, #FFD54F 100%);
    --gradient-purple: linear-gradient(135deg, #9C27B0 0%, #CE93D8 100%);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
    --shadow-red: 0 4px 20px rgba(229, 57, 53, 0.3);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    min-height: 100vh;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ================================================================
   SIDEBAR
   ================================================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-brand {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-brand .brand-logo {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    object-fit: cover;
    box-shadow: 0 2px 12px rgba(229, 57, 53, 0.3);
}

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

.sidebar-brand .brand-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    line-height: 1.2;
}

.sidebar-brand .brand-tag {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--sentry-red);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}

.sidebar-nav .nav-section {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    padding: 0.75rem 1.25rem 0.4rem;
    margin-top: 0.5rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.25rem;
    margin: 2px 0.75rem;
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    position: relative;
}

.sidebar-nav .nav-link:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.04);
}

.sidebar-nav .nav-link.active {
    color: #fff;
    background: var(--gradient-red);
    box-shadow: var(--shadow-red);
    font-weight: 600;
}

.sidebar-nav .nav-link i {
    font-size: 1.1rem;
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-subtle);
}

.sidebar-footer .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    color: var(--text-muted);
    font-size: 0.825rem;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s;
}

.sidebar-footer .nav-link:hover {
    color: var(--sentry-red);
}

/* ================================================================
   MAIN CONTENT
   ================================================================ */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.top-bar {
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.85rem 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.top-bar .page-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.top-bar .page-title .title-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--sentry-red);
    display: inline-block;
    box-shadow: 0 0 8px rgba(229, 57, 53, 0.5);
}

.top-bar .user-info {
    color: var(--text-secondary);
    font-size: 0.825rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.top-bar .user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--gradient-red);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
}

.content-area {
    padding: 1.5rem 1.75rem;
}

/* ================================================================
   CARDS
   ================================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    border-color: var(--border-hover);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-subtle);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 1rem 1.25rem;
    color: var(--text-primary);
}

.card-header i {
    color: var(--sentry-red);
}

.card-body {
    padding: 1.25rem;
}

/* ================================================================
   KPI CARDS
   ================================================================ */
.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-hover);
}

.kpi-card:hover::before {
    opacity: 1;
}

.kpi-card.kpi-blue::before { background: var(--gradient-blue); }
.kpi-card.kpi-green::before { background: var(--gradient-green); }
.kpi-card.kpi-yellow::before { background: var(--gradient-yellow); }
.kpi-card.kpi-red::before { background: var(--gradient-red); }

.kpi-card .kpi-value {
    font-size: 2rem;
    font-weight: 800;
    color: #fff;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.kpi-card .kpi-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}

.kpi-card .kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

/* ================================================================
   BADGES
   ================================================================ */
.badge-sentry {
    background: var(--gradient-red) !important;
    box-shadow: 0 2px 8px rgba(229, 57, 53, 0.25);
}

.badge {
    font-weight: 600;
    font-size: 0.7rem;
    letter-spacing: 0.3px;
    padding: 0.35em 0.65em;
    border-radius: 6px;
}

/* ================================================================
   BUTTONS
   ================================================================ */
.btn-sentry {
    background: var(--gradient-red);
    border: none;
    color: #fff;
    font-weight: 600;
    border-radius: 10px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 12px rgba(229, 57, 53, 0.25);
}

.btn-sentry:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(229, 57, 53, 0.4);
    color: #fff;
    background: linear-gradient(135deg, #C62828 0%, #E53935 100%);
}

.btn-sentry:active {
    transform: translateY(0);
}

/* ================================================================
   TABLES
   ================================================================ */
.table {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.875rem;
}

.table thead th {
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
    padding: 0.85rem 1rem;
}

.table td {
    border-bottom-color: var(--border-subtle);
    vertical-align: middle;
    padding: 0.75rem 1rem;
}

.table-hover tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

/* ================================================================
   PROGRESS BARS
   ================================================================ */
.progress {
    background-color: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    overflow: hidden;
}

.progress-bar {
    border-radius: 6px;
    transition: width 0.6s ease;
}

/* ================================================================
   FORMS
   ================================================================ */
.form-control, .form-select {
    background-color: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    border-radius: 10px;
    font-size: 0.875rem;
    padding: 0.6rem 0.85rem;
    transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--sentry-red);
    box-shadow: 0 0 0 3px var(--sentry-red-glow);
    background-color: var(--bg-input);
    color: var(--text-primary);
}

.form-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

/* ================================================================
   FLASH MESSAGES
   ================================================================ */
.flash-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    width: 380px;
}

.flash-container .alert {
    border-radius: 12px;
    border: none;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px);
    animation: slideIn 0.3s ease;
    font-size: 0.875rem;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ================================================================
   PERIOD SELECTOR (Monitoring page)
   ================================================================ */
.period-selector {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 3px;
}

.period-btn {
    padding: 0.35rem 0.85rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s ease;
}

.period-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.period-btn.active {
    background: var(--sentry-red);
    color: #fff;
    box-shadow: 0 2px 8px rgba(229, 57, 53, 0.3);
}

/* ================================================================
   AUTH PAGES (Login / TOTP / 2FA Setup)
   ================================================================ */
.auth-page {
    min-height: 100vh;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.auth-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(229, 57, 53, 0.08) 0%, transparent 70%);
    top: -200px;
    right: -200px;
    border-radius: 50%;
}

.auth-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(229, 57, 53, 0.05) 0%, transparent 70%);
    bottom: -100px;
    left: -100px;
    border-radius: 50%;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    width: 100%;
    max-width: 420px;
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
}

.auth-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.auth-logo img {
    width: 72px;
    height: 72px;
    border-radius: 18px;
    box-shadow: 0 4px 24px rgba(229, 57, 53, 0.35);
}

.auth-logo .auth-title {
    text-align: center;
}

.auth-logo .auth-title h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    line-height: 1.2;
}

.auth-logo .auth-title p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0.25rem 0 0;
    font-weight: 500;
}

.auth-icon {
    width: 60px;
    height: 60px;
    background: var(--sentry-red-light);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--sentry-red);
    margin: 0 auto 1.25rem;
}

.code-input {
    font-size: 1.75rem;
    text-align: center;
    letter-spacing: 0.5rem;
    font-weight: 700;
    padding: 0.75rem !important;
}

.qr-container {
    background-color: #fff;
    border-radius: 14px;
    padding: 1rem;
    display: inline-block;
    box-shadow: var(--shadow-sm);
}

.qr-container img {
    display: block;
    width: 200px;
    height: 200px;
}

.secret-box {
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
    color: var(--sentry-red);
    word-break: break-all;
    text-align: center;
    font-weight: 600;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ================================================================
   SERVER STATUS INDICATOR
   ================================================================ */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.status-dot.online {
    background: #34A853;
    box-shadow: 0 0 8px rgba(52, 168, 83, 0.5);
    animation: pulse-green 2s infinite;
}

.status-dot.offline {
    background: var(--sentry-red);
    box-shadow: 0 0 8px rgba(229, 57, 53, 0.5);
}

@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 4px rgba(52, 168, 83, 0.4); }
    50% { box-shadow: 0 0 12px rgba(52, 168, 83, 0.6); }
}

/* ================================================================
   STAT ITEMS (Server health, etc)
   ================================================================ */
.stat-item {
    text-align: center;
    padding: 0.5rem;
}

.stat-item .stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.stat-item .stat-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ================================================================
   CONTAINER STATUS BADGES
   ================================================================ */
.container-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.3em 0.6em;
    border-radius: 6px;
}

/* ================================================================
   DATATABLES DARK THEME
   ================================================================ */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    background-color: var(--bg-input, #1a1a2e);
    color: #fff;
    border-color: var(--border-subtle, rgba(255,255,255,0.1));
}
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate .paginate_button {
    color: rgba(255,255,255,0.7) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--sentry-red, #E53935) !important;
    border-color: var(--sentry-red) !important;
    color: white !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: rgba(229, 57, 53, 0.3) !important;
    border-color: var(--sentry-red) !important;
    color: white !important;
}
.dataTables_empty { color: rgba(255,255,255,0.5); }

/* ================================================================
   STALE DATA (vehicles > 24h without data)
   ================================================================ */
.table-danger, .table-dark .table-danger {
    background-color: rgba(239, 68, 68, 0.15) !important;
}

/* ================================================================
   PAGINATION DARK THEME
   ================================================================ */
.pagination .page-link {
    background-color: var(--bg-card);
    border-color: var(--border-subtle);
    color: rgba(255,255,255,0.7);
    font-size: 0.8rem;
}
.pagination .page-item.active .page-link {
    background-color: var(--sentry-red);
    border-color: var(--sentry-red);
    color: #fff;
}
.pagination .page-link:hover {
    background-color: rgba(229, 57, 53, 0.2);
    border-color: var(--sentry-red);
    color: #fff;
}
.pagination .page-item.disabled .page-link {
    background-color: var(--bg-card);
    border-color: var(--border-subtle);
    color: rgba(255,255,255,0.3);
}

/* ================================================================
   SCROLLBAR
   ================================================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ================================================================
   PHASE 3 — HEALTH SEVERITY TOKENS
   ================================================================ */
:root {
    --health-positive: #34A853;
    --health-warn: #FBBC04;
    --health-crit: #E53935;
    --health-info: rgba(255, 255, 255, 0.45);
}

/* ================================================================
   PHASE 3 — USER HEALTH BANNER (fiche 360)
   ================================================================ */
.user-health-banner {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 18px 16px 22px;
    border-radius: 14px;
    border: 1px solid var(--border-subtle);
    margin-bottom: 1rem;
    background: rgba(255, 255, 255, 0.02);
    overflow: hidden;
}

.user-health-banner__bar {
    position: absolute;
    top: 10px;
    bottom: 10px;
    left: 6px;
    width: 4px;
    border-radius: 2px;
    background: var(--health-info);
}

.user-health-banner__icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.06);
    color: var(--health-info);
}

.user-health-banner__body {
    flex: 1;
    min-width: 0;
}

.user-health-banner__title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.user-health-banner__subtitle {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-top: 3px;
}

.user-health-banner__meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Severity variants — background tint + bar color + icon color. */
.user-health-banner--positive {
    background: rgba(52, 168, 83, 0.08);
}
.user-health-banner--positive .user-health-banner__bar { background: var(--health-positive); }
.user-health-banner--positive .user-health-banner__icon {
    background: rgba(52, 168, 83, 0.18);
    color: var(--health-positive);
}

.user-health-banner--warn {
    background: rgba(251, 188, 4, 0.09);
}
.user-health-banner--warn .user-health-banner__bar { background: var(--health-warn); }
.user-health-banner--warn .user-health-banner__icon {
    background: rgba(251, 188, 4, 0.18);
    color: var(--health-warn);
}

.user-health-banner--crit {
    background: rgba(229, 57, 53, 0.10);
}
.user-health-banner--crit .user-health-banner__bar { background: var(--health-crit); }
.user-health-banner--crit .user-health-banner__icon {
    background: rgba(229, 57, 53, 0.18);
    color: var(--health-crit);
}

.user-health-banner--info .user-health-banner__bar { background: var(--health-info); }

/* ================================================================
   PHASE 3 — SUMMARY CARDS (3 cartes sous le banner)
   ================================================================ */
.summary-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 14px 16px 14px 22px;
    height: 100%;
    overflow: hidden;
    transition: border-color 0.2s ease;
}

.summary-card:hover { border-color: var(--border-hover); }

.summary-card__bar {
    position: absolute;
    top: 10px;
    bottom: 10px;
    left: 6px;
    width: 4px;
    border-radius: 2px;
    background: var(--health-info);
}

.summary-card--positive .summary-card__bar { background: var(--health-positive); }
.summary-card--warn .summary-card__bar { background: var(--health-warn); }
.summary-card--crit .summary-card__bar { background: var(--health-crit); }
.summary-card--info .summary-card__bar { background: var(--health-info); }

.summary-card__content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.summary-card__header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
}

.summary-card__header i {
    color: var(--sentry-red);
}

.summary-card--positive .summary-card__header i { color: var(--health-positive); }
.summary-card--warn .summary-card__header i { color: var(--health-warn); }
.summary-card--crit .summary-card__header i { color: var(--health-crit); }
.summary-card--info .summary-card__header i { color: var(--health-info); }

.summary-card__hero {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
}

.summary-card__hero--small {
    font-size: 1.2rem;
    font-weight: 700;
}

.summary-card__hero-unit {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: none;
    letter-spacing: 0;
}

.summary-card__line {
    font-size: 0.88rem;
    color: var(--text-primary);
}

.summary-card__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 2px;
}

.summary-card__footer {
    font-size: 0.72rem;
    margin-top: 4px;
}

/* ================================================================
   PHASE 3 — EVENTS TIMELINE TABLE (fiche 360)
   ================================================================ */
.events-timeline-table tbody tr {
    vertical-align: middle;
}

.events-timeline-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.025);
}

/* ================================================================
   PHASE 3 — DASHBOARD WIDGETS
   ================================================================ */
.dashboard-widget {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 18px;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dashboard-widget__header {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.dashboard-widget__value {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.dashboard-widget__value--crit { color: var(--health-crit); }
.dashboard-widget__value--ok { color: var(--health-positive); }

.dashboard-widget__sublabel {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.dashboard-widget__stacked-bar {
    display: flex;
    height: 10px;
    width: 100%;
    border-radius: 5px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.04);
    margin-top: 6px;
}

.dashboard-widget__stacked-bar-segment {
    display: block;
    height: 100%;
    transition: filter 0.2s ease;
    cursor: pointer;
    position: relative;
}

.dashboard-widget__stacked-bar-segment:hover {
    filter: brightness(1.2);
}

.dashboard-widget__legend {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.78rem;
    margin-top: 6px;
}

.dashboard-widget__legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    text-decoration: none;
}

.dashboard-widget__legend-item:hover {
    color: var(--text-primary);
}

.dashboard-widget__legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

.dashboard-widget__legend-count {
    margin-left: auto;
    font-weight: 600;
    color: var(--text-primary);
}

/* Distribution pastilles — horizontal row of labelled pills. */
.dashboard-widget__distro {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.dashboard-widget__pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.04);
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.dashboard-widget__pill-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dashboard-widget__pill-count {
    font-weight: 600;
    color: var(--text-primary);
}

/* ================================================================
   PHASE 3 — EMPTY STATES
   ================================================================ */
.empty-state {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
    opacity: 0.6;
}

/* ================================================================
   PHASE 3 — USERS LIST "PROBLEM" column tooltip fix
   ================================================================ */
.problem-cell {
    min-width: 110px;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }
}

/* =====================================================================
   Phase 2 — Command Center
   Sober, dense, business-first. Designed for the operator who needs to
   read 30 KPI in 5 seconds without alarmist colours overpowering the data.
   ===================================================================== */

.cc-banner {
    padding: 0.5rem 0.85rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    font-size: 0.78rem;
}

.cc-block {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1rem 1.1rem 1.1rem;
    margin-bottom: 1.1rem;
}

.cc-block-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.55rem;
}

.cc-block-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.cc-block-sub {
    font-size: 0.72rem;
    text-transform: none;
}

/* KPI cell — minimalist tile inside a CC block. */
.cc-kpi {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    padding: 0.6rem 0.7rem;
    text-align: center;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.cc-kpi-clickable:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.12);
}

.cc-kpi a {
    color: inherit;
}

.cc-kpi-value {
    font-size: 1.6rem;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.cc-kpi-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.2rem;
}

/* Distribution panel — small horizontal bars + counts. */
.cc-dist-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
}

.cc-dist-row {
    padding: 0.2rem 0;
    font-size: 0.78rem;
    gap: 0.5rem;
}

.cc-dist-label {
    flex: 0 0 auto;
    min-width: 3.2rem;
    color: rgba(255, 255, 255, 0.85);
    font-family: 'SF Mono', monospace;
    font-size: 0.7rem;
}

.cc-dist-bar-wrap {
    flex: 1 1 auto;
    background: rgba(255, 255, 255, 0.05);
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    margin: 0 0.35rem;
}

.cc-dist-bar {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #4285F4 0%, #69B4FF 100%);
}

.cc-dist-count {
    flex: 0 0 auto;
    color: rgba(255, 255, 255, 0.55);
    font-variant-numeric: tabular-nums;
    font-size: 0.72rem;
    min-width: 1.8rem;
    text-align: right;
}

/* Actionable list panel. */
.cc-list {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    overflow: hidden;
}

.cc-list-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.cc-list-table {
    margin: 0;
    font-size: 0.78rem;
}

.cc-list-table thead th {
    border-top: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.45);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.65rem;
    letter-spacing: 0.05em;
    padding: 0.4rem 1rem;
}

.cc-list-table tbody td {
    border-color: rgba(255, 255, 255, 0.04);
    padding: 0.4rem 1rem;
    vertical-align: middle;
}

.cc-list-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.025);
}

/* Phase 3 — Trial / Conversion sub-blocks (user_detail.html) */

.trial-subblock {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 0.7rem 0.8rem;
    height: 100%;
}

.trial-subblock-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.55);
    margin-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    padding-bottom: 0.35rem;
}

.trial-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.18rem 0;
    font-size: 0.78rem;
    flex-wrap: wrap;
}

.trial-label {
    color: rgba(255, 255, 255, 0.45);
    flex: 0 0 auto;
    min-width: 6rem;
    font-size: 0.72rem;
}

.trial-value {
    color: rgba(255, 255, 255, 0.85);
    font-variant-numeric: tabular-nums;
}

.trial-tooltip {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.65rem;
    margin-left: 0.3rem;
}

.trial-debug code {
    color: #69B4FF;
    font-size: 0.7rem;
}

/* Phase 4 — /users saved views chips bar */
.users-saved-views {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 1rem;
    align-items: center;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 0.55rem 0.8rem;
}

.users-saved-views-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}

.users-saved-views-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-right: 0.4rem;
    opacity: 0.7;
}

.users-saved-view-chip {
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    font-weight: 400;
    font-size: 0.72rem;
    padding: 0.32rem 0.55rem;
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: background 0.12s ease, border-color 0.12s ease;
}

.users-saved-view-chip:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    color: white;
}

.users-saved-view-chip-active {
    background: linear-gradient(90deg, #4285F4 0%, #69B4FF 100%);
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 0 1px rgba(105, 180, 255, 0.35);
}

/* Phase 4 — denser table for the 16-column users page */
.users-table-phase4 {
    font-size: 0.78rem;
}

.users-table-phase4 thead th {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.5rem 0.5rem;
    color: rgba(255, 255, 255, 0.55);
}

.users-table-phase4 tbody td {
    padding: 0.4rem 0.5rem;
    vertical-align: middle;
    white-space: nowrap;
}

/* Phase 5 — /billing */
.billing-tabs .nav-link {
    color: rgba(255, 255, 255, 0.65);
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-right: 0.35rem;
    margin-bottom: 0.35rem;
    font-size: 0.78rem;
    padding: 0.35rem 0.75rem;
}

.billing-tabs .nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.9);
}

.billing-tabs .nav-link.active {
    background: linear-gradient(90deg, #4285F4 0%, #69B4FF 100%);
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 0 1px rgba(105, 180, 255, 0.35);
}

.billing-table-phase5 {
    font-size: 0.76rem;
}

.billing-table-phase5 thead th {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.5rem 0.45rem;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
}

.billing-table-phase5 tbody td {
    padding: 0.4rem 0.45rem;
    vertical-align: middle;
    white-space: nowrap;
}

/* Phase 6 — /events table dense (13 columns) */
.events-table-phase6 {
    font-size: 0.76rem;
}

.events-table-phase6 thead th {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.5rem 0.45rem;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
}

.events-table-phase6 tbody td {
    padding: 0.4rem 0.45rem;
    vertical-align: middle;
    white-space: nowrap;
}

.events-table-phase6 tbody td:nth-child(11) {
    /* failure reason — allow wrapping */
    white-space: normal;
}
