/* ============================================================
   COMPOZIT V2 — design system « 2026 vibrant »
   Verre dépoli + dégradés cyan→indigo sur identité bleu ciel.
   Thèmes clair & sombre via [data-theme]. Identité badges conservée.
   ============================================================ */

:root {
    color-scheme: light;

    /* Encre & texte */
    --ink: #16202B;
    --ink-strong: #0B1622;
    --muted: #5B6776;

    /* Fond applicatif (mesh dégradé) */
    --app-bg:
        radial-gradient(1100px 620px at 8% -12%, #DCF1FF 0%, transparent 60%),
        radial-gradient(1000px 680px at 112% 8%, #E9E4FF 0%, transparent 55%),
        linear-gradient(180deg, #F6FBFF 0%, #F1F6FC 100%);

    /* Surfaces */
    --surface: #FFFFFF;
    --surface-glass: rgba(255, 255, 255, .66);
    --surface-glass-strong: rgba(255, 255, 255, .82);
    --glass-border: rgba(255, 255, 255, .6);
    --blur: 16px;

    --border: rgba(17, 42, 70, .10);
    --border-input: rgba(17, 42, 70, .18);
    --hover-row: rgba(60, 140, 220, .07);

    /* Accents vibrants */
    --accent: #2F86E0;
    --accent-grad: linear-gradient(135deg, #3FC1F0 0%, #4F9BF0 48%, #6C7BFF 100%);
    --accent-soft: rgba(79, 155, 240, .14);

    /* Sidebar (verre teinté ciel) */
    --sidebar-grad: linear-gradient(180deg, rgba(196, 236, 255, .88) 0%, rgba(214, 238, 255, .55) 100%);
    --sidebar-item-active: linear-gradient(135deg, #A6DBFF 0%, #C6E9FF 100%);
    --sidebar-line: rgba(29, 31, 37, .14);

    /* Ombres & halos */
    --glow: 0 10px 26px rgba(79, 140, 230, .30);
    --shadow-card: 0 8px 26px rgba(20, 50, 90, .09), inset 0 1px 0 rgba(255, 255, 255, .55);
    --shadow-pop: 0 32px 80px rgba(15, 30, 60, .30);

    /* Badges (identité Airtable conservée) */
    --badge-ink: #173249;
    --badge-en-cours: #BCE2F5;
    --badge-archive: #DCE3EA;
    --badge-categorie: #C4ECFF;
    --badge-particulier: #B1E0DC;
    --badge-professionnel: #C1F5F0;
    --diff-positive: #D7507F;
    --diff-negative: #2FA15A;
    --charge-bg: #CFF5D1;

    --radius: 10px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --radius-modal: 18px;
}

[data-theme="dark"] {
    color-scheme: dark;

    --ink: #E6ECF3;
    --ink-strong: #F5F8FC;
    --muted: #93A1B3;

    --app-bg:
        radial-gradient(1100px 620px at 8% -12%, #15314C 0%, transparent 60%),
        radial-gradient(1000px 680px at 112% 8%, #221C49 0%, transparent 55%),
        linear-gradient(180deg, #0C1119 0%, #090D13 100%);

    --surface: #161D27;
    --surface-glass: rgba(28, 37, 50, .60);
    --surface-glass-strong: rgba(30, 40, 54, .80);
    --glass-border: rgba(255, 255, 255, .08);

    --border: rgba(255, 255, 255, .09);
    --border-input: rgba(255, 255, 255, .16);
    --hover-row: rgba(120, 180, 255, .08);

    --accent: #5AA8F5;
    --accent-soft: rgba(90, 168, 245, .18);

    --sidebar-grad: linear-gradient(180deg, rgba(30, 48, 72, .72) 0%, rgba(18, 26, 40, .55) 100%);
    --sidebar-item-active: linear-gradient(135deg, rgba(79, 155, 240, .50) 0%, rgba(108, 123, 255, .38) 100%);
    --sidebar-line: rgba(255, 255, 255, .12);

    --glow: 0 10px 28px rgba(60, 130, 230, .45);
    --shadow-card: 0 10px 30px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .04);
    --shadow-pop: 0 32px 90px rgba(0, 0, 0, .62);

    --badge-ink: #0E1B27;
    --charge-bg: rgba(110, 200, 140, .20);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: var(--ink);
    background: var(--app-bg) fixed;
}

a { color: inherit; }

::selection { background: var(--accent-soft); }

/* Scrollbars discrètes */
* { scrollbar-width: thin; scrollbar-color: rgba(120, 150, 190, .45) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: rgba(120, 150, 190, .4); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }

/* ---------- Layout ---------- */

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 244px;
    flex-shrink: 0;
    background: var(--sidebar-grad);
    -webkit-backdrop-filter: blur(var(--blur)) saturate(140%);
    backdrop-filter: blur(var(--blur)) saturate(140%);
    border-right: 1px solid var(--glass-border);
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar .brand {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -.01em;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px 18px;
}

.sidebar .section {
    font-weight: 700;
    font-size: 12.5px;
    letter-spacing: .02em;
    text-transform: uppercase;
    opacity: .75;
    padding: 12px 10px 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar a.item {
    display: block;
    padding: 8px 10px 8px 30px;
    text-decoration: none;
    color: var(--ink);
    border-left: 2px solid var(--sidebar-line);
    border-radius: 0 999px 999px 0;
    margin-left: 14px;
    transition: background .16s ease, transform .16s ease, box-shadow .16s ease;
}

.sidebar a.item:hover { background: rgba(255, 255, 255, .45); transform: translateX(2px); }

.sidebar a.item.active {
    background: var(--sidebar-item-active);
    font-weight: 600;
    border-left-color: transparent;
    box-shadow: 0 6px 16px rgba(79, 140, 230, .22);
}

.sidebar .spacer { flex: 1; }

.theme-toggle {
    margin: 6px 8px 4px;
    padding: 9px 12px;
    border-radius: 999px;
    border: 1px solid var(--glass-border);
    background: var(--surface-glass);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    color: var(--ink);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: transform .15s ease, box-shadow .15s ease;
}
.theme-toggle:hover { transform: translateY(-1px); box-shadow: var(--shadow-card); }

.sidebar .user-box {
    font-size: 12px;
    padding: 12px 10px 4px;
    color: var(--ink);
    border-top: 1px solid var(--sidebar-line);
    margin-top: 4px;
}

.sidebar .user-box a { font-weight: 600; }

.content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 28px;
}

.breadcrumb { color: var(--muted); }
.breadcrumb .sep { margin: 0 6px; color: var(--muted); }
.breadcrumb .current { color: var(--ink); font-weight: 600; }

.topbar .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.page-body { padding: 0 28px 36px; }

h1.page-title {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--ink-strong);
    margin: 12px 0 20px;
}

/* ---------- Boutons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: var(--radius);
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    background: none;
    font-family: inherit;
    transition: transform .15s ease, box-shadow .15s ease, filter .15s ease, background .15s ease;
}

.btn-primary { background: var(--accent-grad); color: #fff; box-shadow: var(--glow); }
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
    background: var(--surface-glass-strong);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border-color: var(--border-input);
    color: var(--ink);
}
.btn-secondary:hover { background: var(--surface); transform: translateY(-1px); box-shadow: var(--shadow-card); }

.btn-danger { background: var(--surface); border-color: #E5B8C5; color: #C0436B; }
.btn-danger:hover { background: rgba(214, 80, 127, .10); }

.btn-link { color: var(--accent); text-decoration: none; border: none; background: none; cursor: pointer; padding: 8px 0; font-size: 13px; font-weight: 600; }
.btn-link:hover { text-decoration: underline; }

/* ---------- Filtres ---------- */

.filters {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 4px 0 16px;
    flex-wrap: wrap;
}

.filters .right { margin-left: auto; display: flex; gap: 10px; align-items: center; }

select.filter, input.filter {
    border: 1px solid var(--border-input);
    background: var(--surface-glass-strong);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: 13px;
    font-family: inherit;
    color: var(--ink);
    transition: border-color .15s ease, box-shadow .15s ease;
}
select.filter:focus, input.filter:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Tableaux ---------- */

.table-wrap {
    overflow-x: auto;
    background: var(--surface-glass-strong);
    -webkit-backdrop-filter: blur(var(--blur));
    backdrop-filter: blur(var(--blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

table.data th {
    text-align: left;
    font-weight: 600;
    color: var(--muted);
    font-size: 12px;
    letter-spacing: .02em;
    text-transform: uppercase;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table.data td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background .14s ease; }
table.data tbody tr:hover { background: var(--hover-row); }
table.data tbody tr.clickable { cursor: pointer; }

table.data td.num, table.data th.num { text-align: right; }

.table-footer { color: var(--muted); font-size: 12.5px; padding: 12px 4px; }

/* ---------- Badges ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border-radius: 999px;
    padding: 3px 11px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--badge-ink);
    white-space: nowrap;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35);
}

.badge-en_cours { background: var(--badge-en-cours); }
.badge-archive { background: var(--badge-archive); }
.badge-a_venir { background: #FFE9C7; }
.badge-categorie { background: var(--badge-categorie); }
.badge-particulier { background: var(--badge-particulier); }
.badge-professionnel { background: var(--badge-professionnel); }
.badge-chip { background: #EDF4FA; }

.diff-pos { color: var(--diff-positive); font-weight: 700; }
.diff-neg { color: var(--diff-negative); }
.diff-zero { color: var(--diff-negative); }

/* ---------- Formulaires ---------- */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px; max-width: 860px; }
.form-grid .full { grid-column: 1 / -1; }

.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-row label { font-weight: 600; font-size: 13px; }
.form-row label.required::after { content: ' *'; color: var(--diff-positive); }

.form-row input[type=text], .form-row input[type=number], .form-row input[type=email],
.form-row input[type=date], .form-row input[type=tel], .form-row input[type=password],
.form-row input[type=file], .form-row select, .form-row textarea {
    border: 1px solid var(--border-input);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 13.5px;
    font-family: inherit;
    width: 100%;
    background: var(--surface);
    color: var(--ink);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-row .help { color: var(--muted); font-size: 12px; }
.form-errors { color: var(--diff-positive); font-size: 12.5px; }

/* ---------- Modal ---------- */

dialog.modal {
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-modal);
    padding: 0;
    width: min(820px, calc(100vw - 48px));
    background: var(--surface-glass-strong);
    -webkit-backdrop-filter: blur(28px) saturate(150%);
    backdrop-filter: blur(28px) saturate(150%);
    color: var(--ink);
    box-shadow: var(--shadow-pop);
}

dialog.modal::backdrop {
    background: rgba(10, 16, 28, .55);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

.modal-inner { padding: 30px 36px 20px; position: relative; }
.modal-inner h2 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; color: var(--ink-strong); margin: 4px 0 22px; }

.modal-close {
    position: absolute;
    top: 14px;
    right: 16px;
    border: none;
    background: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--muted);
    border-radius: 8px;
    width: 32px;
    height: 32px;
    transition: background .15s ease;
}
.modal-close:hover { background: var(--hover-row); }

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border);
    padding: 16px 36px;
}

/* ---------- Trombinoscope ---------- */

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 18px;
}

.gallery .card {
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    text-decoration: none;
    background: var(--surface-glass-strong);
    -webkit-backdrop-filter: blur(var(--blur));
    backdrop-filter: blur(var(--blur));
    box-shadow: var(--shadow-card);
    transition: transform .18s ease, box-shadow .18s ease;
}

.gallery .card:hover { transform: translateY(-4px); box-shadow: 0 16px 40px rgba(20, 50, 90, .16); }

.gallery .card .photo {
    aspect-ratio: 4 / 5;
    background: linear-gradient(135deg, #E8F4FF, #EEE9FF) center / cover no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 56px;
    color: #9FB6D0;
}

.gallery .card .infos { padding: 12px 14px; }
.gallery .card .nom { font-weight: 700; }
.gallery .card .meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---------- Dashboard ---------- */

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 24px; }

.panel {
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    background: var(--surface-glass-strong);
    -webkit-backdrop-filter: blur(var(--blur));
    backdrop-filter: blur(var(--blur));
    box-shadow: var(--shadow-card);
}

.panel h3 { margin: 0 0 2px; font-size: 15px; color: var(--ink-strong); }
.panel .subtitle { color: var(--muted); font-size: 12.5px; margin-bottom: 12px; }
.panel .chart-box { position: relative; height: 280px; }

/* ---------- Planification (Gantt hebdomadaire) ---------- */

.calendar-shell {
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 14px;
    background: var(--surface-glass-strong);
    -webkit-backdrop-filter: blur(var(--blur));
    backdrop-filter: blur(var(--blur));
    box-shadow: var(--shadow-card);
}

.gantt-toolbar { display: flex; align-items: center; gap: 12px; margin: 8px 0 4px; }

.gantt-grille {
    display: grid;
    grid-template-columns: 160px repeat(7, 1fr);
    position: relative;
}

.gantt-entete .gantt-jour {
    text-align: left;
    padding: 6px 8px;
    color: var(--muted);
    font-size: 12px;
    border-bottom: 1px solid var(--border);
    border-left: 1px solid var(--border);
}

.gantt-entete .gantt-jour strong { color: var(--ink); font-size: 14px; }
.gantt-entete .gantt-jour.aujourdhui strong { color: var(--accent); }

.gantt-label {
    padding: 8px 10px;
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gantt-rangee { border-bottom: 1px solid var(--border); min-height: 36px; }

.gantt-cellule {
    border-left: 1px solid var(--border);
    position: relative;
}

.gantt-cellule.aujourdhui { background: var(--accent-soft); }

.gantt-charge-perso {
    position: absolute;
    bottom: 3px;
    right: 6px;
    font-size: 11px;
    color: var(--muted);
}

/* Couche des barres : recouvre les 7 colonnes de jours (pas le label) */
.gantt-couche {
    position: absolute;
    left: 160px;
    right: 0;
    top: 0;
    bottom: 0;
    pointer-events: none;
}

.gantt-barre {
    position: absolute;
    top: 5px;
    height: 26px;
    background: linear-gradient(135deg, #8FCFF0 0%, #9FB4FF 100%);
    border: 1px solid rgba(79, 140, 230, .5);
    color: #15324A;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    line-height: 24px;
    padding: 0 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: auto;
    cursor: pointer;
    box-sizing: border-box;
    box-shadow: 0 4px 12px rgba(79, 140, 230, .28);
}

.gantt-barre.editable { cursor: grab; }
.gantt-barre.editable:active { cursor: grabbing; }
.gantt-barre.continue-avant { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-style: dashed; }
.gantt-barre.continue-apres { border-top-right-radius: 0; border-bottom-right-radius: 0; border-right-style: dashed; }

.gantt-poignee {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 10px;
    cursor: ew-resize;
    border-right: 3px solid rgba(29, 31, 37, .35);
    border-radius: 0 8px 8px 0;
}

.charge-row {
    display: grid;
    margin-top: 8px;
    background: var(--charge-bg);
    border-radius: var(--radius);
    overflow: hidden;
}

.gantt-grille-pied { grid-template-columns: 160px repeat(7, 1fr); }

.charge-row .cell {
    padding: 8px 10px;
    font-size: 12.5px;
    border-right: 1px solid rgba(0, 0, 0, .06);
}

.charge-row .cell.label { font-weight: 600; }

/* ---------- Planification : bascule semaine / mois ---------- */

.vue-bascule { display: inline-flex; }
.vue-bascule .btn { border-radius: 0; }
.vue-bascule .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.vue-bascule .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; margin-left: -1px; }
.vue-bascule .btn:hover { transform: none; }
.vue-bascule .btn.actif { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* Vue mois : ~22 colonnes. Colonnes compactes, défilement horizontal si l'écran est
   trop étroit, et un trait plus marqué au début de chaque semaine. */
.vue-mois .calendar-shell { overflow-x: auto; }
.vue-mois .gantt-entete .gantt-jour { padding: 5px 2px; text-align: center; font-size: 10px; line-height: 1.25; }
.vue-mois .gantt-entete .gantt-jour strong { display: block; font-size: 12.5px; }
.vue-mois .gantt-barre { font-size: 11.5px; padding: 0 6px; }
.vue-mois .charge-row .cell { padding: 8px 2px; font-size: 11.5px; text-align: center; }
.vue-mois .charge-row .cell.label { text-align: left; padding-left: 10px; }

.vue-mois .gantt-jour.debut-semaine,
.vue-mois .gantt-cellule.debut-semaine,
.vue-mois .charge-row .cell.debut-semaine { border-left: 1px solid var(--border-input); }

/* filtre opérateurs : masquer / réafficher une ligne du calendrier */
.gantt-filtres { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 14px; }
.gantt-filtres .filtre-label { color: var(--muted); font-size: 12.5px; font-weight: 600; margin-right: 2px; }

.filtre-op {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .12s, background .12s;
}

.filtre-op::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}

.filtre-op.masque { color: var(--muted); text-decoration: line-through; opacity: .55; background: transparent; }
.filtre-op.masque::before { background: var(--muted); }

.filtre-reset {
    border: none;
    background: none;
    color: var(--accent);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    padding: 4px 6px;
}

/* libellé d'une barre trop courte : affiché à droite, non tronqué */
.gantt-barre.etroite { overflow: visible; }
.gantt-barre.etroite .gantt-barre-titre {
    position: absolute;
    left: calc(100% + 6px);
    top: 0;
    line-height: 26px;
    color: var(--ink);
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
}

/* panneau "Voir projets" */
.projets-a-placer { margin-top: 14px; }
.projets-a-placer .pill {
    display: inline-block;
    background: var(--badge-categorie);
    color: var(--badge-ink);
    border-radius: 999px;
    padding: 5px 13px;
    margin: 0 6px 6px 0;
    font-size: 12.5px;
    font-weight: 600;
}

/* Pastille que l'on glisse sur le tableau pour positionner le chantier */
.projets-a-placer .pill.deplacable { cursor: grab; touch-action: none; }
.projets-a-placer .pill.deplacable::before { content: '⠿ '; opacity: .55; }
.projets-a-placer .pill.deplacable:active { cursor: grabbing; }

.pill-fantome {
    position: fixed;
    z-index: 60;
    pointer-events: none;
    background: var(--badge-categorie);
    color: var(--badge-ink);
    border-radius: 999px;
    padding: 5px 13px;
    font-size: 12.5px;
    font-weight: 600;
    box-shadow: var(--shadow-pop);
    opacity: .92;
}

/* Colonne visée pendant le dépôt */
.gantt-jour.cible,
.gantt-cellule.cible,
.charge-row .cell.cible { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }

/* Pendant un dépôt, les barres ne doivent pas masquer les colonnes */
.depot-en-cours .gantt-barre { pointer-events: none; }

/* ---------- Fiche projet : déroulé des actions + notes ---------- */

.deroule { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.deroule li { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm); }
.deroule li:nth-child(odd) { background: rgba(127, 127, 127, .06); }
.deroule li .puce { color: var(--muted); font-weight: 700; }
.deroule li.fait .puce { color: var(--accent); }
.deroule li .nom { flex: 1; }
.deroule li .heures { color: var(--muted); font-size: 12.5px; font-weight: 600; }

.notes-bloc {
    margin-top: 6px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    min-height: 44px;
    white-space: pre-wrap;
    line-height: 1.5;
}

/* ---------- Fiche projet : heures vendues / réalisées ---------- */

.heures-bilan {
    margin: 8px 0 12px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.heures-bilan .chiffres {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px 22px;
}

.heures-bilan .libelle { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
.heures-bilan .valeur { font-size: 16px; font-weight: 700; margin-top: 2px; }

.jauge {
    position: relative;
    height: 22px;
    margin-top: 14px;
    border-radius: 999px;
    background: rgba(127, 127, 127, .16);
    overflow: hidden;
}

.jauge .remplissage { height: 100%; background: var(--charge-bg); transition: width .2s; }
.jauge.depassement .remplissage { background: #F2B8CC; }

.jauge .etiquette {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--ink-strong);
}

.heures-par-salarie { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }

.saisie-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
    margin: 10px 0 14px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.saisie-inline .champ { display: flex; flex-direction: column; gap: 4px; min-width: 160px; }
.saisie-inline .champ.court { min-width: 110px; }
.saisie-inline label { color: var(--muted); font-size: 12px; font-weight: 600; }
.saisie-inline ul { margin: 2px 0 0; padding-left: 16px; color: #C0436B; font-size: 12px; }

table.data td .btn-link.danger { color: #C0436B; padding: 0; }
table.data .colonne-actions { text-align: right; width: 1%; white-space: nowrap; }

/* ---------- Photos de chantier (fiche projet) ---------- */

.photos-upload {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin: 10px 0 14px;
}

.photos-upload input[type="text"] { min-width: 220px; }
.photos-upload input[type="file"] { max-width: 100%; font-size: 13px; }

.photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px;
    margin: 6px 0 4px;
}

.photo-tuile {
    margin: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.photo-tuile img {
    display: block;
    width: 100%;
    height: 145px;
    object-fit: cover;
    background: rgba(127, 127, 127, .10);
}

.photo-tuile figcaption {
    padding: 7px 9px 0;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.35;
    word-break: break-word;
}

.photo-tuile .photo-nom { color: var(--muted); font-weight: 500; }

.photo-actions { display: flex; flex-direction: column; gap: 2px; padding: 4px 9px 8px; }
.photo-actions form { display: flex; align-items: center; gap: 8px; }
.photo-actions input[type="text"] { flex: 1; min-width: 0; font-size: 12px; padding: 4px 7px; }
.photo-actions .btn-link { padding: 2px 0; font-size: 12px; }
.photo-actions .btn-link.danger { color: #C0436B; }

/* ---------- Popup « Gérer un opérateur » ---------- */

button.chip-op {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    font: inherit;
    border: 1px solid transparent;
}
button.chip-op:hover { filter: brightness(.96); text-decoration: underline; }

.aff-actions { display: flex; flex-direction: column; gap: 8px; }
.aff-actions label { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }

.aff-resume {
    margin: 12px 0 6px;
    padding: 10px 12px;
    border-radius: var(--radius);
    background: var(--accent-soft);
    color: var(--ink-strong);
    font-weight: 600;
    font-size: 13.5px;
    line-height: 1.45;
}

/* ---------- Impression (fiche chantier sur A4) ---------- */

@media print {
    @page { size: A4; margin: 14mm; }

    .sidebar,
    .topbar,
    #theme-toggle,
    .flash,
    dialog,
    .btn,
    button { display: none !important; }

    html, body { background: #fff !important; }
    .layout, .content, .page-body {
        display: block !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
    }

    body, h1, h2, p, li, td, th, a, .valeur, .libelle, .badge { color: #000 !important; }

    .page-title { font-size: 18pt; margin: 0 0 10pt; }
    .section-title {
        font-size: 12.5pt;
        font-weight: 700;
        margin: 12pt 0 4pt;
        border-bottom: 1px solid #000;
        padding-bottom: 2pt;
        /* jamais un titre seul en bas de page */
        break-after: avoid;
        page-break-after: avoid;
    }

    .fiche-grid { display: grid !important; grid-template-columns: 1fr 1fr; gap: 6pt 22pt; }
    .fiche-grid > div { break-inside: avoid; }
    .fiche-grid .libelle { font-size: 8pt; text-transform: uppercase; letter-spacing: .3px; color: #444 !important; }
    .fiche-grid .valeur { font-size: 10.5pt; font-weight: 600; }

    .badge, .badge-chip {
        background: transparent !important;
        border: 1px solid #999 !important;
        border-radius: 3pt;
        padding: 1pt 5pt;
        font-weight: 600;
    }

    .deroule { padding: 0; }
    .deroule li { background: transparent !important; padding: 3pt 0; break-inside: avoid; }

    .notes-bloc { background: transparent !important; border: 1px solid #999 !important; }

    /* Saisie d'heures : le formulaire et la colonne d'actions ne s'impriment pas ;
       le comparatif vendues / réalisées, si. */
    .saisie-inline,
    .colonne-actions { display: none !important; }

    .heures-bilan { border: 1px solid #999 !important; background: transparent !important; padding: 6pt 8pt; break-inside: avoid; }
    .heures-bilan .valeur { font-size: 11pt; }
    .jauge { border: 1px solid #999; height: 14pt; }
    .jauge .remplissage { background: #DDD !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

    /* Photos : 2 par ligne, jamais coupées par un saut de page. */
    .photos-upload,
    .photo-actions,
    .photos-vide,
    .section-title.sans-photo { display: none !important; }

    .photos-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        align-items: start; /* chaque photo garde sa hauteur, sans blanc de calage */
        gap: 8pt 10pt;
        margin-top: 6pt;
    }

    .photo-tuile {
        border: 1px solid #999 !important;
        border-radius: 3pt;
        box-shadow: none !important;
        break-inside: avoid;
        page-break-inside: avoid;
        overflow: hidden;
    }

    .photo-tuile img {
        width: 100% !important;
        height: auto !important;
        max-height: 78mm;
        object-fit: contain;
        background: transparent !important;
    }

    .photo-tuile figcaption { padding: 3pt 5pt; font-size: 9pt; }
    .photo-tuile .photo-nom { display: none !important; }

    /* ----- Planning (semaine ou mois) affiché en atelier, A4 paysage ----- */

    .gantt-toolbar .actions,
    .gantt-toolbar + .help,
    .projets-a-placer .help { display: none !important; }

    .gantt-toolbar { margin: 0 0 6pt; }

    .calendar-shell {
        overflow: visible !important;
        padding: 0 !important;
        border: 1px solid #666 !important;
        border-radius: 0;
        background: transparent !important;
        box-shadow: none !important;
        break-inside: avoid;
    }

    .gantt-entete .gantt-jour {
        color: #000 !important;
        border-color: #666 !important;
        font-size: 8pt;
        padding: 3pt 2pt;
    }

    .gantt-entete .gantt-jour strong { font-size: 9.5pt; }
    .gantt-rangee { min-height: 26pt; border-bottom: 1px solid #999 !important; break-inside: avoid; }
    .gantt-cellule { border-left: 1px solid #CCC !important; background: transparent !important; }

    .gantt-jour.aujourdhui,
    .gantt-cellule.aujourdhui { background: #EEE !important; }

    /* Les aplats doivent sortir même sans « imprimer les arrière-plans ». */
    .gantt-barre,
    .charge-row,
    .gantt-jour.aujourdhui,
    .gantt-cellule.aujourdhui {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .gantt-label {
        white-space: normal !important;
        overflow: visible !important;
        font-size: 8.5pt;
        line-height: 1.15;
        padding: 4pt 6pt;
    }

    .gantt-barre {
        background: #CFE4F7 !important;
        border: 1px solid #4A7FB5 !important;
        color: #000 !important;
        box-shadow: none !important;
        font-size: 8pt;
        line-height: 20px;
        height: 22px;
    }

    .charge-row { background: #EDEDED !important; border: 1px solid #666; }
    .charge-row .cell { color: #000 !important; font-size: 8.5pt; }

    .projets-a-placer .pill {
        background: transparent !important;
        border: 1px solid #999;
        color: #000 !important;
    }

    /* Les opérateurs du récapitulatif sont des boutons (popup d'affectation) :
       ils doivent quand même figurer sur la feuille affichée en atelier. */
    button.chip-op {
        display: inline-block !important;
        background: transparent !important;
        border: 1px solid #999 !important;
        color: #000 !important;
        padding: 1pt 5pt;
    }

    /* Qui travaille sur quoi : la feuille de détail suit le tableau. */
    .recap-charge { break-before: page; }

    .table-wrap { overflow: visible !important; }
    table.data { width: 100%; border-collapse: collapse; }
    table.data th, table.data td { border: 1px solid #999 !important; padding: 3pt 6pt; text-align: left; font-size: 9.5pt; }
    table.data tr { break-inside: avoid; }
}

/* ---------- Chiffrage ---------- */

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

.chiffrage-table td input {
    width: 90px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    padding: 5px 8px;
    font-size: 13px;
    text-align: right;
    background: var(--surface);
    color: var(--ink);
}
.chiffrage-table td input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.chiffrage-totaux {
    margin-top: 12px;
    border-top: 2px solid var(--accent);
    padding-top: 10px;
    font-size: 14px;
}

.chiffrage-totaux .ligne { display: flex; justify-content: space-between; padding: 3px 0; }
.chiffrage-totaux .ligne.total { font-weight: 800; font-size: 16px; color: var(--ink-strong); }
.chiffrage-totaux .ligne.info { color: var(--muted); }

/* ---------- Login ---------- */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--app-bg) fixed;
    padding: 24px;
}

.login-card {
    background: var(--surface-glass-strong);
    -webkit-backdrop-filter: blur(28px) saturate(150%);
    backdrop-filter: blur(28px) saturate(150%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-modal);
    padding: 38px 40px;
    width: min(420px, calc(100vw - 32px));
    box-shadow: var(--shadow-pop);
}

.login-card h1 { margin: 0 0 4px; font-size: 24px; font-weight: 800; letter-spacing: -.02em; color: var(--ink-strong); }
.login-card .sub { color: var(--muted); margin-bottom: 20px; font-size: 13px; }

/* ---------- Divers ---------- */

.flash {
    border-radius: var(--radius);
    padding: 12px 16px;
    margin: 10px 0;
    font-size: 13.5px;
    font-weight: 500;
    border: 1px solid transparent;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.flash-success { background: rgba(64, 190, 120, .16); border-color: rgba(64, 190, 120, .35); }
.flash-error { background: rgba(216, 80, 127, .14); border-color: rgba(216, 80, 127, .35); }
.flash-warning { background: rgba(245, 180, 60, .16); border-color: rgba(245, 180, 60, .38); }

.empty-state { color: var(--muted); padding: 36px 0; text-align: center; }

.fiche-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px 28px; max-width: 980px; }
.fiche-grid .libelle { color: var(--muted); font-size: 12px; }
.fiche-grid .valeur { font-size: 14px; margin-top: 2px; }

.section-title { font-size: 16px; font-weight: 700; color: var(--ink-strong); margin: 28px 0 10px; }

.actions-chips { display: flex; gap: 6px; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
