:root {
    --navy: #2d5577;
    --navy-deep: #23455f;
    --teal: #419aa5;
    --teal-dark: #337f89;
    --ice: #eef5f7;
    --surface: #ffffff;
    --surface-soft: #f7fafb;
    --text: #243746;
    --muted: #6d7f8c;
    --border: #dbe6ea;
    --danger: #b84242;
    --danger-bg: #fff0f0;
    --success: #2d7b5e;
    --success-bg: #edf8f3;
    --warning: #9a6a1a;
    --warning-bg: #fff8e8;
    --info: #2d6d85;
    --info-bg: #edf7fb;
    --shadow: 0 12px 32px rgba(33, 67, 89, .09);
    --radius: 14px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--ice); }
body {
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    color: var(--text);
    background: linear-gradient(180deg, #f8fbfc 0, #eef5f7 100%);
    font-family: Inter, Avenir, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.45;
}
a { color: var(--navy); }
a:hover { color: var(--teal-dark); }
button, input, select { font: inherit; }

.site-header {
    background: rgba(255,255,255,.98);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}
.site-header-inner, .app-nav-inner, .main-container, .site-footer > div {
    width: min(1240px, calc(100% - 40px));
    margin: 0 auto;
}
.site-header-inner {
    min-height: 82px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: var(--navy-deep);
}
.brand img { width: 58px; height: 58px; object-fit: contain; }
.brand span { display: flex; flex-direction: column; line-height: 1.05; }
.brand strong { font-size: 21px; letter-spacing: .01em; }
.brand small { margin-top: 6px; color: var(--teal-dark); font-weight: 700; letter-spacing: .09em; text-transform: uppercase; font-size: 10px; }
.header-user { display: flex; align-items: center; gap: 10px; }
.user-summary { display: flex; flex-direction: column; text-align: right; margin-right: 6px; }
.user-summary strong { font-size: 14px; }
.user-summary span { color: var(--muted); font-size: 12px; }

.app-nav { background: var(--navy); }
.app-nav-inner { display: flex; gap: 2px; overflow-x: auto; }
.app-nav a { color: #fff; text-decoration: none; padding: 12px 16px; font-size: 14px; font-weight: 650; white-space: nowrap; border-bottom: 3px solid transparent; }
.app-nav a:hover { background: rgba(255,255,255,.08); border-bottom-color: var(--teal); }

.main-container { flex: 1; padding: 34px 0 56px; }
.public-container { width: min(560px, calc(100% - 32px)); display: flex; align-items: center; justify-content: center; }
.page-heading { margin-bottom: 24px; }
.page-heading h1 { margin: 4px 0 8px; color: var(--navy-deep); font-size: clamp(27px, 3vw, 38px); letter-spacing: -.025em; }
.page-heading p { margin: 0; color: var(--muted); max-width: 820px; }
.centered { text-align: center; }
.centered p { margin-inline: auto; }
.split-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.eyebrow { color: var(--teal-dark); text-transform: uppercase; font-size: 12px; font-weight: 800; letter-spacing: .11em; }

.panel, .auth-card, .role-card, .stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.panel { padding: 24px; margin-bottom: 24px; }
.panel h2 { margin: 0 0 16px; color: var(--navy-deep); font-size: 20px; }
.panel-head { display: flex; justify-content: space-between; gap: 20px; align-items: start; margin-bottom: 18px; }
.panel-head h2 { margin-bottom: 4px; }
.panel-head p { margin: 0; color: var(--muted); }
.narrow-panel { max-width: 680px; }

.auth-card { width: 100%; padding: 38px; text-align: center; border-top: 5px solid var(--teal); }
.auth-card h1 { color: var(--navy-deep); margin: 8px 0; }
.auth-icon { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 12px; background: var(--ice); color: var(--teal-dark); font-weight: 900; font-size: 13px; letter-spacing: .08em; }
.auth-link { margin: 20px 0 0; font-size: 14px; }

.role-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(250px,1fr)); gap: 20px; }
.role-card { padding: 28px; text-align: center; }
.role-card h2 { color: var(--navy-deep); margin: 10px 0 6px; }
.role-card p { color: var(--muted); min-height: 64px; }
.role-symbol { width: 54px; height: 54px; margin: auto; display: grid; place-items: center; border-radius: 50%; background: var(--ice); color: var(--teal-dark); font-size: 20px; font-weight: 900; }

.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { padding: 20px; border-left: 4px solid var(--teal); }
.stat-card span { color: var(--muted); font-size: 13px; font-weight: 650; }
.stat-card strong { display: block; font-size: 32px; color: var(--navy-deep); margin-top: 5px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }

.stack-form { display: grid; gap: 16px; }
.grid-form { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
.grid-form .wide { grid-column: span 2; }
label > span, fieldset legend { display: block; margin-bottom: 7px; color: var(--navy-deep); font-size: 13px; font-weight: 750; }
input[type="text"], input[type="email"], input[type="password"], input[type="file"], select {
    width: 100%;
    min-height: 43px;
    border: 1px solid #cbd9df;
    border-radius: 9px;
    background: #fff;
    color: var(--text);
    padding: 10px 12px;
    outline: none;
}
input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(65,154,165,.13); }
input[type="checkbox"] { accent-color: var(--teal); }
label small, .form-help { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.role-checkboxes, .check-panel { border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.role-checkboxes { display: flex; flex-wrap: wrap; gap: 16px; }
.role-checkboxes legend { padding: 0 6px; }
.role-checkboxes label { white-space: nowrap; font-size: 14px; }
.check-row { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); padding: 10px 4px; }
.check-row:last-child { border-bottom: 0; }
.check-row span { margin: 0; color: var(--text); font-weight: 600; }
.check-row small { display: block; }
.assignment-list { max-width: 760px; }
.filter-row { display: flex; align-items: end; gap: 12px; margin-bottom: 22px; }
.filter-row label { flex: 1; max-width: 520px; }
.upload-row { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 18px; }
.file-field { min-width: 0; }
.compact-form { display: grid; gap: 8px; }
.compact-checks { display: flex; flex-wrap: wrap; gap: 8px 12px; font-size: 12px; }
.inline-form { display: inline-flex; margin: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; border: 1px solid transparent; border-radius: 9px; padding: 9px 15px; font-weight: 750; font-size: 14px; text-decoration: none; cursor: pointer; transition: transform .12s ease, background .12s ease, border-color .12s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); color: #fff; }
.btn-secondary { background: var(--navy); color: #fff; }
.btn-secondary:hover { background: var(--navy-deep); color: #fff; }
.btn-ghost { border-color: rgba(45,85,119,.18); color: var(--navy); background: #fff; }
.btn-ghost:hover { background: var(--ice); }
.btn-ghost-dark { border-color: var(--border); color: var(--navy); background: var(--surface-soft); }
.btn-ghost-dark:hover { background: var(--ice); }
.btn-small { min-height: 32px; padding: 6px 10px; font-size: 12px; }
.btn-large { min-height: 48px; }

.alert { padding: 13px 15px; border-radius: 10px; margin: 0 0 18px; border: 1px solid transparent; font-size: 14px; }
.alert-danger { background: var(--danger-bg); border-color: #f0c8c8; color: #8f3030; }
.alert-success { background: var(--success-bg); border-color: #c6e5d6; color: #25684f; }
.alert-warning { background: var(--warning-bg); border-color: #ead8aa; color: #7d5817; }
.alert-info { background: var(--info-bg); border-color: #c7e4ef; color: #285f73; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 11px; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; font-size: 13px; }
th { background: #f1f7f8; color: var(--navy-deep); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdfe; }
.actions { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.empty { text-align: center; color: var(--muted); padding: 30px; }

.badge { display: inline-flex; align-items: center; padding: 5px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.badge-waiting { background: var(--warning-bg); color: var(--warning); }
.badge-progress { background: var(--info-bg); color: var(--info); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-muted { background: #eef1f3; color: #697780; }
.muted { color: var(--muted); }
.small { font-size: 11px; }

.check-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 24px; }
.check-item { border: 1px solid var(--border); border-radius: 10px; padding: 14px; display: grid; gap: 4px; }
.check-item span { font-size: 12px; color: var(--muted); }
.check-item strong { color: var(--navy-deep); }
.check-item em { font-style: normal; font-size: 11px; font-weight: 900; }
.ok { color: var(--success); }.ko { color: var(--danger); }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { padding: 6px 9px; border-radius: 8px; font-size: 12px; font-weight: 700; }
.tag-ok { background: var(--success-bg); color: var(--success); }.tag-ko { background: var(--danger-bg); color: var(--danger); }
hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }

.site-footer { margin-top: auto; background: var(--navy-deep); color: #d9e5eb; padding: 24px 0; font-size: 12px; text-align: center; }
.site-footer strong { color: #fff; }.site-footer span { color: #bfcfd8; }

@media (max-width: 900px) {
    .stats-grid { grid-template-columns: repeat(2,1fr); }
    .two-col { grid-template-columns: 1fr; }
    .grid-form { grid-template-columns: repeat(2,1fr); }
    .check-grid { grid-template-columns: repeat(2,1fr); }
    .header-user .user-summary { display: none; }
}
@media (max-width: 620px) {
    .site-header-inner, .app-nav-inner, .main-container, .site-footer > div { width: min(100% - 24px, 1240px); }
    .site-header-inner { min-height: 70px; }
    .brand img { width: 46px; height: 46px; }
    .brand strong { font-size: 18px; }
    .header-user { gap: 5px; }
    .header-user .btn { padding: 6px 8px; }
    .main-container { padding-top: 24px; }
    .panel, .auth-card { padding: 18px; }
    .split-heading { align-items: stretch; flex-direction: column; }
    .stats-grid, .check-grid, .grid-form { grid-template-columns: 1fr; }
    .grid-form .wide { grid-column: auto; }
    .upload-row { grid-template-columns: 1fr; }
    .role-checkboxes { flex-direction: column; }
}

/* Facturation V1.0.3 */
.billing-card { margin-top: 22px; border: 1px solid var(--border); border-radius: 11px; overflow: hidden; }
.billing-card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; background: var(--surface-soft); }
.billing-card-head strong { display: block; color: var(--navy-deep); }
.billing-card-head span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.billing-card-head .billing-count { margin: 0; background: var(--ice); color: var(--teal-dark); border-radius: 999px; padding: 6px 10px; font-weight: 800; white-space: nowrap; }
@media (max-width: 620px) { .billing-card-head { align-items: flex-start; flex-direction: column; } }

/* ========================================================================== 
   TRANSFERT DE FICHIERS VOLUMINEUX
   ========================================================================== */
.upload-progress {
    grid-column: 1 / -1;
    width: 100%;
    box-sizing: border-box;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f7fbfc;
}
.upload-progress[hidden] { display: none !important; }
.upload-progress-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 9px;
    color: var(--navy);
    font-size: 14px;
    font-weight: 700;
}
.upload-progress-track {
    position: relative;
    width: 100%;
    height: 14px;
    overflow: hidden;
    border-radius: 999px;
    background: #dce8ec;
}
.upload-progress-bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--teal);
    transition: width .12s linear;
}
.upload-progress small {
    display: block;
    margin-top: 8px;
    color: var(--muted);
}
.upload-progress-error {
    border-color: #e2a2a2;
    background: #fff7f7;
}
.upload-progress-error .upload-progress-bar { background: #b83c3c; }
.upload-progress-error .upload-progress-head { color: #8f2525; }

/* ========================================================================== */
/* PATCH V1.0.8 - Suppression utilisateur / confirmation destructive          */
/* ========================================================================== */
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #963535; color: #fff; }

.danger-confirm-backdrop {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(18, 35, 49, .64);
    backdrop-filter: blur(2px);
}
.danger-confirm-backdrop[hidden] { display: none; }
.danger-confirm-dialog {
    width: min(520px, 100%);
    border-radius: 18px;
    background: #fff;
    border: 1px solid #eccaca;
    box-shadow: 0 24px 70px rgba(18, 35, 49, .28);
    padding: 30px;
    text-align: center;
}
.danger-confirm-icon {
    width: 86px;
    height: 86px;
    margin: 0 auto 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--danger-bg);
    color: var(--danger);
    border: 3px solid #e5a4a4;
    font-size: 58px;
    line-height: 1;
    font-weight: 900;
}
.danger-confirm-dialog h2 { margin: 0 0 12px; color: var(--navy); }
.danger-confirm-dialog p { margin: 0; color: var(--muted); line-height: 1.55; }
.danger-confirm-actions { display: flex; justify-content: center; gap: 12px; margin-top: 26px; flex-wrap: wrap; }
@media (max-width: 560px) {
    .danger-confirm-dialog { padding: 24px 18px; }
    .danger-confirm-actions .btn { flex: 1 1 100%; }
}
