/* ===========================================================================
   AntiVPN — Design system
   ---------------------------------------------------------------------------
   Feuille unique, sans framework. Remplace le CDN Tailwind qui compilait le
   CSS dans le navigateur à chaque chargement de page.

   Sommaire
     1.  Jetons (couleurs, espacements, typographie)
     2.  Base & reset
     3.  Mise en page (shell, sidebar, topbar)
     4.  Surfaces (card, panel, section)
     5.  Typographie & textes utilitaires
     6.  Formulaires
     7.  Boutons
     8.  Badges, puces, jetons
     9.  Tableaux
     10. Statistiques & graphiques
     11. Listes & éléments métier
     12. États (vide, chargement, erreur)
     13. Overlays (modale, toasts)
     14. Utilitaires
     15. Responsive & impression
   =========================================================================== */

/* ─── 1. Jetons ──────────────────────────────────────────────────────────── */

:root {
    color-scheme: dark;

    /* Palette de base */
    --slate-950: #05080f;
    --slate-900: #0a1120;
    --slate-850: #0e1626;
    --slate-800: #131d31;
    --slate-700: #1d2941;
    --slate-600: #2c3a55;
    --slate-500: #4a5a78;
    --slate-400: #7688a8;
    --slate-300: #a3b2cb;
    --slate-200: #c9d4e6;
    --slate-100: #e8eef8;

    /* Accents */
    --accent: #5b8cff;
    --accent-strong: #3f6fe6;
    --accent-soft: rgba(91, 140, 255, 0.14);
    --accent-border: rgba(91, 140, 255, 0.38);

    --success: #34d399;
    --success-soft: rgba(52, 211, 153, 0.13);
    --success-border: rgba(52, 211, 153, 0.36);

    --danger: #fb7185;
    --danger-soft: rgba(251, 113, 133, 0.13);
    --danger-border: rgba(251, 113, 133, 0.36);

    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.13);
    --warning-border: rgba(251, 191, 36, 0.36);

    --info: #38bdf8;
    --info-soft: rgba(56, 189, 248, 0.13);
    --info-border: rgba(56, 189, 248, 0.36);

    /* Rôles sémantiques */
    --bg: var(--slate-950);
    --bg-elevated: var(--slate-900);
    --surface: rgba(14, 22, 38, 0.86);
    --surface-solid: var(--slate-850);
    --surface-muted: rgba(10, 17, 32, 0.62);
    --surface-hover: rgba(29, 41, 65, 0.6);
    --border: rgba(124, 146, 184, 0.16);
    --border-strong: rgba(124, 146, 184, 0.3);
    --text: var(--slate-100);
    --text-muted: var(--slate-400);
    --text-dim: var(--slate-500);

    /* Formes */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 22px;
    --radius-full: 999px;

    /* Espacements */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;
    --sp-10: 40px;

    /* Ombres */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.65);
    --shadow-lg: 0 28px 60px -24px rgba(0, 0, 0, 0.8);

    /* Typographie */
    --font-sans: 'Manrope', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

    /* Gabarit */
    --sidebar-w: 252px;
    --topbar-h: 64px;
    --content-max: 1560px;

    --transition: 140ms cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme='light'] {
    color-scheme: light;

    --bg: #f2f5fa;
    --bg-elevated: #ffffff;
    --surface: rgba(255, 255, 255, 0.92);
    --surface-solid: #ffffff;
    --surface-muted: rgba(241, 245, 250, 0.85);
    --surface-hover: rgba(91, 140, 255, 0.07);
    --border: rgba(31, 48, 82, 0.13);
    --border-strong: rgba(31, 48, 82, 0.24);
    --text: #10182a;
    --text-muted: #5a6b88;
    --text-dim: #7d8ca6;

    --accent: #3163e0;
    --accent-strong: #244fbd;
    --accent-soft: rgba(49, 99, 224, 0.1);
    --accent-border: rgba(49, 99, 224, 0.3);

    --success: #0f9d6b;
    --success-soft: rgba(15, 157, 107, 0.1);
    --success-border: rgba(15, 157, 107, 0.3);

    --danger: #d5304c;
    --danger-soft: rgba(213, 48, 76, 0.09);
    --danger-border: rgba(213, 48, 76, 0.28);

    --warning: #b7791f;
    --warning-soft: rgba(183, 121, 31, 0.1);
    --warning-border: rgba(183, 121, 31, 0.28);

    --info: #0b7fa8;
    --info-soft: rgba(11, 127, 168, 0.1);
    --info-border: rgba(11, 127, 168, 0.28);

    --shadow-sm: 0 1px 2px rgba(16, 24, 42, 0.06);
    --shadow: 0 10px 28px -14px rgba(16, 24, 42, 0.28);
    --shadow-lg: 0 24px 56px -26px rgba(16, 24, 42, 0.34);
}

/* ─── 2. Base & reset ────────────────────────────────────────────────────── */

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

* {
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    background-image:
        radial-gradient(900px 520px at 12% -8%, rgba(91, 140, 255, 0.11), transparent 62%),
        radial-gradient(760px 420px at 92% 4%, rgba(56, 189, 248, 0.08), transparent 60%);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

img,
svg {
    display: block;
    max-width: 100%;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border: 3px solid transparent;
    background-clip: padding-box;
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--slate-500);
    background-clip: padding-box;
}

::selection {
    background: var(--accent-soft);
}

[hidden] {
    display: none !important;
}

/* ─── 3. Mise en page ────────────────────────────────────────────────────── */

.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-height: 100vh;
}

/* Barre latérale */

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: var(--sp-5) var(--sp-4);
    gap: var(--sp-5);
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    z-index: 40;
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 0 var(--sp-2);
}

.brand__mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: var(--radius);
    background: linear-gradient(140deg, var(--accent), #7c5cff);
    color: #fff;
    font-size: 18px;
    box-shadow: 0 6px 18px -6px var(--accent);
}

.brand__text {
    min-width: 0;
}

.brand__name {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.brand__sub {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--sp-5);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.nav__group-label {
    padding: 0 var(--sp-3) var(--sp-2);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.nav__list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    list-style: none;
}

.nav__link {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    width: 100%;
    padding: 9px var(--sp-3);
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: none;
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.nav__link:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.nav__link[aria-current='page'] {
    background: var(--accent-soft);
    border-color: var(--accent-border);
    color: var(--text);
}

.nav__icon {
    flex-shrink: 0;
    width: 18px;
    text-align: center;
    font-size: 14px;
    opacity: 0.9;
}

.nav__badge {
    margin-left: auto;
    padding: 1px 7px;
    border-radius: var(--radius-full);
    background: var(--surface-muted);
    border: 1px solid var(--border);
    font-size: 10px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}

.sidebar__footer {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    padding-top: var(--sp-4);
    border-top: 1px solid var(--border);
}

/* Zone principale */

.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    min-height: var(--topbar-h);
    padding: var(--sp-3) var(--sp-6);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.topbar__title {
    min-width: 0;
    flex: 1;
}

.topbar__title h1 {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.015em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar__title p {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar__actions {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-shrink: 0;
}

.content {
    flex: 1;
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--sp-6);
}

.panel {
    display: flex;
    flex-direction: column;
    gap: var(--sp-5);
    animation: panel-in 200ms ease both;
}

@keyframes panel-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ─── 4. Surfaces ────────────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card--pad {
    padding: var(--sp-5);
}

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

.card__header {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-4);
    padding: var(--sp-5);
    border-bottom: 1px solid var(--border);
}

.card__header--plain {
    border-bottom: none;
    padding-bottom: 0;
}

.card__icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: var(--radius);
    background: var(--accent-soft);
    border: 1px solid var(--accent-border);
    font-size: 17px;
}

.card__heading {
    flex: 1;
    min-width: 0;
}

.card__heading h2 {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.card__heading p {
    margin-top: 2px;
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.5;
}

.card__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
    flex-shrink: 0;
}

.card__body {
    padding: var(--sp-5);
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}

.card__body--tight {
    gap: var(--sp-3);
}

.card__footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-5);
    border-top: 1px solid var(--border);
    background: var(--surface-muted);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.subcard {
    padding: var(--sp-4);
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.subcard__title {
    margin-bottom: var(--sp-1);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.subcard__hint {
    margin-bottom: var(--sp-3);
    font-size: 12px;
    color: var(--text-dim);
}

.grid {
    display: grid;
    gap: var(--sp-4);
}

.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.grid--auto {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.grid--auto-sm {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.stack {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
}

.row--between {
    justify-content: space-between;
}

.row--end {
    justify-content: flex-end;
}

/* ─── 5. Typographie ─────────────────────────────────────────────────────── */

h1, h2, h3, h4 {
    letter-spacing: -0.012em;
    line-height: 1.3;
}

.section-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.strong { font-weight: 700; }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.break-all { word-break: break-all; }
.numeric { font-variant-numeric: tabular-nums; }

.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-accent { color: var(--accent); }

.code-block {
    padding: var(--sp-4);
    max-height: 460px;
    overflow: auto;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 11.5px;
    line-height: 1.6;
    color: var(--text-muted);
    white-space: pre-wrap;
    word-break: break-word;
}

/* ─── 6. Formulaires ─────────────────────────────────────────────────────── */

.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.field__label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.field__hint {
    font-size: 11.5px;
    color: var(--text-dim);
}

.input,
.select,
.textarea {
    width: 100%;
    padding: 9px var(--sp-3);
    background: var(--surface-muted);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13.5px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.input::placeholder,
.textarea::placeholder {
    color: var(--text-dim);
}

.input:hover,
.select:hover,
.textarea:hover {
    border-color: var(--slate-500);
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.input--mono {
    font-family: var(--font-mono);
    font-size: 12.5px;
}

.textarea {
    min-height: 92px;
    resize: vertical;
}

.select {
    appearance: none;
    padding-right: 30px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='%237688a8'%3E%3Cpath d='M6 8.5 1.8 4.3l.9-.9L6 6.7l3.3-3.3.9.9z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    cursor: pointer;
}

.input-group {
    display: flex;
    align-items: stretch;
    gap: var(--sp-2);
}

.input-group > .input,
.input-group > .select {
    flex: 1;
    min-width: 0;
}

.form-grid {
    display: grid;
    gap: var(--sp-3);
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    align-items: end;
}

.search-field {
    position: relative;
    flex: 1;
    min-width: 180px;
}

.search-field .input {
    padding-left: 34px;
}

.search-field::before {
    content: '⌕';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 15px;
    color: var(--text-dim);
    pointer-events: none;
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 7px 10px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}

.checkbox:hover {
    border-color: var(--border-strong);
    background: var(--surface-hover);
}

.checkbox input {
    width: 15px;
    height: 15px;
    accent-color: var(--accent);
    cursor: pointer;
}

.checkbox:has(input:checked) {
    border-color: var(--accent-border);
    background: var(--accent-soft);
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    cursor: pointer;
    font-size: 12.5px;
    color: var(--text-muted);
}

/* ─── 7. Boutons ─────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px var(--sp-4);
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: var(--surface-muted);
    color: var(--text);
    font-size: 13px;
    font-weight: 650;
    white-space: nowrap;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition),
        color var(--transition), transform var(--transition), opacity var(--transition);
}

.btn:hover {
    background: var(--surface-hover);
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn--primary:hover {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
}

.btn--ghost {
    background: transparent;
    border-color: var(--border-strong);
    color: var(--text-muted);
}

.btn--ghost:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.btn--success {
    background: var(--success-soft);
    border-color: var(--success-border);
    color: var(--success);
}

.btn--success:hover {
    background: color-mix(in srgb, var(--success) 22%, transparent);
}

.btn--danger {
    background: var(--danger-soft);
    border-color: var(--danger-border);
    color: var(--danger);
}

.btn--danger:hover {
    background: color-mix(in srgb, var(--danger) 22%, transparent);
}

.btn--warning {
    background: var(--warning-soft);
    border-color: var(--warning-border);
    color: var(--warning);
}

.btn--warning:hover {
    background: color-mix(in srgb, var(--warning) 22%, transparent);
}

.btn--sm {
    padding: 5px 10px;
    font-size: 11.5px;
    border-radius: var(--radius-sm);
}

.btn--icon {
    padding: 8px;
    width: 34px;
    height: 34px;
    border-radius: var(--radius);
}

.btn--block {
    width: 100%;
}

.btn--loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn--loading::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid currentcolor;
    border-top-color: transparent;
    border-radius: 50%;
    color: var(--text);
    animation: spin 640ms linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.btn-group {
    display: inline-flex;
    padding: 3px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    gap: 2px;
}

.btn-group button {
    padding: 5px 11px;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 650;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.btn-group button:hover {
    color: var(--text);
}

.btn-group button[aria-pressed='true'] {
    background: var(--accent-soft);
    color: var(--text);
    box-shadow: inset 0 0 0 1px var(--accent-border);
}

/* ─── 8. Badges, puces, jetons ───────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--surface-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--text-muted);
    white-space: nowrap;
}

.badge--success { background: var(--success-soft); border-color: var(--success-border); color: var(--success); }
.badge--danger  { background: var(--danger-soft);  border-color: var(--danger-border);  color: var(--danger); }
.badge--warning { background: var(--warning-soft); border-color: var(--warning-border); color: var(--warning); }
.badge--info    { background: var(--info-soft);    border-color: var(--info-border);    color: var(--info); }
.badge--accent  { background: var(--accent-soft);  border-color: var(--accent-border);  color: var(--accent); }

.badge--dot::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentcolor;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 5px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--surface-muted);
    font-size: 12px;
    font-weight: 650;
}

.status-pill__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-dim);
    flex-shrink: 0;
}

.status-pill--online .status-pill__dot {
    background: var(--success);
    box-shadow: 0 0 0 3px var(--success-soft);
}

.status-pill--admin .status-pill__dot {
    background: var(--warning);
    box-shadow: 0 0 0 3px var(--warning-soft);
}

/* Puce cliquable (types, pays, noms d'AS) */

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 650;
    text-align: left;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition), color var(--transition);
}

.chip:hover {
    border-color: var(--border-strong);
    color: var(--text);
}

.chip[aria-pressed='true'] {
    background: var(--danger-soft);
    border-color: var(--danger-border);
    color: var(--danger);
}

.chip--allowed {
    border-color: var(--success-border);
    color: var(--success);
    background: var(--success-soft);
}

.chip__flag {
    width: 18px;
    height: 13px;
    flex-shrink: 0;
    border-radius: 2px;
    object-fit: cover;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.chip__label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chip-grid {
    display: grid;
    gap: 6px;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    max-height: 320px;
    overflow-y: auto;
    padding-right: 4px;
}

.chip-grid--wide {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.chip-grid--narrow {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
}

/* Jeton supprimable */

.token-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 34px;
}

.token {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 6px 4px 11px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-full);
    background: var(--surface-muted);
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text);
}

.token__remove {
    display: grid;
    place-items: center;
    width: 17px;
    height: 17px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-dim);
    font-size: 11px;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.token__remove:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

/* Bouton copier */

.copy {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    cursor: copy;
    transition: border-color var(--transition), color var(--transition);
}

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

.copy.is-copied {
    border-color: var(--success-border);
    color: var(--success);
}

/* ─── 9. Tableaux ────────────────────────────────────────────────────────── */

.table-wrap {
    overflow: auto;
    max-height: 620px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-muted);
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12.5px;
}

.table th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 10px var(--sp-3);
    background: var(--surface-solid);
    border-bottom: 1px solid var(--border-strong);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    text-align: left;
    white-space: nowrap;
}

.table td {
    padding: 9px var(--sp-3);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover td {
    background: var(--surface-hover);
}

.table td.mono,
.table td .mono {
    font-family: var(--font-mono);
    font-size: 11.5px;
}

.table--compact td,
.table--compact th {
    padding: 6px 10px;
}

.table__num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

tr.is-clickable {
    cursor: pointer;
}

tr.is-refused td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
tr.is-accepted td:first-child { box-shadow: inset 3px 0 0 var(--success); }
tr.is-treated td:first-child { box-shadow: inset 3px 0 0 var(--warning); }

/* ─── 10. Statistiques & graphiques ──────────────────────────────────────── */

.stat {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: var(--sp-4);
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.stat__value {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.025em;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}

.stat__label {
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.stat__meta {
    margin-top: 2px;
    font-size: 11.5px;
    color: var(--text-dim);
}

.stat--accent .stat__value { color: var(--accent); }
.stat--success .stat__value { color: var(--success); }
.stat--danger .stat__value { color: var(--danger); }
.stat--warning .stat__value { color: var(--warning); }
.stat--info .stat__value { color: var(--info); }

.stat--compact {
    padding: var(--sp-3);
}

.stat--compact .stat__value {
    font-size: 19px;
}

.chart {
    width: 100%;
    height: auto;
    overflow: visible;
}

.chart__grid line {
    stroke: var(--border);
    stroke-width: 1;
}

.chart__axis {
    fill: var(--text-dim);
    font-size: 9px;
    font-family: var(--font-sans);
}

.meter {
    display: flex;
    height: 8px;
    overflow: hidden;
    border-radius: var(--radius-full);
    background: var(--surface-muted);
    border: 1px solid var(--border);
}

.meter__part {
    height: 100%;
}

.meter__part--accepted { background: var(--success); }
.meter__part--refused { background: var(--danger); }

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-4);
    font-size: 11.5px;
    color: var(--text-muted);
}

.legend__item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend__swatch {
    width: 9px;
    height: 9px;
    border-radius: 3px;
    background: currentcolor;
}

.bar-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.bar {
    display: grid;
    grid-template-columns: minmax(90px, 30%) minmax(0, 1fr) 56px;
    align-items: center;
    gap: var(--sp-3);
    font-size: 12px;
}

.bar__label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
}

.bar__track {
    height: 7px;
    border-radius: var(--radius-full);
    background: var(--surface-muted);
    border: 1px solid var(--border);
    overflow: hidden;
}

.bar__fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--accent), #7c5cff);
    transition: width 320ms ease;
}

.bar__value {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 650;
}

/* ─── 11. Listes métier ──────────────────────────────────────────────────── */

.list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.list-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 10px var(--sp-3);
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color var(--transition), background var(--transition);
}

.list-item--interactive {
    cursor: pointer;
    width: 100%;
    text-align: left;
}

.list-item--interactive:hover {
    border-color: var(--accent-border);
    background: var(--surface-hover);
}

.list-item__main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.list-item__title {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
    font-size: 13px;
    font-weight: 700;
}

.list-item__meta {
    font-size: 11.5px;
    color: var(--text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item__side {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-shrink: 0;
}

.list-item.is-blacklisted { border-left: 3px solid var(--danger); }
.list-item.is-whitelisted { border-left: 3px solid var(--success); }

.detail-grid {
    display: grid;
    gap: var(--sp-3);
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.detail {
    min-width: 0;
}

.detail__label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 2px;
}

.detail__value {
    font-size: 13px;
    font-weight: 650;
    word-break: break-word;
}

.kv {
    display: grid;
    grid-template-columns: minmax(90px, auto) minmax(0, 1fr);
    gap: 4px var(--sp-3);
    font-size: 12.5px;
}

.kv dt {
    color: var(--text-muted);
}

.kv dd {
    font-weight: 650;
    word-break: break-word;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.split {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--sp-4);
    align-items: start;
}

.sticky-bar {
    position: sticky;
    bottom: var(--sp-3);
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    background: color-mix(in srgb, var(--surface-solid) 94%, transparent);
    backdrop-filter: blur(10px);
    border: 1px solid var(--accent-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* ─── 12. États ──────────────────────────────────────────────────────────── */

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: var(--sp-8) var(--sp-4);
    text-align: center;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-muted);
}

.empty__icon {
    font-size: 26px;
    opacity: 0.6;
}

.empty__title {
    font-size: 13.5px;
    font-weight: 700;
}

.empty__text {
    font-size: 12.5px;
    color: var(--text-muted);
    max-width: 42ch;
}

.empty--error {
    border-color: var(--danger-border);
    background: var(--danger-soft);
}

.empty--error .empty__title {
    color: var(--danger);
}

.skeleton {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
}

.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, var(--surface-hover), transparent);
    animation: shimmer 1.3s infinite;
}

@keyframes shimmer {
    to { transform: translateX(100%); }
}

.skeleton--row { height: 38px; }
.skeleton--line { height: 12px; }
.skeleton--card { height: 88px; }

.skeleton-stack {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

/* ─── 13. Overlays ───────────────────────────────────────────────────────── */

.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: grid;
    place-items: center;
    padding: var(--sp-4);
    background: rgba(3, 6, 14, 0.72);
    backdrop-filter: blur(4px);
    animation: fade-in 130ms ease;
}

@keyframes fade-in {
    from { opacity: 0; }
}

.modal__box {
    width: min(480px, 100%);
    max-height: 88vh;
    overflow: auto;
    background: var(--surface-solid);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: modal-in 160ms cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--border);
}

.modal__header h3 {
    font-size: 15px;
    font-weight: 700;
}

.modal__body {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
    padding: var(--sp-5);
}

.modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--sp-2);
    padding: var(--sp-4) var(--sp-5);
    border-top: 1px solid var(--border);
    background: var(--surface-muted);
}

.toasts {
    position: fixed;
    right: var(--sp-5);
    bottom: var(--sp-5);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    width: min(370px, calc(100vw - 32px));
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    background: var(--surface-solid);
    border: 1px solid var(--border-strong);
    border-left-width: 3px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    pointer-events: auto;
    animation: toast-in 190ms cubic-bezier(0.2, 0.9, 0.3, 1);
}

.toast.is-leaving {
    animation: toast-out 160ms ease forwards;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(24px); }
}

@keyframes toast-out {
    to { opacity: 0; transform: translateX(24px); }
}

.toast--success { border-left-color: var(--success); }
.toast--error { border-left-color: var(--danger); }
.toast--warning { border-left-color: var(--warning); }
.toast--info { border-left-color: var(--accent); }

.toast__icon {
    font-size: 15px;
    line-height: 1.4;
}

.toast__content {
    flex: 1;
    min-width: 0;
}

.toast__title {
    font-size: 13px;
    font-weight: 700;
}

.toast__text {
    font-size: 12px;
    color: var(--text-muted);
    word-break: break-word;
}

.toast__close {
    border: none;
    background: none;
    color: var(--text-dim);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

.toast__close:hover {
    color: var(--text);
}

/* ─── 14. Utilitaires ────────────────────────────────────────────────────── */

.flex-1 { flex: 1; min-width: 0; }
.w-full { width: 100%; }
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.scroll-y { overflow-y: auto; }
.max-h-320 { max-height: 320px; }
.max-h-420 { max-height: 420px; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.divider {
    height: 1px;
    background: var(--border);
    border: none;
}

/* ─── 15. Responsive ─────────────────────────────────────────────────────── */

.sidebar__toggle {
    display: none;
}

.scrim {
    display: none;
}

@media (max-width: 1180px) {
    .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
    .app {
        grid-template-columns: minmax(0, 1fr);
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: var(--sidebar-w);
        transform: translateX(-100%);
        transition: transform var(--transition);
        box-shadow: var(--shadow-lg);
    }

    body.nav-open .sidebar {
        transform: none;
    }

    body.nav-open .scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 35;
        background: rgba(3, 6, 14, 0.6);
    }

    .sidebar__toggle {
        display: inline-flex;
    }

    .content {
        padding: var(--sp-4);
    }

    .topbar {
        padding: var(--sp-3) var(--sp-4);
    }

    .grid--2,
    .grid--3,
    .grid--4 {
        grid-template-columns: minmax(0, 1fr);
    }

    .bar {
        grid-template-columns: minmax(80px, 40%) minmax(0, 1fr) 48px;
    }
}

@media (max-width: 620px) {
    .card__header {
        flex-wrap: wrap;
        padding: var(--sp-4);
    }

    .card__body,
    .card__footer {
        padding: var(--sp-4);
    }

    .topbar__title p {
        display: none;
    }

    .kv {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media print {
    .sidebar,
    .topbar__actions,
    .toasts,
    .sticky-bar {
        display: none !important;
    }

    body {
        background: #fff;
        color: #000;
    }
}
