/* ═══════════════════════════════════════════════════════════════════
   Adsterra Pro — Feuille de style
   Refonte du 2026-08-02

   Contraintes respectees :
     - tous les noms de variables CSS sont conserves : le JavaScript
       genere du HTML inline qui reference var(--accent-light),
       var(--green), var(--text-primary), var(--border), var(--text-muted).
       Les renommer casserait renderFeeCascade().
     - tous les noms de classes existants sont conserves.
     - les classes manquantes sont ajoutees : .sidebar-backdrop,
       .empty-state, .empty-icon, .empty-text, .skeleton, .login-error.
   ═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* ── Jetons de design ─────────────────────────────────────────────── */
:root {
    /* Fonds : progression du plus sombre au plus clair, pour hierarchiser
       la profondeur sans multiplier les bordures. */
    --bg-base:        #07090f;
    --bg-surface:     #0b0e16;
    --bg-elevated:    #10141f;
    --bg-card:        rgba(17, 21, 33, 0.72);
    --bg-card-hover:  rgba(24, 30, 45, 0.88);
    --bg-input:       rgba(10, 13, 20, 0.85);

    --border:         rgba(255, 255, 255, 0.07);
    --border-hover:   rgba(255, 255, 255, 0.14);
    --border-accent:  rgba(99, 102, 241, 0.32);

    --accent:         #6366f1;
    --accent-hover:   #4f52e0;
    --accent-light:   #818cf8;
    --accent-glow:    rgba(99, 102, 241, 0.22);

    --green:          #10b981;
    --green-glow:     rgba(16, 185, 129, 0.18);
    --yellow:         #f59e0b;
    --red:            #ef4444;
    --purple:         #a855f7;
    --blue:           #3b82f6;

    --text-primary:   #f8fafc;
    --text-secondary: #97a3b6;
    --text-muted:     #5f6b7f;

    --radius-xl:      18px;
    --radius:         13px;
    --radius-sm:      9px;

    --shadow:         0 12px 32px -8px rgba(0,0,0,0.6);
    --shadow-card:    0 2px 14px -4px rgba(0,0,0,0.45);
    --shadow-lift:    0 16px 40px -12px rgba(0,0,0,0.7);

    --sidebar-w:      258px;
    --header-h:       68px;

    --transition:     0.22s cubic-bezier(0.16, 1, 0.3, 1);

    --font:           'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono:           'JetBrains Mono', 'SF Mono', Menlo, monospace;
}

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

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

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg-base);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Halo discret en haut de page : donne de la profondeur sans image. */
    background-image:
        radial-gradient(900px 420px at 18% -8%, rgba(99,102,241,0.10), transparent 70%),
        radial-gradient(760px 380px at 92% 4%, rgba(16,185,129,0.06), transparent 70%);
    background-attachment: fixed;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

::selection { background: var(--accent-glow); color: #fff; }

/* Barre de defilement : fine et discrete, cohérente avec le theme sombre. */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.10);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

/* ── Mise en page ─────────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

/* ── Barre laterale ───────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: linear-gradient(180deg, rgba(13,17,26,0.97), rgba(9,12,19,0.99));
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 200;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    transition: transform var(--transition);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 18px;
    height: var(--header-h);
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
}

.logo-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 14px -2px var(--accent-glow);
}
.logo-icon svg, .logo-icon i { width: 19px; height: 19px; }

.logo-text {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
}
.logo-sub {
    font-size: 10.5px;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.02em;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 11px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.nav-section {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.11em;
    color: var(--text-muted);
    padding: 16px 9px 7px;
}
.nav-section:first-child { padding-top: 2px; }

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9.5px 11px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: color var(--transition), background var(--transition);
}
.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.045);
}
.nav-item.active {
    color: #fff;
    background: linear-gradient(90deg, var(--accent-glow), rgba(99,102,241,0.04));
    font-weight: 600;
}
/* Liseré gauche sur l'element actif : repere visuel immediat. */
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 17px;
    border-radius: 0 3px 3px 0;
    background: var(--accent-light);
}
.nav-icon {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    opacity: 0.85;
}
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
    padding: 13px 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.sync-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11.5px;
    color: var(--text-muted);
    font-weight: 500;
}
.pulse-dot {
    width: 7px;
    height: 7px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 3px var(--green-glow);
    animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1;   transform: scale(1); }
    50%      { opacity: 0.45; transform: scale(0.85); }
}

/* Voile derriere la sidebar en mobile.
   Cette classe etait creee par initSidebar() dans /js/dashboard.js mais
   n'avait AUCUN style : le voile etait donc invisible et ne fermait rien
   visuellement. Ajoutee ici. */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.62);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    z-index: 190;
    transition: opacity var(--transition), visibility var(--transition);
}
.sidebar-backdrop.active { opacity: 1; visibility: visible; }

/* ── Contenu principal ────────────────────────────────────────────── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-width: 0;   /* indispensable : sans cela les tableaux larges
                       debordent au lieu de defiler */
    display: flex;
    flex-direction: column;
}

.header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 0 22px;
    background: rgba(8, 11, 18, 0.82);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.header-title {
    font-size: 16.5px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
    line-height: 1.2;
}
.header-subtitle {
    font-size: 11.5px;
    color: var(--text-muted);
    font-weight: 500;
    margin: 1px 0 0;
    line-height: 1.3;
}
.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Bouton d'ouverture de la sidebar, masque sur grand ecran. */
.mobile-toggle {
    display: none;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    /* Cible tactile confortable, au-dela du visuel. */
    -webkit-tap-highlight-color: transparent;
}
.mobile-toggle:hover, .mobile-toggle:active {
    color: var(--text-primary);
    border-color: var(--border-hover);
}
.mobile-toggle svg, .mobile-toggle i { width: 19px; height: 19px; }

.page-content {
    padding: 22px;
    flex: 1;
    width: 100%;
    max-width: 1560px;
    margin: 0 auto;
}

/* ── Boutons ──────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9.5px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn svg, .btn i { width: 15px; height: 15px; flex-shrink: 0; }

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    color: #fff;
    box-shadow: 0 4px 14px -3px var(--accent-glow);
}
.btn-primary:hover {
    box-shadow: 0 6px 20px -3px var(--accent-glow);
    filter: brightness(1.08);
}

.btn-secondary {
    background: var(--bg-card);
    border-color: var(--border);
    color: var(--text-secondary);
}
.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.btn-success {
    background: linear-gradient(135deg, var(--green), #059669);
    color: #fff;
}
.btn-success:hover { filter: brightness(1.08); }

.btn-danger {
    background: rgba(239,68,68,0.12);
    border-color: rgba(239,68,68,0.3);
    color: var(--red);
}
.btn-danger:hover { background: rgba(239,68,68,0.2); }

.btn-sm {
    padding: 7px 12px;
    font-size: 12.5px;
    gap: 6px;
}
.btn-sm svg, .btn-sm i { width: 14px; height: 14px; }

/* ── Cartes ───────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-card);
    transition: var(--transition);
}

/* ── Indicateurs cles ─────────────────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
    gap: 13px;
    margin-bottom: 20px;
}

.kpi-card {
    position: relative;
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 17px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-card);
    transition: var(--transition);
}
.kpi-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lift);
}
/* Filet colore en haut de carte : identifie la nature de la metrique. */
.kpi-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 2px;
    background: var(--accent);
    opacity: 0.85;
}
.kpi-card.green::before  { background: var(--green); }
.kpi-card.blue::before   { background: var(--blue); }
.kpi-card.yellow::before { background: var(--yellow); }
.kpi-card.purple::before { background: var(--purple); }
.kpi-card.red::before    { background: var(--red); }

.kpi-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 11px;
    background: rgba(99,102,241,0.13);
    color: var(--accent-light);
}
.kpi-card.green  .kpi-icon { background: rgba(16,185,129,0.13); color: var(--green); }
.kpi-card.blue   .kpi-icon { background: rgba(59,130,246,0.13); color: var(--blue); }
.kpi-card.yellow .kpi-icon { background: rgba(245,158,11,0.13); color: var(--yellow); }
.kpi-card.purple .kpi-icon { background: rgba(168,85,247,0.13); color: var(--purple); }
.kpi-card.red    .kpi-icon { background: rgba(239,68,68,0.13);  color: var(--red); }
.kpi-icon svg, .kpi-icon i { width: 17px; height: 17px; }

.kpi-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.kpi-value {
    font-family: var(--mono);
    font-size: 25px;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
    color: var(--text-primary);
    /* Evite que les longs montants debordent sur mobile. */
    overflow-wrap: anywhere;
}

.kpi-change {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11.5px;
    font-weight: 600;
    margin-top: 6px;
}
.kpi-change.up   { color: var(--green); }
.kpi-change.down { color: var(--red); }

/* ── Graphiques ───────────────────────────────────────────────────── */
.chart-grid   { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 20px; }
.chart-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.split-grid   { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 20px; }

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 17px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-card);
    min-width: 0;   /* laisse le canvas se reduire au lieu de deborder */
}
.chart-card.full-width { grid-column: 1 / -1; }

.chart-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}
.chart-title {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.chart-subtitle {
    font-size: 11.5px;
    color: var(--text-muted);
    font-weight: 500;
    margin: 2px 0 0;
}
.chart-container {
    position: relative;
    height: 244px;
    width: 100%;
}

/* ── Tableaux ─────────────────────────────────────────────────────── */
.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 17px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

/* Enveloppe de defilement horizontal. Le tableau garde sa largeur
   minimale et c'est le conteneur qui defile : les colonnes restent
   lisibles sur telephone au lieu d'etre ecrasees. */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table thead th {
    position: sticky;
    top: 0;
    background: rgba(12,15,23,0.96);
    backdrop-filter: blur(8px);
    text-align: left;
    padding: 11px 15px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}
.data-table tbody td {
    padding: 12px 15px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: var(--text-secondary);
    white-space: nowrap;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: rgba(255,255,255,0.028); }
/* Les valeurs numeriques en police monospace s'alignent verticalement,
   ce qui rend les colonnes de montants bien plus lisibles. */
.data-table .num,
.data-table .mono { font-family: var(--mono); color: var(--text-primary); }

/* ── Etiquettes ───────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3.5px 9px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.01em;
    white-space: nowrap;
}
.badge-green  { background: rgba(16,185,129,0.13); color: var(--green);  border: 1px solid rgba(16,185,129,0.25); }
.badge-red    { background: rgba(239,68,68,0.13);  color: var(--red);    border: 1px solid rgba(239,68,68,0.25); }
.badge-blue   { background: rgba(59,130,246,0.13); color: var(--blue);   border: 1px solid rgba(59,130,246,0.25); }
.badge-yellow { background: rgba(245,158,11,0.13); color: var(--yellow); border: 1px solid rgba(245,158,11,0.25); }

/* ── Filtres ──────────────────────────────────────────────────────── */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
    margin-bottom: 17px;
}
.filter-btn {
    padding: 7.5px 14px;
    border: 1px solid var(--border);
    border-radius: 100px;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.filter-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}
.filter-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 3px 12px -2px var(--accent-glow);
}

/* ── Formulaires ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 15px; }

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10.5px 13px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    /* 16px minimum sur mobile : en dessous, iOS zoome automatiquement
       sur le champ au focus, ce qui casse la mise en page. */
    font-size: 14px;
    transition: var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--border-accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-control::placeholder { color: var(--text-muted); }
select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235f6b7f' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 34px;
}
textarea.form-control { resize: vertical; min-height: 74px; }

/* ── Fenetre modale ───────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.72);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    opacity: 0;
    visibility: hidden;
    z-index: 500;
    transition: opacity var(--transition), visibility var(--transition);
}
.modal-overlay.open { opacity: 1; visibility: visible; }

.modal {
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 22px;
    box-shadow: var(--shadow-lift);
    transform: translateY(14px) scale(0.985);
    transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }

.modal-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 17px;
    display: flex;
    align-items: center;
    gap: 9px;
}

/* ── Cascade de frais (generee par renderFeeCascade) ──────────────── */
.fee-cascade {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    font-size: 13px;
}
.fee-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 5px 0;
}
.fee-row.total {
    border-top: 1px solid var(--border);
    margin-top: 8px;
    padding-top: 11px;
    font-weight: 700;
}
.fee-label     { color: var(--text-secondary); font-size: 12.5px; }
.fee-deduction { color: var(--red);   font-family: var(--mono); font-size: 12.5px; }
.fee-result    { color: var(--green); font-family: var(--mono); font-weight: 700; }
.fee-arrow {
    text-align: center;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1;
    padding: 1px 0;
}

/* ── Notifications ────────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 900;
    display: flex;
    flex-direction: column;
    gap: 9px;
    max-width: 370px;
}
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lift);
    animation: slideInRight 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.success { border-left-color: var(--green); }
.toast.error   { border-left-color: var(--red); }
.toast.warning { border-left-color: var(--yellow); }
.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 19px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
    flex-shrink: 0;
}
.toast-close:hover { color: var(--text-primary); }
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(28px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ── Etat vide (genere par renderTable de withdrawals) ────────────── */
.empty-state {
    padding: 44px 20px;
    text-align: center;
    color: var(--text-muted);
}
.empty-icon {
    font-size: 34px;
    opacity: 0.35;
    margin-bottom: 11px;
    display: block;
}
.empty-text {
    font-size: 13px;
    font-weight: 500;
}

/* ── Chargement (applique par setLoading) ─────────────────────────── */
.skeleton {
    position: relative;
    overflow: hidden;
    background: rgba(255,255,255,0.055);
    border-radius: 6px;
    color: transparent !important;
    min-height: 1em;
    min-width: 54px;
    display: inline-block;
}
.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.09), transparent);
    animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* ── Page de connexion ────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-card {
    width: 100%;
    max-width: 396px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 34px 30px;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: var(--shadow-lift);
}
.login-logo { text-align: center; margin-bottom: 26px; }
.login-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 15px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 8px 24px -4px var(--accent-glow);
}
.login-icon svg, .login-icon i { width: 26px; height: 26px; }
.login-title {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin: 0 0 4px;
}
.login-sub {
    font-size: 12.5px;
    color: var(--text-muted);
    margin: 0;
}
/* Cette classe n'existait que dans un <style> inline de login.html.
   Centralisee ici. */
.login-error {
    display: none;
    padding: 10px 13px;
    margin-bottom: 15px;
    background: rgba(239,68,68,0.11);
    border: 1px solid rgba(239,68,68,0.28);
    border-radius: var(--radius-sm);
    color: var(--red);
    font-size: 12.5px;
    font-weight: 500;
}
.login-error.show { display: block; }

/* ── Utilitaires ──────────────────────────────────────────────────── */
.mono      { font-family: var(--mono); }
.text-muted{ color: var(--text-muted); }
.text-green{ color: var(--green); }
.text-red  { color: var(--red); }

/* ═══════════════════════════════════════════════════════════════════
   Adaptation aux ecrans

   Points de rupture :
     1100px : les grilles de graphiques passent sur une colonne, la place
              disponible ne permet plus deux courbes lisibles cote a cote.
      860px : la barre laterale devient un panneau coulissant. C'est le
              seuil ou 258px de menu + le contenu deviennent trop serres.
      560px : ajustements de densite pour telephone.
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 1100px) {
    .chart-grid,
    .chart-grid-3,
    .split-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
    /* Panneau coulissant, hors flux tant qu'il est ferme. */
    .sidebar {
        transform: translateX(-100%);
        width: 272px;
        box-shadow: none;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 12px 0 40px -8px rgba(0,0,0,0.75);
    }

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

    .mobile-toggle { display: inline-flex; }

    .header { padding: 0 14px; gap: 10px; }
    .header-title    { font-size: 15px; }
    .header-subtitle { font-size: 11px; }

    .page-content { padding: 15px 14px 26px; }

    .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 11px; }

    /* Cette regle existait dans l'ancien CSS et ciblait un id precis.
       Conservee : le bloc des revenus reste sur une seule colonne pour
       que les montants ne soient pas tronques. */
    #kpi-revenues { grid-template-columns: 1fr; }

    .chart-container { height: 214px; }

    .toast-container {
        top: auto;
        bottom: 14px;
        left: 14px;
        right: 14px;
        max-width: none;
    }

    .modal { padding: 18px; border-radius: var(--radius); }

    /* La barre de filtres defile plutot que de passer a la ligne :
       l'ordre chronologique des periodes reste lisible. */
    .filter-bar {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        scrollbar-width: none;
    }
    .filter-bar::-webkit-scrollbar { display: none; }
    .filter-btn { flex-shrink: 0; }

    .table-scroll { margin: 0 -1px; }
    .data-table { min-width: 620px; }
}

@media (max-width: 560px) {
    :root { --header-h: 60px; }

    .kpi-grid { grid-template-columns: 1fr; gap: 10px; }
    .kpi-card { padding: 14px 15px; }
    .kpi-value { font-size: 22px; }
    .kpi-icon { width: 30px; height: 30px; margin-bottom: 9px; }

    .header-actions { gap: 6px; }
    /* Sur les tres petits ecrans, les libelles des boutons d'action
       sont masques au profit des icones seules : la barre reste sur
       une ligne au lieu de passer a deux. */
    .header-actions .btn-sm { padding: 7px 9px; }
    .header-actions .btn-sm .btn-label { display: none; }

    .page-content { padding: 13px 11px 24px; }
    .card, .chart-card { padding: 14px; }
    .chart-container { height: 190px; }

    .table-header { padding: 13px 14px; }
    .data-table thead th { padding: 9px 12px; font-size: 10px; }
    .data-table tbody td { padding: 10px 12px; font-size: 12.5px; }

    .login-card { padding: 26px 20px; }
    .login-title { font-size: 18px; }
}

/* Impression : Export.pdf() appelle window.print(). On retire
   l'ossature applicative pour ne garder que les donnees. */
@media print {
    .sidebar, .header, .sidebar-backdrop,
    .header-actions, .toast-container, .filter-bar { display: none !important; }
    .main-content { margin-left: 0; }
    body { background: #fff; color: #000; }
    .card, .kpi-card, .chart-card, .table-card {
        background: #fff;
        border-color: #ddd;
        box-shadow: none;
        break-inside: avoid;
    }
    .kpi-value, .data-table .num { color: #000; }
}

/* ═══════════════════════════════════════════════════════════════════
   Composants ajoutes par la refonte du 2026-08-02

   Ces blocs remplacent des styles qui etaient ecrits en attribut
   style="..." directement dans le HTML. Les sortir ici permet :
     - de garder le HTML lisible ;
     - d'adapter ces elements aux petits ecrans, ce qui est impossible
       avec un style inline (aucune media query ne peut le cibler).
   ═══════════════════════════════════════════════════════════════════ */

/* ── En-tete de section ───────────────────────────────────────────── */
.section-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 28px 0 14px;
    flex-wrap: wrap;
}
.section-head:first-child { margin-top: 0; }

.section-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99,102,241,0.13);
    color: var(--accent-light);
}
.section-icon.green  { background: rgba(16,185,129,0.13); color: var(--green); }
.section-icon.yellow { background: rgba(245,158,11,0.13); color: var(--yellow); }
.section-icon.purple { background: rgba(168,85,247,0.13); color: var(--purple); }
.section-icon.accent { background: rgba(99,102,241,0.13); color: var(--accent-light); }
.section-icon svg, .section-icon i { width: 15px; height: 15px; }

.section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--text-secondary);
    margin: 0;
}

/* Note sous une valeur d'indicateur. */
.kpi-note {
    font-size: 10.5px;
    color: var(--text-muted);
    margin-top: 5px;
    font-weight: 500;
}

/* ── Cartes de repartition ────────────────────────────────────────── */
.party-card { padding: 0; overflow: hidden; }

.party-card.notimax {
    border-color: rgba(99,102,241,0.3);
    background: linear-gradient(150deg, rgba(99,102,241,0.09), rgba(99,102,241,0.015) 60%);
}
.party-card.floki {
    border-color: rgba(245,158,11,0.3);
    background: linear-gradient(150deg, rgba(245,158,11,0.09), rgba(245,158,11,0.015) 60%);
}

.party-head {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 15px 17px;
    border-bottom: 1px solid var(--border);
}

.party-icon {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.party-card.notimax .party-icon { background: rgba(99,102,241,0.18); color: var(--accent-light); }
.party-card.floki   .party-icon { background: rgba(245,158,11,0.18); color: var(--yellow); }
.party-icon svg, .party-icon i { width: 17px; height: 17px; }

.party-name {
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1.2;
}
.party-card.notimax .party-name { color: var(--accent-light); }
.party-card.floki   .party-name { color: var(--yellow); }

.party-role {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.party-pct {
    margin-left: auto;
    font-family: var(--mono);
    font-size: 12.5px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 100px;
    white-space: nowrap;
}
.party-card.notimax .party-pct { background: rgba(99,102,241,0.16); color: var(--accent-light); }
.party-card.floki   .party-pct { background: rgba(245,158,11,0.16); color: var(--yellow); }

.party-body {
    padding: 20px 17px 22px;
    text-align: center;
}
.party-label {
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 7px;
}
.party-value {
    font-family: var(--mono);
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.035em;
    line-height: 1.05;
    overflow-wrap: anywhere;
}
.party-card.notimax .party-value { color: var(--accent-light); }
.party-card.floki   .party-value { color: var(--yellow); }

/* ── Barre de repartition ─────────────────────────────────────────── */
.split-bar-card {
    padding: 15px 18px;
    margin-bottom: 6px;
}

.split-bar-legend {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 11px;
    flex-wrap: wrap;
    font-size: 12px;
    font-weight: 600;
}
.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.legend-item.notimax { color: var(--accent-light); }
.legend-item.floki   { color: var(--yellow); }
.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.legend-item.notimax .legend-dot { background: var(--accent); }
.legend-item.floki   .legend-dot { background: var(--yellow); }
.legend-total {
    font-size: 11.5px;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}
.legend-total strong { color: var(--text-primary); }

.split-bar-track {
    display: flex;
    height: 9px;
    border-radius: 100px;
    background: rgba(255,255,255,0.055);
    overflow: hidden;
}
.split-bar-fill { height: 100%; transition: width 0.6s cubic-bezier(0.16,1,0.3,1); }
.split-bar-fill.notimax { background: linear-gradient(90deg, var(--accent), var(--accent-light)); }
.split-bar-fill.floki   { background: linear-gradient(90deg, var(--yellow), #fbbf24); }

/* ── Bloc d'information ───────────────────────────────────────────── */
.info-box {
    display: flex;
    gap: 11px;
    padding: 13px 15px;
    border-radius: var(--radius-sm);
    background: rgba(99,102,241,0.07);
    border: 1px solid rgba(99,102,241,0.18);
    font-size: 12.5px;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-bottom: 16px;
}
.info-box.warning { background: rgba(245,158,11,0.07); border-color: rgba(245,158,11,0.2); }
.info-box.green   { background: rgba(16,185,129,0.07); border-color: rgba(16,185,129,0.2); }
.info-box-icon {
    flex-shrink: 0;
    color: var(--accent-light);
    margin-top: 1px;
}
.info-box.warning .info-box-icon { color: var(--yellow); }
.info-box.green   .info-box-icon { color: var(--green); }
.info-box-icon svg, .info-box-icon i { width: 16px; height: 16px; }
.info-box strong { color: var(--text-primary); font-weight: 600; }

/* ── Champ avec adresse copiable ──────────────────────────────────── */
.copy-field {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.copy-field code {
    flex: 1;
    min-width: 0;
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--green);
    /* Une adresse crypto est longue : on la laisse se couper plutot que
       de faire deborder la carte sur telephone. */
    overflow-wrap: anywhere;
    line-height: 1.45;
}

/* ── Grille de formulaire ─────────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 0 14px;
}
.form-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 5px;
    line-height: 1.45;
}

/* ── Actions groupees ─────────────────────────────────────────────── */
.btn-row {
    display: flex;
    gap: 9px;
    flex-wrap: wrap;
    align-items: center;
}

/* ── Adaptation ecran ─────────────────────────────────────────────── */
@media (max-width: 860px) {
    .party-value { font-size: 26px; }
    .party-body  { padding: 17px 15px 19px; }

    /* La legende passe en colonne : sur une seule ligne les trois blocs
       se chevauchaient sous 400px de large. */
    .split-bar-legend {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    .legend-total { order: 3; }
}

@media (max-width: 560px) {
    .section-head { margin: 22px 0 12px; gap: 8px; }
    .section-icon { width: 25px; height: 25px; }
    .section-title { font-size: 11px; }
    .party-value { font-size: 23px; }
    .form-grid { grid-template-columns: 1fr; }
}

/* ── Champs de plage de dates ─────────────────────────────────────── */
/* Etait un style inline avec width:160px fixe : les deux champs et le
   bouton debordaient sur telephone. */
.date-range {
    display: flex;
    align-items: flex-end;
    gap: 11px;
    margin-top: 14px;
    flex-wrap: wrap;
}
.date-range-field {
    flex: 1 1 148px;
    min-width: 0;
}
.date-range-field .form-label { margin-bottom: 5px; }
/* Les champs date natifs de Safari iOS ignorent width:100% sans cette
   declaration explicite. */
.date-range input[type="date"] {
    width: 100%;
    min-width: 0;
    -webkit-appearance: none;
    appearance: none;
}
.date-range .btn { flex-shrink: 0; }

@media (max-width: 560px) {
    .date-range { gap: 9px; }
    .date-range .btn { width: 100%; justify-content: center; }
}

/* Etat vide place dans une cellule de tableau : la classe .empty-state
   sert aussi bien dans un bloc que dans un <td>. */
td.empty-state {
    padding: 34px 18px;
    text-align: center;
}

/* ── Bloc depliable ───────────────────────────────────────────────── */
/* Remplace un div avec onclick et styles inline. En <button>, le bloc
   devient accessible au clavier et annonce correctement son role. */
.collapsible {
    margin-top: 14px;
    background: rgba(255,255,255,0.028);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.collapsible-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 11px 13px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 12.5px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: color var(--transition);
}
.collapsible-head:hover { color: var(--text-primary); }
.collapsible-head > span:first-child {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}
.collapsible-arrow {
    font-size: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
}
#custom-fee-group { padding: 0 13px 13px; }

/* ── Actions en fin de ligne de tableau ───────────────────────────── */
.row-actions {
    display: flex;
    gap: 6px;
}
/* Boutons carres contenant seulement une icone : on neutralise le
   padding horizontal herite de .btn-sm. */
.row-actions .btn {
    padding: 6px;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
}
.row-actions .btn svg,
.row-actions .btn i { width: 14px; height: 14px; }

/* ── Detail du reste a payer ──────────────────────────────────────── */
/* Ces lignes etaient injectees avec des styles inline depuis le JS. En
   classes, elles s'adaptent aux petits ecrans. */
.pending-detail {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 7px;
    font-family: var(--font);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0;
}
.pending-line strong {
    color: var(--yellow);
    font-family: var(--mono);
    font-weight: 700;
}

/* La valeur du reste a payer contient un bloc de detail : on autorise
   une hauteur libre au lieu de la ligne unique des autres indicateurs. */
#w-pending-floki {
    line-height: 1.15;
}

@media (max-width: 560px) {
    .row-actions .btn { width: 32px; height: 32px; }
}

/* ── Cartes de reglages ───────────────────────────────────────────── */
.settings-card {
    padding: 22px;
    margin-bottom: 16px;
}

.settings-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14.5px;
    font-weight: 700;
    letter-spacing: -0.015em;
    margin: 0 0 18px;
    padding-bottom: 13px;
    border-bottom: 1px solid var(--border);
}

.settings-icon {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99,102,241,0.13);
    color: var(--accent-light);
}
.settings-icon.green  { background: rgba(16,185,129,0.13); color: var(--green); }
.settings-icon.yellow { background: rgba(245,158,11,0.13); color: var(--yellow); }
.settings-icon.red    { background: rgba(239,68,68,0.13);  color: var(--red); }
.settings-icon.accent { background: rgba(99,102,241,0.13); color: var(--accent-light); }
.settings-icon svg, .settings-icon i { width: 16px; height: 16px; }

/* Champ en lecture seule : signale visuellement qu'il n'est pas
   modifiable, sans recourir a un style inline. */
.form-control[readonly] {
    opacity: 0.68;
    cursor: not-allowed;
    background: rgba(255,255,255,0.02);
}

/* ── Simulateur ───────────────────────────────────────────────────── */
.simulator {
    margin-top: 6px;
    padding: 15px;
    background: rgba(99,102,241,0.055);
    border: 1px solid rgba(99,102,241,0.18);
    border-radius: var(--radius-sm);
}
.simulator-head {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--accent-light);
    margin-bottom: 11px;
}
.simulator-body {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.simulator-body .form-control {
    max-width: 168px;
    flex: 0 1 168px;
}
.simulator-arrow {
    color: var(--text-muted);
    font-weight: 700;
    flex-shrink: 0;
}
.simulator-out {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}
#sim-result {
    font-size: 19px;
    font-weight: 700;
    color: var(--green);
    letter-spacing: -0.02em;
}
.simulator-caption {
    font-size: 11.5px;
    color: var(--text-muted);
    font-weight: 500;
}

@media (max-width: 560px) {
    .settings-card { padding: 17px; }
    .settings-title { font-size: 13.5px; margin-bottom: 15px; }

    /* En colonne : sur un ecran etroit, le champ, la fleche et le
       resultat ne tenaient pas sur une ligne et se chevauchaient. */
    .simulator-body { flex-direction: column; align-items: stretch; gap: 9px; }
    .simulator-body .form-control { max-width: none; flex: 1 1 auto; }
    .simulator-arrow { display: none; }
    .simulator-out { justify-content: space-between; }
}

/* ── Connexion : complements ──────────────────────────────────────── */
.login-submit {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 13.5px;
}
.login-foot {
    margin: 22px 0 0;
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
}
/* Le message d'erreur est desormais au-dessus du formulaire : la marge
   passe donc en bas. */
.login-error {
    margin-bottom: 15px;
    text-align: center;
}
