:root {
    --primary: #7a99ac;
    --primary-dark: #5c7d91;
    --primary-light: #eaf0f3;
    --ink: #1e293b;
    --ink-soft: #64748b;
    --bg: #f1f0fb;
    --card: #ffffff;
    --border: #e2e8f0;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(30,41,59,.06), 0 4px 16px rgba(30,41,59,.05);
    --shadow-hover: 0 6px 24px rgba(30,41,59,.12);

    /* Palette vive pour l'admin (dégradés) */
    --grad-violet: linear-gradient(135deg, #7c6ff0, #a78bfa);
    --grad-pink:   linear-gradient(135deg, #ec4899, #f9a8d4);
    --grad-coral:  linear-gradient(135deg, #fb7185, #fda4af);
    --grad-base:   linear-gradient(135deg, #5c7d91, #7a99ac);
    --grad-green:  linear-gradient(135deg, #22c55e, #86efac);
    --violet: #7c6ff0;
    --violet-dark: #5b4fd6;
    --admin-canvas: #e7e6f7;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
}
a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
p { margin: 0 0 1em; }
img { max-width: 100%; }

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ---------- Coque publique flottante (même esprit que l'admin) ---------- */
.public-shell { background: #fff; }
@media (min-width: 901px) {
    .public-shell {
        max-width: 1200px; margin: 22px auto; border-radius: 28px; overflow: hidden;
        box-shadow: 0 20px 60px rgba(76,60,180,.14);
    }
}

/* ---------- Topbar (public) ---------- */
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}
.topbar .container { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; color: var(--ink); }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }
.topbar nav a {
    color: var(--ink-soft); font-weight: 600; margin-left: 22px; font-size: .93rem;
}
.topbar nav a:hover { color: var(--primary-dark); text-decoration: none; }

@media (max-width: 680px) {
    .topbar .container {
        flex-direction: column; align-items: flex-start; height: auto; padding-top: 14px; padding-bottom: 14px; gap: 10px;
    }
    .brand { font-size: 1rem; }
    .topbar nav { display: flex; flex-wrap: wrap; gap: 6px 16px; }
    .topbar nav a { margin-left: 0; margin-right: 14px; font-size: .87rem; }
}

/* ---------- Hero ---------- */
.hero {
    padding: 46px 40px; text-align: center; border-radius: 24px; margin: 24px 0 8px;
    background: var(--grad-violet); color: #fff;
}
.hero h1 { font-size: clamp(1.6rem, 3.5vw, 2.4rem); color: #fff; }
.hero p { color: rgba(255,255,255,.9); font-size: 1.05rem; max-width: 640px; margin: 0 auto; }

/* ---------- Cards ---------- */
.card {
    background: var(--card);
    border: none;
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 22px;
}
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 18px;
    margin: 24px 0;
}
.support-card {
    background: var(--card);
    border: none;
    border-radius: 22px;
    box-shadow: var(--shadow);
    padding: 22px;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease;
    display: block;
}
.support-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); text-decoration: none; }
.support-card .icon {
    width: 46px; height: 46px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center; font-size: 1.3rem; margin-bottom: 14px;
    color: #fff;
}
.support-card:nth-of-type(4n+1) .icon { background: var(--grad-violet); }
.support-card:nth-of-type(4n+2) .icon { background: var(--grad-pink); }
.support-card:nth-of-type(4n+3) .icon { background: var(--grad-coral); }
.support-card:nth-of-type(4n+4) .icon { background: var(--grad-base); }
.support-card h3 { font-size: 1.05rem; color: var(--ink); margin-bottom: 4px; }
.support-card p { color: var(--ink-soft); font-size: .88rem; margin: 0; }
.category-label {
    text-transform: uppercase; letter-spacing: .06em; font-size: .72rem; font-weight: 700;
    color: var(--violet-dark); margin: 28px 0 4px;
}

/* ---------- Sélection multiple de supports (accueil) ---------- */
.support-card-checkbox { position: relative; }
.support-card-checkbox input[type=checkbox] { position: absolute; opacity: 0; width: 0; height: 0; }
.support-card-checkbox .check-indicateur {
    position: absolute; top: 16px; right: 16px; width: 24px; height: 24px; border-radius: 50%;
    border: 2px solid var(--border); display: flex; align-items: center; justify-content: center;
    font-size: .8rem; color: transparent; transition: all .15s ease; background: #fff;
}
.support-card-checkbox input[type=checkbox]:checked ~ .check-indicateur {
    background: var(--grad-violet); border-color: transparent; color: #fff;
}
.support-card-checkbox:has(input[type=checkbox]:checked) {
    box-shadow: 0 0 0 2px var(--violet), var(--shadow-hover);
}
.barre-selection {
    position: sticky; bottom: 16px; margin-top: 26px;
    background: var(--ink); color: #fff; border-radius: 16px; padding: 14px 20px;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.barre-selection button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Sélecteur de quantité (accueil) ---------- */
.support-card-qty { position: relative; transition: box-shadow .15s ease, transform .15s ease; }
.support-card-qty.qte-active { box-shadow: 0 0 0 2px var(--violet), var(--shadow-hover); }
.qty-stepper {
    display: flex; align-items: center; gap: 12px; margin-top: 14px; padding-top: 14px;
    border-top: 1px solid var(--border);
}
.qty-btn {
    width: 32px; height: 32px; border-radius: 10px; border: 1px solid var(--border); background: #fff;
    color: var(--violet-dark); font-size: 1.1rem; font-weight: 700; cursor: pointer; line-height: 1;
    display: flex; align-items: center; justify-content: center; transition: all .15s ease;
}
.qty-btn:hover { background: var(--primary-light); border-color: transparent; }
.qty-value { font-weight: 800; font-size: 1.05rem; color: var(--ink); min-width: 20px; text-align: center; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 18px; }
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 6px; color: var(--ink); }
.hint { color: var(--ink-soft); font-size: .8rem; margin-top: 4px; }
input[type=text], input[type=email], input[type=date], input[type=number], input[type=password],
input[type=file], select, textarea {
    width: 100%; padding: 10px 13px; border: 1px solid var(--border); border-radius: 10px;
    font-size: .95rem; font-family: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(122,153,172,.25);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 22px; }
.form-row > * { min-width: 0; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr !important; } }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 20px; border-radius: 12px; border: 1px solid transparent;
    font-weight: 600; font-size: .9rem; cursor: pointer; transition: all .15s ease;
    background: var(--grad-violet); color: #fff;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--ink); border-color: var(--border); }
.btn.secondary:hover { background: var(--bg); }
.btn.btn-tinted { background: var(--primary-light); color: var(--violet-dark); border: 1px solid #d8d3fb; font-weight: 700; }
.btn.btn-tinted:hover { background: #ded8fc; }
.btn.danger { background: var(--danger); }
.btn.success { background: var(--success); }
.btn.small { padding: 6px 12px; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.icon-btn { width: 40px; height: 40px; padding: 0; font-size: 1rem; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn svg { display: block; }
.icon-btn-violet { background: var(--primary-light); color: var(--violet-dark); border: 1px solid #d8d3fb; }
.icon-btn-violet:hover { background: #ded8fc; }
.icon-btn-neutral { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.icon-btn-neutral:hover { background: #e2e8f0; }
.icon-btn-amber { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.icon-btn-amber:hover { background: #fde68a; }
.icon-btn-blue { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }
.icon-btn-blue:hover { background: #bfdbfe; }
.icon-btn.danger {
    background: #fee2e2; color: #dc2626; border: 1px solid #fecaca;
}
.icon-btn.danger:hover { background: #fecaca; }

/* ---------- Badges ---------- */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .76rem; font-weight: 700;
    white-space: nowrap;
}

/* ---------- Alerts ---------- */
.alert { padding: 14px 16px; border-radius: 10px; margin-bottom: 18px; font-size: .9rem; }
.alert.success { background: #ecfdf5; color: #15803d; border: 1px solid #bbf7d0; }
.alert.error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert.info { background: var(--primary-light); color: var(--primary-dark); border: 1px solid #cfe0e8; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--ink-soft); font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; }
tr:hover td { background: var(--primary-light); }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.table-wrap table { min-width: 640px; }
@media (max-width: 680px) {
    .hide-mobile { display: none !important; }
    .table-wrap table { min-width: 480px; }
    table { font-size: .82rem; }
    th, td { padding: 8px 10px !important; }
    td input[type="text"], td input[type="email"], td input[type="number"], td input[type="password"], td select {
        min-width: 110px;
    }
}
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 18px; }
.pagination-info { color: var(--ink-soft); font-size: .85rem; }

/* ---------- Timeline (historique) ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 20px 26px; border-left: 2px solid var(--border); }
.timeline li:last-child { border-color: transparent; padding-bottom: 0; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.timeline .meta { color: var(--ink-soft); font-size: .78rem; }

/* ---------- Admin layout ---------- */
body:has(.admin-shell) { background: var(--admin-canvas); margin: 0; }
.admin-shell {
    display: flex; min-height: 100vh;
}
.sidebar {
    width: 226px; flex-shrink: 0;
    background: var(--grad-violet);
    display: flex; flex-direction: column; align-items: stretch;
    padding: 22px 14px;
    /* position: fixed (et non "sticky") pour être certain que le menu ne bouge
       jamais au défilement, quel que soit le navigateur ou la hauteur de page. */
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 100;
    overflow-y: auto;
}
.admin-main { margin-left: 226px; flex: 1; min-width: 0; background: var(--bg); }
.sidebar .brand {
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1.02rem; margin-bottom: 26px; padding: 10px 6px;
}
.sidebar .brand-logo-img-large { height: 92px; max-width: 100%; }
.brand-icon {
    width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
    background: rgba(255,255,255,.22); display: flex; align-items: center; justify-content: center;
}
.brand-logo-img { height: 32px; width: auto; max-width: 140px; object-fit: contain; border-radius: 8px; }
.brand-logo-img-large { height: 48px; max-width: 190px; }
.sidebar nav { display: flex; flex-direction: column; gap: 6px; flex: 1; width: 100%; overflow-y: auto; }
.sidebar nav a {
    display: flex; align-items: center; gap: 12px;
    width: 100%; padding: 11px 14px; border-radius: 12px;
    color: rgba(255,255,255,.8); font-size: .9rem; font-weight: 600;
}
.sidebar nav a:hover { background: rgba(255,255,255,.14); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: #fff; color: var(--violet-dark); box-shadow: 0 6px 16px rgba(0,0,0,.15); }
.nav-badge {
    margin-left: auto; background: var(--danger); color: #fff; font-size: .72rem; font-weight: 700;
    border-radius: 999px; padding: 1px 7px; min-width: 20px; text-align: center;
}
.sidebar nav a.active .nav-badge { background: var(--danger); color: #fff; }
.sidebar .user-box {
    padding-top: 16px; margin-top: 10px; border-top: 1px solid rgba(255,255,255,.2);
    display: flex; align-items: center; gap: 8px; width: 100%; padding-left: 6px; flex-shrink: 0;
}
.user-avatar {
    width: 36px; height: 36px; border-radius: 12px; background: rgba(255,255,255,.25);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: .74rem; font-weight: 700; flex-shrink: 0;
}
.user-info { font-size: .76rem; color: #fff; line-height: 1.3; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-link {
    color: rgba(255,255,255,.75); font-size: 1rem; flex-shrink: 0; width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center; border-radius: 8px;
}
.logout-link .label { display: none; }
.logout-link:hover { color: #fff; background: rgba(255,255,255,.14); text-decoration: none; }
.admin-topbar {
    background: #fff; border-bottom: 1px solid var(--border); padding: 18px 30px;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.admin-topbar h1 { font-size: 1.3rem; margin: 0; }
.admin-content { padding: 26px 30px 60px; }
.menu-toggle { display: none; background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--ink); }

@media (max-width: 900px) {
    .admin-shell { display: block; }
    .sidebar {
        position: fixed; left: -240px; top: 0; height: 100%; z-index: 200; transition: left .2s ease; width: 226px;
    }
    .sidebar.open { left: 0; box-shadow: var(--shadow-hover); }
    .menu-toggle { display: inline-block; }
    .admin-content { padding: 18px 16px 50px; }
    .admin-topbar { padding: 14px 16px; }
    .admin-main { width: 100%; margin-left: 0; }
}

/* ---------- Dashboard tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 18px; margin-bottom: 28px; }
.tile {
    background: var(--card); border: none; border-radius: 22px; padding: 22px;
    box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.tile .value { font-size: 1.8rem; font-weight: 800; color: var(--ink); }
.tile .label { color: var(--ink-soft); font-size: .82rem; margin-top: 2px; }
.tile.accent, .tile.grad-violet { background: var(--grad-violet); }
.tile.grad-pink { background: var(--grad-pink); }
.tile.grad-coral { background: var(--grad-coral); }
.tile.grad-base { background: var(--grad-base); }
.tile.grad-green { background: var(--grad-green); }
.tile.grad-violet, .tile.grad-pink, .tile.grad-coral, .tile.grad-base, .tile.grad-green {
    color: #fff;
}
.tile.grad-violet .value, .tile.grad-pink .value, .tile.grad-coral .value, .tile.grad-base .value, .tile.grad-green .value { color: #fff; }
.tile.grad-violet .label, .tile.grad-pink .label, .tile.grad-coral .label, .tile.grad-base .label, .tile.grad-green .label { color: rgba(255,255,255,.85); }

/* ---------- Utilities ---------- */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.text-soft { color: var(--ink-soft); }
.text-sm { font-size: .85rem; }
.section { margin-bottom: 34px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 22px 0; }
.footer { text-align: center; color: var(--ink-soft); font-size: .82rem; padding: 34px 0; }
.wizard-progress { text-align: center; color: var(--violet-dark); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 10px; }
.etape-concerne { margin: -6px 0 16px; font-size: .85rem; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.etape-concerne .badge { font-size: .74rem; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.checkbox-row input { width: auto; }
.poignee { cursor: grab; text-align: center; color: var(--ink-soft); font-size: 1.1rem; width: 30px; }
.ligne-glissable { transition: opacity .15s ease; }
.ligne-glissable:active .poignee { cursor: grabbing; }

/* ---------- Impression ---------- */
@media print {
    @page { margin: 14mm 12mm; }
    body { background: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .topbar, .footer, .sidebar, .admin-topbar, .menu-toggle, .wizard-progress,
    .no-print, .btn-group, form button, .barre-selection, nav {
        display: none !important;
    }
    .public-shell, .admin-shell, .admin-main, .admin-content {
        margin: 0 !important; padding: 0 !important; box-shadow: none !important; border-radius: 0 !important; background: #fff !important;
    }
    .card { box-shadow: none !important; border: 1px solid #e2e8f0 !important; break-inside: avoid; }
    a[href]::after { content: none !important; }
    .container { max-width: 100% !important; }
    .print-table-wrap { break-inside: auto; }
    .print-table-wrap table { break-inside: auto; }
    .print-table-wrap tr { break-inside: avoid; }
    .print-section { break-inside: avoid; }
}
.print-page { max-width: 860px; margin: 0 auto; padding: 0 0 40px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
.print-letterhead {
    background: var(--grad-violet); color: #fff; padding: 26px 34px; border-radius: 16px;
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px;
}
.print-letterhead .print-brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 1.15rem; }
.print-letterhead .print-brand-icon { width: 36px; height: 36px; border-radius: 10px; background: rgba(255,255,255,.25); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.print-letterhead .print-doc-info { text-align: right; font-size: .82rem; opacity: .92; }
.print-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; padding-bottom: 16px; border-bottom: 2px solid var(--ink); }
.print-header h1 { font-size: 1.4rem; margin: 0 0 4px; }
.print-meta { text-align: right; font-size: .85rem; color: var(--ink-soft); }
.print-field-label { font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--violet-dark); margin-top: 14px; }
.print-field-value { font-size: .98rem; margin-top: 2px; }
.print-section { margin: 26px 0; }
.print-section h2 { font-size: 1.05rem; margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); color: var(--ink); }
.print-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 26px; }
.print-tile { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.print-tile .print-tile-value { font-size: 1.5rem; font-weight: 800; color: var(--violet-dark); }
.print-tile .print-tile-label { font-size: .78rem; color: var(--ink-soft); margin-top: 2px; }
.print-table-wrap table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.print-table-wrap th { text-align: left; background: var(--primary-light); color: var(--violet-dark); font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; padding: 9px 10px; }
.print-table-wrap td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.print-footer { margin-top: 34px; padding-top: 14px; border-top: 1px solid var(--border); font-size: .76rem; color: var(--ink-soft); text-align: center; }
