:root {
    /* Thème sombre */
    --bg-color: #0c0d10;
    --bg-elevated: #101218;
    --card-bg: #1a1b21;
    --card-border: #333642;
    --text-color: #e5e7eb;
    --muted-text: #9ca3af;

    --highlight-color: #38bdf8;
    --accent-color: #06b6d4;
    --success-color: #22c55e;
    --warning-color: #facc15;
    --error-color: #ef4444;

    --progress-bg: #333642;
    --transition-speed: 0.2s;

    --radius-lg: 16px;
    --radius-md: 8px;
    --radius-sm: 4px;

    --shadow-soft: 0 8px 25px rgba(0, 0, 0, 0.5);
    --shadow-hover: 0 12px 35px rgba(56, 189, 248, 0.15);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    background: radial-gradient(circle at top, #111827 0, #020617 45%, #000 100%);
    color: var(--text-color);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    margin: 0;
    padding: 30px 20px 40px;
    line-height: 1.6;
    overflow-x: hidden;
}

/* HEADER GLOBAL */
header {
    max-width: 1400px;
    margin: 0 auto 25px auto;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

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

.brand-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: radial-gradient(circle at 30% 30%, #38bdf8 0, #0f172a 45%, #020617 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.35);
    font-size: 20px;
}

.brand-text h1 {
    font-size: clamp(22px, 4vw, 30px);
    margin: 0 0 2px 0;
    color: var(--highlight-color);
    text-shadow: 0 0 16px rgba(56, 189, 248, 0.3);
    font-weight: 700;
}

.brand-text p {
    margin: 0;
    font-size: 13px;
    color: var(--muted-text);
}

/* Résumé système (hostname, OS, uptime…) */
.header-system-info {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--muted-text);
}

.info-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(51, 54, 66, 0.8);
    backdrop-filter: blur(8px);
}

.info-pill-label {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 10px;
    color: #9ca3af;
}

.info-pill-value {
    font-weight: 500;
}

/* BARRE D'OUTILS GLOBALE */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* NAVIGATION */
.nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.nav a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--card-border);
    color: var(--text-color);
    text-decoration: none;
    font-size: 13px;
    background: rgba(15, 23, 42, 0.9);
    transition: all var(--transition-speed) ease;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.nav a:hover {
    background: var(--highlight-color);
    color: #020617;
    border-color: var(--highlight-color);
    box-shadow: 0 4px 14px rgba(56, 189, 248, 0.4);
    transform: translateY(-1px);
}

.nav a:active {
    transform: translateY(0);
}

/* BOUTONS GLOBAUX */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--card-border);
    background: #020617;
    color: var(--text-color);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

.btn span.icon {
    font-size: 14px;
}

.btn-primary {
    background: linear-gradient(135deg, #38bdf8, #06b6d4);
    border-color: transparent;
    color: #0b1120;
    font-weight: 600;
    box-shadow: 0 6px 18px rgba(56, 189, 248, 0.35);
}

.btn-primary:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
}

.btn-ghost:hover {
    background: rgba(15, 23, 42, 0.8);
}

/* Toggle auto-refresh */
.toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--muted-text);
}

.toggle input {
    appearance: none;
    width: 32px;
    height: 18px;
    border-radius: 999px;
    border: 1px solid var(--card-border);
    background: #020617;
    position: relative;
    cursor: pointer;
    outline: none;
    transition: background var(--transition-speed);
}

.toggle input::before {
    content: "";
    position: absolute;
    top: 1px;
    left: 1px;
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: #9ca3af;
    transition: transform var(--transition-speed), background var(--transition-speed);
}

.toggle input:checked {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border-color: transparent;
}

.toggle input:checked::before {
    transform: translateX(12px);
    background: #f9fafb;
}

/* GRILLE DU TABLEAU DE BORD */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

/* CARDS */
.card {
    background: linear-gradient(145deg, rgba(15,23,42,0.95), rgba(17,24,39,0.95));
    padding: 20px 20px 16px;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(51, 54, 66, 0.85);
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    min-height: 260px;
    position: relative;
    overflow: hidden;
    transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease, border-color var(--transition-speed) ease;
}

.card::before {
    content: "";
    position: absolute;
    inset: -40%;
    background: radial-gradient(circle at top right, rgba(56,189,248,0.18), transparent 55%);
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
    pointer-events: none;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    border-color: rgba(56, 189, 248, 0.6);
}

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

.card.full-width {
    grid-column: 1 / -1;
}

/* HEADER DE CARTE */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}

.card-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-icon {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    background: radial-gradient(circle at 30% 30%, #38bdf8 0, #0f172a 55%, #020617 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
}

.card h2 {
    font-size: 15px;
    margin: 0;
    padding-bottom: 0;
    border-bottom: none;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.card-subtitle {
    font-size: 11px;
    color: var(--muted-text);
    margin-top: 2px;
}

/* Métadonnées de carte (timestamp, statut) */
.card-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    font-size: 11px;
    color: var(--muted-text);
}

.card-timestamp span {
    font-variant-numeric: tabular-nums;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border: 1px solid transparent;
}

.badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
}

.badge-ok {
    background: rgba(22, 163, 74, 0.15);
    color: #bbf7d0;
    border-color: rgba(22, 163, 74, 0.4);
}

.badge-ok .badge-dot {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.8);
}

.badge-warn {
    background: rgba(234, 179, 8, 0.18);
    color: #fef9c3;
    border-color: rgba(234, 179, 8, 0.45);
}

.badge-warn .badge-dot {
    background: #eab308;
    box-shadow: 0 0 6px rgba(234, 179, 8, 0.8);
}

.badge-err {
    background: rgba(239, 68, 68, 0.18);
    color: #fee2e2;
    border-color: rgba(239, 68, 68, 0.5);
}

.badge-err .badge-dot {
    background: #ef4444;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.8);
}

/* Boutons d’action dans les cartes */
.card-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.icon-button {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    border: 1px solid rgba(55, 65, 81, 0.9);
    background: rgba(15, 23, 42, 0.9);
    color: #9ca3af;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

.icon-button:hover {
    background: rgba(31, 41, 55, 0.9);
    color: var(--highlight-color);
    border-color: var(--highlight-color);
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
}

/* Zone d’affichage principale */
.data-display {
    background: radial-gradient(circle at top, #020617 0, #020617 35%, #020617 100%);
    border-radius: var(--radius-md);
    padding: 14px 14px 12px;
    font-family: "Fira Code", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 13px;
    overflow-x: auto;
    overflow-y: auto;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.5;
    flex: 1;
    max-height: 480px;
    -webkit-overflow-scrolling: touch;
    border: 1px solid rgba(31, 41, 55, 0.9);
}

.data-display.loading {
    opacity: 0.6;
    background-image: repeating-linear-gradient(
        -45deg,
        rgba(148, 163, 184, 0.08),
        rgba(148, 163, 184, 0.08) 10px,
        transparent 10px,
        transparent 20px
    );
    background-size: 200% 200%;
    animation: shimmer 1.3s linear infinite;
}

@keyframes shimmer {
    0% { background-position: 0 0; }
    100% { background-position: 100% 100%; }
}

.data-key {
    color: var(--highlight-color);
    font-weight: 500;
}

/* Petites grilles de données (System, CPU, Memory) */
.data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 6px 18px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.data-grid li {
    font-size: 12px;
}

.data-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted-text);
}

.data-value {
    display: block;
    font-size: 12px;
}

/* Progress bars */
.progress-bar-container {
    width: 100%;
    background-color: var(--progress-bg);
    border-radius: var(--radius-sm);
    margin-top: 6px;
    overflow: hidden;
    height: 8px;
    position: relative;
}

.progress-bar {
    height: 100%;
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--highlight-color), #06b6d4);
    transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.45);
}

.progress-danger {
    background: linear-gradient(90deg, var(--error-color), #dc2626) !important;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5) !important;
}

/* Tooltips (infobulles) */
.tooltip-hint {
    border-bottom: 1px dashed rgba(148, 163, 184, 0.7);
    cursor: help;
    color: var(--highlight-color);
}

/* Statuts UP/DOWN réseau & services */
.status-up,
.status-down {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 999px;
    border: 1px solid transparent;
}

.status-up::before,
.status-down::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 999px;
}

.status-up {
    background: rgba(22, 163, 74, 0.15);
    color: #bbf7d0;
    border-color: rgba(22, 163, 74, 0.45);
}

.status-up::before {
    background: #22c55e;
}

.status-down {
    background: rgba(239, 68, 68, 0.15);
    color: #fee2e2;
    border-color: rgba(239, 68, 68, 0.5);
}

.status-down::before {
    background: #ef4444;
}

/* TABLEAUX GÉNÉRIQUES */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 12px;
    background: #020617;
    border-radius: var(--radius-md);
    overflow: hidden;
}

table thead {
    background: rgba(15, 23, 42, 0.98);
}

table th,
table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid rgba(31, 41, 55, 0.95);
}

table th {
    color: #e5e7eb;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.06em;
}

table tbody tr {
    transition: background-color var(--transition-speed) ease;
}

table tbody tr:hover {
    background-color: rgba(15, 23, 42, 0.9);
}

/* TABLE DISKS SPÉCIFIQUE */
.table-disks th:nth-child(1) {
    width: 24%;
}

.table-disks th:nth-child(2) {
    width: 12%;
}

.table-disks th:nth-child(3) {
    width: 18%;
}

.table-disks th:nth-child(4) {
    width: 18%;
}

.table-disks th:nth-child(5) {
    width: 28%;
}

.disk-mount {
    font-weight: 500;
    color: #e5e7eb;
}

.disk-fs {
    font-size: 11px;
    color: var(--muted-text);
}

.disk-device {
    font-size: 11px;
    color: var(--muted-text);
}

.disk-usage-bar {
    margin-top: 4px;
}

/* JSON brut */
.raw-json {
    margin-top: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    background: #020617;
    border: 1px dashed rgba(51, 65, 85, 0.9);
    font-family: "Fira Code", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 11px;
    max-height: 260px;
    overflow: auto;
    white-space: pre;
    color: #e5e7eb;
}

/* Messages d’erreur / info */
.message {
    padding: 8px 10px;
    border-radius: var(--radius-md);
    font-size: 12px;
    margin-bottom: 8px;
}

.message-error {
    background: rgba(127, 29, 29, 0.65);
    border: 1px solid rgba(248, 113, 113, 0.9);
    color: #fee2e2;
}

.message-warn {
    background: rgba(113, 63, 18, 0.7);
    border: 1px solid rgba(251, 191, 36, 0.9);
    color: #fef3c7;
}

/* UTILITAIRES */
hr {
    border: none;
    border-top: 1px solid var(--card-border);
    margin: 8px 0;
}

/* RESPONSIVE */
@media (max-width: 900px) {
    body {
        padding: 20px 15px 30px;
    }

    header {
        margin-bottom: 18px;
    }

    .brand-text h1 {
        font-size: 22px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .card {
        min-height: auto;
    }
}

@media (max-width: 700px) {
    header {
        padding-bottom: 14px;
    }

    .toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .toolbar-right {
        align-self: stretch;
        justify-content: space-between;
    }

    .data-display {
        max-height: 380px;
        font-size: 12px;
    }

    /* Tableaux adaptatifs mobiles */
    table, thead, tbody, th, td, tr {
        display: block;
        width: 100%;
    }

    table thead {
        display: none;
    }

    table tr {
        border: 1px solid rgba(31, 41, 55, 0.9);
        margin-bottom: 10px;
        border-radius: var(--radius-md);
        overflow: hidden;
        padding: 6px 0;
    }

    table td {
        border: none;
        position: relative;
        padding: 6px 14px 6px 45%;
        text-align: right;
        font-size: 12px;
    }

    table td::before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        width: 40%;
        text-align: left;
        font-weight: 600;
        color: var(--highlight-color);
        font-size: 11px;
    }
}

/* Accessibilité : réduire les animations */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Optimisation impression */
@media print {
    body {
        background: white;
        color: black;
        padding: 0;
    }

    .nav,
    .toolbar,
    .icon-button,
    .card:hover {
        display: none !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }

    .data-display {
        max-height: none;
    }
}
