:root {
  --accent: #0d6efd;
  --accent-dark: #0047b3;
  --accent-soft: #e7f0ff;
  --ink: #182437;
  --ink-soft: #5B6B84;
  --line: #E3E7EE;
}

body {
    background: #eef2f7;
    color: var(--ink);
}

/* ------------------------------------------------------------
   En-tête
------------------------------------------------------------ */
.app-header {
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.app-header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-header-brand .coris-logo {
    display: block;
    width: 112px;
    height: auto;
    max-height: 52px;
    object-fit: contain;
    flex: 0 0 auto;
}

.app-header-brand .title {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.1;
    color: var(--ink);
}

.app-header-brand .subtitle {
    font-size: 11px;
    color: var(--ink-soft);
}

.app-search {
    flex: 1;
    max-width: 420px;
}

.app-search input {
    border-radius: 999px;
    border: 1px solid var(--line);
    padding: 8px 16px 8px 38px;
    background: #f5f6f8 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%235B6B84' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E") no-repeat 14px center;
    width: 100%;
    font-size: 13.5px;
}

.app-header-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.app-help-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink-soft);
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-avatar-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-avatar-circle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.app-avatar-name {
    font-weight: 700;
    font-size: 13.5px;
    line-height: 1.1;
    color: var(--ink);
}

.app-avatar-role {
    font-size: 11px;
    color: var(--ink-soft);
}

/* ------------------------------------------------------------
   Navigation latérale
------------------------------------------------------------ */
.app-layout { display: flex; min-height: calc(100vh - 66px); }
.app-sidebar { width: 245px; flex: 0 0 245px; background: #07549b; color: #fff; border-right: 1px solid #064780; padding: 20px 12px; }
.sidebar-caption { padding: 0 12px 12px; color: rgba(255,255,255,.68); font-size: 10px; font-weight: 800; letter-spacing: .1em; }
.app-tabs { display: flex; flex-direction: column; gap: 5px; }
.app-tab { width: 100%; border: 0; background: transparent; color: rgba(255,255,255,.88); text-align: left; font-weight: 600; font-size: 13.5px; padding: 11px 13px; border-radius: 4px; white-space: normal; }
.app-tab.active { background: #fff; color: #07549b; }
.app-content { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.app-content > .container-fluid { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#app-main { flex: 1 0 auto; }
.app-tab i { width: 22px; display: inline-block; }

.app-tab:hover:not(.active) {
    background: rgba(255,255,255,.12);
}

/* ------------------------------------------------------------
   Boutons — pilules partout
------------------------------------------------------------ */
.btn {
    border-radius: 999px !important;
}

.btn-sm {
    padding: 5px 14px !important;
}

/* ------------------------------------------------------------
   Titres de page
------------------------------------------------------------ */
.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 2px;
}

.page-subtitle {
    font-size: 13px;
    color: var(--ink-soft);
    margin: 0 0 18px;
}

/* ------------------------------------------------------------
   Barre de filtres
------------------------------------------------------------ */
.filter-bar {
    background: #f5f6f8;
    border-radius: 14px;
    padding: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 18px;
}

.filter-pill-wrap {
    position: relative;
}

.filter-pill {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-pill .badge-count {
    background: var(--accent);
    color: #fff;
    border-radius: 999px;
    font-size: 10px;
    padding: 1px 6px;
}

.filter-check-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 40;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,.1);
    min-width: 220px;
    padding: 10px;
    display: none;
}

.filter-check-menu.ouvert {
    display: block;
}

.filter-check-menu input[type="search"] {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12.5px;
    margin-bottom: 8px;
}

.filter-check-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 4px;
    font-size: 13px;
    border-radius: 6px;
}

.filter-check-item:hover {
    background: #f5f6f8;
}

/* ------------------------------------------------------------
   Tableaux — cellules à deux niveaux, en-têtes triables
------------------------------------------------------------ */
.table thead {
    background: transparent;
}

.table thead th {
    color: var(--ink-soft);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .3px;
    border-bottom: 2px solid var(--line);
    font-weight: 700;
    cursor: pointer;
    user-select: none;
}

.table thead th .tri {
    font-size: 9px;
    margin-left: 3px;
    opacity: .5;
}

.cell-main {
    font-weight: 600;
    color: var(--ink);
}

.cell-sub {
    font-size: 11.5px;
    color: var(--ink-soft);
}

.amount {
    font-weight: bold;
}

/* ------------------------------------------------------------
   Cartes KPI avec icône
------------------------------------------------------------ */
.stat-card {
    border: none;
    border-radius: 14px;
    box-shadow: 0 0 15px rgba(0,0,0,.06);
    position: relative;
    padding: 16px;
}

.stat-card .stat-icon {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}

.stat-card .stat-label {
    font-size: 12.5px;
    color: var(--ink-soft);
    margin-bottom: 4px;
}

.stat-card .stat-value {
    font-size: 26px;
    font-weight: 800;
    color: var(--ink);
}

.stat-icon.icon-amber { background: #FBEDDB; color: #C97A1E; }
.stat-icon.icon-blue { background: var(--accent-soft); color: var(--accent-dark); }
.stat-icon.icon-green { background: #E4F4F1; color: #0F8C7C; }
.stat-icon.icon-red { background: #FBE8E8; color: #C13F3F; }

/* ------------------------------------------------------------
   Bloc d'alerte (contrats en retard)
------------------------------------------------------------ */
.alert-retard {
    background: #FBE8E8;
    border-radius: 14px;
    padding: 16px 18px;
    margin-bottom: 18px;
}

.alert-retard .titre {
    font-weight: 700;
    color: #a02c2c;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.alert-retard-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border-radius: 10px;
    padding: 8px 12px;
    margin-bottom: 6px;
    font-size: 13px;
}

/* ------------------------------------------------------------
   Widgets de synthèse
------------------------------------------------------------ */
.widget-card .widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.widget-card .widget-header a {
    font-size: 12px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

/* ------------------------------------------------------------
   Badges de statut (pilules colorées)
------------------------------------------------------------ */
.badge-statut {
    font-size: 11px;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 999px;
}

/* ------------------------------------------------------------
   Divers
------------------------------------------------------------ */
.login-card {
    max-width: 380px;
    margin: 70px auto;
    border: none;
    border-radius: 18px;
    box-shadow: 0 0 25px rgba(0,0,0,.1);
}

.cursor-pointer {
    cursor: pointer;
}

#app-root {
    display: none;
}

/* Timeline de l'historique d'un contrat */
.cm-timeline {
    position: relative;
    padding-left: 4px;
    max-height: 320px;
    overflow-y: auto;
}

.cm-timeline-item {
    position: relative;
    padding-left: 26px;
    padding-bottom: 20px;
}

.cm-timeline-item:last-child {
    padding-bottom: 2px;
}

.cm-timeline-marker {
    position: absolute;
    left: 0;
    top: 3px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--dot-color, #0d6efd);
    box-shadow: 0 0 0 3px #fff, 0 0 0 4px rgba(0,0,0,.06);
    z-index: 2;
}

.cm-timeline-item::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 15px;
    bottom: -4px;
    width: 2px;
    background: var(--line);
}

.cm-timeline-item:last-child::after {
    display: none;
}

.cm-timeline-heure {
    font-size: 11px;
    font-weight: 700;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: .3px;
}

.cm-timeline-texte {
    font-size: 13.5px;
    color: var(--ink);
    margin: 2px 0 6px;
}

.cm-timeline-badge {
    font-size: 10.5px;
    font-weight: 600;
}

/* ------------------------------------------------------------
   Responsive — petits écrans
------------------------------------------------------------ */
@media (max-width: 768px) {
    .app-header { padding: 10px 14px; }
    .app-search { order: 3; max-width: 100%; flex-basis: 100%; }
    .app-avatar-name, .app-avatar-role { display: none; }
    .app-layout { display: block; }
    .app-sidebar { width: 100%; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--line); }
    .sidebar-caption { display: none; }
    .app-tabs { flex-direction: row; overflow-x: auto; }
    .app-tab { width: auto; flex: 0 0 auto; }
    .page-title { font-size: 18px; }
    .filter-bar { padding: 8px; }
}


/* Ajustements de présentation */
.app-header-brand { min-width: 0; }
.app-header-brand .coris-logo { object-position: left center; }
@media (max-width: 767.98px) {
    .app-header-brand .coris-logo { width: 88px; max-height: 42px; }
    .app-sidebar { background: #07549b; }
    .app-content > .container-fluid { padding-bottom: 12px; }
}

/* ------------------------------------------------------------
   Harmonisation visuelle — interface professionnelle
------------------------------------------------------------ */
:root {
  --accent: #07549b;
  --accent-dark: #063d72;
  --accent-soft: #e8f2fb;
  --ink: #172b42;
  --ink-soft: #68788b;
  --line: #dfe6ee;
  --surface: #ffffff;
  --surface-muted: #f5f8fb;
}
body { background: #f3f6fa; color: var(--ink); font-family: Inter, "Segoe UI", Arial, sans-serif; }
.app-layout { min-height: calc(100vh - 66px); }
.app-sidebar { background: linear-gradient(180deg, #07549b 0%, #063d72 100%); box-shadow: 4px 0 18px rgba(15, 42, 74, .08); }
.app-tab { border-radius: 7px; padding: 11px 13px; transition: background .18s ease, color .18s ease, transform .18s ease; }
.app-tab.active { box-shadow: inset 3px 0 0 #e31b3d, 0 3px 10px rgba(0,0,0,.07); }
.app-tab:hover:not(.active) { transform: translateX(2px); }
.app-content > .container-fluid { padding-top: 24px !important; padding-bottom: 24px !important; }
.page-title { font-size: clamp(1.35rem, 2vw, 1.75rem); letter-spacing: -.025em; font-weight: 750; }
.page-subtitle { color: var(--ink-soft); font-size: .92rem; margin-top: 5px; }
.card { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: 0 3px 14px rgba(20, 45, 75, .045); overflow: hidden; }
.card + .card { margin-top: 18px; }
.card-body { padding: clamp(16px, 2vw, 24px); }
.card-title, .modal-title { color: var(--ink); font-weight: 700; letter-spacing: -.01em; }
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table thead th { background: #f4f7fb; color: #52657a; font-size: .76rem; text-transform: uppercase; letter-spacing: .045em; font-weight: 750; border-bottom: 1px solid var(--line); padding: 13px 12px; white-space: nowrap; }
.table tbody td { padding: 12px; border-color: #edf1f5; font-size: .88rem; vertical-align: middle; }
.table tbody tr:hover { --bs-table-bg: #f8fbfe; }
.form-control, .form-select { border-color: #d5dee8; border-radius: 6px !important; min-height: 40px; color: var(--ink); }
.form-control:focus, .form-select:focus { border-color: #75a9d6; box-shadow: 0 0 0 .2rem rgba(7,84,155,.12); }
.form-label { font-size: .82rem; font-weight: 650; color: #43566b; margin-bottom: 6px; }
.btn { border-radius: 6px !important; font-weight: 650; letter-spacing: .005em; padding: 8px 14px; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); box-shadow: 0 2px 5px rgba(7,84,155,.12); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-sm { border-radius: 5px !important; padding: 5px 10px !important; font-size: .78rem; }
.badge { font-weight: 650; letter-spacing: .01em; padding: .42em .7em; }
.modal-content { border: 0; border-radius: 12px; box-shadow: 0 22px 70px rgba(9, 29, 52, .25); overflow: hidden; }
.modal-header { background: #f7f9fc; border-bottom: 1px solid var(--line); padding: 18px 22px; }
.modal-body { padding: 22px; }
.alert { border-radius: 7px; }
.filter-bar { background: #fff; border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 2px 8px rgba(20,45,75,.03); }
@media (max-width: 767.98px) {
  .app-sidebar { width: 100%; flex: 0 0 100%; padding: 10px; }
  .app-layout { display: block; }
  .app-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
  .app-tab { font-size: 12px; padding: 9px; }
  .app-content > .container-fluid { padding: 16px !important; }
  .table-responsive, .card-body { max-width: 100%; }
  .modal-body { padding: 16px; }
}

/* Ajustements demandés : titres plus compacts, actions plus discrètes et cohérentes */
.page-title { font-size: clamp(1.12rem, 1.6vw, 1.42rem) !important; line-height: 1.3; }
.page-heading { margin-bottom: 1.15rem !important; }
.page-actions { margin-left: auto; }
.btn-action-page { min-height: 38px; padding: 8px 13px !important; }

/* Actions sur les utilisateurs : palette sémantique, format compact */
button[data-modifier] { color: #07549b; background: #e8f2fb; border: 1px solid #c9e0f4; }
button[data-modifier]:hover { color: #fff; background: #07549b; border-color: #07549b; }
button[data-desactiver] { color: #b42332; background: #fff0f1; border: 1px solid #f5c7cc; }
button[data-desactiver]:hover { color: #fff; background: #b42332; border-color: #b42332; }
button[data-reactiver] { color: #16794b; background: #eaf7ef; border: 1px solid #bfe6ce; }
button[data-reactiver]:hover { color: #fff; background: #16794b; border-color: #16794b; }
button[data-reset-mdp] { color: #8a5a00; background: #fff6dc; border: 1px solid #f1dda1; }
button[data-reset-mdp]:hover { color: #493000; background: #ffe8a3; border-color: #e6c76a; }
td button[data-modifier], td button[data-desactiver], td button[data-reactiver], td button[data-reset-mdp] {
  min-height: 28px; padding: 3px 7px !important; font-size: .70rem !important; line-height: 1.25; border-radius: 4px !important;
}
td button[data-modifier] { width: 29px; padding: 3px !important; }
.page-actions .btn { white-space: nowrap; }
@media (max-width: 767.98px) {
  .page-actions { width: 100%; margin-left: 0; }
  .page-actions > div, .page-actions > button { flex: 1 1 auto; }
  .page-actions > div button { width: 100%; }
}


/* ------------------------------------------------------------
   Coquille à hauteur d'écran : entête, menu latéral, titre, filtres et
   pagination restent figés ; seule la zone du tableau (.zone-defilement)
   défile, avec son en-tête de colonnes collant.
   (Sur mobile, le défilement redevient normal : voir plus bas.)
------------------------------------------------------------ */
#app-root { flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.app-header { flex: 0 0 auto; }
.app-layout { flex: 1 1 auto; min-height: 0; }
.app-content { min-width: 0; min-height: 0; }
.app-content > .container-fluid { min-height: 0; }

/* #app-main : colonne flexible. Les blocs fixes gardent leur taille ; la carte
   de liste se réduit si besoin (jamais plus haute que l'espace disponible).
   Le padding/margin négatif évite que l'ombre des cartes soit rognée. */
#app-main {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 2px 6px 12px;
    margin: 0 -6px;
}
#app-main > * { flex: 0 0 auto; }
#app-main > .card-liste { flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; }
.card-liste > .card-body { display: flex; flex-direction: column; min-height: 0; }
.card-liste .zone-defilement { flex: 0 1 auto; min-height: 0; overflow: auto; }
.card-liste .widget-header,
.card-liste #bulk-toolbar,
.card-liste #zone-pagination { flex: 0 0 auto; }

/* En-tête de colonnes qui reste visible pendant le défilement du tableau */
.zone-defilement .table thead th { position: sticky; top: 0; z-index: 2; }

/* Petites tables du tableau de bord : défilent plutôt que d'agrandir la page */
.zone-widget { max-height: max(160px, calc(100vh - 470px)); overflow: auto; }

/* Pied de page : texte en bas du menu latéral (remplace l'ancienne barre blanche) */
.app-sidebar { display: flex; flex-direction: column; overflow-y: auto; }
.sidebar-footer {
    margin-top: auto;
    padding: 14px 4px 2px;
    border-top: 1px solid rgba(255, 255, 255, .18);
    font-size: 11px;
    line-height: 1.5;
    color: rgba(255, 255, 255, .68);
}

@media (max-width: 768px) {
    #app-root { height: auto; min-height: 100vh; overflow: visible; }
    .app-layout { min-height: 0; }
    #app-main { overflow: visible; display: block; padding: 0; margin: 0; }
    #app-main > .card-liste, .card-liste > .card-body { display: block; }
    .card-liste .zone-defilement { overflow-x: auto; overflow-y: visible; }
    .zone-widget { max-height: none; }
    .sidebar-footer { display: none; }
}

/* ------------------------------------------------------------
   Modale de confirmation d'action (notification de succès)
------------------------------------------------------------ */
.modal-notification { z-index: 1065; background: rgba(9, 29, 52, .45); }
.modal-notification .modal-content { border: 0; border-radius: 16px; box-shadow: 0 18px 50px rgba(9, 29, 52, .28); }
.notif-icone {
    width: 64px; height: 64px; margin: 0 auto 14px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; background: #e6f6ee; color: #16794b; font-size: 34px;
}
.notif-titre { font-weight: 700; margin-bottom: 6px; color: var(--ink); }
.notif-message { margin-bottom: 18px; color: var(--ink-soft); }

/* ------------------------------------------------------------
   Page de connexion : logo, titre puis formulaire, empilés et centrés
------------------------------------------------------------ */
.login-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
    padding: 24px 16px;
}

.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}

.login-brand .coris-logo {
    display: block;
    width: 150px;
    height: auto;
    object-fit: contain;
}

.login-brand .title {
    font-weight: 700;
    font-size: 21px;
    line-height: 1.2;
    color: var(--ink);
}

.login-brand .subtitle {
    margin-top: 3px;
    font-size: 12.5px;
    color: var(--ink-soft);
}

.login-wrap .login-card {
    width: 100%;
    max-width: 380px;
    margin: 0;
}
