:root { --th-primary: #1a3a5c; --th-accent: #e8891a; }
body { font-family: Inter, sans-serif; }
.main-sidebar { background-color: var(--th-primary) !important; }
.card { border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.btn-primary { background-color: var(--th-primary); border-color: var(--th-primary); }

/* Module Paramètres */
.rb-parametres-subnav .nav-link { border-radius: 999px; padding: .45rem .9rem; }
.rb-parametres-subnav .nav-link.active { background-color: var(--th-primary); }
.rb-module-card { transition: transform .15s ease, box-shadow .15s ease; }
.rb-module-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.12) !important; }
.rb-module-icon { width: 2.5rem; height: 2.5rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rb-page-header-actions .btn { margin-left: .35rem; margin-bottom: .35rem; }
.border-top-3 { border-top-width: 3px !important; }
.content-wrapper > .content-header { padding-bottom: 0; }

/* Menu Paramètres (navbar) */
.rb-settings-dropdown {
    min-width: 320px;
    max-width: 380px;
    max-height: 80vh;
    overflow-y: auto;
    padding-bottom: .5rem;
}
.rb-settings-item { font-size: .9rem; padding: .45rem 1rem; }
.rb-settings-item:hover { background-color: #f4f6f9; }
.rb-settings-dropdown .dropdown-header a { color: var(--th-primary); }
.th-compagnie-themed .main-sidebar { background-color: var(--rb-comp-primary, var(--th-primary)) !important; }
.th-compagnie-themed .btn-primary { background-color: var(--rb-comp-primary); border-color: var(--rb-comp-primary); }
.th-compagnie-themed .nav-sidebar .nav-link.active { background-color: var(--rb-comp-accent) !important; }

/* Cartes compagnies */
.th-compagnie-card { position: relative; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.th-compagnie-card:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,.12) !important; }
.th-compagnie-card-link { display: block; }
.th-compagnie-card-banner { height: 72px; }
.th-compagnie-card-logo-wrap { width: 72px; height: 72px; margin-top: -36px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,.1); overflow: hidden; }
.th-compagnie-card-logo { max-width: 56px; max-height: 56px; object-fit: contain; }
.th-compagnie-card-logo-placeholder { color: #6c757d; font-size: 1.5rem; }
.th-compagnie-card-swatches span { display: inline-block; width: 18px; height: 18px; border-radius: 50%; margin: 0 2px; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.1); }
.th-compagnie-card-edit { position: absolute; top: 8px; right: 8px; z-index: 2; border-radius: 50%; width: 32px; height: 32px; padding: 0; }
.th-compagnie-card-delete { position: absolute; top: 8px; right: 44px; z-index: 2; }
.th-compagnie-card-delete .btn { border-radius: 50%; width: 32px; height: 32px; padding: 0; }
.th-compagnie-card-create { position: absolute; top: 8px; right: 44px; z-index: 2; }
.th-compagnie-card-create .btn { border-radius: 50%; width: 32px; height: 32px; padding: 0; }
.th-compagnie-card-add { cursor: pointer; border: 2px dashed #dee2e6 !important; background: #fafbfc; }
.th-compagnie-card-add:hover { border-color: var(--th-primary) !important; background: #fff; }

.th-param-entity-card { position: relative; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.th-param-entity-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,.1) !important; }
.th-entity-sidebar .nav-link.disabled { cursor: default; opacity: .55; pointer-events: none; }
.th-entity-sidebar .brand-link { border-bottom: 1px solid rgba(255,255,255,.08); }
.card.border-dashed { border: 2px dashed #dee2e6 !important; background: #fafbfc; }
.th-compagnie-logo-lg { max-height: 64px; max-width: 120px; object-fit: contain; }
.th-compagnie-logo-placeholder-lg { width: 64px; height: 64px; border-radius: 8px; background: #f4f6f9; display: flex; align-items: center; justify-content: center; color: #6c757d; }
.th-theme-preview { min-height: 120px; border: 2px solid rgba(255,255,255,.3); }
.th-theme-preview-logo { max-height: 48px; max-width: 100px; object-fit: contain; }

/* Modale compagnie — footer toujours visible */
.th-compagnie-modal-content { max-height: calc(100vh - 2rem); display: flex; flex-direction: column; }
.th-compagnie-modal-content form { display: flex; flex-direction: column; max-height: calc(100vh - 2rem); min-height: 0; }
.th-compagnie-modal-content .modal-body { overflow-y: auto; flex: 1 1 auto; min-height: 120px; max-height: calc(100vh - 12rem); }
.th-compagnie-modal-content .modal-footer { flex-shrink: 0; display: flex !important; visibility: visible !important; border-top: 1px solid #dee2e6; padding: 0.75rem 1rem; background: #f8f9fa; }

/* Espace compagnie — menu paramètres (engrenage) */
.th-settings-dropdown { min-width: 340px; max-width: 420px; max-height: 85vh; overflow-y: auto; }
.th-settings-mega { font-size: .875rem; }
.th-settings-link { display: block; padding: .15rem 0; border-radius: 4px; }
.th-settings-link:hover { color: var(--rb-comp-primary, var(--th-primary)) !important; text-decoration: none; }
.th-settings-row .btn-xs { font-size: .7rem; line-height: 1.4; }
.th-btn-compagnie { background-color: var(--rb-comp-primary, var(--th-primary)); border-color: var(--rb-comp-primary, var(--th-primary)); }
.th-compagnie-sidebar .brand-text-wrap { max-width: calc(100% - 48px); }

/* Tableau de bord décisionnel compagnie */
.th-dash-hero { overflow: hidden; position: relative; }
.th-dash-hero-inner { position: relative; z-index: 1; }
.th-dash-hero-logo { width: 72px; height: 72px; object-fit: contain; background: rgba(255,255,255,.95); border-radius: 12px; padding: 8px; }
.th-dash-hero-logo-placeholder { width: 72px; height: 72px; border-radius: 12px; background: rgba(255,255,255,.2); display: flex; align-items: center; justify-content: center; color: #fff; }
.letter-spacing { letter-spacing: .08em; }

.th-kpi-card { display: flex; align-items: flex-start; gap: 1rem; padding: 1.25rem; border-radius: 12px; background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.06); border-left: 4px solid #dee2e6; transition: transform .15s, box-shadow .15s; }
.th-kpi-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,.1); }
.th-kpi-primary { border-left-color: var(--rb-comp-primary, #1a3a5c); }
.th-kpi-success { border-left-color: #28a745; }
.th-kpi-warning { border-left-color: #ffc107; }
.th-kpi-info { border-left-color: #17a2b8; }
.th-kpi-icon { width: 48px; height: 48px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; flex-shrink: 0; background: #f4f6f9; color: var(--rb-comp-primary, #1a3a5c); }
.th-kpi-success .th-kpi-icon { color: #28a745; background: #e8f5e9; }
.th-kpi-warning .th-kpi-icon { color: #856404; background: #fff8e1; }
.th-kpi-info .th-kpi-icon { color: #17a2b8; background: #e3f2fd; }
.th-kpi-body { display: flex; flex-direction: column; min-width: 0; }
.th-kpi-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: #6c757d; font-weight: 600; }
.th-kpi-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; color: #212529; }
.th-kpi-sub { margin-top: .25rem; }

.th-structure-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; }
.th-structure-item { display: flex; flex-direction: column; align-items: center; padding: 1rem .5rem; border-radius: 10px; background: #f8f9fa; color: #212529; transition: background .15s, transform .15s; }
.th-structure-item:hover { background: #e9ecef; transform: translateY(-2px); color: var(--rb-comp-primary, var(--th-primary)); }
.th-structure-icon { font-size: 1.25rem; margin-bottom: .35rem; opacity: .7; }
.th-structure-val { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.th-structure-label { font-size: .75rem; color: #6c757d; text-transform: uppercase; letter-spacing: .03em; }

.th-alert-card { border-radius: 10px; }

/* Tableaux de bord entité (zone / agence / gare) */
.th-entity-dash-hero { background: linear-gradient(135deg, var(--rb-comp-primary, #1a3a5c) 0%, var(--rb-comp-secondary, #0369a1) 100%); }
.th-entity-dash-agence { background: linear-gradient(135deg, #0d9488 0%, var(--rb-comp-primary, #1a3a5c) 100%); }
.th-entity-dash-gare { background: linear-gradient(135deg, #059669 0%, #047857 100%); }
.th-entity-dash-icon { width: 64px; height: 64px; border-radius: 14px; background: rgba(255,255,255,.15); display: flex; align-items: center; justify-content: center; color: #fff; }

.th-health-ring {
    width: 120px; height: 120px; border-radius: 50%;
    background: conic-gradient(#28a745 calc(var(--th-health-pct) * 1%), #e9ecef 0);
    display: flex; align-items: center; justify-content: center; position: relative;
}
.th-health-ring::before {
    content: ''; position: absolute; inset: 10px; border-radius: 50%; background: #fff;
}
.th-health-score {
    position: relative; z-index: 1; font-size: 1.5rem; font-weight: 700; color: #212529;
}
.th-structure-grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (min-width: 768px) {
    .th-structure-grid-4 { grid-template-columns: repeat(4, 1fr); }
}

.th-parametres-modal-content .modal-body { overflow-y: auto; max-height: calc(100vh - 12rem); }
.th-parametres-modal-content .rb-geo-secteur-field { min-height: 48px; font-size: 1rem; }
.th-parametres-modal-content .rb-geo-secteur-wrap { margin-bottom: 1rem; }
.th-parametres-modal-content .modal-footer { flex-shrink: 0; display: flex !important; border-top: 1px solid #dee2e6; background: #f8f9fa; }
.rb-module-create { position: absolute; top: 8px; right: 8px; z-index: 2; width: 28px; height: 28px; padding: 0; display: flex; align-items: center; justify-content: center; border-radius: 50%; }

/* Combobox commune / localité (escales) */
.rb-combobox { position: relative; }
.rb-combobox-list {
    display: none !important;
    position: absolute;
    z-index: 1060;
    left: 0;
    right: 0;
    top: 100%;
    max-height: 220px;
    margin: 2px 0 0;
    padding: .25rem 0;
    overflow-y: auto;
    overflow-x: hidden;
    list-style: none;
    background: #fff;
    border: 1px solid #ced4da;
    border-radius: .25rem;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .12);
}
.rb-combobox-list[hidden] { display: none !important; }
.rb-combobox.is-open .rb-combobox-list:not([hidden]) { display: block !important; }
.rb-combobox-item {
    padding: .45rem .75rem;
    cursor: pointer;
    font-size: .925rem;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rb-combobox-item:hover,
.rb-combobox-item.is-active {
    background: var(--th-primary, #1a3a5c);
    color: #fff;
}

