/* =============================================================
   ToolBox — Framework CSS Responsive Mobile-First
   ============================================================= */

/* -----------------------------------------------------------
   Variables CSS
   ----------------------------------------------------------- */
:root {
    --primary: #4361ee;
    --primary-dark: #3a56d4;
    --primary-light: #6c83f2;
    --secondary: #7209b7;
    --success: #06d6a0;
    --success-dark: #05b588;
    --warning: #ffd166;
    --warning-dark: #e6b84d;
    --danger: #ef476f;
    --danger-dark: #d93a5f;
    --info: #118ab2;
    --info-dark: #0e7a9e;
    --light: #f8f9fa;
    --dark: #212529;
    --gray: #6c757d;
    --gray-light: #dee2e6;
    --gray-lighter: #e9ecef;
    --white: #ffffff;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --border-radius: 8px;
    --border-radius-sm: 4px;
    --border-radius-lg: 12px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.08);
    --transition: all 0.2s ease;
    --sidebar-width: 260px;
    --navbar-height: 60px;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    color: var(--dark);
    background-color: var(--light);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

a:hover {
    color: var(--primary-dark);
}

img {
    max-width: 100%;
    height: auto;
}

/* -----------------------------------------------------------
   Typographie
   ----------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.5rem;
    color: var(--dark);
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

p { margin-bottom: 1rem; }

/* -----------------------------------------------------------
   Container
   ----------------------------------------------------------- */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* -----------------------------------------------------------
   Navbar
   ----------------------------------------------------------- */
.navbar {
    background: var(--white);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 1000;
    height: var(--navbar-height);
}

.navbar-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

.navbar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-brand:hover {
    color: var(--primary-dark);
}

.navbar-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 30px;
    height: 30px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.navbar-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--dark);
    transition: var(--transition);
    border-radius: 1px;
}

.navbar-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.navbar-link {
    color: var(--gray);
    font-weight: 500;
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
}

.navbar-link:hover {
    color: var(--primary);
    background: var(--light);
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: 0.5rem;
    padding-left: 1rem;
    border-left: 1px solid var(--gray-light);
}

.navbar-profile-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.navbar-avatar-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-light);
    color: var(--white);
    font-size: 0.8rem;
    font-weight: 600;
}

/* -----------------------------------------------------------
   Sidebar
   ----------------------------------------------------------- */
.layout-with-sidebar {
    display: flex;
    flex: 1;
    min-height: calc(100vh - var(--navbar-height));
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--white);
    border-right: 1px solid var(--gray-light);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: var(--navbar-height);
    height: calc(100vh - var(--navbar-height));
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--gray-light);
}

.sidebar-header h3 {
    font-size: 1rem;
    color: var(--dark);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    color: var(--gray);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
}

.sidebar-link:hover {
    color: var(--primary);
    background: var(--light);
}

.sidebar-link.active {
    color: var(--primary);
    background: rgba(67, 97, 238, 0.1);
    font-weight: 600;
}

.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--gray-light);
}

.main-content {
    flex: 1;
    padding: 1.5rem;
    min-width: 0;
}

.main-content.with-sidebar {
    padding: 1.5rem 2rem;
}

/* -----------------------------------------------------------
   Boutons
   ----------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    white-space: nowrap;
    font-family: var(--font-family);
    line-height: 1.4;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: var(--white);
}

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

.btn-success:hover {
    background: var(--success-dark);
    border-color: var(--success-dark);
    color: var(--white);
}

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

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

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

.btn-danger:hover {
    background: var(--danger-dark);
    border-color: var(--danger-dark);
    color: var(--white);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: var(--white);
}

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

.btn-outline-danger:hover {
    background: var(--danger);
    color: var(--white);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

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

.btn-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* -----------------------------------------------------------
   Cartes
   ----------------------------------------------------------- */
.card {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow);
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.card-header h2,
.card-header h3 {
    margin: 0;
}

/* -----------------------------------------------------------
   Collapse de sections (card-header cliquable)
   ----------------------------------------------------------- */
.card-header.is-collapsible {
    cursor: pointer;
    user-select: none;
}

.card-header.is-collapsible:hover {
    background: rgba(0, 0, 0, 0.025);
}

.card-collapse-btn {
    margin-left: auto;
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 0.3rem 0.35rem;
    cursor: pointer;
    color: var(--gray);
    border-radius: var(--border-radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    line-height: 1;
}

.card-collapse-btn:hover {
    background: rgba(0, 0, 0, 0.07);
    color: var(--dark);
}

.card-collapse-btn i {
    font-size: 0.85rem;
    transition: transform 0.2s ease;
    pointer-events: none;
}

.card-header--collapsed {
    border-bottom-color: transparent;
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--gray-light);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

.card-link {
    display: block;
    color: inherit;
}

.card-link:hover {
    color: inherit;
}

.card-link:hover .card {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

/* -----------------------------------------------------------
   Formulaires
   ----------------------------------------------------------- */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.375rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--dark);
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.9rem;
    font-family: var(--font-family);
    border: 2px solid var(--gray-light);
    border-radius: var(--border-radius);
    background: var(--white);
    color: var(--dark);
    transition: var(--transition);
    line-height: 1.4;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

.form-control::placeholder {
    color: var(--gray);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236c757d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

.password-wrapper {
    position: relative;
}

.password-wrapper .form-control {
    padding-right: 2.75rem;
}

.btn-toggle-password {
    position: absolute;
    right: 1px;
    top: 1px;
    bottom: 1px;
    width: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-left: 1px solid var(--gray-light);
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
    cursor: pointer;
    color: var(--gray);
    transition: color 0.2s, background-color 0.2s;
}

.btn-toggle-password:hover {
    background-color: var(--gray-lighter);
    color: var(--dark);
}

.btn-toggle-password:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.btn-toggle-password.active {
    color: var(--primary);
    background-color: rgba(67, 97, 238, 0.06);
}

.btn-toggle-password i {
    font-size: 1.1rem;
    pointer-events: none;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--gray);
    margin-top: 0.25rem;
}

.form-error {
    font-size: 0.8rem;
    color: var(--danger);
    margin-top: 0.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--primary);
}

/* -----------------------------------------------------------
   Alertes / Messages Flash
   ----------------------------------------------------------- */
.alert {
    padding: 0.875rem 1.25rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.9rem;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-success {
    background: rgba(6, 214, 160, 0.15);
    color: #047857;
    border: 1px solid rgba(6, 214, 160, 0.3);
}

.alert-danger {
    background: rgba(239, 71, 111, 0.15);
    color: #b91c4a;
    border: 1px solid rgba(239, 71, 111, 0.3);
}

.alert-warning {
    background: rgba(255, 209, 102, 0.2);
    color: #92400e;
    border: 1px solid rgba(255, 209, 102, 0.4);
}

.alert-info {
    background: rgba(17, 138, 178, 0.15);
    color: #0e7a9e;
    border: 1px solid rgba(17, 138, 178, 0.3);
}

.alert-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
    padding: 0;
    line-height: 1;
}

.alert-close:hover {
    opacity: 1;
}

/* -----------------------------------------------------------
   Badges
   ----------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 20px;
    white-space: nowrap;
}

.badge-primary {
    background: rgba(67, 97, 238, 0.15);
    color: var(--primary);
}

.badge-secondary {
    background: var(--gray-lighter);
    color: var(--gray);
}

.badge-success {
    background: rgba(6, 214, 160, 0.15);
    color: #047857;
}

.badge-warning {
    background: rgba(255, 209, 102, 0.2);
    color: #92400e;
}

.badge-danger {
    background: rgba(239, 71, 111, 0.15);
    color: #b91c4a;
}

.badge-info {
    background: rgba(17, 138, 178, 0.15);
    color: var(--info);
}

.badge-frozen {
    background: rgba(96, 165, 250, 0.18);
    color: #1d4ed8;
}

.badge-mod {
    background: rgba(139, 92, 246, 0.15);
    color: #6d28d9;
}

/* -----------------------------------------------------------
   Gel de compte
   ----------------------------------------------------------- */
.alert-frozen {
    background: rgba(96, 165, 250, 0.12);
    border: 1px solid rgba(96, 165, 250, 0.4);
    border-left: 4px solid #3b82f6;
    color: #1d4ed8;
    border-radius: var(--border-radius);
    padding: 0.9rem 1.1rem;
    margin-bottom: 1rem;
}

.row-frozen td {
    opacity: 0.65;
}

.row-frozen td:first-child {
    border-left: 3px solid #3b82f6;
}

.row-disabled td {
    opacity: 0.7;
}

.row-disabled td:first-child {
    border-left: 3px solid var(--danger);
}

.btn-freeze {
    background: rgba(96, 165, 250, 0.15);
    color: #1d4ed8;
    border: 1px solid rgba(96, 165, 250, 0.4);
    border-radius: var(--border-radius);
    padding: 0.35rem 0.75rem;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-freeze:hover {
    background: rgba(96, 165, 250, 0.28);
}

.navbar-link-mod {
    color: #6d28d9 !important;
}

/* -----------------------------------------------------------
   Tableaux
   ----------------------------------------------------------- */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--border-radius);
}

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

.table th,
.table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-light);
}

.table th {
    font-weight: 600;
    color: var(--gray);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--light);
}

.table tbody tr:hover {
    background: rgba(67, 97, 238, 0.02);
}

.table td .btn-group {
    justify-content: flex-end;
}

/* -----------------------------------------------------------
   Grille de statistiques
   ----------------------------------------------------------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    text-align: center;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--gray);
    margin-top: 0.25rem;
}

/* -----------------------------------------------------------
   Pages
   ----------------------------------------------------------- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--gray-light);
}

.page-header h1 {
    margin: 0;
}

.page-description {
    color: var(--gray);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* -----------------------------------------------------------
   Page d'erreur
   ----------------------------------------------------------- */
.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
    padding: 2rem;
}

.error-page h1 {
    font-size: 5rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.error-page p {
    font-size: 1.25rem;
    color: var(--gray);
    margin-bottom: 2rem;
}

/* -----------------------------------------------------------
   Page d'accueil (non connecté)
   ----------------------------------------------------------- */
.hero {
    text-align: center;
    padding: 4rem 1rem;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--dark);
}

.hero p {
    font-size: 1.1rem;
    color: var(--gray);
    max-width: 600px;
    margin: 0 auto 2rem;
}

.hero .btn-group {
    justify-content: center;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    padding: 2rem 0;
}

.feature-card {
    text-align: center;
    padding: 2rem 1.5rem;
    background: var(--white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
}

.feature-card .feature-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.feature-card h3 {
    margin-bottom: 0.5rem;
}

.feature-card p {
    color: var(--gray);
    font-size: 0.9rem;
    margin: 0;
}

/* -----------------------------------------------------------
   Auth pages
   ----------------------------------------------------------- */
.auth-container {
    max-width: 420px;
    margin: 2rem auto;
}

.auth-container .card {
    padding: 0;
}

.auth-container .card-body {
    padding: 2rem;
}

.auth-container h2 {
    text-align: center;
    margin-bottom: 1.5rem;
}

/* -----------------------------------------------------------
   Profil
   ----------------------------------------------------------- */
.profile-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--gray-lighter);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: var(--gray);
    flex-shrink: 0;
}

.profile-info h2 {
    margin-bottom: 0.25rem;
}

.profile-info .profile-role {
    color: var(--gray);
    font-size: 0.9rem;
}

/* -----------------------------------------------------------
   Empty state
   ----------------------------------------------------------- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    margin-bottom: 1.5rem;
}

/* -----------------------------------------------------------
   Footer
   ----------------------------------------------------------- */
.footer {
    margin-top: auto;
    padding: 1.5rem 0;
    text-align: center;
    color: var(--gray);
    font-size: 0.85rem;
    border-top: 1px solid var(--gray-light);
    background: var(--white);
}

/* -----------------------------------------------------------
   Pagination
   ----------------------------------------------------------- */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.5rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid var(--gray-light);
    color: var(--gray);
    background: var(--white);
}

.pagination a:hover {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.pagination .active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* -----------------------------------------------------------
   Modal de confirmation
   ----------------------------------------------------------- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    max-width: 450px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal h3 {
    margin-bottom: 1rem;
}

.modal p {
    color: var(--gray);
    margin-bottom: 1.5rem;
}

.modal .btn-group {
    justify-content: flex-end;
}

/* -----------------------------------------------------------
   Toast notifications
   ----------------------------------------------------------- */
.toast-container {
    position: fixed;
    top: calc(var(--navbar-height) + 1rem);
    right: 1rem;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.875rem 1.25rem;
    border-radius: var(--border-radius);
    background: var(--white);
    box-shadow: var(--shadow-lg);
    font-size: 0.9rem;
    animation: toastIn 0.3s ease;
    max-width: 350px;
}

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

.toast-success { border-left: 4px solid var(--success); }
.toast-danger { border-left: 4px solid var(--danger); }
.toast-info { border-left: 4px solid var(--info); }

/* -----------------------------------------------------------
   Utilitaires
   ----------------------------------------------------------- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray); }
.text-success { color: var(--success-dark); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }
.text-small { font-size: 0.85rem; }
.text-warning { color: var(--warning, #f59e0b); }
.text-nowrap { white-space: nowrap; }
.font-bold { font-weight: 600; }
.font-italic { font-style: italic; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }

/* -----------------------------------------------------------
   Comptes bancaires
   ----------------------------------------------------------- */
.account-card {
    border-left: 4px solid var(--gray-light);
    transition: var(--transition);
}

.account-card.account-positive {
    border-left-color: var(--success);
}

.account-card.account-negative {
    border-left-color: var(--danger);
}

.account-card.account-shared {
    border-left-color: var(--info);
}

.account-balance {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 0.5rem;
}

.balance-positive {
    color: var(--success-dark);
}

.balance-negative {
    color: var(--danger);
}

/* Jauge de découvert */
.overdraft-gauge {
    margin-top: 0.75rem;
}

.overdraft-gauge-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: var(--danger);
}

.overdraft-gauge-label .overdraft-icon {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.overdraft-gauge-track {
    width: 100%;
    height: 8px;
    background: var(--gray-light);
    border-radius: 999px;
    overflow: hidden;
}

.overdraft-gauge-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease;
    background: var(--warning);
}

.overdraft-gauge-fill.overdraft-critical {
    background: var(--danger);
}

.overdraft-gauge-fill.overdraft-full {
    background: var(--danger);
    animation: pulse-danger 1.2s infinite;
}

@keyframes pulse-danger {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.55; }
}

.account-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

@media (max-width: 992px) {
    .account-detail-grid {
        grid-template-columns: 1fr;
    }
}

/* -----------------------------------------------------------
   Responsive - Tablette
   ----------------------------------------------------------- */
@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: var(--navbar-height);
        height: calc(100vh - var(--navbar-height));
        z-index: 1500;
        transition: left 0.3s ease;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        left: 0;
    }

    .main-content.with-sidebar {
        padding: 1.25rem;
        margin-left: 0;
    }

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

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

/* -----------------------------------------------------------
   Responsive - Mobile
   ----------------------------------------------------------- */
@media (max-width: 768px) {
    html {
        font-size: 15px;
    }

    .navbar-toggle {
        display: flex;
    }

    .navbar-menu {
        display: none;
        position: absolute;
        top: var(--navbar-height);
        left: 0;
        right: 0;
        background: var(--white);
        flex-direction: column;
        padding: 1rem;
        box-shadow: var(--shadow);
        gap: 0.5rem;
        z-index: 999;
        max-height: calc(100vh - var(--navbar-height));
        overflow-y: auto;
    }

    .navbar-menu.open {
        display: flex;
    }

    .navbar-user {
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        padding-top: 0.5rem;
        border-top: 1px solid var(--gray-light);
        width: 100%;
        justify-content: space-between;
    }

    .navbar-link {
        width: 100%;
        padding: 0.5rem;
    }

    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }

    .hero h1 { font-size: 1.75rem; }
    .hero { padding: 2.5rem 1rem; }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

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

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

    .table th,
    .table td {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    .profile-header {
        flex-direction: column;
        text-align: center;
    }

    .stat-card .stat-value {
        font-size: 1.5rem;
    }

    .btn-group {
        width: 100%;
    }

    /* Comptes : masquer total entrées / dépenses */
    .stat-hide-mobile { display: none; }

    /* Table prélèvements planifiés : masquer Motif (col 3) */
    #upcoming-debits-table th:nth-child(3),
    #upcoming-debits-table td:nth-child(3) { display: none; }

    /* Table mandats à venir : masquer Descriptif (col 5) */
    #upcoming-mandates-table th:nth-child(5),
    #upcoming-mandates-table td:nth-child(5) { display: none; }

    /* Virements permanents : masquer Intervalle (col 5) et Motif (col 7) */
    #recurring-transfers-table th:nth-child(5),
    #recurring-transfers-table td:nth-child(5),
    #recurring-transfers-table th:nth-child(7),
    #recurring-transfers-table td:nth-child(7) { display: none; }
}

/* -----------------------------------------------------------
   Responsive - Petit mobile
   ----------------------------------------------------------- */
@media (max-width: 480px) {
    .container {
        padding: 0 0.75rem;
    }

    .main-content {
        padding: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

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

    .toast {
        max-width: calc(100vw - 2rem);
    }

    /* Mandats à venir : masquer Contrepartie (col 4) sur très petit écran */
    #upcoming-mandates-table th:nth-child(4),
    #upcoming-mandates-table td:nth-child(4) { display: none; }
}

/* -----------------------------------------------------------
   Tables opérations — layout carte sur mobile (≤ 600px)
   ----------------------------------------------------------- */
@media (max-width: 600px) {

    /* Barre de filtres : 2 colonnes */
    #tx-filter-bar {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem !important;
        align-items: end;
    }
    #tx-filter-bar > .form-group {
        min-width: 0 !important;
    }
    #tx-filter-bar > div:last-child { /* compteur */
        grid-column: 1 / -1;
        margin-left: 0 !important;
    }

    /* Cacher le <thead> */
    #tx-table thead,
    #pending-tx-table thead { display: none; }

    /* Chaque ligne = carte */
    #tx-table tbody tr,
    #pending-tx-table tbody tr {
        display: grid;
        grid-template-columns: 1fr auto;
        padding: 0.65rem 0.5rem;
        gap: 0.15rem 0.5rem;
        border-bottom: 1px solid var(--gray-light);
        border-radius: 0;
    }

    #tx-table tbody tr:last-child,
    #pending-tx-table tbody tr:last-child { border-bottom: none; }

    #tx-table td,
    #pending-tx-table td {
        padding: 0;
        border: none;
        font-size: 0.85rem;
    }

    /* Ligne 1 gauche : Type (badge) */
    #tx-table td:nth-child(2),
    #pending-tx-table td:nth-child(2) {
        grid-column: 1; grid-row: 1;
        align-self: center;
    }

    /* Ligne 1 droite : Montant */
    #tx-table td:nth-child(6),
    #pending-tx-table td:nth-child(6) {
        grid-column: 2; grid-row: 1;
        text-align: right;
        font-size: 1rem;
        align-self: center;
    }

    /* Ligne 2 : Date (pleine largeur, discrète) */
    #tx-table td:nth-child(1),
    #pending-tx-table td:nth-child(1) {
        display: block;
        grid-column: 1 / -1; grid-row: 2;
        font-size: 0.73rem;
        color: var(--gray);
        margin-top: 0.1rem;
    }

    /* Ligne 3 gauche : Catégorie */
    #tx-table td:nth-child(3),
    #pending-tx-table td:nth-child(3) {
        display: block;
        grid-column: 1; grid-row: 3;
        font-size: 0.78rem;
        color: var(--gray);
    }

    /* Ligne 3 droite : Commentaire (italique) */
    #tx-table td:nth-child(5),
    #pending-tx-table td:nth-child(5) {
        display: block;
        grid-column: 2; grid-row: 3;
        font-size: 0.78rem;
        color: var(--gray);
        font-style: italic;
        text-align: right;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 140px;
    }

    /* Ligne 4 gauche : Par (auteur) */
    #tx-table td:nth-child(4),
    #pending-tx-table td:nth-child(4) {
        display: block;
        grid-column: 1; grid-row: 4;
        font-size: 0.78rem;
    }

    /* Ligne 4 droite : Actions (bouton suppression) */
    #tx-table td:nth-child(7),
    #pending-tx-table td:nth-child(7) {
        grid-column: 2; grid-row: 4;
        text-align: right;
        align-self: end;
    }
}

/* =====================================================================
   NOTIFICATIONS
   ===================================================================== */

/* Cloche dans la navbar */
.navbar-notif-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .35rem .55rem;
    border-radius: 6px;
    transition: background .2s;
}
.navbar-notif-link:hover {
    background: rgba(0,0,0,.06);
}
.notif-badge {
    position: absolute;
    top: 1px;
    right: 1px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    background: var(--danger, #e53e3e);
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    line-height: 18px;
    border-radius: 9px;
    text-align: center;
    pointer-events: none;
}

/* Liste des notifications */
.notif-list {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.notif-item {
    display: flex;
    align-items: flex-start;
    gap: .85rem;
    padding: .85rem 1rem;
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 10px;
    transition: background .15s, border-color .15s;
}
.notif-item--unread {
    background: #eef4ff;
    border-color: #b3ccf8;
}
.notif-item--unread .notif-title {
    font-weight: 700;
}

.notif-icon {
    flex-shrink: 0;
    width: 2.2rem;
    height: 2.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,.05);
    border-radius: 50%;
    font-size: 1.1rem;
}

.notif-content {
    flex: 1;
    min-width: 0;
}
.notif-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .5rem;
    flex-wrap: wrap;
}
.notif-title {
    font-size: .95rem;
    color: var(--text-primary, #1a202c);
}
.notif-time {
    flex-shrink: 0;
    font-size: .78rem;
    color: var(--text-muted, #718096);
}
.notif-body {
    margin: .3rem 0 0;
    font-size: .88rem;
    color: var(--text-secondary, #4a5568);
    line-height: 1.45;
}

/* Boutons d'action d'une notification */
.notif-controls {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: .3rem;
}
.notif-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    transition: background .15s, color .15s;
    text-decoration: none;
    color: var(--text-secondary, #4a5568);
}
.notif-btn:hover {
    background: rgba(0,0,0,.08);
}
.notif-btn-read:hover   { color: var(--success, #38a169); }
.notif-btn-link:hover   { color: var(--primary, #4361ee); }
.notif-btn-delete:hover { color: var(--danger, #e53e3e); background: #fef2f2; }

/* Badge générique (utilisé dans la page) */
.badge {
    display: inline-block;
    padding: .2em .55em;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 700;
    line-height: 1;
}
.badge-primary { background: var(--primary, #4361ee); color: #fff; }

/* Responsive */
@media (max-width: 600px) {
    .notif-item {
        flex-wrap: wrap;
    }
    .notif-controls {
        width: 100%;
        justify-content: flex-end;
    }
}

/* -----------------------------------------------------------
   Pavé numérique PIN
   ----------------------------------------------------------- */
.pin-display {
    display: flex;
    justify-content: center;
    gap: 0.875rem;
    margin: 0.5rem 0 1.5rem;
}

.pin-display span {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 2px solid var(--gray);
    background: transparent;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.pin-display span.filled {
    background: var(--primary);
    border-color: var(--primary);
    transform: scale(1.15);
}

.pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    max-width: 252px;
    margin: 0 auto 1.25rem;
}

.pin-key {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 58px;
    font-size: 1.35rem;
    font-weight: 600;
    background: var(--white);
    border: 2px solid var(--gray-light);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s, box-shadow 0.15s;
    color: var(--dark);
    font-family: var(--font-family);
    user-select: none;
    -webkit-user-select: none;
    box-shadow: var(--shadow-sm);
}

.pin-key:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.pin-key:active {
    transform: translateY(0);
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: var(--white);
    box-shadow: none;
}

.pin-key-del {
    color: var(--danger);
    border-color: rgba(239, 71, 111, 0.3);
    background: rgba(239, 71, 111, 0.04);
}

.pin-key-del:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: var(--white);
}

.pin-key-del:active {
    background: var(--danger-dark);
    border-color: var(--danger-dark);
}

@media (max-width: 420px) {
    .pin-pad {
        max-width: 100%;
    }
    .pin-key {
        height: 52px;
        font-size: 1.2rem;
    }
}
