/* ═══════════════════════════════════════════════════
   Gestion JOL — Mobile First
   Base: mobile (< 768px)  →  Desktop: min-width 768px+
   ═══════════════════════════════════════════════════ */

:root {
    --green: #10b981;
    --green-dark: #059669;
    --green-bg: #ecfdf5;
    --red: #ef4444;
    --red-dark: #dc2626;
    --red-bg: #fef2f2;
    --orange: #f97316;
    --orange-bg: #fff7ed;
    --yellow: #eab308;
    --yellow-bg: #fefce8;
    --blue: #3b82f6;
    --blue-dark: #2563eb;
    --blue-bg: #eff6ff;
    --navy: #0f172a;
    --navy-light: #1e293b;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-700: #334155;
    --gray-900: #0f172a;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 1px 3px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.04);
    --shadow-lg: 0 8px 32px rgba(15,23,42,.12);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --header-h: 3.75rem;
    --bottom-nav-h: 4.25rem;
    --touch: 48px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
}

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

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

body {
    font-family: var(--font);
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ─── Auth (mobile first) ─── */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 1rem;
    padding-top: calc(1rem + var(--safe-t));
    padding-bottom: calc(1rem + var(--safe-b));
    background: linear-gradient(160deg, var(--navy-light) 0%, var(--navy) 100%);
}

.auth-container { width: 100%; max-width: 420px; }

.auth-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 1.75rem 1.25rem;
    box-shadow: var(--shadow-lg);
}

.auth-logo { text-align: center; margin-bottom: 1.5rem; }
.logo-icon { font-size: 2.75rem; margin-bottom: .5rem; }
.logo-icon-sm { font-size: 1.35rem; line-height: 1; }
.auth-logo h1 { font-size: 1.35rem; font-weight: 700; }
.auth-subtitle { color: var(--gray-500); font-size: .875rem; margin-top: .25rem; }
.auth-footer { text-align: center; margin-top: 1.25rem; font-size: .875rem; color: var(--gray-500); }
.auth-footer a { color: var(--blue); text-decoration: none; font-weight: 600; }

/* ─── Forms ─── */
.form-group { margin-bottom: 1rem; }
.form-group label,
.form-field label {
    display: block;
    font-size: .8125rem;
    font-weight: 600;
    margin-bottom: .4rem;
    color: var(--gray-700);
}

.form-group input,
.form-field input,
.form-field select,
.form-row input,
.form-row select {
    width: 100%;
    min-height: var(--touch);
    padding: .75rem 1rem;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    background: #fff;
    color: var(--gray-900);
    transition: border-color .15s, box-shadow .15s;
    -webkit-appearance: none;
    appearance: none;
}

.form-group input:focus,
.form-field input:focus,
.form-field select:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(59,130,246,.2);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: .875rem;
    margin-bottom: 1.25rem;
}

.form-field-full { grid-column: 1 / -1; }

.form-field-check {
    display: flex;
    align-items: center;
    min-height: var(--touch);
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin-top: .25rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .9375rem;
    font-weight: 500;
    cursor: pointer;
    min-height: var(--touch);
}

.checkbox-label input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    min-height: auto;
    accent-color: var(--blue);
}

.notify-opt { margin: .75rem 0; padding: .75rem; background: var(--gray-50); border-radius: var(--radius-sm); }

.form-row {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    margin-bottom: 1rem;
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    min-height: var(--touch);
    padding: .75rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: .9375rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform .1s, background .15s, opacity .15s;
    text-decoration: none;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: .5rem .875rem; font-size: .8125rem; }

.btn-icon {
    padding: 0;
    background: transparent;
    border: none;
    min-height: auto;
    font-size: 1.25rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.btn-icon-round {
    width: 44px;
    height: 44px;
    min-height: 44px;
    border-radius: 50%;
    background: var(--gray-100);
    font-size: 1.125rem;
    flex-shrink: 0;
}

.btn-icon-round:active { background: var(--gray-200); }

.btn-primary { background: var(--blue); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-info { background: var(--blue); color: #fff; }
.btn-outline { background: #fff; border: 1.5px solid var(--gray-200); color: var(--gray-700); }

/* ─── Alerts ─── */
.alert {
    padding: .875rem 1rem;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    margin-bottom: 1rem;
    line-height: 1.4;
}
.alert-error { background: var(--red-bg); color: var(--red-dark); border: 1px solid #fecaca; }

/* ═══════════════════════════════════════════════════
   APP LAYOUT — Mobile
   ═══════════════════════════════════════════════════ */
.app-page {
    padding-bottom: calc(var(--bottom-nav-h) + var(--safe-b) + 1rem);
}

/* Header compact */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--navy);
    color: #fff;
    padding-top: var(--safe-t);
    box-shadow: 0 2px 12px rgba(0,0,0,.15);
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .625rem 1rem;
    min-height: var(--header-h);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: .625rem;
    min-width: 0;
    flex: 1;
}

.header-brand-text { min-width: 0; }

.header-brand h1 {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-greeting {
    display: block;
    font-size: .75rem;
    color: var(--gray-400);
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: .375rem;
    flex-shrink: 0;
}

.header-actions .btn-icon-round {
    background: rgba(255,255,255,.12);
    color: #fff;
}

.header-actions .btn-icon-round:active {
    background: rgba(255,255,255,.22);
}

/* Desktop nav hidden on mobile */
.desktop-nav { display: none; }

/* Bottom navigation — primary mobile nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    display: flex;
    align-items: stretch;
    background: #fff;
    border-top: 1px solid var(--gray-200);
    padding-bottom: var(--safe-b);
    box-shadow: 0 -4px 20px rgba(15,23,42,.08);
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .2rem;
    padding: .5rem .25rem;
    min-height: var(--bottom-nav-h);
    text-decoration: none;
    color: var(--gray-400);
    font-size: .625rem;
    font-weight: 600;
    letter-spacing: .01em;
    transition: color .15s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.bottom-nav-item:active { background: var(--gray-50); }

.bottom-nav-icon {
    font-size: 1.375rem;
    line-height: 1;
    transition: transform .15s;
}

.bottom-nav-item.active {
    color: var(--blue);
}

.bottom-nav-item.active .bottom-nav-icon {
    transform: scale(1.1);
}

.bottom-nav-item.active .bottom-nav-label {
    font-weight: 700;
}

/* Main content */
.app-main {
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.page-section {
    scroll-margin-top: calc(var(--header-h) + var(--safe-t) + .5rem);
    margin-bottom: 2rem;
}

.section-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: .875rem;
    color: var(--gray-900);
}

.section-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}

/* ─── Hero balance card ─── */
.hero-card {
    background: linear-gradient(135deg, var(--navy-light) 0%, var(--navy) 100%);
    color: #fff;
    border-radius: var(--radius);
    padding: 1.5rem 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-lg);
}

.hero-label {
    font-size: .8125rem;
    color: var(--gray-400);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.hero-balance {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -.02em;
    margin: .25rem 0 1.25rem;
    line-height: 1.1;
}

.hero-projections {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,.12);
}

.hero-proj {
    text-align: center;
    padding: .5rem .25rem;
    background: rgba(255,255,255,.08);
    border-radius: var(--radius-sm);
}

.hero-proj .proj-label {
    display: block;
    font-size: .6875rem;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.hero-proj .proj-value {
    display: block;
    font-size: .875rem;
    font-weight: 700;
    margin-top: .2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── Stats grid 2×2 ─── */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .625rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius-sm);
    padding: .875rem;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
}

.stat-revenu::before { background: var(--green); }
.stat-depense::before { background: var(--red); }
.stat-info::before { background: var(--orange); }
.stat-alert::before { background: var(--blue); }

.stat-icon {
    font-size: .875rem;
    font-weight: 700;
    display: block;
    margin-bottom: .25rem;
}

.stat-revenu .stat-icon { color: var(--green); }
.stat-depense .stat-icon { color: var(--red); }
.stat-info .stat-icon { color: var(--orange); }
.stat-alert .stat-icon { color: var(--blue); }

.stat-label {
    display: block;
    font-size: .6875rem;
    color: var(--gray-500);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.stat-value {
    display: block;
    font-size: 1.0625rem;
    font-weight: 700;
    margin-top: .15rem;
    line-height: 1.2;
    word-break: break-word;
}

.stat-revenu .stat-value { color: var(--green-dark); }
.stat-depense .stat-value { color: var(--red-dark); }
.stat-info .stat-value { color: var(--orange); }
.stat-alert .stat-value { color: var(--blue-dark); }

.stat-hint {
    display: block;
    font-size: .625rem;
    color: var(--gray-400);
    margin-top: .1rem;
}

/* ─── Chart + checklist row ─── */
.dashboard-chart-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.chart-container {
    background: #fff;
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    height: 260px;
    position: relative;
    min-width: 0;
}

.expense-checklist {
    background: #fff;
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    min-height: 260px;
    max-height: 320px;
}

.expense-checklist-header {
    margin-bottom: .75rem;
}

.expense-checklist-title {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--gray-500);
    margin: 0;
}

.expense-checklist-meta {
    font-size: .75rem;
    color: var(--gray-400);
    margin: .25rem 0 0;
}

.expense-checklist-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    -webkit-overflow-scrolling: touch;
}

.expense-check-item {
    display: flex;
    align-items: flex-start;
    gap: .625rem;
    padding: .625rem .75rem;
    border: 1px solid var(--gray-100);
    border-radius: var(--radius-sm);
    background: var(--gray-50);
    cursor: pointer;
    transition: background .15s, border-color .15s;
}

.expense-check-item:hover {
    background: #fff;
    border-color: var(--gray-200);
}

.expense-check-item.is-paid {
    background: #ecfdf5;
    border-color: #a7f3d0;
}

.expense-check-item input[type="checkbox"] {
    width: 1.125rem;
    height: 1.125rem;
    margin-top: .125rem;
    flex-shrink: 0;
    accent-color: var(--success);
    cursor: pointer;
}

.expense-check-label {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: .125rem;
}

.expense-check-title {
    font-size: .875rem;
    font-weight: 600;
    color: var(--gray-800);
    line-height: 1.3;
}

.expense-check-item.is-paid .expense-check-title {
    text-decoration: line-through;
    color: var(--gray-500);
}

.expense-check-amount {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--danger);
}

.expense-check-sub {
    font-size: .6875rem;
    color: var(--gray-400);
}

.list-item-paid {
    display: flex;
    align-items: center;
    gap: .375rem;
    margin-right: .5rem;
    flex-shrink: 0;
}

.list-item-paid input[type="checkbox"] {
    width: 1.125rem;
    height: 1.125rem;
    accent-color: var(--success);
    cursor: pointer;
}

.list-item-paid span {
    font-size: .6875rem;
    font-weight: 600;
    color: var(--gray-500);
}

.list-item.is-paid-expense {
    background: #f0fdf4;
}

.list-item.is-paid-expense .list-item-title {
    text-decoration: line-through;
    color: var(--gray-500);
}

.chart-title {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--gray-500);
    margin-bottom: .75rem;
    text-align: center;
}

.chart-container canvas {
    max-height: 200px !important;
}

/* ─── Tabs (segmented control) ─── */
.tabs {
    display: flex;
    gap: .25rem;
    padding: .25rem;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

.tab {
    flex: 1;
    padding: .625rem .5rem;
    min-height: 44px;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: .8125rem;
    font-weight: 600;
    font-family: inherit;
    color: var(--gray-500);
    cursor: pointer;
    transition: background .15s, color .15s, box-shadow .15s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.tab.active {
    background: #fff;
    color: var(--blue);
    box-shadow: 0 1px 4px rgba(15,23,42,.08);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── Data list / cards ─── */
.data-list {
    display: flex;
    flex-direction: column;
    gap: .625rem;
}

.list-item {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: .375rem .75rem;
    padding: .875rem;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
}

.list-item-main {
    grid-column: 1;
    grid-row: 1 / 3;
    align-self: center;
    min-width: 0;
}

.list-item-title {
    font-weight: 600;
    font-size: .9375rem;
    line-height: 1.3;
    word-break: break-word;
}

.list-item-meta {
    font-size: .75rem;
    color: var(--gray-500);
    margin-top: .2rem;
    line-height: 1.4;
}

.list-item-amount {
    grid-column: 2;
    grid-row: 1;
    font-weight: 700;
    font-size: .9375rem;
    white-space: nowrap;
    align-self: start;
}

.list-item-amount.positive { color: var(--green-dark); }
.list-item-amount.negative { color: var(--red-dark); }

.list-item-actions {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    gap: .375rem;
    justify-content: flex-end;
}

.list-item-actions .btn-sm {
    min-height: 36px;
    min-width: 36px;
    padding: .375rem .5rem;
}

.debt-card {
    border-left: 3px solid var(--orange);
    display: flex;
    flex-direction: column;
    gap: .625rem;
}

.debt-card .list-item-main { grid-column: unset; grid-row: unset; }

.debt-card .list-item-actions {
    grid-column: unset;
    grid-row: unset;
    justify-content: flex-start;
    padding-top: .375rem;
    border-top: 1px solid var(--gray-200);
}

.badge {
    display: inline-block;
    padding: .2rem .5rem;
    border-radius: 999px;
    font-size: .625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    vertical-align: middle;
}

.badge-recurrent { background: var(--blue-bg); color: var(--blue-dark); }
.badge-ok { background: var(--green-bg); color: var(--green-dark); }
.badge-proche { background: var(--yellow-bg); color: #a16207; }
.badge-imminent { background: var(--orange-bg); color: var(--orange); }
.badge-retard { background: var(--red-bg); color: var(--red-dark); }

.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--gray-400);
    font-size: .875rem;
}

/* ─── Debt section ─── */
.debt-stats-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .625rem;
    margin-bottom: 1rem;
    padding: .875rem;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
}

.debt-stat { text-align: center; padding: .375rem; }
.debt-stat span { display: block; font-size: .6875rem; color: var(--gray-500); font-weight: 600; text-transform: uppercase; }
.debt-stat strong { display: block; font-size: .9375rem; margin-top: .2rem; }

.credit-indicator { margin-bottom: 1rem; }

.credit-bar {
    height: 10px;
    background: var(--gray-200);
    border-radius: 999px;
    overflow: hidden;
}

.credit-fill {
    height: 100%;
    border-radius: 999px;
    transition: width .4s, background .4s;
    width: 0%;
}

.credit-fill.vert { background: var(--green); }
.credit-fill.jaune { background: var(--yellow); }
.credit-fill.orange { background: var(--orange); }
.credit-fill.rouge { background: var(--red); }

.credit-label {
    display: block;
    text-align: center;
    font-size: .75rem;
    color: var(--gray-500);
    margin-top: .5rem;
}

.debt-progress {
    height: 5px;
    background: var(--gray-200);
    border-radius: 999px;
    margin-top: .5rem;
    overflow: hidden;
}

.debt-progress-fill { height: 100%; border-radius: 999px; transition: width .3s; }

.paiements-history { margin-top: .5rem; font-size: .75rem; color: var(--gray-500); }
.paiements-history li { list-style: none; padding: .125rem 0; }

.paiements-block {
    margin-top: .75rem;
    padding-top: .625rem;
    border-top: 1px dashed var(--gray-200);
    font-size: .8125rem;
}

.paiements-block strong {
    display: block;
    font-size: .75rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: .35rem;
}

/* ─── Debt form & cards ─── */
.debt-help {
    background: var(--blue-bg);
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-sm);
    padding: .875rem 1rem;
    margin-bottom: 1rem;
    font-size: .8125rem;
    line-height: 1.5;
    color: var(--gray-700);
}

.debt-help strong { display: block; margin-bottom: .35rem; color: var(--gray-900); }

.debt-help ul {
    margin: .35rem 0 0 1rem;
    padding: 0;
}

.debt-help li { margin-bottom: .2rem; }

.form-section-title {
    font-size: .9375rem;
    font-weight: 700;
    margin-bottom: 1rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--gray-200);
    color: var(--gray-900);
}

.field-hint {
    display: block;
    font-size: .6875rem;
    color: var(--gray-400);
    margin-top: .35rem;
    line-height: 1.35;
}

.field-hint-warn { color: var(--orange) !important; font-weight: 600; }

.debt-min-box {
    background: var(--gray-50);
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: .875rem !important;
}

.debt-min-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}

.debt-min-label {
    display: block;
    font-size: .6875rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.debt-min-value {
    display: block;
    font-size: 1.375rem;
    font-weight: 800;
    color: var(--blue-dark);
    margin-top: .15rem;
}

.debt-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .5rem;
    margin: .625rem 0;
    padding: .625rem;
    background: #fff;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
}

.debt-detail-grid div span {
    display: block;
    font-size: .625rem;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: .03em;
}

.debt-detail-grid div strong {
    display: block;
    font-size: .875rem;
    margin-top: .1rem;
}

.text-red { color: var(--red-dark) !important; }
.text-blue { color: var(--blue-dark) !important; }

.modal-subtitle {
    font-size: .875rem;
    color: var(--gray-500);
    margin: -.5rem 0 1rem;
    text-align: center;
}

/* ─── Mon compte / SMS ─── */
.account-info {
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    padding: .875rem 1rem;
    margin-bottom: 1.25rem;
    font-size: .875rem;
    line-height: 1.7;
}

.account-desc {
    font-size: .875rem;
    color: var(--gray-500);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.sms-status {
    margin-top: 1rem;
    padding: .875rem 1rem;
    border-radius: var(--radius-sm);
    font-size: .8125rem;
    line-height: 1.45;
}

.sms-ok { background: var(--green-bg); color: var(--green-dark); border: 1px solid #a7f3d0; }
.sms-warn { background: var(--yellow-bg); color: #a16207; border: 1px solid #fde68a; }

.header-actions .nav-link.btn-settings { text-decoration: none; }

@media (min-width: 480px) {
    .debt-detail-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ─── Calendar ─── */
.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .875rem;
}

.calendar-nav span {
    font-weight: 700;
    font-size: .9375rem;
    text-align: center;
    flex: 1;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--gray-200);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: .875rem;
}

.cal-header, .cal-day {
    background: #fff;
    padding: .375rem .125rem;
    text-align: center;
    font-size: .75rem;
    min-height: 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.cal-header {
    font-weight: 700;
    background: var(--gray-50);
    font-size: .625rem;
    color: var(--gray-500);
    min-height: 32px;
}

.cal-day.other-month { color: var(--gray-300); background: var(--gray-50); }
.cal-day.today { background: var(--blue-bg); font-weight: 700; color: var(--blue-dark); }
.cal-day.has-events { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.cal-day.has-events:active { background: var(--gray-100); }

.cal-dots {
    display: flex;
    justify-content: center;
    gap: 2px;
    margin-top: 2px;
    flex-wrap: wrap;
}

.cal-dot { width: 5px; height: 5px; border-radius: 50%; }
.cal-dot.revenu { background: var(--green); }
.cal-dot.depense { background: var(--red); }
.cal-dot.dette { background: var(--orange); }
.cal-dot.rappel { background: var(--blue); }

.cal-events-list { display: flex; flex-direction: column; gap: .375rem; }

.cal-event-item {
    padding: .75rem;
    border-radius: var(--radius-sm);
    font-size: .8125rem;
    border-left: 3px solid var(--gray-300);
    line-height: 1.4;
}

.cal-event-item.revenu { border-left-color: var(--green); background: var(--green-bg); }
.cal-event-item.depense { border-left-color: var(--red); background: var(--red-bg); }
.cal-event-item.dette { border-left-color: var(--orange); background: var(--orange-bg); }
.cal-event-item.rappel { border-left-color: var(--blue); background: var(--blue-bg); }

/* ─── Modal (bottom sheet on mobile) ─── */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 300;
    padding: 0;
    backdrop-filter: blur(2px);
}

.modal-content {
    background: #fff;
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 1.25rem 1rem;
    padding-bottom: calc(1.25rem + var(--safe-b));
    width: 100%;
    max-width: 100%;
    box-shadow: var(--shadow-lg);
    animation: slideUp .25s ease;
}

.modal-content h3 {
    font-size: 1.0625rem;
    margin-bottom: 1rem;
    text-align: center;
}

.modal-content::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--gray-300);
    border-radius: 999px;
    margin: 0 auto 1rem;
}

.modal-actions {
    display: flex;
    flex-direction: column-reverse;
    gap: .5rem;
    margin-top: 1rem;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* ─── Toast ─── */
.toast-container {
    position: fixed;
    bottom: calc(var(--bottom-nav-h) + var(--safe-b) + .75rem);
    left: .75rem;
    right: .75rem;
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    pointer-events: none;
}

.toast {
    background: #fff;
    border-radius: var(--radius-sm);
    padding: .875rem 1rem;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--blue);
    animation: toastIn .3s ease;
    font-size: .875rem;
    pointer-events: auto;
}

.toast.warning { border-left-color: var(--orange); }
.toast.danger { border-left-color: var(--red); }
.toast.success { border-left-color: var(--green); }

@keyframes toastIn {
    from { transform: translateY(1rem); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.notification-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: .75rem 1rem;
    padding-top: calc(.75rem + var(--safe-t));
    background: var(--orange);
    color: #fff;
    text-align: center;
    font-weight: 600;
    font-size: .875rem;
    z-index: 150;
    line-height: 1.3;
}

/* ═══════════════════════════════════════════════════
   TABLET  ≥ 480px
   ═══════════════════════════════════════════════════ */
@media (min-width: 480px) {
    .auth-card { padding: 2rem 1.75rem; }

    .hero-balance { font-size: 2.75rem; }

    .stat-value { font-size: 1.1875rem; }

    .form-actions {
        flex-direction: row;
    }

    .form-actions .btn { flex: 1; }

    .modal-actions {
        flex-direction: row;
        justify-content: flex-end;
    }

    .modal-actions .btn { flex: none; min-width: 120px; }

    .debt-stats-bar {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ═══════════════════════════════════════════════════
   DESKTOP  ≥ 768px
   ═══════════════════════════════════════════════════ */
@media (min-width: 768px) {
    .app-page {
        padding-bottom: 0;
    }

    /* Header desktop */
    .app-header {
        background: #fff;
        color: var(--gray-900);
        border-bottom: 1px solid var(--gray-200);
        box-shadow: none;
    }

    .header-top {
        padding: .75rem 1.5rem .5rem;
        min-height: auto;
    }

    .header-brand h1 { font-size: 1.125rem; }

    .header-greeting { color: var(--gray-500); font-size: .8125rem; }

    .header-actions .btn-icon-round {
        background: var(--gray-100);
        color: var(--gray-700);
    }

    .btn-logout::after {
        content: ' Déconnexion';
        font-size: .8125rem;
        font-weight: 600;
    }

    .btn-logout {
        width: auto;
        border-radius: var(--radius-sm);
        padding: 0 1rem;
        gap: .25rem;
    }

    .desktop-nav {
        display: flex;
        align-items: center;
        gap: .25rem;
        padding: 0 1.5rem .75rem;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .desktop-nav::-webkit-scrollbar { display: none; }

    .nav-link {
        padding: .5rem .875rem;
        border-radius: var(--radius-sm);
        font-size: .875rem;
        font-weight: 600;
        color: var(--gray-500);
        text-decoration: none;
        white-space: nowrap;
        transition: color .15s, background .15s;
    }

    .nav-link:hover { color: var(--gray-900); background: var(--gray-100); }
    .nav-link.active { color: var(--blue); background: var(--blue-bg); }

    /* Hide bottom nav on desktop */
    .bottom-nav { display: none; }

    .app-main { padding: 1.5rem; }

    .page-section { scroll-margin-top: 6rem; }

    .hero-card { padding: 2rem 1.75rem; }
    .hero-balance { font-size: 3rem; }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 1rem;
    }

    .stat-card { padding: 1.125rem; }
    .stat-value { font-size: 1.375rem; }

    .chart-container { height: 320px; padding: 1.5rem; }
    .chart-container canvas { max-height: 260px !important; }

    .dashboard-chart-row {
        grid-template-columns: 1.2fr .8fr;
        gap: 1.25rem;
        align-items: stretch;
    }

    .expense-checklist {
        max-height: 320px;
        padding: 1.25rem;
    }

    .section-card { padding: 1.25rem; }

    .form-grid {
        grid-template-columns: 1fr 1fr;
    }

    .form-field-full { grid-column: 1 / -1; }

    .tabs { max-width: 480px; }

    .list-item {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
    }

    .list-item-main { flex: 1; min-width: 150px; }
    .list-item-amount { align-self: center; }
    .list-item-actions { margin-left: auto; }

    .modal {
        align-items: center;
        padding: 1rem;
    }

    .modal-content {
        border-radius: var(--radius);
        max-width: 420px;
        padding: 1.5rem;
        animation: none;
    }

    .modal-content::before { display: none; }

    .toast-container {
        top: 1rem;
        bottom: auto;
        left: auto;
        right: 1rem;
        width: 320px;
    }

    @keyframes toastIn {
        from { transform: translateX(100%); opacity: 0; }
        to { transform: translateX(0); opacity: 1; }
    }
}

/* ═══════════════════════════════════════════════════
   LARGE DESKTOP  ≥ 1024px
   ═══════════════════════════════════════════════════ */
@media (min-width: 1024px) {
    .header-top,
    .desktop-nav {
        max-width: 1200px;
        margin: 0 auto;
        width: 100%;
    }

    .form-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ═══════════════════════════════════════════════════
   BUDGET PLAID — Comptes, transactions, sync
   ═══════════════════════════════════════════════════ */
.hero-card-bank { background: linear-gradient(135deg, var(--navy-light) 0%, var(--blue-dark) 100%); }
.hero-hint { font-size: .8125rem; opacity: .85; margin-top: .25rem; }
.hero-balance-sm { font-size: 1.75rem !important; }
.hero-card-compact { padding: 1.25rem; margin-bottom: 1rem; }
.legacy-section { margin-top: 1.5rem; padding: 1rem; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
.legacy-section summary { cursor: pointer; font-weight: 600; color: var(--gray-700); padding: .5rem 0; }
.stats-grid-compact { margin-top: 1rem; }
.stats-grid-compact .stat-card { padding: .75rem; }
.section-desc { color: var(--gray-500); margin-bottom: 1rem; font-size: .875rem; }
.section-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.section-actions { margin-top: 1rem; display: flex; gap: .75rem; flex-wrap: wrap; }
.chart-container-bank {
    height: auto;
    min-height: 260px;
}

.chart-container-bank canvas.hidden {
    display: none;
}

.plaid-sandbox-notice {
    margin-top: 1rem;
    padding: .875rem 1rem;
    border-radius: var(--radius-sm);
    background: #fffbeb;
    border: 1px solid #fcd34d;
    font-size: .8125rem;
    color: #92400e;
    line-height: 1.5;
}

.plaid-sandbox-notice strong {
    color: #78350f;
}

.plaid-sandbox-notice code {
    background: #fef3c7;
    padding: .1rem .35rem;
    border-radius: 4px;
    font-size: .8125rem;
}
.sync-link { color: inherit; text-decoration: underline; font-size: inherit; }

.accounts-grid { display: grid; gap: 1rem; }
@media (min-width: 768px) { .accounts-grid { grid-template-columns: repeat(2, 1fr); } }

.account-card {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 1rem;
}
.account-card-header { display: flex; justify-content: space-between; margin-bottom: .5rem; }
.account-institution { font-size: .75rem; font-weight: 600; color: var(--blue); text-transform: uppercase; }
.account-type { font-size: .75rem; color: var(--gray-500); }
.account-name { font-size: 1rem; margin-bottom: .75rem; }
.account-balances { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.account-balances span { display: block; font-size: .75rem; color: var(--gray-500); }
.account-balances strong { font-size: 1.125rem; }
.account-sync-hint { font-size: .75rem; color: var(--gray-400); margin-top: .75rem; }

.tx-expense { color: var(--red); font-weight: 600; }
.tx-income { color: var(--green); font-weight: 600; }
.tx-category-select { margin-top: .35rem; font-size: .8125rem; padding: .25rem .5rem; border-radius: 6px; border: 1px solid var(--gray-200); max-width: 100%; }

.filter-bar { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.input-month { padding: .5rem .75rem; border: 1px solid var(--gray-200); border-radius: var(--radius-sm); font: inherit; }

.categories-list { display: flex; flex-direction: column; gap: .5rem; margin-top: 1rem; }
.category-item {
    display: flex; align-items: center; gap: .75rem;
    padding: .75rem 1rem; background: var(--gray-50); border-radius: var(--radius-sm);
    border-left: 4px solid var(--cat-color, var(--blue));
}
.category-icon { font-size: 1.25rem; }
.category-name { flex: 1; font-weight: 600; }

.budget-summary { text-align: center; font-weight: 600; margin: .75rem 0 1rem; color: var(--gray-700); }
.budget-list { display: flex; flex-direction: column; gap: 1rem; }
.budget-row { padding: .75rem 0; border-bottom: 1px solid var(--gray-100); }
.budget-row-header { display: flex; justify-content: space-between; font-size: .875rem; margin-bottom: .35rem; }
.budget-bar { height: 8px; background: var(--gray-200); border-radius: 4px; overflow: hidden; margin-bottom: .5rem; }
.budget-bar-fill { height: 100%; border-radius: 4px; transition: width .3s; }
.budget-bar-fill.over { background: var(--red) !important; }
.budget-row-input { display: flex; align-items: center; gap: .5rem; font-size: .875rem; }
.budget-row-input input { width: 100px; padding: .35rem .5rem; border: 1px solid var(--gray-200); border-radius: 6px; }

.plaid-status-grid { display: grid; gap: .75rem; margin-bottom: 1rem; }
.label-muted { display: block; font-size: .75rem; color: var(--gray-500); }
.sync-info { font-size: .875rem; color: var(--gray-700); line-height: 1.6; margin-bottom: .5rem; }
.plaid-item-card { display: flex; justify-content: space-between; align-items: center; padding: .75rem 0; border-bottom: 1px solid var(--gray-100); gap: 1rem; }
.sync-log-list { display: flex; flex-direction: column; gap: .5rem; }
.sync-log-item { font-size: .8125rem; padding: .5rem 0; border-bottom: 1px solid var(--gray-100); display: flex; flex-direction: column; gap: .25rem; }
.plaid-help ol { padding-left: 1.25rem; font-size: .875rem; color: var(--gray-700); line-height: 1.7; }
.plaid-help code { background: var(--gray-100); padding: .1rem .35rem; border-radius: 4px; font-size: .8125rem; }
.empty-msg { color: var(--gray-500); font-size: .875rem; padding: 1rem 0; text-align: center; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
