/* =====================================================================
   The Slow Climb — charte visuelle (assets/app.css)
   Thème sombre ardoise · 3 accents : menthe (positif), ambre (alerte), corail (dépassement)
   ===================================================================== */

:root {
    /* Fonds et surfaces */
    --bg: #0e141b;
    --surface: #151d26;
    --surface-2: #1b2531;
    --surface-3: #22303f;
    --border: rgba(148, 163, 184, 0.10);
    --border-strong: rgba(148, 163, 184, 0.20);

    /* Texte */
    --text: #e6ecf2;
    --text-muted: #8b9aab;
    --text-faint: #5f6e7f;

    /* Accents (3 maximum) */
    --mint: #3ecf8e;
    --mint-strong: #5fe0a6;
    --mint-soft: rgba(62, 207, 142, 0.13);
    --amber: #f2b45a;
    --amber-soft: rgba(242, 180, 90, 0.14);
    --coral: #ff7666;
    --coral-soft: rgba(255, 118, 102, 0.13);

    /* Espacements */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;

    /* Rayons */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-pill: 999px;

    /* Élévation */
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 6px 20px rgba(0, 0, 0, 0.28);
    --shadow-lg: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 16px 40px rgba(0, 0, 0, 0.45);

    /* Typo */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --fs-xs: 0.75rem;
    --fs-sm: 0.8125rem;
    --fs-md: 0.9375rem;
    --fs-lg: 1.125rem;
    --fs-xl: 1.5rem;
    --fs-2xl: 2rem;

    /* Mouvements */
    --t-fast: 150ms ease;
    --t: 200ms ease;

    /* Hauteur de la barre d'onglets mobile */
    --tabbar-h: 64px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }

body {
    font-family: var(--font);
    font-size: var(--fs-md);
    line-height: 1.45;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--mint); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--mint-strong); }

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

/* Tous les montants : chiffres tabulaires, alignés */
.money, input.money, .tbb-amount, td.num, .num {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    white-space: nowrap;
}

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.pos { color: var(--mint); }
.warn { color: var(--amber); }
.neg { color: var(--coral); }

/* ---------- En-tête (bureau) ---------- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-5);
    background: rgba(14, 20, 27, 0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
}
.brand-mark {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: var(--mint-soft);
    font-size: 16px;
}

.nav { display: flex; gap: var(--space-1); }
.nav a {
    color: var(--text-muted);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
    font-weight: 500;
    transition: background var(--t-fast), color var(--t-fast);
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--surface-2); color: var(--text); box-shadow: inset 0 -2px 0 var(--mint); }

/* ---------- Mise en page ---------- */
.page {
    max-width: 1180px;
    margin: 0 auto;
    padding: var(--space-5);
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
}

.layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: var(--space-5);
    align-items: start;
}

/* ---------- Cartes ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-4) var(--space-2);
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.card-body { padding: var(--space-2) var(--space-4) var(--space-4); }
.card-link { text-transform: none; letter-spacing: 0; font-weight: 500; }

.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; }

/* ---------- Navigation de mois ---------- */
.month-nav { display: flex; align-items: center; gap: var(--space-2); }
.month-title {
    font-size: var(--fs-xl);
    font-weight: 700;
    letter-spacing: -0.02em;
    min-width: 190px;
    text-align: center;
}
.icon-btn {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }

.select {
    appearance: none;
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b9aab' stroke-width='1.5' fill='none'/%3E%3C/svg%3E") no-repeat right 12px center;
    border: 1px solid var(--border);
    color: var(--text);
    font: inherit;
    font-size: var(--fs-sm);
    padding: var(--space-2) var(--space-6) var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color var(--t-fast);
}
.select:hover { border-color: var(--border-strong); }

/* ---------- « À budgétiser » ---------- */
.tbb {
    text-align: right;
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.tbb-label { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.tbb-amount { font-size: var(--fs-2xl); font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.tbb.is-pos .tbb-amount { color: var(--mint); }
.tbb.is-zero .tbb-amount { color: var(--text); }
.tbb.is-neg { border-color: rgba(255, 118, 102, 0.4); }
.tbb.is-neg .tbb-amount { color: var(--coral); }

/* ---------- Comptes ---------- */
.account-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: var(--space-2) 0;
    font-size: var(--fs-md);
}
.account-row + .account-row { border-top: 1px solid var(--border); }
.account-total {
    display: flex;
    justify-content: space-between;
    margin-top: var(--space-2);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-strong);
    font-weight: 700;
    font-size: var(--fs-lg);
}

/* ---------- Boutons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 10px var(--space-4);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font: inherit;
    font-size: var(--fs-sm);
    font-weight: 600;
    cursor: pointer;
    transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), color var(--t-fast);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--mint); color: #07150e; }
.btn-primary:hover { background: var(--mint-strong); color: #07150e; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-coral { background: var(--coral-soft); color: var(--coral); border-color: rgba(255, 118, 102, 0.35); }
.btn-coral:hover { background: rgba(255, 118, 102, 0.22); color: #ff9184; }
.btn-sm { padding: 6px var(--space-3); font-size: var(--fs-xs); }
.btn-block { width: 100%; }

/* ---------- Bandeaux ---------- */
.banner {
    border-radius: var(--radius);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-4);
    border: 1px solid;
}
.banner-title { display: flex; align-items: center; gap: var(--space-2); font-weight: 600; margin-bottom: var(--space-2); }
.banner-coral { background: var(--coral-soft); border-color: rgba(255, 118, 102, 0.35); }
.banner-coral .banner-title { color: var(--coral); }
.banner-amber { background: var(--amber-soft); border-color: rgba(242, 180, 90, 0.35); }
.banner-amber .banner-title { color: var(--amber); }
.banner-mint { background: var(--mint-soft); border-color: rgba(62, 207, 142, 0.35); }
.banner-mint .banner-title { color: var(--mint); margin: 0; }
.banner-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    border-top: 1px solid rgba(255, 118, 102, 0.18);
}

/* ---------- Tableau du budget ---------- */
.budget-cols, .group-head, .cat-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px 110px 120px;
    gap: var(--space-3);
    align-items: center;
}
.budget-cols {
    padding: 0 var(--space-4) var(--space-2);
    font-size: var(--fs-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-faint);
}
.budget-cols span:not(:first-child) { text-align: right; }

.group {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: var(--space-4);
    overflow: hidden;
}
.group-head {
    padding: var(--space-3) var(--space-4);
    background: var(--surface-2);
    font-weight: 700;
    font-size: var(--fs-sm);
}
.group-head .num { text-align: right; color: var(--text-muted); font-weight: 600; }
.group-head .num.pos { color: var(--mint); }
.group-head .num.neg { color: var(--coral); }

.cat-row {
    padding: 10px var(--space-4);
    border-top: 1px solid var(--border);
    transition: background var(--t-fast);
}
.cat-row:hover { background: rgba(255, 255, 255, 0.02); }
.cat-row .num { text-align: right; }

.cat-name { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.cat-icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--surface-3);
    font-size: 17px;
    line-height: 1;
}
.cat-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }

.cat-row.is-over { background: linear-gradient(90deg, var(--coral-soft), transparent 60%); box-shadow: inset 3px 0 0 var(--coral); }
.cat-row.is-over .cat-label { color: var(--coral); }

/* Champ « budgété » */
.amount-input {
    width: 100%;
    text-align: right;
    font: inherit;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 6px var(--space-2);
    transition: background var(--t-fast), border-color var(--t-fast);
}
.amount-input:hover { background: var(--surface-2); border-color: var(--border); }
.amount-input:focus { outline: none; background: var(--surface-3); border-color: var(--mint); }
.amount-input.is-zero { color: var(--text-faint); font-weight: 500; }

/* Pastille « disponible » */
.pill {
    display: inline-block;
    min-width: 92px;
    text-align: right;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    transition: background var(--t), color var(--t);
}
.pill-pos { background: var(--mint-soft); color: var(--mint); }
.pill-warn { background: var(--amber-soft); color: var(--amber); }
.pill-neg { background: var(--coral-soft); color: var(--coral); }
.pill-zero { color: var(--text-faint); font-weight: 500; }

.badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: var(--radius-pill);
    font-size: var(--fs-xs);
    font-weight: 600;
    background: var(--surface-3);
    color: var(--text-muted);
}
.badge-warn { background: var(--amber-soft); color: var(--amber); }

/* ---------- Fenêtres ---------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    background: rgba(5, 8, 12, 0.7);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t);
}
.modal.active { opacity: 1; pointer-events: auto; }
.modal-content {
    width: 100%;
    max-width: 440px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-5);
    transform: translateY(8px);
    transition: transform var(--t);
}
.modal.active .modal-content { transform: none; }

.field { margin-bottom: var(--space-4); }
.field label { display: block; margin-bottom: var(--space-1); font-size: var(--fs-sm); color: var(--text-muted); }
.input {
    width: 100%;
    font: inherit;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 10px var(--space-3);
    transition: border-color var(--t-fast);
}
.input:focus { outline: none; border-color: var(--mint); }

.cat-icon-letter { font-size: var(--fs-sm); font-weight: 700; color: var(--text-muted); }

/* ---------- Titres de page ---------- */
.page-title { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.02em; }
.page-subtitle { color: var(--text-muted); font-size: var(--fs-sm); margin-top: 2px; }
.section-title { font-size: var(--fs-md); font-weight: 700; margin: var(--space-5) 0 var(--space-3); }

/* ---------- Messages ---------- */
.flash {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    margin-bottom: var(--space-4);
    border: 1px solid;
    font-weight: 500;
}
.flash-ok { background: var(--mint-soft); border-color: rgba(62, 207, 142, 0.35); color: var(--mint); }
.flash-err { background: var(--coral-soft); border-color: rgba(255, 118, 102, 0.35); color: var(--coral); }

/* ---------- Formulaires ---------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: var(--space-3) var(--space-4);
}
.form-grid .field { margin-bottom: 0; }
.field-wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: var(--space-2); margin-top: var(--space-4); flex-wrap: wrap; }
.form-hint { font-size: var(--fs-xs); color: var(--text-muted); margin-top: var(--space-1); }
.form-hint.warn { color: var(--amber); }
.form-hint.neg { color: var(--coral); }
.form-hint.pos { color: var(--mint); }
select.input { appearance: none; padding-right: var(--space-6); background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b9aab' stroke-width='1.5' fill='none'/%3E%3C/svg%3E") no-repeat right 12px center; cursor: pointer; }
input.input[type="date"] { color-scheme: dark; }
.inline-form { display: inline; }

/* ---------- Barre d'outils ---------- */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-bottom: var(--space-4);
}
.toolbar-group { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

/* ---------- Listes (comptes, catégories) ---------- */
.list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--border);
    transition: background var(--t-fast);
}
.list-row:first-child { border-top: none; }
.list-row:hover { background: rgba(255, 255, 255, 0.02); }
.list-main { display: flex; align-items: center; gap: var(--space-3); min-width: 0; flex: 1; }
.list-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-sub { font-size: var(--fs-xs); color: var(--text-muted); }
.list-actions { display: flex; gap: var(--space-2); flex: none; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left;
    font-size: var(--fs-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-faint);
    padding: var(--space-2) var(--space-4);
    border-bottom: 1px solid var(--border);
}
.table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
.table .num, .table th.num { text-align: right; }
.table .center { text-align: center; }
.cell-cat { display: flex; align-items: center; gap: var(--space-2); }
.cell-cat .cat-icon { width: 26px; height: 26px; font-size: 14px; }

.tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: var(--radius-pill);
    font-size: var(--fs-xs);
    font-weight: 600;
    background: var(--surface-3);
    color: var(--text-muted);
    vertical-align: middle;
}
.tag-income { background: var(--mint-soft); color: var(--mint); }

/* ---------- Stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); margin-bottom: var(--space-5); }
.stat-card { padding: var(--space-4); }
.stat-label { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.stat-value { font-size: var(--fs-xl); font-weight: 800; letter-spacing: -0.02em; margin-top: var(--space-1); font-variant-numeric: tabular-nums; }
.stat-sub { font-size: var(--fs-xs); color: var(--text-muted); margin-top: var(--space-1); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); margin-bottom: var(--space-4); }
.stack > * + * { margin-top: var(--space-4); }

.bar-row { padding: var(--space-2) 0; }
.bar-row + .bar-row { border-top: 1px solid var(--border); }
.bar-line { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); margin-bottom: 6px; }
.bar-track { height: 6px; border-radius: var(--radius-pill); background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; border-radius: var(--radius-pill); background: var(--coral); transition: width var(--t); }
.bar-fill.mint { background: var(--mint); }
.percent { color: var(--text-faint); font-size: var(--fs-xs); margin-left: var(--space-1); }

.legend { display: flex; gap: var(--space-4); font-size: var(--fs-xs); color: var(--text-muted); margin-bottom: var(--space-3); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart { display: flex; align-items: flex-end; gap: var(--space-3); height: 190px; padding-top: var(--space-2); overflow-x: auto; }
.chart-col { flex: 1; min-width: 36px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.chart-bars { display: flex; align-items: flex-end; gap: 3px; height: 160px; }
.chart-bar { width: 14px; border-radius: 4px 4px 0 0; min-height: 2px; transition: opacity var(--t-fast); }
.chart-bar:hover { opacity: 0.8; }
.chart-bar.mint { background: var(--mint); }
.chart-bar.coral { background: var(--coral); }
.chart-label { font-size: var(--fs-xs); color: var(--text-muted); }

/* Graphiques Chart.js */
.chart-box { position: relative; height: 280px; }
.chart-box-donut { height: 260px; }
.chart-note { font-size: var(--fs-xs); color: var(--text-muted); margin: var(--space-3) var(--space-4) var(--space-4); }
.card-body .chart-note { margin: var(--space-3) 0 0; }

/* Sélecteur segmenté (Groupes / Catégories, 6 / 12 mois) */
.seg { display: inline-flex; padding: 2px; border-radius: var(--radius-sm); background: var(--surface-2); text-transform: none; letter-spacing: 0; }
.seg-btn { border: none; background: none; color: var(--text-muted); font: inherit; font-size: var(--fs-xs); font-weight: 600; padding: 4px 10px; border-radius: 6px; cursor: pointer; transition: background var(--t-fast), color var(--t-fast); }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--surface-3); color: var(--text); }

/* Évolution : ↑ hausse des dépenses (corail), ↓ baisse (menthe) */
.delta { display: inline-block; font-size: var(--fs-xs); font-weight: 700; padding: 1px 6px; border-radius: var(--radius-pill); background: var(--surface-3); color: var(--text-muted); white-space: nowrap; }
.delta-up { background: var(--coral-soft); color: var(--coral); }
.delta-down { background: var(--mint-soft); color: var(--mint); }

.compare-list { margin-top: var(--space-4); border-top: 1px solid var(--border); padding-top: var(--space-3); }
.compare-title { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: var(--space-2); }
.compare-item { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: 6px 0; font-size: var(--fs-sm); }
.compare-item + .compare-item { border-top: 1px solid var(--border); }

/* Où part mon argent */
.flow-table td:first-child { min-width: 200px; }
.flow-bar { display: flex; align-items: center; gap: var(--space-2); margin-top: 6px; }
.flow-bar i { display: block; height: 4px; min-width: 2px; max-width: 160px; flex: none; border-radius: var(--radius-pill); background: var(--text-muted); opacity: 0.6; }
.flow-bar span { font-size: var(--fs-xs); color: var(--text-faint); }
.flow-table tr.flow-over td:first-child { box-shadow: inset 3px 0 0 var(--coral); }
.flow-table tr.flow-rising td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
.tag-over { background: var(--coral-soft); color: var(--coral); margin-left: var(--space-1); }
.tag-rising { background: var(--amber-soft); color: var(--amber); margin-left: var(--space-1); }

.empty { text-align: center; padding: var(--space-6) var(--space-4); color: var(--text-muted); }
.empty a { font-weight: 600; }

/* ---------- Choix d'icône ---------- */
.icon-picker { display: grid; grid-template-columns: repeat(8, 1fr); gap: var(--space-1); margin-top: var(--space-2); }
.icon-choice {
    display: grid;
    place-items: center;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--surface-2);
    font-size: 18px;
    cursor: pointer;
    transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.icon-choice:hover { background: var(--surface-3); transform: translateY(-1px); }
.icon-choice.selected { border-color: var(--mint); background: var(--mint-soft); }
.icon-input { width: 72px; text-align: center; font-size: 20px; }

/* ---------- Connexion ---------- */
.auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: var(--space-4);
    background: radial-gradient(900px 500px at 50% -10%, rgba(62, 207, 142, 0.10), transparent 60%), var(--bg);
}
.auth-card { width: 100%; max-width: 400px; padding: var(--space-6) var(--space-5); }
.auth-brand { text-align: center; margin-bottom: var(--space-5); }
.auth-brand .brand-mark { width: 52px; height: 52px; font-size: 26px; margin: 0 auto var(--space-3); border-radius: var(--radius); }
.auth-brand h1 { font-size: var(--fs-xl); letter-spacing: -0.02em; }
.auth-brand p { color: var(--text-muted); font-size: var(--fs-sm); margin-top: var(--space-1); }

/* ---------- Menu « Plus » (mobile) ---------- */
.sheet {
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgba(5, 8, 12, 0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t);
}
.sheet.active { opacity: 1; pointer-events: auto; }
.sheet-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: var(--space-3) var(--space-4) calc(var(--space-5) + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border-strong);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(100%);
    transition: transform var(--t);
}
.sheet.active .sheet-panel { transform: none; }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 0 auto var(--space-3); }
.sheet-link { display: block; padding: var(--space-3) var(--space-2); color: var(--text); font-weight: 500; border-radius: var(--radius-sm); }
.sheet-link:hover { background: var(--surface-2); color: var(--text); }
.sheet-link-muted { color: var(--text-muted); }

/* ---------- Budget : total du mois et part des dépenses ---------- */
.group-total { border-color: var(--border-strong); }
.group-total .group-head { background: var(--surface-3); font-size: var(--fs-md); }
.group-total .group-head .num { color: var(--text); font-weight: 700; }

.share { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 3px; }
.share i { display: block; height: 4px; max-width: 56px; min-width: 2px; border-radius: var(--radius-pill); background: var(--text-muted); opacity: 0.6; }
.share span { font-size: var(--fs-xs); color: var(--text-faint); font-weight: 600; min-width: 34px; text-align: right; }
.share-badge {
    display: inline-block;
    margin-left: var(--space-2);
    padding: 0 6px;
    border-radius: var(--radius-pill);
    background: var(--surface-3);
    color: var(--text-muted);
    font-size: var(--fs-xs);
    font-weight: 700;
    vertical-align: 1px;
}
.share-badge:empty { display: none; }

/* ---------- Budget : résumé, barre d'outils, groupes repliables ---------- */
.month-summary { margin-bottom: var(--space-5); }
.budget-toolbar { margin-bottom: var(--space-3); }

.group-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    background: none;
    border: none;
    color: inherit;
    font: inherit;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    padding: 0;
    min-width: 0;
}
.group-toggle .chevron { display: inline-block; color: var(--text-faint); transition: transform var(--t-fast); }
.group.is-collapsed .chevron { transform: rotate(-90deg); }
.group.is-collapsed .group-body { display: none; }
body.hide-empty .cat-row.is-empty { display: none; }

/* Barre de progression dépensé / budgété */
.progress { display: inline-flex; align-items: center; gap: var(--space-2); margin-left: auto; flex: 0 1 190px; min-width: 70px; }
.progress-track { flex: 1; height: 6px; border-radius: var(--radius-pill); background: var(--surface-3); overflow: hidden; }
.progress-track i { display: block; height: 100%; border-radius: var(--radius-pill); transition: width var(--t), background var(--t); }
.progress-ok i { background: var(--mint); }
.progress-warn i { background: var(--amber); }
.progress-over i { background: var(--coral); }
.progress-label { font-size: var(--fs-xs); font-weight: 600; color: var(--text-faint); min-width: 38px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.progress-warn .progress-label { color: var(--amber); }
.progress-over .progress-label { color: var(--coral); }
.cat-name { padding-right: var(--space-2); }

/* Badge d'objectif */
.goal-badge { border: none; cursor: pointer; font-family: inherit; transition: filter var(--t-fast); }
.goal-badge:hover { filter: brightness(1.2); }
.goal-complete { background: var(--mint-soft); color: var(--mint); }
.goal-on_track { background: var(--surface-3); color: var(--text-muted); }
.goal-over { background: var(--coral-soft); color: var(--coral); }

/* Champ budgété + bouton d'options */
.cell-budget { display: block; }
.budget-line { display: flex; align-items: center; gap: 2px; }
.cell-budget .share { padding-right: 26px; }
.cell-budget .share span:empty { visibility: hidden; }
.cat-menu-btn {
    flex: none;
    width: 24px;
    height: 28px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-faint);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast);
}
.cat-menu-btn:hover, .cat-menu-btn:focus-visible { background: var(--surface-2); color: var(--text); }
.budget-cols, .group-head, .cat-row { grid-template-columns: minmax(0, 1fr) 146px 110px 120px; }

/* Menus déroulants */
.menu-wrap { position: relative; }
.menu {
    display: none;
    position: absolute;
    z-index: 120;
    top: calc(100% + 6px);
    left: 0;
    min-width: 280px;
    padding: var(--space-1);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}
.menu.open { display: block; animation: menu-in var(--t-fast); }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.menu-floating { width: 280px; }
.menu-title { padding: var(--space-2) var(--space-3); font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.menu-item {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text);
    font: inherit;
    font-size: var(--fs-sm);
    text-align: left;
    cursor: pointer;
    transition: background var(--t-fast);
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); }
.menu-item .money { color: var(--text-muted); }
.menu-sep { height: 1px; margin: var(--space-1) 0; background: var(--border); }

/* ---------- Devise à la saisie ---------- */
.amount-with-currency { display: flex; gap: var(--space-2); }
.amount-with-currency .input:first-child { flex: 1; min-width: 0; }
.amount-with-currency select.input { width: 96px; flex: none; }
.quick-currency {
    position: absolute;
    right: var(--space-2);
    top: 50%;
    transform: translateY(-50%);
    appearance: none;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-3);
    color: var(--text);
    font: inherit;
    font-weight: 700;
    font-size: var(--fs-sm);
    padding: 6px 10px;
    cursor: pointer;
}
/* Conversion pendant la saisie : bien visible */
.quick-preview { text-align: center; margin: calc(-1 * var(--space-2)) 0 var(--space-4); min-height: 2.6em; }
.quick-eur { display: block; font-size: var(--fs-xl); font-weight: 800; color: var(--mint); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.quick-rate { display: block; font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; }
#eur-preview { font-size: var(--fs-md); font-weight: 700; color: var(--mint); }

/* ---------- Saisie rapide : type, catégories favorites ---------- */
.quick-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
#queue-status { margin: calc(-1 * var(--space-2)) 0 var(--space-3); }
.fav-cats { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: calc(-1 * var(--space-2)) 0 var(--space-4); }
.fav-cat {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: var(--fs-sm);
    cursor: pointer;
    transition: background var(--t-fast), border-color var(--t-fast);
}
.fav-cat span { font-size: 15px; line-height: 1; }
.fav-cat:hover { background: var(--surface-3); }
.fav-cat.selected { border-color: var(--mint); background: var(--mint-soft); color: var(--mint); }

/* ---------- Réglages, récurrentes, bandeaux ambre ---------- */
.toggle-row { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) 0; cursor: pointer; }
.toggle-row + .toggle-row { border-top: 1px solid var(--border); }
.toggle-row input { accent-color: var(--mint); width: 18px; height: 18px; margin-top: 2px; flex: none; }
.list-row.is-paused { opacity: 0.55; }
.banner-item-amber { border-top-color: rgba(242, 180, 90, 0.22); }
.banner-amber .list-sub { color: var(--text-muted); }

/* ---------- Installer l'application ---------- */
.install-banner {
    position: fixed;
    left: var(--space-3);
    right: var(--space-3);
    bottom: calc(var(--tabbar-h) + var(--space-3) + env(safe-area-inset-bottom));
    z-index: 80;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    font-size: var(--fs-sm);
}
.install-banner[hidden] { display: none; }
.install-text { flex: 1; line-height: 1.3; }
.install-close { border: none; background: none; color: var(--text-faint); font-size: 16px; cursor: pointer; padding: var(--space-1); }
.install-help { padding: 0 var(--space-2) var(--space-2); }

/* ---------- Filtres des transactions ---------- */
.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3);
    margin-bottom: var(--space-4);
}
.filters .input { width: auto; padding: 8px var(--space-3); font-size: var(--fs-sm); }
.filters .filter-search { flex: 1 1 240px; }
.filter-check { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-muted); cursor: pointer; }
.filter-check input { accent-color: var(--mint); width: 16px; height: 16px; }

/* Ligne de jour avec sous-total */
.table tr.day-row td {
    background: var(--surface-2);
    padding-top: var(--space-2);
    padding-bottom: var(--space-2);
    font-size: var(--fs-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
.table tr.day-row td.num span + span { margin-left: var(--space-2); }

/* ---------- Saisie rapide ---------- */
.quick-amount { position: relative; margin-bottom: var(--space-4); }
.quick-amount .input {
    font-size: 2rem;
    font-weight: 800;
    text-align: center;
    padding: var(--space-3) 70px;
    letter-spacing: -0.02em;
}
.quick-amount span {
    position: absolute;
    right: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-weight: 600;
}
@media (min-width: 761px) {
    .sheet-quick .sheet-panel {
        left: 50%;
        right: auto;
        bottom: auto;
        top: 50%;
        width: 460px;
        border: 1px solid var(--border-strong);
        border-radius: var(--radius-lg);
        transform: translate(-50%, -46%);
        opacity: 0;
        transition: transform var(--t), opacity var(--t);
    }
    .sheet-quick.active .sheet-panel { transform: translate(-50%, -50%); opacity: 1; }
    .sheet-quick .sheet-handle { display: none; }
}
.nav .btn { margin-left: var(--space-2); }
button.fab { border: none; cursor: pointer; font-family: inherit; }

/* ---------- Mobile : barre d'onglets + bouton flottant ---------- */
.tabbar, .fab { display: none; }

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

@media (max-width: 760px) {
    .app-header { padding: var(--space-3) var(--space-4); }
    .app-header .nav { display: none; }

    .page { padding: var(--space-4) var(--space-3) calc(var(--tabbar-h) + var(--space-7)); }
    .page-head { align-items: stretch; flex-direction: column; gap: var(--space-3); margin-bottom: var(--space-4); }
    .month-nav { justify-content: space-between; }
    .month-title { min-width: 0; font-size: var(--fs-lg); }
    .tbb { text-align: left; display: flex; justify-content: space-between; align-items: center; }

    .layout { grid-template-columns: minmax(0, 1fr); }
    .layout > aside { order: 2; }

    .budget-cols { display: none; }
    .group-head { grid-template-columns: minmax(0, 1fr) auto; }
    .group-head .num:not(.group-available) { display: none; }

    /* Catégorie sur deux lignes : icône + nom + disponible / budgété · dépensé */
    .cat-row {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas: "name avail" "meta budget";
        row-gap: 2px;
        padding: var(--space-3) var(--space-3);
    }
    .cat-row .cat-name { grid-area: name; }
    .cat-row .cell-avail { grid-area: avail; text-align: right; }
    .cat-row .cell-budget { grid-area: budget; width: 112px; justify-self: end; }
    .cat-row .cell-budget .amount-input { padding: 4px var(--space-2); font-size: var(--fs-sm); background: var(--surface-2); border-color: var(--border); }
    .cat-row .cell-spent { display: none; }
    .cat-row .cell-meta { display: block; grid-area: meta; align-self: center; min-width: 0; padding-left: 44px; font-size: var(--fs-xs); line-height: 1.35; color: var(--text-muted); white-space: normal; }
    /* Les morceaux passent à la ligne entre eux, jamais sous le champ du budget */
    .cat-row .cell-meta > span { display: inline-block; white-space: nowrap; }
    .pill { min-width: 0; }

    .month-title { white-space: nowrap; }
    .month-nav .select { display: none; }

    /* Transactions : une carte compacte par ligne */
    .tx-table thead { display: none; }
    .tx-table tr {
        display: grid;
        grid-template-columns: 32px minmax(0, 1fr) auto;
        grid-template-areas: "cat desc amt" "cat date act";
        column-gap: var(--space-3);
        row-gap: 2px;
        align-items: center;
        padding: var(--space-3);
        border-bottom: 1px solid var(--border);
    }
    .tx-table tbody tr:last-child { border-bottom: none; }
    .group-total .group-head { grid-template-columns: minmax(0, 1fr) auto auto auto; column-gap: var(--space-3); }
    .cat-row .cell-budget { width: 124px; }
    .cat-row .cell-budget .share { display: none; }
    /* Barre de progression : fine ligne au bas de la catégorie, pour laisser la place au nom */
    .cat-row { position: relative; padding-bottom: calc(var(--space-3) + 4px); }
    .progress { position: absolute; left: 56px; right: var(--space-3); bottom: 6px; margin: 0; }
    .progress-track { height: 3px; }
    .progress-label { display: none; }
    .month-summary .stat-card { padding: var(--space-3); }
    .budget-toolbar .toolbar-group { width: 100%; justify-content: space-between; flex-wrap: wrap; row-gap: var(--space-2); }
    .flow-table td:first-child { min-width: 0; }
    .flow-table .tag { display: none; }
    .flow-table th, .flow-table td { padding-left: var(--space-2); padding-right: var(--space-2); }
    .flow-bar i { max-width: 60px; }
    .group-total .group-head .num { display: block; font-size: var(--fs-sm); }
    .tx-table tr.day-row { display: flex; justify-content: space-between; padding: var(--space-2) var(--space-3); background: var(--surface-2); }
    .tx-table tr.day-row td { background: none; }
    .filters .input { flex: 1 1 140px; }
    .filters .filter-search { flex-basis: 100%; }
    .tx-table td { padding: 0; border: none; }
    .tx-cat { grid-area: cat; }
    .tx-cat .cat-name-text { display: none; }
    .tx-desc { grid-area: desc; font-weight: 500; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; }

    /* Top 10 des dépenses : même carte compacte que les transactions */
    .top-table thead { display: none; }
    .top-table tr {
        display: grid;
        grid-template-columns: 32px minmax(0, 1fr) auto;
        grid-template-areas: "cat desc amt" "cat date amt";
        column-gap: var(--space-3);
        row-gap: 2px;
        align-items: center;
        padding: var(--space-3);
        border-bottom: 1px solid var(--border);
    }
    .top-table tbody tr:last-child { border-bottom: none; }
    .top-table td { padding: 0; border: none; }
    .top-table .top-cat { grid-area: cat; }
    .top-table .top-cat .cell-cat { font-size: 0; gap: 0; }
    .top-table .top-cat .cat-icon { font-size: 17px; }
    .top-table .top-desc { grid-area: desc; font-weight: 500; overflow-wrap: anywhere; }
    .top-table .top-date { grid-area: date; font-size: var(--fs-xs); }
    .top-table .top-amt { grid-area: amt; }
    .tx-date { grid-area: date; font-size: var(--fs-xs); }
    .tx-amt { grid-area: amt; }
    .tx-act { grid-area: act; }
    .tx-act .btn-sm { padding: 2px var(--space-2); }
    .tag-expense { display: none; }

    .list-row { padding: var(--space-3); flex-wrap: wrap; row-gap: var(--space-2); }
    .list-actions { flex-basis: 100%; justify-content: flex-end; }
    .table th, .table td { padding: var(--space-2) var(--space-3); }
    .hide-mobile { display: none; }
    .stat-value { font-size: var(--fs-lg); }
    .modal { align-items: flex-end; padding: 0; }
    .modal-content { max-width: none; border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom)); transform: translateY(100%); }

    .tabbar {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 60;
        height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
        background: rgba(21, 29, 38, 0.92);
        backdrop-filter: blur(12px);
        border-top: 1px solid var(--border);
    }
    .tabbar a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        font-size: 11px;
        font-weight: 500;
        color: var(--text-faint);
        transition: color var(--t-fast);
    }
    .tabbar a .tab-icon { font-size: 20px; line-height: 1; filter: grayscale(1); opacity: 0.75; transition: filter var(--t-fast), opacity var(--t-fast); }
    .tabbar a.active { color: var(--mint); }
    .tabbar a.active .tab-icon { filter: none; opacity: 1; }

    .fab {
        display: grid;
        place-items: center;
        position: fixed;
        right: var(--space-4);
        bottom: calc(var(--tabbar-h) + var(--space-4) + env(safe-area-inset-bottom));
        z-index: 70;
        width: 58px;
        height: 58px;
        border-radius: 50%;
        background: var(--mint);
        color: #07150e;
        font-size: 30px;
        font-weight: 400;
        line-height: 1;
        box-shadow: 0 8px 24px rgba(62, 207, 142, 0.35), var(--shadow-lg);
        transition: transform var(--t-fast), background var(--t-fast);
    }
    .fab:hover { background: var(--mint-strong); color: #07150e; }
    .fab:active { transform: scale(0.95); }
}

/* Petits téléphones (320–400 px) : on resserre le tableau « Où part mon argent » */
@media (max-width: 400px) {
    .table.flow-table th, .table.flow-table td { padding-left: 6px; padding-right: 6px; }
    .table.flow-table th { letter-spacing: 0; }
    .flow-bar i { max-width: 40px; }
}

/* Ligne « budgété · dépensé » visible seulement sur mobile */
.cell-meta { display: none; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; }
}
