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

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    height: auto;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
    color: #111827;
}

/* ---------- COULEURS / VARIABLES ---------- */
:root {
    --bg-body: #f2f2f7;
    --bg-main: #f9fafb;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --accent: #007aff;
    --accent-soft: rgba(0,122,255,0.08);
    --text-muted: #6b7280;
    --border-soft: #e5e7eb;
    --radius-xl: 22px;
    --radius: 14px;
}

/* ---------- LAYOUT GLOBAL ---------- */

body {
    background: var(--bg-body);
    min-height: 100vh;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
}

.layout {
    display: flex;
    width: 100%;
    min-height: 100vh;
    margin: 0;
    background: var(--bg-main);
    border-radius: 0;
    overflow: hidden;
    box-shadow: none;
    border: none;
}

/* ---------- SIDEBAR ---------- */

.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    padding: 18px 16px 14px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 6px 14px;
    border-bottom: 1px solid #edf0f4;
    margin-bottom: 10px;
}

.brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: radial-gradient(circle at 30% 0, #9dc5ff, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #ffffff;
    font-size: 0.95rem;
    box-shadow: 0 0 0 1px rgba(191,219,254,0.9);
}

.brand-title {
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
}

.brand-subtitle {
    font-size: 0.8rem;
    color: #9ca3af;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    margin-top: 10px;
    gap: 4px;
    padding: 4px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 9px;
    border-radius: 10px;
    color: #111827;
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.16s ease, transform 0.06s ease, color 0.15s ease;
}

.sidebar-menu a:hover {
    background: var(--accent-soft);
    color: #0b1120;
    transform: translateX(1px);
}

.sidebar-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 10px;
    border-top: 1px solid #edf0f4;
}

/* ---------- BOUTONS ---------- */

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 9px 12px;
    border-radius: 999px;
    font-size: 0.86rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.06s ease, box-shadow 0.12s ease, background 0.18s ease;
}

.btn-primary {
    background: var(--accent);
    color: #ffffff;
    box-shadow: 0 12px 24px rgba(0,122,255,0.35);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 30px rgba(0,122,255,0.45);
}

.btn-secondary {
    background: #f3f4f6;
    color: #111827;
    border: 1px solid #e5e7eb;
}

.btn-secondary:hover {
    background: #e5e7eb;
}

/* ---------- MAIN / TOPBAR ---------- */

.main {
    flex: 1;
    background: var(--bg-main);
    display: flex;
    flex-direction: column;
}

.topbar {
    padding: 16px 22px 12px;
    border-bottom: 1px solid #e5e7eb;
    background: rgba(249,250,251,0.95);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.hello {
    font-size: 1.1rem;
    font-weight: 600;
    color: #111827;
}

.subtitle {
    font-size: 0.87rem;
    color: var(--text-muted);
}

/* ---------- CONTENU ---------- */

.content {
    flex: 1;
    padding: 18px 24px 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.content-inner {
    width: 100%;
    max-width: none !important;
    padding-right: 40px;
}


.content-inner {
    max-width: 2000px;  /* ou 1300px si tu veux très large */
    margin: 0 auto;     /* centre le bloc */
}


/* ---------- TITRES ---------- */

.content h1 {
    margin: 0 0 6px;
    font-size: 1.3rem;
    font-weight: 600;
    color: #111827;
}

.content p {
    margin-top: 0;
    color: #4b5563;
}

/* ---------- CARTES / DASHBOARD ---------- */

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    margin-top: 8px;
    align-items: flex-start;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px 14px 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 10px 20px rgba(15,23,42,0.04);
}

.card h2 {
    font-size: 0.86rem;
    margin: 0 0 4px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.card p {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #111827;
}

/* ---------- TABLES ---------- */

.table-wrapper {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid #e5e7eb;
    box-shadow: 0 8px 18px rgba(15,23,42,0.04);
    overflow: hidden;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}

.table th,
.table td {
    padding: 8px 10px;
    border-bottom: 1px solid #e5e7eb;
}

.table th {
    text-align: left;
    background: #f3f4f6;
    color: #6b7280;
    font-weight: 500;
}

.table tbody tr:nth-child(even) {
    background: #f9fafb;
}

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

.table tbody tr:hover {
    background: #eef2ff;
}

/* ---------- ALERTES ---------- */

.alert {
    padding: 9px 11px;
    border-radius: 10px;
    font-size: 0.85rem;
    margin-bottom: 10px;
}

.alert-success {
    background: #ecfdf3;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

/* ---------- FORMULAIRES ---------- */

.content-inner {
    padding-left: 40px;
    padding-right: 40px;
}


form label {
    display: block;
    margin-bottom: 3px;
    font-size: 0.85rem;
    color: #374151;
}

form input,
form select,
form textarea {
    width: 100%;
    padding: 7px 9px;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    font-size: 0.9rem;
    margin-bottom: 10px;
    outline: none;
    color: #111827;
}

form input:focus,
form select:focus,
form textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0,122,255,0.18);
}

form textarea {
    min-height: 90px;
    resize: vertical;
}

form button {
    border-radius: 999px;
    border: none;
    padding: 8px 16px;
    background: var(--accent);
    color: #ffffff;
    font-size: 0.9rem;
    cursor: pointer;
    margin-top: 4px;
}

form button:hover {
    background: #0059c9;
}

/* ---------- FILTRES (transactions) ---------- */

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 16px;
    margin-bottom: 12px;
    padding: 10px 12px;
    background: #ffffff;
    border-radius: var(--radius);
    border: 1px solid #e5e7eb;
}

.filters > div {
    display: flex;
    flex-direction: column;
    min-width: 150px;
}

.filters-actions {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

/* ---------- LOGIN ---------- */

body.login {
    background: radial-gradient(circle at top, #e0edff, #f2f2f7);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: #ffffff;
    padding: 22px 24px 18px;
    border-radius: 20px;
    box-shadow: 0 18px 38px rgba(15,23,42,0.16);
    border: 1px solid #e5e7eb;
    width: 360px;
    color: #111827;
}

.login-card h1 {
    margin: 0 0 5px;
    font-size: 1.26rem;
}

.login-card p.subtitle {
    margin: 0 0 14px;
    color: #6b7280;
    font-size: 0.9rem;
}

/* ---------- TEXTE LISIBLE DANS LE CONTENU ---------- */

.content,
.content-inner,
.content h1,
.content h2,
.content p,
.content label,
.content input,
.content select,
.content textarea,
.content td,
.content th {
    color: #111827;
}

/* ---------- STEPS (assistant en 3 étapes) ---------- */

.steps {
    display: flex;
    gap: 8px;
    margin: 10px 0 16px;
    font-size: 0.85rem;
}

.step-item {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    color: #6b7280;
}

.step-item.active {
    border-color: #007aff;
    background: rgba(0,122,255,0.08);
    color: #0b1120;
    font-weight: 500;
}

/* ---------- MONTANTS COLORÉS ---------- */

.amount-expense,
.type-expense,
.content td.amount-expense,
.table td.amount-expense {
    color: #dc2626;
    font-weight: 600;
}

.amount-income,
.type-income,
.content td.amount-income,
.table td.amount-income {
    color: #16a34a;
    font-weight: 600;
}

/* ---------- BADGES / BOUTON DANGER ---------- */

.badge-type {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-depense {
    background: #fee2e2;
    color: #b91c1c;
}

.badge-recette {
    background: #dcfce7;
    color: #166534;
}

.table .btn-danger {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
}

.table .btn-danger:hover {
    background: #fecaca;
}

/* ---------- CALENDRIER (documents) ---------- */

/* ========================================
   CALENDRIER — NOUVEAU DESIGN
   ======================================== */

.calendar-card {
    margin-top: 12px;
    padding: 20px 20px 24px;
    border-radius: 16px;
}

/* Header navigation */
.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 0 4px;
}

.calendar-title {
    font-weight: 700;
    font-size: 1.15rem;
    color: #111827;
    letter-spacing: -0.02em;
}

.calendar-nav-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #6b7280;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    text-decoration: none;
}
.calendar-nav-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #111827;
}

/* Légende */
.calendar-legend {
    display: flex;
    gap: 16px;
    font-size: 0.78rem;
    color: #6b7280;
    margin-bottom: 16px;
    align-items: center;
}
.legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    margin-right: 5px;
    vertical-align: middle;
}
.legend-dot-income  { background: #16a34a; }
.legend-dot-expense { background: #dc2626; }
.legend-dot-recurring { background: #93c5fd; }

/* Grille */
.calendar {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #f0f0f0;
}

.calendar-grid-header {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    background: #fafafa;
    border-bottom: 1px solid #f0f0f0;
}

.calendar-grid-header > div {
    padding: 10px 0 8px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9ca3af;
    text-align: center;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0;
}

.calendar-grid-body {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-day {
    min-height: 100px;
    background: #fff;
    padding: 8px 8px 6px;
    border-right: 1px solid #f3f4f6;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    flex-direction: column;
    gap: 3px;
    transition: background 0.12s;
    position: relative;
}
.calendar-day:hover {
    background: #fafbff;
}
.calendar-day:nth-child(7n) {
    border-right: none;
}

.calendar-day-empty {
    background: #fafafa;
    border-right: 1px solid #f3f4f6;
    border-bottom: 1px solid #f3f4f6;
}

.calendar-day-today {
    background: #eff6ff;
}
.calendar-day-today .calendar-day-number {
    background: #2563eb;
    color: white;
    border-radius: 6px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.calendar-day-number {
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 2px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calendar-events {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Event pill */
.calendar-event-link {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    font-size: 0.7rem;
    padding: 3px 6px;
    border-radius: 6px;
    border-left: 3px solid transparent;
    transition: opacity 0.12s;
    line-height: 1.3;
}
.calendar-event-link:hover { opacity: 0.8; }

.calendar-event-income {
    background: #f0fdf4;
    border-left-color: #16a34a;
}
.calendar-event-expense {
    background: #fef2f2;
    border-left-color: #dc2626;
}
.calendar-event-recurring {
    background: #eff6ff;
    border-left-color: #93c5fd;
    opacity: 0.9;
}

.calendar-event-badge { display: none; }

.calendar-event-main {
    font-weight: 600;
    color: #111827;
    font-size: 0.7rem;
}
.calendar-event-sub {
    color: #6b7280;
    font-size: 0.65rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.calendar-more {
    font-size: 0.65rem;
    color: #9ca3af;
    padding: 1px 4px;
    font-weight: 500;
}

/* ---------- BARRES DÉPENSES / RECETTES ---------- */

.progress-cards {
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.progress-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 10px 16px 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 10px 20px rgba(15,23,42,0.04);
}

.progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.progress-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    font-weight: 600;
}

.progress-amount {
    font-size: 1.15rem;
    font-weight: 600;
    color: #111827;
}

.progress-percent {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent);
}

.progress-bar {
    width: 100%;
    height: 7px;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease-out;
}

/* Couleurs spécifiques */
.progress-bar-fill-expense {
    background: linear-gradient(90deg, #f97316, #ef4444);
}

.progress-bar-fill-income {
    background: linear-gradient(90deg, #22c55e, #0ea5e9);
}

.progress-card-expense .progress-title {
    color: #ef4444;
}

.progress-card-income .progress-title {
    color: #16a34a;
}
/* ---------- KPI DÉPENSES / RECETTES ---------- */

.kpi-wrapper {
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.kpi-card {
    /* .card gère déjà le fond / bordure / ombre */
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.kpi-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    font-weight: 600;
}

.kpi-amount {
    font-size: 1.1rem;
    font-weight: 600;
    color: #111827;
}

.kpi-percent {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent);
}

.kpi-bar {
    width: 100%;
    height: 12px; /* plus gros que 7px, bien visible */
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
}

.kpi-bar-inner {
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease-out;
}

.kpi-bar-expense {
    background: linear-gradient(90deg, #f97316, #ef4444);
}

.kpi-bar-income {
    background: linear-gradient(90deg, #22c55e, #0ea5e9);
}
.table .btn-edit {
    background: #e0edff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.table .btn-edit:hover {
    background: #bfdbfe;
}
.btn-secondary {
    background: #f3f4f6;
    color: #111827;
    border: 1px solid #e5e7eb;
}

.btn-secondary:hover {
    background: #e5e7eb;
}

.btn,
.btn-secondary {
    border-radius: 999px;
    padding: 9px 16px;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
}

/* ========================================
   DASHBOARD — NOUVEAUX COMPOSANTS
   ======================================== */

/* --- Page header --- */
.page-header { margin-bottom: 4px; }
.page-header h1 { margin: 0 0 2px; }
.page-header p { margin: 0; color: #6b7280; font-size: 0.88rem; }

/* --- KPI stat cards --- */
.kpi-stat {
    display: flex;
    flex-direction: column;
    gap: 3px;
    position: relative;
    padding-top: 16px;
}

.kpi-stat-icon {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 6px;
    flex-shrink: 0;
}
.kpi-icon-green { background: #dcfce7; color: #16a34a; }
.kpi-icon-red   { background: #fee2e2; color: #dc2626; }
.kpi-icon-blue  { background: #dbeafe; color: #2563eb; }

.kpi-stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9ca3af;
    font-weight: 600;
}
.kpi-stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: #111827;
    line-height: 1.2;
}
.kpi-stat-sub {
    font-size: 0.76rem;
    color: #9ca3af;
    margin-top: 1px;
}

/* --- Section header --- */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    margin-bottom: 8px;
}
.section-header h2 { margin: 0; font-size: 1rem; font-weight: 600; }
.section-link {
    font-size: 0.82rem;
    color: var(--accent);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 3px;
    font-weight: 500;
}
.section-link:hover { text-decoration: underline; }

/* --- Table helpers --- */
.table-sublabel { color: #9ca3af; font-size: 0.78rem; }
.table-muted    { color: #9ca3af; }

/* --- KPI Bars --- */
.kpi-bars { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }

.kpi-bar-card { padding: 12px 16px 14px; }

.kpi-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.kpi-bar-label {
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
    font-weight: 600;
}
.kpi-bar-amount { font-size: 1rem; font-weight: 600; color: #111827; margin-top: 1px; }
.kpi-bar-total  { font-size: 0.8rem; color: #9ca3af; font-weight: 400; }
.kpi-bar-pct    { font-size: 0.95rem; font-weight: 700; color: var(--accent); }
.kpi-bar-pct.pct-danger { color: #dc2626; }
.kpi-bar-pct.pct-warn   { color: #f97316; }

.kpi-bar-track {
    width: 100%;
    height: 7px;
    border-radius: 999px;
    background: #f3f4f6;
    overflow: hidden;
}
.kpi-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.5s cubic-bezier(.4,0,.2,1);
}
.bar-expense { background: linear-gradient(90deg, #f97316, #ef4444); }
.bar-income  { background: linear-gradient(90deg, #22c55e, #0ea5e9); }

/* --- Plafonds légaux --- */
.plafonds-card { margin-top: 16px; padding: 16px 20px 14px; }

.plafonds-header {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #6b7280;
    margin-bottom: 16px;
}

.plafonds-grid {
    display: grid;
    grid-template-columns: 1fr 1px 1fr;
    gap: 0 20px;
}

.plafond-divider {
    background: #f3f4f6;
    width: 1px;
    align-self: stretch;
}

.plafond-col { display: flex; flex-direction: column; gap: 10px; }

.plafond-tour-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: #d1d5db;
    margin-bottom: 2px;
}

/* Chaque ligne plafond a hauteur fixe */
.plafond-row {
    min-height: 74px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 4px;
}
.plafond-row-remb { min-height: 46px; }

.plafond-row-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.plafond-row-left {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.plafond-row-name { font-size: 0.83rem; color: #374151; font-weight: 500; }

.plafond-row-amount {
    font-size: 0.83rem;
    font-weight: 700;
    white-space: nowrap;
    display: flex;
    align-items: baseline;
    gap: 5px;
    flex-shrink: 0;
}
.plafond-pct { font-size: 0.73rem; font-weight: 400; color: #9ca3af; }

/* Ligne de sous-info — hauteur fixe pour alignement */
.plafond-sub-line {
    font-size: 0.75rem;
    min-height: 18px;
    display: flex;
    align-items: center;
    gap: 4px;
    border-radius: 6px;
    padding: 2px 6px;
}
.sub-ghost  { color: #9ca3af; background: transparent; }
.sub-danger { color: #b91c1c; background: #fef2f2; font-weight: 600; }

/* Barre plafond */
.plafond-bar-wrap {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: #f3f4f6;
    overflow: hidden;
}
.plafond-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.5s cubic-bezier(.4,0,.2,1);
}
.bar-ok     { background: linear-gradient(90deg, #22c55e, #0ea5e9); }
.bar-warn   { background: linear-gradient(90deg, #fb923c, #f97316); }
.bar-danger { background: linear-gradient(90deg, #ef4444, #b91c1c); }

/* Badges */
.plafond-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 999px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    flex-shrink: 0;
}
.plafond-badge-danger { background: #fee2e2; color: #b91c1c; }
.plafond-badge-warn   { background: #ffedd5; color: #c2410c; }

/* Couleurs texte montants */
.text-ok     { color: #16a34a; }
.text-warn   { color: #f97316; }
.text-danger { color: #dc2626; }
.text-purple { color: #6366f1; }

.plafonds-footnote {
    font-size: 0.71rem;
    color: #d1d5db;
    margin: 14px 0 0;
}

/* Sidebar icônes SVG (remplacement emojis) */
.sidebar-menu a svg { flex-shrink: 0; opacity: 0.7; }

/* ========================================
   REFINEMENTS GLOBAUX
   ======================================== */

/* Sidebar — lien actif + espacement plus serré */
.sidebar { padding: 16px 12px 14px; }

.sidebar-menu a {
    padding: 7px 10px;
    font-size: 0.875rem;
    font-weight: 450;
    color: #4b5563;
    border-radius: 9px;
    gap: 9px;
}
.sidebar-menu a:hover {
    background: #f3f4f6;
    color: #111827;
    transform: none;
}
.sidebar-menu svg { opacity: 0.5; }
.sidebar-menu a:hover svg { opacity: 0.85; }

/* Topbar plus épurée */
.topbar {
    padding: 12px 28px 10px;
    border-bottom: 1px solid #f3f4f6;
    background: #fff;
    backdrop-filter: none;
}
.hello { font-size: 0.95rem; font-weight: 600; color: #111827; }
.subtitle { font-size: 0.82rem; color: #9ca3af; font-weight: 400; }

/* Content padding plus généreux */
.content { padding: 20px 28px 28px; gap: 0; }
.content-inner { padding-left: 0; padding-right: 0; }

/* H1 + H2 dashboard */
.content h1 { font-size: 1.15rem; font-weight: 700; margin: 0 0 3px; color: #111827; }
.content h2 { font-size: 0.95rem; font-weight: 600; color: #111827; margin: 20px 0 8px; }

/* Cards plus subtiles */
.card {
    border-radius: 12px;
    border: 1px solid #f0f0f0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 4px 12px rgba(0,0,0,0.03);
    padding: 16px;
}

/* Table plus propre */
.table th {
    background: #fafafa;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
    font-weight: 600;
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
}
.table td { padding: 10px 12px; border-bottom: 1px solid #f9f9f9; font-size: 0.875rem; }
.table tbody tr:nth-child(even) { background: transparent; }
.table tbody tr:hover { background: #fafafa; }
.table-wrapper { border: 1px solid #f0f0f0; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }

/* Brand */
.brand-title { font-size: 0.9rem; font-weight: 700; }
.brand-subtitle { font-size: 0.75rem; color: #c4c4c4; }
.brand-logo { border-radius: 10px; background: linear-gradient(135deg, #3b82f6, #1d4ed8); box-shadow: none; }

/* Sidebar footer buttons */
.sidebar-footer .btn { gap: 6px; font-size: 0.83rem; padding: 8px 14px; border-radius: 9px; }
.btn-primary { box-shadow: 0 2px 8px rgba(0,122,255,0.25); }

/* Badges type dans tableau */
.badge-type {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 3px 8px;
    border-radius: 5px;
    text-transform: uppercase;
}
.badge-depense { background: #fef2f2; color: #b91c1c; }
.badge-recette { background: #f0fdf4; color: #166534; }

/* ========================================
   PLAFONDS — NOUVEAU DESIGN
   ======================================== */

.plafond-block {
    padding: 14px 0 10px;
    border-bottom: 1px solid #f3f4f6;
}
.plafond-block:last-child { border-bottom: none; }
.plafond-block-remb { padding-top: 12px; padding-bottom: 4px; }

.plafond-block-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 8px;
}
.plafond-block-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.plafond-block-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.plafond-block-limit {
    font-size: 1.25rem;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.02em;
}
.plafond-block-right {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 2px;
}
.plafond-pct-big {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* Pill badges */
.plafond-pill {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.pill-danger { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.pill-warn   { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }

/* Barre fine */
.plafond-thin-bar-wrap {
    height: 5px;
    background: #f3f4f6;
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 6px;
}
.plafond-thin-bar-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.6s ease;
    max-width: 100%;
}

/* Caption sous la barre */
.plafond-caption {
    font-size: 0.78rem;
    font-weight: 500;
}
.caption-muted  { color: #9ca3af; }
.caption-danger { color: #dc2626; }

/* Remboursement */
.plafond-remb-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: #7c3aed;
    letter-spacing: -0.01em;
}

/* ========================================
   PLAFONDS V3 — DESIGN RAFFINÉ
   ======================================== */

.plafond-block {
    padding: 16px 0 12px;
    border-bottom: 1px solid #f3f4f6;
}

.plafond-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.plafond-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: #9ca3af;
    letter-spacing: 0.01em;
}

.plafond-right {
    display: flex;
    align-items: center;
    gap: 7px;
}

.plafond-pct-num {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.plafond-amount-row {
    display: flex;
    align-items: baseline;
    gap: 5px;
    margin-bottom: 10px;
}

.plafond-spent {
    font-size: 1.45rem;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.03em;
    line-height: 1;
}

.plafond-slash {
    font-size: 1rem;
    color: #d1d5db;
    font-weight: 300;
}

.plafond-limit {
    font-size: 0.9rem;
    font-weight: 500;
    color: #9ca3af;
}

/* Ligne remboursement */
.plafond-remb-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0 4px;
    gap: 12px;
}

.plafond-remb-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.plafond-remb-amounts {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.plafond-remb-est {
    font-size: 1.15rem;
    font-weight: 700;
    color: #7c3aed;
    letter-spacing: -0.02em;
}

.plafond-remb-max {
    font-size: 0.75rem;
    color: #c4b5fd;
    font-weight: 500;
}

/* ========================================
   TOPBAR LOGOS RN + UDR
   ======================================== */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.topbar-logos {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 4px 0;
}

.topbar-logo {
    height: 28px;
    width: auto;
    object-fit: contain;
    opacity: 0.85;
    transition: opacity 0.2s;
    filter: none;
}

.topbar-logo:hover {
    opacity: 1;
}

.topbar-logo-sep {
    width: 1px;
    height: 22px;
    background: #e5e7eb;
}

/* Logos SVG inline topbar */
.topbar-logo-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    transition: transform 0.15s, box-shadow 0.15s;
    cursor: default;
}
.topbar-logo-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0,0,0,0.18);
}

/* Fix topbar layout */
.topbar {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: nowrap !important;
}
.topbar-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Fix logos PNG */
.topbar-logo {
    height: 36px;
    width: auto;
    object-fit: contain;
}

/* Sidebar fixe — footer toujours en bas */
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-menu {
    flex: 1;
}

/* Sidebar scroll interne — footer toujours visible */
.sidebar {
    display: flex !important;
    flex-direction: column !important;
    height: 100vh !important;
    overflow: hidden !important;
}
.sidebar-menu {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    min-height: 0 !important;
}
.sidebar-footer {
    flex-shrink: 0 !important;
}

/* ========================================
   FIX LAYOUT — sidebar fixe, main scrollable
   ======================================== */
html, body {
    height: 100%;
    overflow: hidden;
}
.layout {
    height: 100vh !important;
    overflow: hidden !important;
}
.main {
    overflow-y: auto !important;
    height: 100vh !important;
}
.sidebar {
    height: 100vh !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    position: sticky !important;
    top: 0 !important;
}
.sidebar-menu {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    min-height: 0 !important;
}
.sidebar-footer {
    flex-shrink: 0 !important;
}

/* ================================================================
   RÉSULTATS ÉLECTORAUX
   ================================================================ */

.resultats-page { display: flex; flex-direction: column; gap: 18px; }

/* Header */
.resultats-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}
.resultats-subtitle { font-size: 0.85rem; color: #9ca3af; margin: 2px 0 0; }

/* Progress global */
.resultats-progress-global { text-align: right; min-width: 160px; }
.rpg-numbers { display: flex; align-items: baseline; gap: 4px; justify-content: flex-end; margin-bottom: 6px; }
.rpg-done { font-size: 1.8rem; font-weight: 800; color: #111827; letter-spacing: -0.03em; line-height: 1; }
.rpg-sep { color: #d1d5db; font-size: 1.2rem; }
.rpg-total { font-size: 0.85rem; color: #6b7280; }
.rpg-bar-wrap { height: 6px; background: #f3f4f6; border-radius: 99px; overflow: hidden; margin-bottom: 4px; }
.rpg-bar-fill { height: 100%; background: linear-gradient(90deg, #2563eb, #60a5fa); border-radius: 99px; transition: width 0.6s ease; }
.rpg-label { font-size: 0.78rem; color: #6b7280; font-weight: 500; }

/* KPIs */
.resultats-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.r-kpi { background: white; border: 1px solid #f0f0f0; border-radius: 12px; padding: 14px 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.r-kpi-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: #9ca3af; margin-bottom: 4px; }
.r-kpi-value { font-size: 1.4rem; font-weight: 700; color: #111827; letter-spacing: -0.02em; }
.r-kpi-sub { font-size: 0.75rem; color: #6b7280; margin-top: 2px; }

/* Card */
.resultats-card { padding: 18px 20px; }
.resultats-card-title {
    display: flex; align-items: center; gap: 7px;
    font-size: 0.8rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.07em; color: #6b7280; margin-bottom: 16px;
}

/* Barres listes */
.r-listes { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.r-liste-row { display: flex; align-items: center; gap: 10px; }
.r-liste-left { display: flex; align-items: center; gap: 8px; min-width: 180px; }
.r-liste-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.r-liste-nom { font-size: 0.85rem; font-weight: 500; color: #111827; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.r-liste-bar-wrap { flex: 1; height: 8px; background: #f3f4f6; border-radius: 99px; overflow: hidden; }
.r-liste-bar-fill { height: 100%; border-radius: 99px; transition: width 0.5s ease; }
.r-liste-right { display: flex; gap: 8px; align-items: baseline; min-width: 90px; justify-content: flex-end; }
.r-liste-voix { font-size: 0.85rem; font-weight: 700; color: #111827; }
.r-liste-pct { font-size: 0.8rem; color: #6b7280; font-weight: 500; }

/* Camembert */
.r-camembert-wrap { display: flex; justify-content: center; padding-top: 8px; }
.r-camembert { filter: drop-shadow(0 4px 12px rgba(0,0,0,0.08)); }

/* Gestion listes */
.r-listes-gestion { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.r-liste-tag {
    display: flex; align-items: center; gap: 7px;
    background: #fafafa; border: 1px solid #f0f0f0;
    border-radius: 8px; padding: 6px 10px;
    font-size: 0.82rem; font-weight: 500; color: #111827;
}
.r-liste-tag-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.r-btn-delete {
    background: none; border: none; cursor: pointer;
    color: #d1d5db; padding: 0 2px; display: flex; align-items: center;
    transition: color 0.15s;
}
.r-btn-delete:hover { color: #dc2626; }

.r-add-liste-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.r-input {
    padding: 8px 12px; border: 1px solid #e5e7eb; border-radius: 9px;
    font-size: 0.875rem; color: #111827; background: white;
    outline: none; transition: border-color 0.15s;
}
.r-input:focus { border-color: #2563eb; }
.r-color-input {
    width: 38px; height: 36px; border: 1px solid #e5e7eb;
    border-radius: 9px; cursor: pointer; padding: 2px;
}
.r-btn-add {
    padding: 8px 16px; background: #111827; color: white;
    border: none; border-radius: 9px; font-size: 0.83rem;
    font-weight: 600; cursor: pointer; transition: background 0.15s;
}
.r-btn-add:hover { background: #374151; }

/* Grille bureaux */
.r-bureaux-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
}
.r-bureau-card {
    border: 1px solid #e5e7eb; border-radius: 10px;
    padding: 10px 8px; text-align: center; cursor: pointer;
    transition: all 0.15s; background: white;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.r-bureau-card:hover { border-color: #2563eb; background: #eff6ff; }
.r-bureau-selected { border-color: #2563eb !important; background: #eff6ff !important; box-shadow: 0 0 0 2px rgba(37,99,235,0.15); }
.r-bureau-done { background: #f0fdf4 !important; border-color: #86efac !important; }
.r-bureau-num { font-size: 1rem; font-weight: 800; color: #111827; letter-spacing: -0.02em; }
.r-bureau-name { font-size: 0.62rem; color: #9ca3af; font-weight: 500; }
.r-bureau-status { font-size: 0.7rem; font-weight: 700; }
.r-bureau-status.done { color: #16a34a; }
.r-bureau-status.partial { color: #f59e0b; }
.r-bureau-status.empty { color: #d1d5db; }

/* Formulaire saisie */
.r-saisie-form { display: flex; flex-direction: column; gap: 20px; }
.r-saisie-section { }
.r-saisie-section-title {
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.07em; color: #9ca3af; margin-bottom: 10px;
}
.r-saisie-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; align-items: end; }
.r-saisie-field label { display: block; font-size: 0.78rem; font-weight: 500; color: #6b7280; margin-bottom: 4px; }
.r-saisie-field .r-input { width: 100%; box-sizing: border-box; }
.r-saisie-footer { display: flex; align-items: center; justify-content: space-between; padding-top: 4px; }
.r-checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 0.875rem; color: #374151; cursor: pointer; }
.r-checkbox-label input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: #2563eb; }
.r-btn-save {
    display: flex; align-items: center; gap: 7px;
    padding: 10px 20px; background: #2563eb; color: white;
    border: none; border-radius: 10px; font-size: 0.875rem;
    font-weight: 600; cursor: pointer; transition: background 0.15s;
    box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}
.r-btn-save:hover { background: #1d4ed8; }
.r-btn-reset {
    display: flex; align-items: center; gap: 7px;
    padding: 10px 18px; background: #fff; color: #dc2626;
    border: 1.5px solid #fca5a5; border-radius: 10px; font-size: 0.875rem;
    font-weight: 600; cursor: pointer; transition: all 0.15s;
}
.r-btn-reset:hover { background: #fef2f2; border-color: #dc2626; }
.r-reset-badge {
    margin-left: 10px; padding: 2px 10px; background: #fef2f2;
    color: #dc2626; border-radius: 99px; font-size: 0.75rem;
    font-weight: 700; border: 1px solid #fecaca;
}
.r-saved-badge {
    margin-left: 10px; padding: 2px 10px; background: #f0fdf4;
    color: #16a34a; border-radius: 99px; font-size: 0.75rem;
    font-weight: 700; border: 1px solid #bbf7d0;
}

/* Barres animées réordonnables */
#r-listes-container {
    display: flex;
    flex-direction: column;
}
.r-liste-row {
    transition: order 0.6s ease;
}
.r-liste-reorder {
    animation: flashRow 0.6s ease;
}
@keyframes flashRow {
    0%   { background: transparent; }
    30%  { background: #fef9c3; border-radius: 8px; }
    100% { background: transparent; }
}
.r-liste-bar-fill {
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* ── Sélecteur de tour ── */
.r-tour-selector {
    display: flex; border: 1px solid #e5e7eb; border-radius: 10px; overflow: hidden;
    background: #f9fafb;
}
.r-tour-btn {
    padding: 8px 18px; font-size: 0.83rem; font-weight: 600;
    text-decoration: none; color: #6b7280; transition: all 0.15s;
}
.r-tour-btn.active {
    background: #111827; color: white;
}
.r-tour-btn:not(.active):hover { background: #f3f4f6; color: #111827; }

/* ── Badges qualification ── */
.r-qualif-badge {
    font-size: 0.68rem; font-weight: 700; padding: 2px 8px;
    border-radius: 99px; white-space: nowrap; flex-shrink: 0;
}
.r-qualif-elu  { background: #fef9c3; color: #854d0e; border: 1px solid #fde68a; }
.r-qualif-ok   { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.r-qualif-non  { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }

.r-qualif-note {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.75rem; color: #9ca3af; margin-top: 12px;
    padding-top: 12px; border-top: 1px solid #f3f4f6;
}

/* ── Indicateur tour dans formulaire ── */
.r-tour-indicator {
    font-size: 0.82rem; color: #6b7280;
    padding: 8px 12px; background: #f9fafb;
    border-radius: 8px; border: 1px solid #f0f0f0;
}
.r-tour-indicator strong { color: #111827; }
.r-tour-indicator a { color: #2563eb; text-decoration: none; font-weight: 500; }
.r-tour-indicator a:hover { text-decoration: underline; }

/* ── Alignement label+input voix ── */
.r-saisie-field { display: flex; flex-direction: column; gap: 4px; }