:root {
    --purple: #812C7F;
    --purple-dark: #3F1738;
    --green: #2E9A56;
    --green-dark: #1F6B3B;
    --lilac: #F5EDF5;
    --mint: #E9F6EE;
    --ink: #2A2529;
    --gray: #6E6670;
    --red: #C0392B;
    --white: #FFFFFF;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    color: var(--ink);
    background: #FAFAFA;
    line-height: 1.5;
}

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

/* ===== Navigation ===== */
.topnav {
    background: var(--purple-dark);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    position: sticky;
    top: 0;
    z-index: 50;
}
.topnav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    flex-wrap: wrap;
    gap: 8px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: white;
    font-weight: 700;
}
.brand-mark {
    background: var(--green);
    color: white;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 3px 7px;
    border-radius: 5px;
    letter-spacing: 0.5px;
}
.brand-text { font-size: 0.92rem; }
.nav-links {
    list-style: none;
    display: flex;
    gap: 2px;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}
.nav-links a {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #D8C4D6;
    text-decoration: none;
    font-size: 0.82rem;
    padding: 8px 12px;
    border-radius: 7px;
    transition: background 0.15s, color 0.15s;
}
.nav-links a:hover { background: rgba(255,255,255,0.08); color: white; }
.nav-links a.active { background: var(--green); color: white; font-weight: 600; }
.nav-icon { font-size: 0.95rem; opacity: 0.85; }

/* ===== Header ===== */
.site-header {
    background: var(--purple-dark);
    color: white;
    padding: 32px 0;
}
.site-header.module-header { padding: 26px 0; }

.site-header .eyebrow {
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #A9E0BE;
    margin: 0 0 8px;
}

.site-header h1 {
    margin: 0 0 8px;
    font-size: 1.7rem;
}
.module-header h1 { font-size: 1.5rem; }

.site-header .subtitle {
    margin: 0;
    color: #D8C4D6;
    font-size: 0.95rem;
    max-width: 640px;
}

main.container { padding-top: 24px; padding-bottom: 40px; }

/* ===== Module dashboard cards ===== */
.module-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
    margin-bottom: 24px;
}
.module-card {
    display: block;
    background: white;
    border-radius: 12px;
    padding: 22px;
    text-decoration: none;
    color: var(--ink);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border-top: 4px solid var(--purple);
    transition: transform 0.15s, box-shadow 0.15s;
}
.module-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,0.1); }
.module-card.card-green { border-top-color: var(--green); }
.module-icon { font-size: 1.8rem; margin-bottom: 10px; }
.card-green .module-icon { color: var(--green-dark); }
.card-purple .module-icon { color: var(--purple); }
.module-card h2 { margin: 0 0 4px; font-size: 1.15rem; color: var(--ink); }
.module-eq { font-family: Cambria, Georgia, serif; font-style: italic; color: var(--gray); font-size: 0.82rem; margin: 0 0 10px; }
.module-card p:not(.module-eq) { font-size: 0.88rem; color: #555; margin: 0 0 14px; }
.module-cta { font-size: 0.85rem; font-weight: 700; color: var(--purple); }
.card-green .module-cta { color: var(--green-dark); }

.notice {
    background: var(--lilac);
    border-left: 4px solid var(--purple);
    padding: 14px 18px;
    border-radius: 6px;
    font-size: 0.9rem;
    margin-bottom: 24px;
}

.notice code {
    background: rgba(0,0,0,0.06);
    padding: 1px 5px;
    border-radius: 3px;
}

.alert-error {
    background: #FDEDEC;
    border-left: 4px solid var(--red);
    color: #922B21;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.panel {
    background: white;
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 24px;
}

.panel h2 {
    margin-top: 0;
    color: var(--purple);
    font-size: 1.25rem;
    border-bottom: 2px solid var(--lilac);
    padding-bottom: 10px;
}

.panel h3 {
    color: var(--green-dark);
    font-size: 1.05rem;
    margin-top: 28px;
}

.tag {
    font-family: "Cambria", Georgia, serif;
    font-style: italic;
    color: var(--gray);
}

.input-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12px;
}

.input-table th {
    text-align: left;
    font-size: 0.82rem;
    color: var(--gray);
    padding: 6px 8px;
    font-weight: 600;
}

.input-table td {
    padding: 4px 8px;
}

.input-table input[type=text],
.input-table input[type=number] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #DDD;
    border-radius: 6px;
    font-size: 0.9rem;
}

.input-table input:focus { outline: 2px solid var(--purple); border-color: var(--purple); }

.btn-remove {
    background: none;
    border: none;
    color: var(--red);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px 8px;
}

.btn-secondary {
    background: var(--mint);
    color: var(--green-dark);
    border: 1px solid var(--green);
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 0.85rem;
    cursor: pointer;
    margin-bottom: 20px;
}
.btn-secondary:hover { background: #DBF0E3; }

.params-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin: 20px 0;
    padding-top: 16px;
    border-top: 1px solid #EEE;
}

.field label {
    display: block;
    font-size: 0.82rem;
    color: var(--gray);
    margin-bottom: 6px;
    font-weight: 600;
}

.field select, .field input {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid #DDD;
    border-radius: 6px;
    font-size: 0.9rem;
}

.btn-primary {
    background: var(--purple);
    color: white;
    border: none;
    padding: 13px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: background 0.15s;
}
.btn-primary:hover { background: var(--purple-dark); }

.results { border: 2px solid var(--mint); }

.score-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 8px;
}

.score-box {
    background: var(--lilac);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.score-label { display: block; font-size: 0.78rem; color: var(--gray); margin-bottom: 6px; }
.score-value { display: block; font-size: 1.5rem; font-weight: 700; color: var(--purple); font-family: Cambria, Georgia, serif; }

.decision-box.decision-yes { background: var(--mint); }
.decision-box.decision-yes .score-value { color: var(--green-dark); font-size: 1.15rem; }
.decision-box.decision-no { background: #FDEDEC; }
.decision-box.decision-no .score-value { color: var(--red); font-size: 1.15rem; }

.waterfall {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 220px;
    padding: 16px 8px 0;
    overflow-x: auto;
    border-bottom: 2px solid var(--ink);
}

.wf-bar-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    min-width: 78px;
    height: 100%;
}

.wf-bar-track {
    width: 34px;
    height: 150px;
    display: flex;
    align-items: flex-end;
    background: repeating-linear-gradient(to top, transparent, transparent 20px, #F0F0F0 20px, #F0F0F0 21px);
}

.wf-bar { width: 100%; border-radius: 3px 3px 0 0; min-height: 2px; }
.wf-bar.baseline { background: var(--gray); }
.wf-bar.positive { background: var(--green); }
.wf-bar.negative { background: var(--red); }
.wf-bar.total { background: var(--purple); }

.wf-label { font-size: 0.72rem; text-align: center; color: var(--gray); margin-bottom: 6px; min-height: 28px; }
.wf-value { font-size: 0.78rem; font-weight: 700; margin-top: 6px; }
.val-pos { color: var(--green-dark); }
.val-neg { color: var(--red); }

.contrib-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    font-size: 0.9rem;
}
.contrib-table th {
    text-align: left;
    background: var(--purple);
    color: white;
    padding: 10px 12px;
}
.contrib-table td {
    padding: 9px 12px;
    border-bottom: 1px solid #EEE;
}
.contrib-table .total-row { background: var(--lilac); }
.contrib-table .total-row td { border-top: 2px solid var(--purple); border-bottom: none; }

/* ===== Module 2 : Q-matrice complète ===== */
.qmatrix-scroll { overflow-x: auto; margin-bottom: 16px; }
.qmatrix-table { border-collapse: collapse; width: 100%; min-width: 480px; }
.qmatrix-table th, .qmatrix-table td { border: 1px solid #EAEAEA; padding: 6px 8px; text-align: center; }
.qmatrix-table th.corner { text-align: left; font-size: 0.78rem; color: var(--gray); background: #FAFAFA; }
.qmatrix-table .comp-input { width: 100%; border: none; background: transparent; font-weight: 600; color: var(--purple); text-align: center; font-size: 0.85rem; }
.qmatrix-table .tache-input { width: 130px; border: none; background: transparent; font-size: 0.88rem; }
.qmatrix-table input[type=number] { width: 62px; border: 1px solid #DDD; border-radius: 4px; padding: 5px; text-align: center; }
.qmatrix-table .col-preuve { background: var(--lilac); }
.qmatrix-table .qcell { font-weight: 600; color: var(--ink); }

.pill { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 700; }
.pill-yes { background: var(--mint); color: var(--green-dark); }
.pill-no { background: #FDEDEC; color: var(--red); }
.pill-neutral { background: #F0F0F0; color: var(--gray); }

.summary-line { margin-top: 16px; padding: 12px 16px; background: var(--lilac); border-radius: 8px; font-size: 0.92rem; }

/* ===== Module 3 : Calibration (slider + chart) ===== */
.slider-row { display: flex; align-items: center; gap: 16px; }
.slider-row input[type=range] {
    flex: 1;
    height: 6px;
    accent-color: var(--purple);
}
.slider-value {
    font-family: Cambria, Georgia, serif;
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--purple);
    min-width: 70px;
    text-align: right;
}

.chart-wrap { margin-top: 8px; }
.line-chart { width: 100%; height: auto; }
.chart-legend { display: flex; gap: 20px; margin-top: 10px; font-size: 0.82rem; color: var(--gray); flex-wrap: wrap; }
.chart-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }

.site-footer {
    text-align: center;
    color: var(--gray);
    font-size: 0.8rem;
    padding-top: 20px;
}

@media (max-width: 640px) {
    .params-grid, .score-summary, .module-grid { grid-template-columns: 1fr; }
    .nav-links { width: 100%; justify-content: space-between; }
    .nav-links a { padding: 8px 6px; font-size: 0.75rem; }
    .brand-text { display: none; }
}

/* ===== Module 5 : Historique ===== */
.hist-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--lilac);
}
.btn-danger { border-color: var(--red); color: var(--red); background: #FDEDEC; }
.btn-danger:hover { background: #FAD7D2; }
.empty-state { color: var(--gray); font-style: italic; padding: 30px 0; text-align: center; }
.hist-table-scroll { overflow-x: auto; }
.hist-table { min-width: 100%; font-size: 0.82rem; table-layout: fixed; }
.hist-table th, .hist-table td { padding: 8px 8px; word-wrap: break-word; }
.hist-table th:nth-child(1), .hist-table td:nth-child(1) { width: 4%; }
.hist-table th:nth-child(2), .hist-table td:nth-child(2) { width: 13%; }
.hist-table th:nth-child(3), .hist-table td:nth-child(3) { width: 11%; }
.hist-table th:nth-child(4), .hist-table td:nth-child(4) { width: 11%; }
.hist-table th:nth-child(5), .hist-table td:nth-child(5) { width: 20%; }
.hist-table th:nth-child(6), .hist-table td:nth-child(6) { width: 8%; text-align:center; }
.hist-table th:nth-child(7), .hist-table td:nth-child(7) { width: 10%; }
.hist-table th:nth-child(8), .hist-table td:nth-child(8) { width: 9%; }
.hist-table th:nth-child(9), .hist-table td:nth-child(9) { width: 14%; }
.hist-time { color: var(--gray); font-size: 0.76rem; white-space: nowrap; }
.pill-module { background: var(--lilac); color: var(--purple); font-weight: 600; font-size: 0.7rem; padding: 3px 6px; display: inline-block; line-height: 1.3; }
.container-wide { max-width: 1180px; }
