/* Charte ACTEE — style inspire de chene6 decision.html */
:root {
    --bleu: #0A17A6;
    --cyan: #0DCCCC;
    --orange: #FF5400;
    --lila: #D1BFFC;
    --violet: #8b5cf6;
    --bleu-light: #1a2dbf;
    --cyan-light: #B2EDED;
    --gris-50: #f8f9fa;
    --gris-100: #f0f1f3;
    --gris-200: #e2e4e8;
    --gris-500: #6b7280;
    --gris-700: #374151;
    --gris-900: #111827;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Schibsted Grotesk', sans-serif;
    background: var(--gris-50);
    color: var(--gris-900);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---- Header ---- */
header {
    background: white;
    padding: 0.75rem 2rem;
    border-bottom: 1px solid var(--gris-200);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.title {
    font-family: 'Bitter', serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--bleu);
}

.title-sub {
    font-family: 'Bitter', serif;
    font-size: 1rem;
    font-weight: 400;
    color: var(--gris-900);
}

/* Nav tabs (style chene6) */
.nav-tabs {
    display: flex;
    gap: 0.35rem;
    background: var(--gris-50);
    padding: 0.25rem;
    border-radius: 0.5rem;
}

.nav-tab {
    padding: 0.4rem 1rem;
    border: none;
    border-radius: 0.375rem;
    font-family: 'Schibsted Grotesk', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    background: transparent;
    color: var(--gris-500);
}

.nav-tab:hover { background: var(--gris-200); color: var(--gris-900); }
.nav-tab.active { background: var(--bleu); color: white; font-weight: 600; }

/* ---- Stats bar (style chene6) ---- */
.stats-bar {
    background: white;
    border-bottom: 2px solid var(--gris-200);
    padding: 0.6rem 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    flex-wrap: wrap;
}

.stat-item {
    text-align: center;
    padding: 0.25rem 1.5rem;
}

.stat-sep {
    width: 1px;
    height: 30px;
    background: var(--gris-200);
}

.stat-value {
    font-family: 'Bitter', serif;
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-value.bleu { color: var(--bleu); }
.stat-value.orange { color: var(--orange); }
.stat-value.cyan { color: var(--cyan); }
.stat-value.violet { color: var(--violet); }

.stat-label {
    font-size: 0.65rem;
    color: var(--gris-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

/* ---- Main ---- */
main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    width: 100%;
    flex: 1;
}

/* ---- Filters (style chene6 badges) ---- */
.filters-horizontal {
    margin-bottom: 1rem;
}

.filters-row {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.filter-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gris-700);
    white-space: nowrap;
}

.filter-badges {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.filter-badge {
    display: inline-block;
    padding: 0.3rem 0.7rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid transparent;
    white-space: nowrap;
    user-select: none;
    font-family: 'Schibsted Grotesk', sans-serif;
}

.filter-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.filter-badge.selected {
    font-weight: 700;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.filter-reset-btn {
    background: none;
    border: 1px solid var(--orange);
    color: var(--orange);
    font-family: 'Schibsted Grotesk', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.3rem 0.7rem;
    border-radius: 1rem;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.filter-reset-btn:hover {
    background: var(--orange);
    color: white;
}

/* Search */
.search-row {
    display: flex;
    gap: 0.5rem;
}

.search-box {
    flex: 1;
    position: relative;
    max-width: 500px;
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gris-500);
}

.search-box input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.25rem;
    border: 1px solid var(--gris-200);
    border-radius: 0.375rem;
    font-family: 'Schibsted Grotesk', sans-serif;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
    background: white;
}

.search-box input:focus {
    border-color: var(--bleu);
    box-shadow: 0 0 0 3px rgba(10, 23, 166, 0.1);
}

/* ---- Tableau ---- */
.table-container {
    background: white;
    border-radius: 0.5rem;
    border: 1px solid var(--gris-200);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

table { width: 100%; border-collapse: collapse; }

thead th {
    background: var(--bleu);
    color: white;
    padding: 0.65rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    user-select: none;
    position: sticky;
    top: 0;
    z-index: 5;
}

th.sortable { cursor: pointer; }
th.sortable:hover { background: var(--bleu-light); }
th.sortable::after { content: " \2195"; opacity: 0.4; }
th.active-sort::after { opacity: 1; }
th.sort-asc::after { content: " \2191"; opacity: 1; }
th.sort-desc::after { content: " \2193"; opacity: 1; }

tbody tr {
    border-bottom: 1px solid var(--gris-100);
    transition: background 0.12s;
}

tbody tr:nth-child(even):not(.sub-row) { background: var(--gris-50); }
tbody tr:hover:not(.sub-row) { background: #e8fafa; }

td { padding: 0.5rem 1rem; font-size: 0.83rem; }

td:first-child {
    font-weight: 500;
    max-width: 350px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- Amount with mini bar ---- */
.amount {
    font-variant-numeric: tabular-nums;
    text-align: right;
    font-weight: 600;
    color: var(--bleu);
}

.amount-with-bar {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.amount-bar {
    width: 100%;
    height: 3px;
    background: var(--gris-100);
    border-radius: 2px;
    overflow: hidden;
}

.amount-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.4s ease;
}

/* ---- Grouped rows ---- */
.group-row.expandable {
    cursor: pointer;
}

.group-row.expandable:hover {
    background: #edf5ff !important;
}

.expand-icon {
    display: inline-block;
    font-size: 0.65rem;
    color: var(--bleu);
    transition: transform 0.2s;
    width: 12px;
}

.sub-count {
    display: inline-block;
    font-size: 0.65rem;
    color: var(--gris-500);
    font-weight: 400;
    margin-left: 0.4rem;
    background: var(--gris-100);
    padding: 0.05rem 0.4rem;
    border-radius: 0.5rem;
}

.sub-row {
    background: #f8faff !important;
    border-left: 3px solid var(--bleu);
}

.sub-row:hover {
    background: #eef2ff !important;
}

.sub-cell {
    padding-left: 2rem !important;
}

.sub-label {
    font-size: 0.75rem;
    color: var(--gris-500);
    font-weight: 400;
}

.badge-sub {
    background: var(--gris-500);
    font-size: 0.65rem;
}

.multi-download-hint {
    font-size: 0.7rem;
    color: var(--gris-500);
    font-style: italic;
}

/* ---- Referent link in table ---- */
.referent-link {
    background: none;
    border: none;
    font-family: 'Schibsted Grotesk', sans-serif;
    font-size: 0.83rem;
    color: var(--gris-900);
    cursor: pointer;
    padding: 0;
    border-bottom: 1px dashed var(--gris-200);
    transition: all 0.15s;
}

.referent-link:hover {
    color: var(--bleu);
    border-bottom-color: var(--bleu);
}

/* ---- Badges ---- */
.badge {
    display: inline-block;
    background: var(--bleu);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.45rem;
    border-radius: 1rem;
    min-width: 1.8rem;
    text-align: center;
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.75rem;
    background: var(--cyan);
    color: var(--bleu);
    border: none;
    border-radius: 0.375rem;
    font-family: 'Schibsted Grotesk', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    white-space: nowrap;
}

.btn-download:hover {
    background: #0bb8b8;
    transform: translateY(-1px);
}

.btn-download:active { transform: translateY(0); }
.btn-download.loading { opacity: 0.6; cursor: wait; }

.btn-download-sm {
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
}

/* ---- Tab 2: Suivi par equipe ---- */

/* Toolbar */
.stats-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.stats-search {
    max-width: 320px;
}

.stats-sort-toggle {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.stats-sort-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gris-700);
    white-space: nowrap;
}

/* Legend */
.stats-legend {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.7rem;
    color: var(--gris-500);
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.legend-sep {
    color: var(--gris-200);
}

/* Grid */
.team-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.team-card {
    background: white;
    border-radius: 0.5rem;
    border: 1px solid var(--gris-200);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: opacity 0.2s;
}

.team-card-dimmed {
    opacity: 0.4;
}

.team-card-header {
    padding: 0.6rem 1rem;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: opacity 0.15s;
    user-select: none;
}

.team-card-header:hover {
    opacity: 0.9;
}

.team-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.team-chevron {
    font-size: 0.7rem;
    opacity: 0.8;
}

.team-card-header h3 {
    font-family: 'Bitter', serif;
    font-size: 1rem;
    font-weight: 700;
}

.team-card-header .team-amount {
    font-family: 'Bitter', serif;
    font-size: 1rem;
    font-weight: 700;
}

.team-card-stats {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--gris-100);
    padding: 0.5rem 0;
}

.team-card-stat {
    flex: 1;
    text-align: center;
    padding: 0.2rem 0.5rem;
    border-right: 1px solid var(--gris-100);
}

.team-card-stat:last-child { border-right: none; }

.team-card-stat .val {
    font-family: 'Bitter', serif;
    font-weight: 700;
    font-size: 0.95rem;
}

.team-card-stat .lbl {
    font-size: 0.6rem;
    color: var(--gris-500);
    text-transform: uppercase;
}

.team-card-progress {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--gris-100);
}

.progress-bar {
    height: 6px;
    background: var(--gris-100);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: var(--gris-500);
    margin-top: 0.2rem;
}

/* Referent list header */
.referent-list-header {
    display: flex;
    align-items: center;
    padding: 0.3rem 0.75rem;
    background: var(--gris-50);
    border-bottom: 1px solid var(--gris-200);
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gris-500);
    gap: 0;
}

.rlh-name { width: 90px; flex-shrink: 0; }
.rlh-dossiers { width: 50px; text-align: center; flex-shrink: 0; }
.rlh-actions { width: 50px; text-align: center; flex-shrink: 0; }
.rlh-bar { flex: 1; text-align: center; }
.rlh-taux { width: 52px; text-align: center; flex-shrink: 0; }
.rlh-actions-col { width: 44px; flex-shrink: 0; }

/* Referent rows - new design */
.referent-list {
    padding: 0;
}

.referent-list-scroll {
    max-height: 280px;
    overflow-y: auto;
}

.ref-row {
    display: flex;
    align-items: center;
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid var(--gris-50);
    font-size: 0.8rem;
    transition: background 0.1s;
    gap: 0;
}

.ref-row:hover {
    background: #edf5ff;
}

.ref-row:last-child {
    border-bottom: none;
}

.ref-row-highlight {
    background: #fffbeb !important;
    border-left: 3px solid var(--orange);
}

.ref-name {
    width: 90px;
    flex-shrink: 0;
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--bleu);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    text-align: left;
    font-family: 'Schibsted Grotesk', sans-serif;
    text-decoration: none;
    border-bottom: 1px dashed transparent;
    transition: border-color 0.15s;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ref-name:hover {
    border-bottom-color: var(--bleu);
}

.ref-metric {
    width: 50px;
    text-align: center;
    flex-shrink: 0;
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    color: var(--gris-700);
}

.ref-bar-cell {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    min-width: 0;
    padding: 0 0.3rem;
}

.ref-bar-cell .referent-bar {
    flex: 1;
    height: 14px;
    background: var(--gris-100);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.ref-bar-cell .referent-bar-fill {
    height: 100%;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 4px;
    font-size: 0.55rem;
    color: white;
    font-weight: 600;
    min-width: 0;
    transition: width 0.4s ease;
}

.ref-bar-label {
    font-size: 0.6rem;
    color: var(--gris-500);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.ref-taux {
    width: 52px;
    text-align: center;
    flex-shrink: 0;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.1rem 0.3rem;
    border-radius: 0.25rem;
    font-variant-numeric: tabular-nums;
}

.ref-gen-btn {
    width: 44px;
    flex-shrink: 0;
    background: var(--cyan);
    color: var(--bleu);
    border: none;
    border-radius: 0.25rem;
    font-family: 'Schibsted Grotesk', sans-serif;
    font-size: 0.65rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.2rem 0.3rem;
    text-align: center;
    transition: background 0.15s, transform 0.1s;
    white-space: nowrap;
}

.ref-gen-btn:hover {
    background: #0bb8b8;
    transform: translateY(-1px);
}

.ref-gen-btn.loading {
    opacity: 0.6;
    cursor: wait;
}

/* ---- Error banner ---- */
.error-banner {
    background: #fef2f2;
    color: #991b1b;
    border-bottom: 2px solid #fca5a5;
    padding: 0.5rem 2rem;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
    animation: slideDown 0.3s ease;
}

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

/* ---- Table footer & Pagination ---- */
.table-footer {
    padding: 0.6rem 1rem;
    font-size: 0.75rem;
    color: var(--gris-500);
    border-top: 1px solid var(--gris-100);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-actions {
    display: flex;
    gap: 0.3rem;
    align-items: center;
}

.pagination-btn {
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--gris-200);
    border-radius: 0.25rem;
    background: white;
    font-family: 'Schibsted Grotesk', sans-serif;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--bleu);
}

.pagination-btn:hover:not(:disabled) {
    background: var(--bleu);
    color: white;
}

.pagination-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ---- Empty state ---- */
tbody td[colspan] {
    font-style: italic;
}

/* ---- Loading skeleton ---- */
.skeleton-row td {
    position: relative;
    overflow: hidden;
}

.skeleton-bar {
    height: 12px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--gris-100) 25%, var(--gris-200) 50%, var(--gris-100) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---- Footer ---- */
footer {
    text-align: center;
    padding: 1rem;
    font-size: 0.75rem;
    color: var(--gris-500);
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .stats-bar { padding: 0.5rem 1rem; }
    .stat-item { padding: 0.2rem 0.75rem; }
    .stat-value { font-size: 0.95rem; }
    main { padding: 0.75rem 1rem; }
    .team-grid { grid-template-columns: 1fr; }
    .ref-name { width: 70px; }
    .rlh-name { width: 70px; }
}

@media (max-width: 640px) {
    .stats-bar { flex-direction: column; gap: 0.25rem; }
    .stat-sep { display: none; }
    .stat-item { padding: 0.15rem 0; }
    .filters-row { flex-direction: column; align-items: flex-start; }
    .table-container { overflow-x: auto; }
    .nav-tabs { gap: 0.2rem; }
    .nav-tab { font-size: 0.75rem; padding: 0.3rem 0.6rem; }
    .footer-actions { flex-wrap: wrap; }
}
