/* ============================================================================
   FKG GESTION — Feuille de style principale
   ============================================================================ */

:root {
    --fkg-green-950: #123722;
    --fkg-green-900: #16803c;
    --fkg-green-800: #1a8f45;
    --fkg-green-700: #1fa350;
    --fkg-green-100: #e0f5e7;
    --fkg-gold: #f0a323;
    --fkg-gold-light: #ffb946;
    --fkg-bg: #f3f5f7;
    --fkg-card: #ffffff;
    --fkg-sidebar-bg: #ffffff;
    --fkg-text: #1f2937;
    --fkg-text-muted: #6b7280;
    --fkg-text-muted-dark: #4b5563;
    --fkg-border: #e6e9ed;
    --fkg-danger: #dc2626;
    --fkg-warning: #ea580c;
    --fkg-success: #16a34a;
    --fkg-info: #2563eb;
    --fkg-purple: #7c3aed;
    --sidebar-width: 224px;
    --topbar-height: 66px;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 3px rgba(17, 24, 39, 0.07), 0 2px 6px rgba(17, 24, 39, 0.06);
    --shadow-md: 0 6px 18px rgba(17, 24, 39, 0.08);
    --shadow-lg: 0 14px 32px rgba(17, 24, 39, 0.14);
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14.5px;
    background: var(--fkg-bg);
    color: var(--fkg-text);
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

img, table { max-width: 100%; }

a { text-decoration: none; color: inherit; }
ul { list-style: none; margin: 0; padding: 0; }

/* ---------------------------------------------------------------------- */
/* Layout shell                                                           */
/* ---------------------------------------------------------------------- */

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--fkg-sidebar-bg);
    border-right: 1px solid var(--fkg-border);
    color: var(--fkg-text);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform 0.28s ease;
}

.sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 20px;
    border-bottom: 1px solid var(--fkg-border);
    flex-shrink: 0;
}

.sidebar-brand .brand-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--fkg-green-100);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--fkg-green-900);
    flex-shrink: 0;
}

.sidebar-brand .brand-text strong {
    display: block;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.2px;
    line-height: 1.2;
    color: var(--fkg-green-950);
}

.sidebar-brand .brand-text span {
    display: block;
    font-size: 10.5px;
    color: var(--fkg-text-muted);
    letter-spacing: .3px;
    text-transform: uppercase;
    font-weight: 600;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 12px;
    min-height: 0;
}

.sidebar-nav .nav-section-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: #9aa3af;
    padding: 4px 12px 8px;
    font-weight: 700;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: #263141;
    font-size: 13.8px;
    font-weight: 600;
    margin-bottom: 3px;
    transition: background 0.15s ease, color 0.15s ease;
    position: relative;
}

.sidebar-nav .nav-link:last-child { margin-bottom: 0; }

.sidebar-nav .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 16px;
    color: #6b7280;
    transition: color 0.15s ease;
}

.sidebar-nav .nav-link:hover {
    background: var(--fkg-green-100);
    color: var(--fkg-green-900);
}
.sidebar-nav .nav-link:hover i { color: var(--fkg-green-900); }

.sidebar-nav .nav-link.active {
    background: var(--fkg-green-900);
    color: #ffffff;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.sidebar-nav .nav-link.active i { color: #ffffff; }

.sidebar-nav .nav-badge {
    margin-left: auto;
    background: var(--fkg-danger);
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
}

.page-footer {
    flex-shrink: 0;
    padding: 12px 24px;
    text-align: center;
    border-top: 1px solid var(--fkg-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.page-footer .pf-help {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    color: var(--fkg-text-muted);
}
.page-footer .pf-help i {
    width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
    font-size: 10px; color: #fff; background: var(--fkg-green-900);
    display: flex; align-items: center; justify-content: center;
}
.page-footer .pf-help a { color: var(--fkg-green-700); text-decoration: none; font-weight: 600; }
.page-footer .pf-help a:hover { text-decoration: underline; }
.page-footer .pf-copy { font-size: 11px; color: #9aa3af; }

/* Bouton d'aide flottant (bas droite, sur toutes les pages) */
.help-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--fkg-green-900);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 6px 18px rgba(22,128,60,0.35);
    z-index: 1030;
    text-decoration: none;
    transition: background .15s ease, transform .15s ease;
}
.help-fab:hover { background: var(--fkg-green-800); transform: scale(1.07); color: #fff; }
@media (max-width: 991px) { .help-fab { bottom: 82px; right: 16px; width: 46px; height: 46px; font-size: 18px; } }

/* Page d'aide : bibliotheque de guides */
.help-grid { display: grid; grid-template-columns: 280px 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .help-grid { grid-template-columns: 1fr; } .help-sommaire { position: static !important; } }
.help-sommaire { position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto; }
.help-search { width: 100%; padding: 9px 12px; border: 1px solid var(--fkg-border); border-radius: 8px; font-size: 13px; margin-bottom: 10px; font-family: inherit; }
.help-search:focus { outline: none; border-color: var(--fkg-green-700); }
.help-nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--fkg-text-muted); font-weight: 700; margin: 14px 0 6px; padding: 0 8px; }
.help-nav-group:first-child { margin-top: 4px; }
.help-nav a { display: flex; align-items: center; gap: 9px; padding: 8px 8px; border-radius: 8px; font-size: 13px; color: var(--fkg-text); text-decoration: none; font-weight: 600; }
.help-nav a:hover { background: var(--fkg-bg); }
.help-nav a i { width: 16px; text-align: center; color: var(--fkg-green-700); font-size: 12px; }
.help-section h3 { font-size: 15px; color: var(--fkg-green-900); margin: 18px 0 8px; display: flex; align-items: center; gap: 8px; }
.help-section h3:first-child { margin-top: 0; }
.help-section p { font-size: 13.5px; color: var(--fkg-text); line-height: 1.65; margin: 0 0 10px; }
.help-section ul { margin: 0 0 12px; padding-left: 20px; }
.help-section li { font-size: 13.5px; color: var(--fkg-text); line-height: 1.65; margin-bottom: 5px; }
.help-tip { background: #eef6f0; border-left: 3px solid var(--fkg-green-700); border-radius: 6px; padding: 10px 14px; font-size: 13px; color: #235036; margin: 10px 0 14px; }
.help-tip i { color: var(--fkg-green-700); margin-right: 6px; }
.help-warn { background: #fdf3e3; border-left: 3px solid var(--fkg-gold); border-radius: 6px; padding: 10px 14px; font-size: 13px; color: #7a5a10; margin: 10px 0 14px; }
.help-warn i { color: var(--fkg-gold); margin-right: 6px; }
.help-role { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; margin-bottom: 10px; }
.help-role.both { background: #e0f5e7; color: #16803c; }
.help-role.owner { background: #fdeee0; color: #b8720f; }
.help-badge-icon { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; font-size: 10px; color: #fff; margin-right: 4px; vertical-align: middle; }
.help-section.help-hidden { display: none; }
.help-nav a.help-hidden { display: none; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
    z-index: 1030;
}

/* ---------------------------------------------------------------------- */
/* Main content                                                           */
/* ---------------------------------------------------------------------- */

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.28s ease;
}

.topbar {
    height: var(--topbar-height);
    background: var(--fkg-card);
    border-bottom: 1px solid var(--fkg-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 22px;
    position: sticky;
    top: 0;
    z-index: 1020;
    gap: 16px;
}

.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1; }
.topbar-left > div { min-width: 0; }

.sidebar-toggle {
    display: flex;
    background: var(--fkg-green-100);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    color: var(--fkg-green-900);
    font-size: 15px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.sidebar-toggle:hover { background: #ccebd8; }

.page-title-wrap {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.page-title-icon {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--fkg-green-100);
    color: var(--fkg-green-900);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}

.page-title {
    font-size: 15.5px;
    font-weight: 700;
    color: var(--fkg-text);
    margin: 0;
    overflow-wrap: break-word;
}

.page-subtitle {
    font-size: 13px;
    color: var(--fkg-text-muted);
    overflow-wrap: break-word;
    margin: 2px 0 0;
}

.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.topbar-date {
    font-size: 13px;
    color: var(--fkg-text-muted);
    display: flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
    background: var(--fkg-bg);
    padding: 8px 14px;
    border-radius: 20px;
}

.icon-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--fkg-bg);
    border: 1px solid var(--fkg-border);
    color: var(--fkg-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
}
.icon-btn:hover { background: var(--fkg-green-100); color: var(--fkg-green-900); }
.icon-btn .icon-btn-badge {
    position: absolute;
    top: -3px; right: -3px;
    background: var(--fkg-danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 17px;
    height: 17px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--fkg-card);
    padding: 0 3px;
}

.notif-panel { width: 320px; max-width: 86vw; }
.notif-panel .notif-header { padding: 14px 16px; border-bottom: 1px solid var(--fkg-border); font-size: 13.5px; font-weight: 700; color: var(--fkg-green-950); }
.notif-item { display: flex; gap: 11px; padding: 12px 16px; border-bottom: 1px solid var(--fkg-border); align-items: flex-start; }
.notif-item:last-child { border-bottom: none; }
.notif-item .notif-icon { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.notif-item .notif-title { font-size: 13px; font-weight: 700; color: var(--fkg-text); margin: 0; }
.notif-item .notif-desc { font-size: 12px; color: var(--fkg-text-muted); margin: 2px 0 0; }
.notif-empty { padding: 26px 16px; text-align: center; font-size: 13px; color: var(--fkg-text-muted); }

.user-menu {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 5px 12px 5px 5px;
    border-radius: var(--radius-sm);
    background: var(--fkg-bg);
    cursor: pointer;
    border: 1px solid var(--fkg-border);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--fkg-green-900);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.user-meta { display: flex; flex-direction: column; gap: 3px; }
.user-meta strong { display: block; font-size: 12.5px; line-height: 1; color: var(--fkg-text); }
.user-meta span { font-size: 11.5px; color: var(--fkg-text-muted); }

.role-badge {
    display: inline-block;
    width: fit-content;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .2px;
    padding: 1.5px 7px;
    border-radius: 5px;
    line-height: 1.5;
}
.role-badge.proprietaire { background: #fdecc8; color: #92620a; }
.role-badge.gerant { background: #dcf5e3; color: #157a3d; }

.content-area {
    padding: 18px 20px 40px;
    flex: 1;
}

/* ---------------------------------------------------------------------- */
/* Composants                                                             */
/* ---------------------------------------------------------------------- */

.card-fkg {
    background: var(--fkg-card);
    border-radius: var(--radius);
    border: 1px solid var(--fkg-bg);
    box-shadow: var(--shadow-sm);
}

.card-fkg .card-fkg-header {
    padding: 10px 14px;
    border-bottom: 1px solid var(--fkg-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.card-fkg .card-fkg-header h2 {
    font-size: 14px;
    font-weight: 800;
    margin: 0;
    color: var(--fkg-green-950);
}

.card-fkg .card-fkg-body { padding: 13px; }

.stat-grid {
    display: grid;
    /* minmax(0,1fr) : autant de colonnes que de cartes, jamais de retour a la
       ligne sur ordinateur/portable — les cartes retrecissent plutot que de
       passer sur 2 lignes. Les media queries plus bas reprennent la main
       sur tablette/mobile avec un nombre de colonnes fixe. */
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
    min-width: 0;
}

.stat-tile {
    background: var(--fkg-card);
    border: 1px solid var(--fkg-bg);
    border-radius: var(--radius-sm);
    padding: 12px 13px;
    box-shadow: var(--shadow-sm);
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
        "icon  label"
        "value value"
        "foot  foot";
    column-gap: 9px;
    row-gap: 2px;
    position: relative;
    overflow: hidden;
    min-width: 0;
}

.stat-tile .stat-icon {
    grid-area: icon;
    align-self: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}

.stat-tile .stat-label {
    grid-area: label;
    align-self: center;
    font-size: 11.5px;
    color: var(--fkg-text-muted);
    font-weight: 600;
    line-height: 1.25;
}

.stat-tile .stat-value {
    grid-area: value;
    margin-top: 6px;
    font-size: 17.5px;
    font-weight: 800;
    color: var(--fkg-green-950);
    letter-spacing: -0.2px;
}

.stat-tile .stat-foot {
    grid-area: foot;
    margin-top: 1px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--fkg-text-muted-dark);
    display: flex;
    align-items: flex-start;
    gap: 5px;
    overflow-wrap: anywhere;
}

.stat-tile.alert { border-color: #f5c2c2; background: #fef6f6; }
.stat-tile.alert .stat-value { color: var(--fkg-danger); }

.icon-bg-green { background: #dcf5e3; color: var(--fkg-success); }
.icon-bg-gold { background: #fdecc8; color: #92620a; }
.icon-bg-orange { background: #ffe4cf; color: var(--fkg-warning); }
.icon-bg-blue { background: #dbe9fe; color: var(--fkg-info); }
.icon-bg-red { background: #fbdada; color: var(--fkg-danger); }
.icon-bg-purple { background: #e9defb; color: var(--fkg-purple); }

/* Cartes financieres a fond plein colore (dashboard) */
.finance-card {
    border-radius: var(--radius-sm);
    padding: 11px 13px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.finance-card .fc-label { font-size: 11.5px; font-weight: 700; }
.finance-card .fc-value { font-size: 16.5px; font-weight: 800; }
.finance-card .fc-trend { font-size: 11px; font-weight: 600; }
.finance-card.fc-danger { background: #fdeaea; }
.finance-card.fc-danger .fc-label, .finance-card.fc-danger .fc-trend { color: #b52424; }
.finance-card.fc-danger .fc-value { color: #9c1f1f; }
.finance-card.fc-success { background: #e3f7ea; }
.finance-card.fc-success .fc-label, .finance-card.fc-success .fc-trend { color: #157a3d; }
.finance-card.fc-success .fc-value { color: #0f6b32; }
.finance-card.fc-info { background: #e4edfe; }
.finance-card.fc-info .fc-label, .finance-card.fc-info .fc-trend { color: #1d4fb0; }
.finance-card.fc-info .fc-value { color: #174090; }

/* Grille d'actions rapides */
.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 12px;
}
.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    padding: 12px 8px;
    border-radius: var(--radius-sm);
    background: var(--fkg-card);
    border: 1px solid var(--fkg-bg);
    text-align: center;
    transition: transform .12s ease, box-shadow .12s ease;
}
.quick-action-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.quick-action-btn .qa-icon {
    width: 36px; height: 36px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.quick-action-btn span { font-size: 11.5px; font-weight: 700; color: var(--fkg-text); }

/* Panneau d'alertes */
.alert-list-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 4px;
    border-bottom: 1px solid var(--fkg-border);
}
.alert-list-item:last-child { border-bottom: none; }
.alert-list-item .ali-icon {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.alert-list-item .ali-title { font-size: 13px; font-weight: 700; color: var(--fkg-text); margin: 0; }
.alert-list-item .ali-desc { font-size: 12px; color: var(--fkg-text-muted); margin: 2px 0 0; }
.alert-list-item .ali-chevron { margin-left: auto; color: var(--fkg-border); font-size: 12px; align-self: center; }

.btn-fkg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    border: 1px solid transparent;
    cursor: pointer;
    line-height: 1.2;
    vertical-align: middle;
    transition: filter .15s ease, background .15s ease;
}
.btn-fkg:active { filter: brightness(0.96); }
.btn-fkg-primary { background: var(--fkg-green-900); color: #fff; }
.btn-fkg-primary:hover { background: var(--fkg-green-800); color: #fff; }
.btn-fkg-gold { background: var(--fkg-gold); color: #fff; }
.btn-fkg-gold:hover { background: #d88f13; }
.btn-fkg-outline { background: transparent; border-color: var(--fkg-border); color: var(--fkg-text); }
.btn-fkg-outline:hover { background: var(--fkg-bg); }
.btn-fkg-danger { background: #fbdada; color: var(--fkg-danger); }
.btn-fkg-danger:hover { background: #f5c2c2; }
.btn-fkg-sm { padding: 6px 11px; font-size: 12.5px; }

/* Boutons ronds icone-seule (actions d'en-tete de carte : ajouter, exporter, filtrer) */
.btn-fkg-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 1px solid transparent;
    font-size: 13.5px;
    cursor: pointer;
    line-height: 1;
    transition: filter .15s ease, background .15s ease;
}
.btn-fkg-icon:active { filter: brightness(0.96); }
.btn-fkg-icon.icon-primary { background: var(--fkg-green-900); color: #fff; }
.btn-fkg-icon.icon-primary:hover { background: var(--fkg-green-800); }
.btn-fkg-icon.icon-gold { background: var(--fkg-gold); color: #fff; }
.btn-fkg-icon.icon-gold:hover { background: #d88f13; }
.btn-fkg-icon.icon-outline { background: transparent; border-color: var(--fkg-border); color: var(--fkg-text-muted); }
.btn-fkg-icon.icon-outline:hover { background: var(--fkg-bg); color: var(--fkg-text); }
.btn-fkg-icon.icon-danger { background: #fbdada; color: var(--fkg-danger); }
.btn-fkg-icon.icon-danger:hover { background: #f5c2c2; }
.btn-fkg-icon.icon-pdf { background: #fde3e3; color: #c62828; }
.btn-fkg-icon.icon-pdf:hover { background: #f9c8c8; }
.btn-fkg-icon.icon-excel { background: #dcf3e3; color: #1d7a42; }
.btn-fkg-icon.icon-excel:hover { background: #c2e9d0; }
.btn-fkg-icon.icon-csv { background: #dde8f7; color: #2955a3; }
.btn-fkg-icon.icon-csv:hover { background: #c5d9f2; }
.btn-fkg-icon-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.table-fkg {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

.table-fkg thead th {
    text-align: left;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--fkg-text-muted);
    font-weight: 700;
    padding: 10px 14px;
    border-bottom: 1px solid var(--fkg-border);
    white-space: nowrap;
}

.table-fkg tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--fkg-border);
    vertical-align: middle;
}

.table-fkg tbody tr:hover { background: var(--fkg-bg); }
.table-fkg tbody tr:last-child td { border-bottom: none; }

/* Variante compacte pour les tableaux a nombreuses colonnes (ex: ventes) */
.table-fkg.table-dense { font-size: 13px; }
.table-fkg.table-dense thead th { padding: 9px 8px; font-size: 10.5px; }
.table-fkg.table-dense tbody td { padding: 9px 8px; }
.table-fkg.table-dense td.num, .table-fkg.table-dense th.num { text-align: right; white-space: nowrap; }

/* Espacement homogene entre boutons/formulaires places dans une meme cellule */
.table-fkg td > * { vertical-align: middle; }
.table-fkg td > *:not(:first-child) { margin-left: 6px; }

.badge-fkg {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 11px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}
.badge-success { background: #dcf5e3; color: var(--fkg-success); }
.badge-warning { background: #ffe4cf; color: var(--fkg-warning); }
.badge-danger { background: #fbdada; color: var(--fkg-danger); }
.badge-info { background: #dbe9fe; color: var(--fkg-info); }
.badge-muted { background: #eef0f2; color: var(--fkg-text-muted); }

.form-label-fkg {
    font-size: 13px;
    font-weight: 700;
    color: var(--fkg-text);
    margin-bottom: 6px;
    display: block;
}

.form-control-fkg, select.form-control-fkg {
    width: 100%;
    padding: 9px 12px;
    border-radius: 9px;
    border: 1px solid var(--fkg-border);
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--fkg-text);
    line-height: 1.3;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.form-control-fkg:focus {
    outline: none;
    border-color: var(--fkg-green-700);
    box-shadow: 0 0 0 3px rgba(22, 128, 60, 0.14);
}

.tabs-nav {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--fkg-border);
    margin-bottom: 18px;
    overflow-x: auto;
}
.tab-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 11px 16px;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--fkg-text-muted);
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color .15s ease, border-color .15s ease;
}
.tab-btn:hover { color: var(--fkg-green-800); }
.tab-btn.active { color: var(--fkg-green-900); border-bottom-color: var(--fkg-green-900); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.alert-fkg {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}
.alert-fkg.success { background: #e3f7ea; color: #157a3d; }
.alert-fkg.danger { background: #fdeaea; color: #b52424; }
.alert-fkg.info { background: #e4edfe; color: #1d4fb0; }
.alert-fkg.warning { background: #fff1e2; color: #ad5b0a; }

/* Toasts de notification (messages flash apres une action) — flottants,
   distincts des .alert-fkg qui restent des bandeaux d'info fixes dans la page. */
.toast-stack {
    position: fixed;
    top: calc(var(--topbar-height) + 14px);
    right: 18px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 360px;
    max-width: calc(100vw - 32px);
    pointer-events: none;
}

.toast-fkg {
    pointer-events: auto;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 11px;
    background: #fff;
    border-radius: 12px;
    border-left: 4px solid transparent;
    box-shadow: 0 12px 28px rgba(18, 55, 34, .16), 0 2px 8px rgba(18, 55, 34, .08);
    padding: 13px 34px 13px 14px;
    overflow: hidden;
    animation: toastIn .32s cubic-bezier(.34, 1.56, .64, 1);
}
.toast-fkg.toast-out { animation: toastOut .22s ease forwards; }

.toast-fkg.success { border-left-color: var(--fkg-green-700); }
.toast-fkg.danger { border-left-color: var(--fkg-danger); }
.toast-fkg.info { border-left-color: #2563eb; }
.toast-fkg.warning { border-left-color: var(--fkg-gold); }

.toast-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    margin-top: 1px;
}
.toast-fkg.success .toast-icon { background: #e3f7ea; color: #157a3d; }
.toast-fkg.danger .toast-icon { background: #fdeaea; color: #b52424; }
.toast-fkg.info .toast-icon { background: #e4edfe; color: #1d4fb0; }
.toast-fkg.warning .toast-icon { background: #fff1e2; color: #ad5b0a; }

.toast-msg {
    flex: 1;
    min-width: 0;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--fkg-text);
    line-height: 1.42;
    padding-top: 3px;
    overflow-wrap: anywhere;
}

.toast-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    color: var(--fkg-text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 11.5px;
    border-radius: 50%;
    line-height: 1;
    transition: background .15s ease, color .15s ease;
}
.toast-close:hover { background: var(--fkg-bg); color: var(--fkg-text); }

.toast-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 100%;
    background: currentColor;
    opacity: .25;
    transform-origin: left;
    animation: toastProgress 4.5s linear forwards;
}
.toast-fkg.success .toast-progress { color: var(--fkg-green-700); }
.toast-fkg.danger .toast-progress { color: var(--fkg-danger); }
.toast-fkg.info .toast-progress { color: #2563eb; }
.toast-fkg.warning .toast-progress { color: var(--fkg-gold); }

@keyframes toastIn {
    from { transform: translateX(24px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes toastOut {
    to { transform: translateX(24px); opacity: 0; }
}
@keyframes toastProgress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

@media (max-width: 576px) {
    .toast-stack { top: calc(var(--topbar-height) + 10px); right: 12px; left: 12px; width: auto; }
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--fkg-text-muted);
}
.empty-state i { font-size: 34px; margin-bottom: 12px; color: var(--fkg-border); display: block; }
.empty-state p { font-size: 14px; margin: 0; }

.objectif-bar { background: var(--fkg-border); border-radius: 6px; height: 9px; overflow: hidden; }
.objectif-bar-fill { height: 100%; border-radius: 6px; transition: width .3s ease; background: var(--fkg-text-muted); }
.objectif-bar-fill.ok { background: var(--fkg-green-700); }
.objectif-bar-fill.warn { background: var(--fkg-gold); }
.objectif-bar-fill.danger { background: var(--fkg-danger); }

.dropdown-menu-fkg {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: #fff;
    border: 1px solid var(--fkg-border);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    min-width: 190px;
    z-index: 1050;
    overflow: hidden;
}
.dropdown-menu-fkg.show { display: block; }
.dropdown-menu-fkg a:not(.notif-item) { font-size: 14px; }
.dropdown-menu-fkg a:not(.notif-item):hover { background: var(--fkg-bg); }

/* ---------------------------------------------------------------------- */
/* Modales (creation / edition)                                           */
/* ---------------------------------------------------------------------- */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.5);
    z-index: 1060;
    align-items: flex-start;
    justify-content: center;
    padding: 5vh 16px;
    overflow-y: auto;
}
.modal-overlay.open { display: flex; }

.modal-box {
    background: var(--fkg-card);
    border-radius: var(--radius);
    max-width: 620px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}
.modal-box.modal-wide { max-width: 860px; }

.modal-box-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 20px;
    border-bottom: 1px solid var(--fkg-border);
    flex-shrink: 0;
}
.modal-box-header h2 { font-size: 15.5px; font-weight: 800; margin: 0; color: var(--fkg-green-950); }

.modal-close {
    background: var(--fkg-bg);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: var(--fkg-text-muted);
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-close:hover { background: var(--fkg-border); color: var(--fkg-text); }

.modal-box-body { padding: 20px; overflow-y: auto; }

.btn-fkg-add {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    background: var(--fkg-green-900);
    color: #fff;
}
.btn-fkg-add:hover { background: var(--fkg-green-800); }

.toolbar-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }

/* ---------------------------------------------------------------------- */
/* Navigation mobile (onglets bas)                                        */
/* ---------------------------------------------------------------------- */

.mobile-tabbar {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--fkg-card);
    border-top: 1px solid var(--fkg-border);
    z-index: 1035;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 14px rgba(17,24,39,0.06);
}
.mobile-tabbar .mt-inner { display: flex; }
.mobile-tabbar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 2px;
    font-size: 10.5px;
    font-weight: 700;
    color: #9aa3af;
    border-radius: 10px;
}
.mobile-tabbar a i { font-size: 17px; }
.mobile-tabbar a.active { color: var(--fkg-green-900); }

/* ---------------------------------------------------------------------- */
/* Reduction du sidebar en version desktop (bouton hamburger)             */
/* ---------------------------------------------------------------------- */

@media (min-width: 992px) {
    .sidebar.open { transform: translateX(-100%); }
    .sidebar.open ~ .main-content { margin-left: 0; }
}

/* ---------------------------------------------------------------------- */
/* Responsive                                                             */
/* ---------------------------------------------------------------------- */

@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
        width: 268px;
    }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .sidebar-overlay.open { display: block; }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: flex; }
    .content-area { padding: 16px 14px 90px; }
    .topbar { padding: 0 14px; }
    .user-meta { display: none; }
    .mobile-tabbar { display: block; }
}

@media (max-width: 576px) {
    .page-title { font-size: 15px; }
    .page-title-icon { display: none; }
    .page-subtitle { display: none; }
    .topbar-date { display: none; }
    .card-fkg .card-fkg-body { padding: 14px; }
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-tile { padding: 13px; }
    .stat-tile .stat-value { font-size: 18px; }
}

@media (max-width: 420px) {
    .stat-grid { grid-template-columns: 1fr; }
}

/* Print (factures) */
@media print {
    .sidebar, .topbar, .mobile-tabbar, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; }
    body { background: #fff; }
}
