:root {
    --bg: #f3f5f7;
    --card: #ffffff;
    --text: #1f2933;
    --muted: #65737e;
    --border: #d9e0e5;
    --primary: #1d5f8a;
    --primary-dark: #164968;
    --success-bg: #e9f7ef;
    --success-text: #246b42;
    --error-bg: #fdecec;
    --error-text: #9b2c2c;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", Arial, sans-serif; background: var(--bg); color: var(--text); }
.topbar { min-height: 72px; padding: 14px 28px; background: #fff; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 18px; }
h1 { font-size: 22px; margin: 0; }
h2 { margin: 0 0 8px; font-size: 19px; }
.version { color: var(--muted); font-size: 12px; }
.userbox { text-align: right; font-size: 13px; }
.muted { color: var(--muted); }
.no-margin { margin: 0; }
.container { max-width: 1600px; margin: 24px auto; padding: 0 20px 40px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin-bottom: 18px; box-shadow: 0 2px 8px rgba(0,0,0,.035); }
.login-card { max-width: 620px; margin: 70px auto; text-align: center; padding: 38px; }
.alert { max-width: 900px; margin: 0 auto 18px; border-radius: 8px; padding: 12px 16px; }
.alert.success { background: var(--success-bg); color: var(--success-text); }
.alert.error { background: var(--error-bg); color: var(--error-text); }
.primary-button, .secondary-button, .link-button { border: 0; border-radius: 6px; cursor: pointer; font: inherit; text-decoration: none; display: inline-block; }
.primary-button { background: var(--primary); color: #fff; padding: 10px 16px; font-weight: 600; }
.primary-button:hover { background: var(--primary-dark); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.secondary-button { background: #eef2f5; color: var(--text); padding: 8px 12px; border: 1px solid var(--border); }
.link-button { color: var(--primary); padding: 4px 0; }
.hint { font-size: 13px; color: var(--muted); margin-top: 18px; }
.section-title-row { display: flex; justify-content: space-between; align-items: start; margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(200px, .8fr) 2fr; gap: 14px; align-items: end; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
select, input { border: 1px solid #bcc7cf; border-radius: 6px; min-height: 38px; padding: 7px 9px; background: #fff; color: var(--text); font: inherit; }
.custom-dates { display: grid; grid-template-columns: 1.4fr .8fr 1.4fr .8fr; gap: 8px; }
.hidden { display: none !important; }
.actions-row { margin-top: 16px; display: flex; justify-content: flex-end; }
.progress-box { margin-top: 16px; }
.progress-head { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 13px; }
progress { width: 100%; height: 16px; }
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.stats > div { min-width: 110px; border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; background: #fafbfc; }
.stat-label { display: block; font-size: 12px; color: var(--muted); }
.stats strong { font-size: 21px; }
.filters { display: grid; grid-template-columns: 180px 230px 230px minmax(260px, 1fr); gap: 10px; margin-bottom: 14px; }
/* La zone de résultats utilise presque toute la largeur de la fenêtre,
   indépendamment de la largeur plus contenue du formulaire de recherche. */
#resultsCard {
    width: calc(100vw - 32px);
    max-width: 2200px;
    margin-left: 50%;
    transform: translateX(-50%);
}

/* Le tableau se répartit sur la largeur disponible au lieu d'imposer 1800 px.
   Les contenus longs passent à la ligne : pas d'ascenseur horizontal. */
.table-wrap {
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 62vh;
    border: 1px solid var(--border);
    border-radius: 7px;
}
table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    font-size: 12px;
}
th, td {
    padding: 7px 6px;
    border-right: 1px solid #e5eaee;
    border-bottom: 1px solid #e5eaee;
    vertical-align: top;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
    line-height: 1.25;
}
th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #eaf2f8;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

/* Répartition des 14 colonnes = 100 % */
th:nth-child(1),  td:nth-child(1)  { width: 7%; }
th:nth-child(2),  td:nth-child(2)  { width: 4%; }
th:nth-child(3),  td:nth-child(3)  { width: 5%; }
th:nth-child(4),  td:nth-child(4)  { width: 8%; }
th:nth-child(5),  td:nth-child(5)  { width: 8%; }
th:nth-child(6),  td:nth-child(6)  { width: 6%; }
th:nth-child(7),  td:nth-child(7)  { width: 6%; }
th:nth-child(8),  td:nth-child(8)  { width: 7%; }
th:nth-child(9),  td:nth-child(9)  { width: 9%; }
th:nth-child(10), td:nth-child(10) { width: 7%; }
th:nth-child(11), td:nth-child(11) { width: 8%; }
th:nth-child(12), td:nth-child(12) { width: 7%; }
th:nth-child(13), td:nth-child(13) { width: 11%; }
th:nth-child(14), td:nth-child(14) { width: 7%; }

td:nth-child(2), td:nth-child(3),
td:nth-child(8), td:nth-child(9), td:nth-child(10), td:nth-child(11) {
    text-align: center;
}
tbody tr:nth-child(even) td { background: #fbfcfd; }
.table-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; }
.pager { display: flex; align-items: center; gap: 10px; font-size: 13px; }
@media (max-width: 1050px) {
    .form-grid { grid-template-columns: 1fr 1fr; }
    .custom-dates { grid-column: 1 / -1; }
    .filters { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 650px) {
    .topbar { align-items: flex-start; padding: 14px; }
    .container { padding: 0 10px 30px; }
    #resultsCard { width: calc(100vw - 12px); }
    .form-grid, .filters, .custom-dates { grid-template-columns: 1fr; }
    .table-footer { align-items: stretch; flex-direction: column; }
    .userbox { max-width: 45%; }
}
