/* Suivi de chantier — feuille de style unique (mobile d'abord) */
:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --line: #e2e8f0;
    --line-2: #cbd5e1;
    --brand: #1e293b;
    --accent: #f97316;
    --accent-ink: #ffffff;
    --accent-dark: #c2410c;
    --danger: #dc2626;
    --success: #16a34a;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 2px 8px rgba(15, 23, 42, .05);
    --shadow-lg: 0 10px 40px rgba(15, 23, 42, .25);
    --tap: 44px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    font-size: 16px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.45;
    -webkit-tap-highlight-color: transparent;
}
a { color: #1d4ed8; text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .75rem; line-height: 1.2; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 .75rem; }
.h3, h3 { font-size: 1.02rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pre { white-space: pre-wrap; }
.mt { margin-top: 1rem; }
code { background: #e2e8f0; padding: 1px 5px; border-radius: 4px; font-size: .9em; }
[hidden] { display: none !important; }

/* ---------- Barre du haut ---------- */
.topbar {
    position: sticky; top: 0; z-index: 30;
    background: linear-gradient(180deg, #1e293b 0%, #172033 100%); color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.06);
    box-shadow: 0 2px 10px rgba(15, 23, 42, .18);
}
.topbar-inner {
    max-width: 1200px; margin: 0 auto; min-height: 60px;
    display: flex; align-items: center; gap: 1.25rem;
    padding: .45rem max(1rem, env(safe-area-inset-left));
}
.brand { display: flex; align-items: center; gap: .65rem; color: #fff; min-width: 0; }
.brand:hover { text-decoration: none; }
.brand-logo { display: grid; place-items: center; height: 36px; max-width: 120px; padding: 3px 6px; background: #fff; border-radius: 8px; }
.brand-logo img { max-height: 30px; max-width: 108px; object-fit: contain; }
.brand-text { display: grid; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.brand-text small { font-size: .7rem; color: #94a3b8; letter-spacing: .04em; text-transform: uppercase; }
.mainnav { display: flex; align-items: center; gap: .25rem; margin-left: .5rem; }
.mainnav a {
    position: relative; display: inline-flex; align-items: center; gap: .45rem;
    padding: .55rem .85rem; border-radius: 10px; color: #cbd5e1; font-weight: 600; font-size: .95rem;
    transition: background .15s, color .15s;
}
.mainnav a svg { opacity: .8; }
.mainnav a:hover { color: #fff; background: rgba(255,255,255,.08); text-decoration: none; }
.mainnav a.active { color: #fff; background: rgba(249,115,22,.16); }
.mainnav a.active svg { color: var(--accent); opacity: 1; }
.mainnav a.active::after { content: ""; position: absolute; left: .85rem; right: .85rem; bottom: -.47rem; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent); }
.nav-mobile-only { display: none !important; }

.user-menu { margin-left: auto; }
.user-chip {
    display: flex; align-items: center; gap: .55rem; padding: .3rem .55rem .3rem .3rem;
    border-radius: 999px; border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.05);
    cursor: pointer; list-style: none; transition: background .15s, border-color .15s;
}
.user-chip::-webkit-details-marker { display: none; }
.user-chip:hover, .user-menu[open] .user-chip { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.25); }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, #fb923c, #ea580c); color: #fff; font-weight: 800; font-size: .85rem; letter-spacing: .02em; flex: none; }
.avatar.lg { width: 42px; height: 42px; font-size: 1rem; }
.user-name { display: grid; line-height: 1.15; font-weight: 600; font-size: .9rem; white-space: nowrap; }
.user-name small { font-weight: 500; font-size: .72rem; color: #94a3b8; }
.user-chip .chev { color: #94a3b8; transition: transform .15s; }
.user-menu[open] .chev { transform: rotate(180deg); }
.user-pop { min-width: 250px; padding: .5rem; gap: .1rem; color: var(--ink); top: calc(100% + 8px); }
.user-pop-head { display: flex; align-items: center; gap: .7rem; padding: .5rem .5rem .7rem; border-bottom: 1px solid var(--line); margin-bottom: .3rem; }
.user-pop a { display: flex; align-items: center; gap: .65rem; padding: .6rem .65rem; border-radius: 8px; color: var(--ink); font-weight: 500; }
.user-pop a svg { color: var(--muted); }
.user-pop a:hover { background: #f1f5f9; text-decoration: none; }
.user-pop a.danger, .user-pop a.danger svg { color: var(--danger); }
.user-pop hr { border: 0; border-top: 1px solid var(--line); margin: .3rem 0; }

.nav-toggle { display: none; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.14); color: #fff; width: var(--tap); height: var(--tap); border-radius: 10px; cursor: pointer; place-items: center; }
@media (max-width: 860px) {
    .user-name, .user-chip .chev { display: none; }
    .user-chip { padding: .25rem; }
}
@media (max-width: 760px) {
    .topbar-inner { gap: .6rem; }
    .nav-toggle { display: grid; }
    .user-menu { display: none; }
    .brand { margin-right: auto; }
    .mainnav {
        display: none; position: absolute; top: 100%; left: 0; right: 0; margin: 0;
        flex-direction: column; align-items: stretch; gap: .2rem; padding: .6rem;
        background: #172033; border-bottom: 1px solid rgba(255,255,255,.08); box-shadow: 0 16px 30px rgba(15,23,42,.35);
    }
    .nav-open .mainnav { display: flex; }
    .mainnav a { padding: .85rem 1rem; font-size: 1rem; }
    .mainnav a.active::after { left: 0; right: auto; top: .6rem; bottom: .6rem; width: 3px; height: auto; border-radius: 0 3px 3px 0; }
    .nav-mobile-only { display: inline-flex !important; }
    .mainnav .nav-logout { color: #fca5a5; border-top: 1px solid rgba(255,255,255,.08); border-radius: 0 0 10px 10px; margin-top: .2rem; }
}

.subbar { max-width: 1200px; margin: 0 auto; padding: .75rem 1rem 0; }
.back { display: inline-flex; align-items: center; gap: .25rem; color: var(--muted); font-weight: 500; }

.container { max-width: 1200px; margin: 0 auto; padding: 1rem 1rem calc(3rem + var(--safe-b)); }

/* ---------- Boutons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    min-height: var(--tap); padding: .5rem 1rem;
    border: 1px solid var(--line-2); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--ink); font: inherit; font-weight: 600;
    cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-primary.active { background: var(--brand); border-color: var(--brand); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger-text { color: var(--danger); }
.btn-sm { min-height: 36px; padding: .3rem .7rem; font-size: .9rem; }
.btn-block { width: 100%; }
.icon-btn {
    display: inline-grid; place-items: center; width: var(--tap); height: var(--tap);
    border: 0; background: transparent; border-radius: var(--radius-sm); cursor: pointer;
    font-size: 1.35rem; color: inherit; list-style: none;
}
.icon-btn:hover { background: rgba(15, 23, 42, .06); }
summary.icon-btn::-webkit-details-marker { display: none; }

/* ---------- Formulaires ---------- */
.form { display: grid; gap: .9rem; }
.form label, .field { display: grid; gap: .3rem; font-weight: 600; font-size: .9rem; color: var(--ink-2); }
.field-label { font-weight: 600; font-size: .9rem; color: var(--ink-2); }
input, select, textarea {
    font: inherit; font-size: 16px; /* évite le zoom auto sur iPhone */
    width: 100%; min-height: var(--tap);
    padding: .55rem .75rem; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
    background: #fff; color: var(--ink); font-weight: 400;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
input[type=file] { padding: .45rem; background: #f8fafc; }
.form label.check, label.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; cursor: pointer; }
label.check.danger { color: var(--danger); }
.grid2, .grid3, .grid-ref, .grid-cp { display: grid; gap: .9rem; }
@media (min-width: 640px) {
    .grid2 { grid-template-columns: 1fr 1fr; }
    .grid3 { grid-template-columns: repeat(3, 1fr); }
    .grid-ref { grid-template-columns: 160px 1fr; }
    .grid-cp { grid-template-columns: 140px 1fr; }
}
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
form.inline { display: inline; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }

/* ---------- Cartes / mise en page ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; }
section.card { display: grid; gap: .9rem; }
.narrow { max-width: 560px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar input[type=search] { flex: 1 1 220px; }
.toolbar select { flex: 0 1 200px; width: auto; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--radius); }
.empty .btn { margin-top: .5rem; }

.flash { padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border: 1px solid; }
.flash-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.flash-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.flash-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.flash-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem; font-weight: 700; padding: .12rem .5rem; border-radius: 999px; color: var(--c); background: color-mix(in srgb, var(--c) 12%, white); border: 1px solid color-mix(in srgb, var(--c) 30%, white); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.badge-urgent { --c: #dc2626; }
.badge-urgent::before { display: none; }
.tag { display: inline-block; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: .15rem .5rem; border-radius: 6px; background: #e2e8f0; color: #334155; }
.tag-en_cours { background: #ffedd5; color: #9a3412; }
.tag-preparation { background: #e0e7ff; color: #3730a3; }
.tag-suspendu { background: #fef3c7; color: #92400e; }
.tag-reception { background: #dbeafe; color: #1e40af; }
.tag-termine { background: #dcfce7; color: #166534; }
.count { display: inline-block; min-width: 1.4em; padding: 0 .35em; border-radius: 999px; background: rgba(15,23,42,.08); font-size: .8em; text-align: center; }

.num-badge {
    display: inline-grid; place-items: center; flex: none;
    min-width: 30px; height: 30px; padding: 0 6px; border-radius: 999px;
    background: var(--c); color: #fff; font-weight: 800; font-size: .9rem;
    box-shadow: 0 0 0 2px #fff, 0 1px 3px rgba(0,0,0,.3);
}
.num-badge.urgent { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--danger); }

/* ---------- Liste des chantiers ---------- */
.cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.chantier-card { display: grid; gap: .35rem; color: inherit; transition: border-color .15s, transform .1s; }
.chantier-card:hover { text-decoration: none; border-color: var(--accent); }
.cc-top { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.cc-title { font-size: 1.1rem; margin: .2rem 0 0; }
.chantier-card p { margin: 0; }
.cc-stats { display: flex; gap: .75rem; flex-wrap: wrap; font-size: .85rem; margin-top: .4rem; padding-top: .6rem; border-top: 1px solid var(--line); }
.cc-stats .urgent { color: var(--danger); font-weight: 700; }

/* ---------- Page chantier ---------- */
.chantier-head h1 { margin: .3rem 0 .2rem; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-bottom: 1rem; }
.stat { display: grid; gap: 0; text-align: left; padding: .6rem .75rem; border-radius: var(--radius-sm); border: 1px solid var(--line); border-left: 4px solid var(--c); background: var(--surface); cursor: pointer; font: inherit; }
.stat strong { font-size: 1.4rem; line-height: 1.1; }
.stat span { font-size: .8rem; color: var(--muted); }
@media (max-width: 520px) { .stat { padding: .45rem .5rem; } .stat strong { font-size: 1.15rem; } .stat span { font-size: .7rem; } }

.tabs {
    display: flex; gap: .1rem; border-bottom: 2px solid var(--line); margin-bottom: 1rem;
    overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -ms-overflow-style: none;
    position: sticky; top: 60px; background: var(--bg); z-index: 5;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs.more-right { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
.tabs a { padding: .7rem .75rem; color: var(--muted); font-weight: 600; font-size: .95rem; border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; flex: none; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); }
@media (max-width: 520px) { .tabs a { padding: .7rem .6rem; font-size: .92rem; } }
.tabs-js .tab-panel { display: none; }
.tabs-js .tab-panel.active { display: block; }
.tab-panel { margin-bottom: 2rem; }

.plan-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin-bottom: 1rem; }
.plan-card { padding: 0; overflow: visible; display: grid; grid-template-columns: 1fr auto; position: relative; }
.plan-thumb { grid-column: 1 / -1; display: grid; place-items: center; aspect-ratio: 4 / 3; background: #f8fafc; border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; }
.plan-thumb img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.plan-thumb-ph { font-weight: 800; color: var(--line-2); font-size: 2rem; }
.plan-info { display: grid; padding: .6rem .8rem; }
.plan-title { font-weight: 700; color: var(--ink); }
.plan-card .menu { align-self: center; margin-right: .3rem; }
.upload-card { display: grid; gap: .6rem; }
.upload-row { display: grid; gap: .5rem; }
@media (min-width: 760px) { .upload-row { grid-template-columns: 1fr 1.3fr auto; } }

details.menu { position: relative; }
details.menu > summary { list-style: none; cursor: pointer; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 240px; display: grid; gap: .6rem; padding: .8rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.menu-pop form { display: grid; gap: .4rem; }
.menu-pop label { display: grid; gap: .25rem; font-size: .85rem; font-weight: 600; }

.notes-list { display: grid; gap: .6rem; }
.note-card { display: flex; align-items: flex-start; gap: .8rem; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.note-card:hover { border-color: var(--accent); }
.note-body { display: grid; gap: .3rem; flex: 1; min-width: 0; }
.note-title { font-weight: 700; }
.note-sub { display: flex; flex-wrap: wrap; gap: .3rem .7rem; align-items: center; font-size: .82rem; color: var(--ink-2); }
.note-sub .late { color: var(--danger); font-weight: 700; }
.note-desc { font-size: .88rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.note-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius-sm); flex: none; }

.report-list { display: grid; gap: .6rem; }
.report-item { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.report-main { display: grid; gap: .2rem; min-width: 0; }
.report-title { font-weight: 700; }
.report-actions { display: flex; gap: .4rem; align-items: center; }
.sent { color: var(--success); font-weight: 600; }

.infos { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0; }
.infos dt { color: var(--muted); }
.infos dd { margin: 0; font-weight: 600; }

.interv-list { display: grid; gap: .75rem; }
.interv-row { display: grid; gap: .5rem; padding: .75rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #f8fafc; }
@media (min-width: 900px) { .interv-row { grid-template-columns: 1.1fr 1fr 1fr 1.3fr 1fr auto auto; align-items: center; padding: .5rem; } }
.danger-zone { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px dashed var(--line-2); }

/* ---------- Tableaux ---------- */
.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #f8fafc; }
.table tr:last-child td { border-bottom: 0; }
.table tr.inactive td { opacity: .55; }
.table select { width: auto; min-height: 36px; padding: .25rem .5rem; }
.table .actions { text-align: right; }
@media (max-width: 700px) {
    .table thead { display: none; }
    .table tr { display: grid; padding: .6rem .8rem; border-bottom: 1px solid var(--line); }
    .table td { border: 0; padding: .2rem 0; }
    .table td[data-label]::before { content: attr(data-label) " : "; color: var(--muted); font-size: .8rem; }
    .table .actions { text-align: left; }
}

/* ---------- Connexion / installation ---------- */
.auth-page { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 1rem; background: linear-gradient(160deg, #1e293b, #0f172a); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 16px; padding: 1.75rem; box-shadow: var(--shadow-lg); }
.auth-card.wide { max-width: 620px; }
.auth-brand { text-align: center; margin-bottom: 1.25rem; }
.auth-brand h1 { margin: .5rem 0 0; font-size: 1.35rem; }
.auth-brand p { margin: 0; }
.checks { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .25rem; font-size: .9rem; }
.checks .ok { color: var(--success); }
.checks .ko { color: var(--danger); font-weight: 700; }

/* ---------- Fenêtres modales ---------- */
.modal-open { overflow: hidden; }
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(15, 23, 42, .5); display: flex; align-items: center; justify-content: center; padding: 1rem; animation: fade .15s; }
.modal { width: 100%; max-width: 620px; max-height: calc(100dvh - 2rem); display: flex; flex-direction: column; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); animation: rise .18s; }
.modal-wide { max-width: 900px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .75rem .75rem .75rem 1.25rem; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 1.1rem; display: flex; align-items: center; gap: .6rem; }
.modal-body { padding: 1rem 1.25rem calc(1.25rem + var(--safe-b)); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding-top: .5rem; border-top: 1px solid var(--line); margin-top: .25rem; position: sticky; bottom: calc(-1.25rem - var(--safe-b)); background: var(--surface); padding-bottom: .75rem; }
.modal-actions .spacer { flex: 1; }
@media (max-width: 640px) {
    .modal-backdrop { padding: 0; align-items: flex-end; }
    .modal { max-height: 94dvh; border-radius: 16px 16px 0 0; }
    .modal-actions .btn { flex: 1 1 auto; }
    .modal-actions .spacer { display: none; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(20px); opacity: .5; } }

/* Note */
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: .35rem; }
@media (max-width: 420px) { .seg { grid-template-columns: repeat(2, 1fr); } }
.seg-item { position: relative; cursor: pointer; }
.seg-item input { position: absolute; opacity: 0; pointer-events: none; }
.seg-item span { display: grid; place-items: center; min-height: var(--tap); padding: .3rem; border-radius: var(--radius-sm); border: 2px solid var(--line); font-weight: 700; font-size: .88rem; color: var(--c); text-align: center; background: #fff; }
.seg-item input:checked + span { background: var(--c); border-color: var(--c); color: #fff; }
.seg-item input:focus-visible + span { outline: 2px solid var(--ink); }
.urgent-check { align-self: end; min-height: var(--tap); padding: 0 .75rem; border: 2px solid var(--line); border-radius: var(--radius-sm); }
.urgent-check:has(input:checked) { border-color: var(--danger); color: var(--danger); background: #fef2f2; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: .5rem; }
.photo-tile, .photo-add { position: relative; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; background: #f1f5f9; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-del { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(15,23,42,.7); color: #fff; cursor: pointer; font-size: .85rem; }
.photo-add { display: grid; place-content: center; justify-items: center; gap: .2rem; border: 2px dashed var(--line-2); color: var(--muted); cursor: pointer; font-size: .8rem; font-weight: 600; }
.photo-add:hover { border-color: var(--accent); color: var(--accent); }
.photo-tile.uploading { display: grid; place-items: center; padding: .75rem; }
.progress { width: 100%; height: 6px; border-radius: 3px; background: #cbd5e1; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.recipients { display: grid; gap: .4rem; max-height: 240px; overflow-y: auto; padding: .25rem; }
.recipients label.check { align-items: flex-start; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: var(--radius-sm); font-weight: 400; }

/* Notification */
.toast { position: fixed; left: 50%; bottom: calc(1.25rem + var(--safe-b)); z-index: 200; transform: translate(-50%, 150%); max-width: min(92vw, 520px); padding: .75rem 1.1rem; border-radius: 12px; background: #0f172a; color: #fff; font-weight: 600; box-shadow: var(--shadow-lg); transition: transform .25s, opacity .25s, visibility .25s; pointer-events: none; opacity: 0; visibility: hidden; }
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
.toast-success { background: #166534; }
.toast-error { background: #991b1b; }

/* ---------- Visionneuse de plan ---------- */
.plan-page { height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
.plan-main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.plan-main > .flash { margin: .5rem; }
.plan-toolbar {
    display: flex; align-items: center; gap: .4rem; flex-wrap: wrap;
    padding: .35rem max(.5rem, env(safe-area-inset-left));
    background: var(--brand); color: #fff;
}
.plan-toolbar .icon-btn { color: #fff; }
.plan-toolbar .icon-btn:hover { background: rgba(255,255,255,.12); }
.plan-toolbar a.icon-btn:hover { text-decoration: none; }
.pt-title { display: grid; min-width: 0; flex: 1 1 160px; line-height: 1.2; }
.pt-chantier { font-size: .75rem; color: #94a3b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-title select { min-height: 32px; padding: .1rem .4rem; background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.25); font-weight: 700; }
.pt-title select option { color: var(--ink); }
.pt-group { display: flex; align-items: center; background: rgba(255,255,255,.08); border-radius: var(--radius-sm); }
.pt-group span { min-width: 3em; text-align: center; font-size: .9rem; }
.zoom-label { min-width: 3.6em; height: var(--tap); background: none; border: 0; color: #fff; font: inherit; font-size: .85rem; cursor: pointer; }
.plan-toolbar .btn-sm { background: rgba(255,255,255,.1); border-color: transparent; color: #fff; min-height: var(--tap); }
@media (max-width: 640px) {
    .plan-toolbar > a.icon-btn { order: -2; }
    .pt-title { order: -1; flex-basis: calc(100% - 52px); }
    .plan-toolbar #add-marker { margin-left: auto; }
}
.mode-banner { display: flex; align-items: center; justify-content: center; gap: .75rem; padding: .5rem .75rem; background: var(--accent); color: #fff; font-weight: 700; text-align: center; }
.mode-banner .btn { background: rgba(255,255,255,.95); border-color: transparent; color: var(--ink); }
.plan-layout { flex: 1; display: flex; min-height: 0; position: relative; }
.plan-stage { flex: 1; overflow: auto; background: #94a3b8; position: relative; touch-action: pan-x pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 8px; }
.page-wrap { position: relative; margin: 0 auto; background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.25); }
.page-wrap canvas { display: block; width: 100%; height: 100%; }
.placing .page-wrap { cursor: crosshair; }
.placing .marker { pointer-events: none; opacity: .65; }
.plan-loading { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 700; padding: 1rem; text-align: center; }
.markers { position: absolute; inset: 0; pointer-events: none; }
.drawings { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.drawing .drawings { pointer-events: all; touch-action: none; cursor: crosshair; }
.drawing .marker { pointer-events: none; }
.note-drawing.dim { opacity: .35; }
.draw-bar { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem 1rem; padding: .4rem .5rem; background: #111a2e; }
.btn-dark { background: var(--brand); border-color: var(--brand); color: #fff; }
.marker {
    position: absolute; transform: translate(-50%, -50%); pointer-events: auto;
    min-width: 30px; height: 30px; padding: 0 6px; border-radius: 999px;
    border: 2px solid #fff; background: var(--c); color: #fff; font: 800 .85rem/1 system-ui, sans-serif;
    box-shadow: 0 2px 6px rgba(0,0,0,.45); cursor: pointer; display: grid; place-items: center;
    transition: transform .12s;
}
.marker::after { content: ""; position: absolute; inset: -9px; border-radius: 999px; } /* zone de toucher élargie */
.marker:hover, .marker.selected { transform: translate(-50%, -50%) scale(1.2); z-index: 2; }
.marker.selected { box-shadow: 0 0 0 3px var(--ink), 0 2px 8px rgba(0,0,0,.5); }
.marker.urgent { box-shadow: 0 0 0 3px var(--danger), 0 2px 6px rgba(0,0,0,.45); }
.marker.closed { opacity: .75; }
.marker.pulse { animation: pulse 1s ease-out 2; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c) 80%, transparent); } 100% { box-shadow: 0 0 0 22px transparent; } }

.plan-side { display: none; width: 320px; flex: none; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line); min-height: 0; }
.side-open .plan-side { display: flex; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: .4rem .5rem .4rem 1rem; border-bottom: 1px solid var(--line); }
.plan-side > label.check { padding: .6rem 1rem; border-bottom: 1px solid var(--line); }
.side-list { overflow-y: auto; padding: .5rem; display: grid; gap: .35rem; align-content: start; }
.side-list > p { padding: .5rem; }
.side-item { display: flex; gap: .6rem; align-items: center; text-align: left; width: 100%; padding: .55rem; border: 1px solid transparent; border-radius: var(--radius-sm); background: none; font: inherit; color: inherit; cursor: pointer; }
.side-item:hover { background: #f8fafc; border-color: var(--line); }
.side-item.selected { background: #fff7ed; border-color: #fed7aa; }
.side-text { display: grid; min-width: 0; }
.side-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 899px) {
    .plan-side { position: absolute; inset: auto 0 0 0; width: auto; max-height: 60%; border-left: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; box-shadow: var(--shadow-lg); z-index: 10; padding-bottom: var(--safe-b); }
}
@media (min-width: 900px) { .side-close { display: none; } }

/* ---------- Rapport ---------- */
.report-form { display: grid; gap: 1rem; }
.report-preview { display: grid; gap: .4rem; }
.preview-item { display: flex; gap: .6rem; align-items: center; padding: .45rem .6rem; border-radius: var(--radius-sm); background: #f8fafc; font-size: .92rem; }
.preview-item .t { flex: 1; min-width: 0; }
.statut-checks { display: flex; flex-wrap: wrap; gap: .5rem 1rem; }
.gen-progress { display: grid; gap: .5rem; }
.logo-field { display: grid; gap: .5rem; }
.logo-preview { max-height: 70px; max-width: 220px; object-fit: contain; background: #f8fafc; padding: .25rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }

/* ---------- Dessin sur photo ---------- */
.annot { position: fixed; inset: 0; z-index: 300; display: flex; flex-direction: column; background: #0b1220; color: #fff; }
.annot-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem max(.75rem, env(safe-area-inset-left)); padding-top: max(.5rem, env(safe-area-inset-top)); }
.annot-title { font-weight: 700; }
.annot-top .btn:not(.btn-primary) { background: rgba(255,255,255,.12); border-color: transparent; color: #fff; }
.annot-stage { flex: 1; min-height: 0; position: relative; }
.annot-stage canvas { position: absolute; inset: 0; touch-action: none; cursor: crosshair; }
.annot-tools { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem 1.25rem; padding: .5rem .5rem calc(.6rem + var(--safe-b)); background: #111a2e; }
.annot-group { display: flex; align-items: center; gap: .3rem; }
.annot-tool { display: grid; justify-items: center; gap: 1px; min-width: 52px; padding: .3rem .25rem; border: 0; border-radius: 10px; background: transparent; color: #cbd5e1; font: inherit; font-size: .68rem; cursor: pointer; }
.annot-tool.active { background: var(--accent); color: #fff; }
.annot-color { width: 30px; height: 30px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25); background: var(--c); cursor: pointer; padding: 0; }
.annot-color.active { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.photo-edit { position: absolute; bottom: 4px; right: 4px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; cursor: pointer; display: grid; place-items: center; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.photo-tile.pending::after { content: "⏳"; position: absolute; left: 4px; bottom: 4px; font-size: .8rem; background: rgba(255,255,255,.85); border-radius: 6px; padding: 0 3px; }
.photo-tile.uploading-overlay { opacity: .5; pointer-events: none; }

/* ---------- Hors-ligne ---------- */
.net-indicator { position: fixed; left: max(.75rem, env(safe-area-inset-left, 0px)); bottom: calc(.75rem + var(--safe-b)); z-index: 150; border: 0; border-radius: 999px; padding: .45rem .9rem; font: inherit; font-size: .85rem; font-weight: 700; background: var(--accent); color: #fff; box-shadow: var(--shadow-lg); cursor: pointer; }
.net-indicator.off { background: #475569; }
.net-indicator.syncing { background: #2563eb; }
.marker.pending { border-style: dashed; }
.pending-tag { font-size: .75rem; font-weight: 700; color: #92400e; background: #fef3c7; border-radius: 6px; padding: 0 .4rem; }
.offline-btn.ready { border-color: #86efac; background: #f0fdf4; color: #166534; }
.offline-btn.ready span::after { content: " ✓"; }

/* ---------- Métré (devis) ---------- */
.amount { white-space: nowrap; }
.total-line { text-align: right; margin: .25rem .25rem 0; }
.devis-item { color: inherit; }
.devis-item:hover { text-decoration: none; border-color: var(--accent); }
.add-devis { margin-top: 1rem; }
.add-devis > summary { cursor: pointer; margin: 0; list-style: none; }
.add-devis[open] > summary { margin-bottom: .75rem; }
.menu-pop.wide { min-width: 300px; }
.icon-btn.sm { width: 32px; height: 32px; font-size: 1rem; }
.icon-btn:disabled { opacity: .3; cursor: default; }
.postes-editor { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.postes-editor > :first-child { border-radius: var(--radius) var(--radius) 0 0; }
.postes-editor > .pt-row:last-of-type { border-bottom: 0; }
.postes-editor > .empty { border: 0; }
.pt-head, .pt-row { display: grid; grid-template-columns: 72px 1fr 56px 64px 92px 104px 112px 104px; gap: .4rem; align-items: start; padding: .35rem .5rem; }
.pt-head { background: #f8fafc; font-size: .75rem; font-weight: 700; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); position: sticky; top: 60px; z-index: 3; box-shadow: 0 1px 0 var(--line); }
.pt-row { border-bottom: 1px solid var(--line); }
.pt-row input, .pt-row textarea { min-height: 36px; padding: .35rem .5rem; font-size: 15px; }
.pt-row textarea { resize: none; overflow: hidden; min-height: 36px; line-height: 1.35; }
.pt-q, .pt-pu { text-align: right; }
.pt-mm { text-transform: uppercase; text-align: center; padding-left: .2rem !important; padding-right: .2rem !important; }
.pt-total { align-self: center; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pt-actions { display: flex; justify-content: flex-end; }
.pt-row.chapitre { background: #f1f5f9; grid-template-columns: 72px 1fr 112px 104px; }
.pt-row.chapitre .pt-desc { font-weight: 700; }
.pt-row.chapitre .pt-total { color: var(--muted); }
@media (max-width: 860px) {
    .pt-head { display: none; }
    .pt-row { grid-template-columns: 64px 1fr 1fr 1fr; grid-template-areas: "num desc desc desc" "mm u q pu" "tot tot act act"; }
    .pt-row .pt-mm { grid-area: mm; }
    .pt-row .pt-num { grid-area: num; } .pt-row .pt-desc { grid-area: desc; } .pt-row .pt-u { grid-area: u; }
    .pt-row .pt-q { grid-area: q; } .pt-row .pt-pu { grid-area: pu; } .pt-row .pt-total { grid-area: tot; text-align: left; }
    .pt-row .pt-actions { grid-area: act; }
    .pt-row.chapitre { grid-template-columns: 64px 1fr; grid-template-areas: "num desc" "tot act"; }
    .pt-row.chapitre .pt-total:empty { display: none; }
}
.editor-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .75rem 0 5rem; }
.editor-actions .spacer { flex: 1; }
.editor-total { font-size: 1.05rem; }
.savebar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(1rem + var(--safe-b)); z-index: 60; display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem .5rem 1rem; background: var(--brand); color: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); width: min(560px, calc(100vw - 2rem)); }
.savebar .spacer { flex: 1; }
.savebar > span:first-child { flex: 1; font-weight: 600; }
.savebar .btn:not(.btn-primary) { background: rgba(255,255,255,.12); border-color: transparent; color: #fff; }
.savebar .btn-danger-text { color: #fca5a5 !important; }
.savebar #save-state { color: #cbd5e1; flex: 0 1 auto; }
.import-box .form { margin-bottom: 1rem; }
.map-grid { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: .5rem; }
.map-grid label { display: grid; gap: .25rem; font-weight: 600; font-size: .85rem; }
.preview-table { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: .75rem; }
.preview-table .table td, .preview-table .table th { padding: .35rem .5rem; font-size: .85rem; }
.preview-table tr.chap td { background: #f1f5f9; }
@media (max-width: 700px) { .preview-table .table tr { display: table-row; } .preview-table .table td { display: table-cell; } .preview-table .table td::before { display: none; } }

/* ---------- Avancement ---------- */
.progress.big { height: 12px; border-radius: 6px; }
.progress.big span { border-radius: 6px; }
.progress-card { display: grid; gap: .5rem; margin-bottom: 1rem; }
.pc-row { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.new-etat { margin-top: 1rem; }
.etat-params { margin-bottom: 1rem; }
.et-devis { margin: 1.25rem 0 .5rem; }
.et-head, .et-row, .et-chap { display: grid; grid-template-columns: 56px 1fr 150px 120px 170px 150px; gap: .5rem; align-items: center; padding: .45rem .6rem; }
.et-head { font-size: .72rem; text-transform: uppercase; font-weight: 700; color: var(--muted); background: #f8fafc; border: 1px solid var(--line); border-radius: var(--radius-sm) var(--radius-sm) 0 0; position: sticky; top: 60px; z-index: 2; }
.et-row { background: var(--surface); border: 1px solid var(--line); border-top: 0; font-size: .88rem; }
.et-chap { background: #f1f5f9; border: 1px solid var(--line); border-top: 0; font-weight: 700; grid-template-columns: 64px 1fr auto; }
.et-devis-c, .et-prec, .et-mois, .et-cumul, .et-saisie { text-align: right; font-variant-numeric: tabular-nums; }
.et-mois { display: block; color: #166534; }
.mm-tag { display: inline-block; font-size: .7rem; font-weight: 700; color: var(--muted); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 .3rem; margin-left: .25rem; vertical-align: 1px; }
.et-row.moved .et-mois { color: #166534; }
.et-row.neg .et-mois { color: var(--danger); }
.et-row.over .et-input input, .et-row.over .et-cumul b { border-color: #f59e0b; background: #fffbeb; color: #b45309; }
.et-input { display: flex; align-items: center; gap: .3rem; }
.et-input input { text-align: right; min-height: 40px; font-weight: 700; }
.et-input em { font-style: normal; color: var(--muted); min-width: 1.6em; font-size: .85rem; }

@media (max-width: 860px) {
    .et-head { display: none; }
    .et-row { grid-template-columns: 1fr 1fr; grid-template-areas: "num num" "desc desc" "devis prec" "saisie cumul"; border-radius: 0; }
    .et-saisie { grid-area: saisie; text-align: left; } .et-saisie .et-mois { text-align: left; }
    .et-num { grid-area: num; font-weight: 700; color: var(--muted); } .et-desc { grid-area: desc; font-weight: 600; }
    .et-devis-c { grid-area: devis; text-align: left; } .et-prec { grid-area: prec; }
    .et-cumul { grid-area: cumul; align-self: end; }
    .et-prec::before { content: "Précédent "; color: var(--muted); font-size: .75rem; display: block; }
    .et-cumul::before { content: "Cumulé"; color: var(--muted); font-size: .75rem; display: block; }
    .et-saisie::before { content: "Réalisé ce mois"; color: var(--muted); font-size: .75rem; display: block; margin-bottom: 2px; }
    .et-chap { grid-template-columns: 48px 1fr; }
    .et-chap-actions { grid-column: 1 / -1; }
}
.etat-totals { margin: 1.25rem 0 6rem; display: grid; gap: .6rem; max-width: 520px; margin-left: auto; }
.et-progress { display: flex; justify-content: space-between; }
.et-recap { display: grid; grid-template-columns: 1fr auto; gap: .35rem 1rem; margin: 0; }
.et-recap dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.et-recap .strong { font-weight: 700; }
.et-recap .total { font-weight: 800; font-size: 1.1rem; padding-top: .4rem; border-top: 2px solid var(--ink); }
.envois { padding-left: 1.2rem; font-size: .88rem; color: var(--ink-2); }
.envois .fail { color: var(--danger); }
@media (max-width: 640px) {
    .savebar { width: calc(100vw - 1rem); gap: .4rem; padding: .45rem .5rem .45rem .75rem; bottom: calc(.5rem + var(--safe-b)); }
    .savebar .btn { padding: .3rem .6rem; font-size: .85rem; white-space: normal; line-height: 1.15; }
    .savebar #save-state { font-size: .75rem; max-width: 5.5rem; }
    .etat-bar .spacer { display: none; }
}

/* ---------- Plans : indices et versions ---------- */
.indice { font-size: .75rem; font-weight: 700; color: var(--muted); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 .3rem; margin-left: .2rem; vertical-align: 1px; }
.versions { display: grid; gap: .2rem; border-top: 1px solid var(--line); padding-top: .5rem; }
@media (min-width: 760px) { .upload-row:has(.indice-input) { grid-template-columns: 1fr 110px 1.3fr auto; } }

/* ---------- Documents ---------- */
.doc-cat { margin: 1.25rem 0 .5rem; }
.doc-list { padding: .25rem; margin-bottom: 1rem; }
.doc-item { display: flex; align-items: center; gap: .75rem; padding: .5rem; border-radius: var(--radius-sm); }
.doc-item + .doc-item { border-top: 1px solid var(--line); }
.doc-ico { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 8px; background: #e2e8f0; color: #334155; font-size: .7rem; font-weight: 800; text-decoration: none; }
.doc-ico.ext-pdf { background: #fee2e2; color: #b91c1c; }
.doc-ico.ext-doc, .doc-ico.ext-docx { background: #dbeafe; color: #1d4ed8; }
.doc-ico.ext-xls, .doc-ico.ext-xlsx, .doc-ico.ext-csv { background: #dcfce7; color: #15803d; }
.doc-ico.ext-jpg, .doc-ico.ext-jpeg, .doc-ico.ext-png { background: #fef3c7; color: #b45309; }
.doc-ico:hover { text-decoration: none; }
.doc-main { flex: 1; min-width: 0; display: grid; color: inherit; }
.doc-main:hover { text-decoration: none; }
.doc-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shared { color: #15803d; font-weight: 600; }

/* ---------- Journal ---------- */
.journal-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.journal-item { color: inherit; }
.journal-item:hover { text-decoration: none; border-color: var(--accent); }
.journal-nav { display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.journal-nav .icon-btn { font-size: 2rem; background: var(--surface); border: 1px solid var(--line); }
.journal-date { flex: 1; text-align: center; }
.journal-date h1 { margin: 0 0 .3rem; font-size: 1.25rem; }
.journal-date input { max-width: 200px; margin: 0 auto; display: block; }
.journal-form { margin-bottom: 6rem; }
.journal-form section { gap: .75rem; }
.meteo-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-flex; align-items: center; gap: .3rem; min-height: 40px; padding: .3rem .75rem; border: 2px solid var(--line); border-radius: 999px; background: #fff; font-weight: 600; font-size: .9rem; }
.chip input:checked + span { border-color: var(--accent); background: #fff7ed; color: var(--accent-dark); }
.eff-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.eff-rows { display: grid; gap: .4rem; }
.eff-row { display: grid; grid-template-columns: 1fr 96px 84px auto; gap: .4rem; align-items: center; }
.eff-n { display: flex !important; align-items: center; gap: .25rem; font-weight: 400 !important; }
.eff-n input { text-align: right; }
.eff-n span { color: var(--muted); font-size: .85rem; }
@media (max-width: 520px) { .eff-row { grid-template-columns: 1fr 1fr auto; } .eff-row .eff-soc { grid-column: 1 / -1; } }

/* ---------- Commentaires / accès intervenants ---------- */
.comments { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.comments li { padding: .45rem .6rem; border-radius: var(--radius-sm); background: #f8fafc; border-left: 3px solid var(--line-2); font-size: .9rem; }
.comments li.ext { background: #eff6ff; border-left-color: #2563eb; }
.comment-add { display: flex; gap: .4rem; margin-top: .4rem; }
.done-tag { font-size: .75rem; font-weight: 700; color: #1d4ed8; background: #dbeafe; border-radius: 6px; padding: 0 .4rem; }
.link-row { display: flex; gap: .4rem; }
.link-row input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }

/* Page intervenant */
.portail .topbar .brand span { max-width: 70vw; }
.portail-logo { max-height: 32px; max-width: 140px; background: #fff; border-radius: 4px; padding: 2px; }
.portail-head h1 { margin: .2rem 0; }
.portail-head p { margin: 0; }
.stat-row.three { grid-template-columns: repeat(3, 1fr); margin-top: 1rem; }
.stat-row.three .stat { cursor: default; }
.p-note { display: grid; gap: .75rem; margin-bottom: 1rem; scroll-margin-top: 70px; }
.p-note-head { display: flex; gap: .75rem; align-items: flex-start; }
.p-note-head h2 { margin: 0 0 .3rem; }
.p-note .pre { margin: 0; }
.p-crop { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: #fff; min-height: 60px; display: grid; place-items: center; }
.p-crop canvas { width: 100%; height: auto; display: block; }
.p-crop a { padding: .4rem; }
.p-form { border-top: 1px solid var(--line); padding-top: .75rem; }
.p-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; }
.file-btn { display: inline-flex !important; align-items: center; justify-content: center; min-height: var(--tap); border: 2px dashed var(--line-2); border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; color: var(--ink-2); }
.file-btn input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.p-done > summary { cursor: pointer; margin: 1.5rem 0 1rem; }
.portail h2 { margin-top: 1.75rem; }

/* ---------- Tableau de bord ---------- */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: .6rem; margin-bottom: 1.25rem; }
.kpi { --c: var(--brand); display: grid; padding: .8rem 1rem; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--c); border-radius: var(--radius); color: inherit; }
.kpi:hover { text-decoration: none; }
.kpi strong { font-size: 1.7rem; line-height: 1.1; }
.kpi span { color: var(--muted); font-size: .85rem; }
@media (max-width: 760px) { .kpis { grid-template-columns: repeat(3, 1fr); } .kpi { padding: .6rem; } .kpi strong { font-size: 1.3rem; } .kpi span { font-size: .72rem; } }
.dash-grid { display: grid; gap: 1.5rem; }
@media (min-width: 1000px) { .dash-grid { grid-template-columns: 1fr 340px; } }
.dash-grid h2 { margin-top: 0; }
.dash-grid section h2 + * + h2 { margin-top: 1.5rem; }
.todo-list { padding: .25rem; margin-bottom: 1.5rem; }
.todo-item { display: flex; gap: .75rem; align-items: flex-start; padding: .6rem; border-radius: var(--radius-sm); color: inherit; }
.todo-item + .todo-item { border-top: 1px solid var(--line); }
.todo-item:hover { background: #f8fafc; text-decoration: none; }
.todo-main { display: grid; gap: .25rem; min-width: 0; }
.todo-title { font-weight: 600; }
.late { color: var(--danger); font-weight: 700; }
.dash-table .urgent { color: var(--danger); font-weight: 700; }
.dash-table td.warn { color: #b45309; font-weight: 600; }
.mini-progress { height: 8px; border-radius: 4px; background: #e2e8f0; overflow: hidden; width: 140px; margin-bottom: .2rem; }
.mini-progress span { display: block; height: 100%; background: var(--accent); }
.activity { list-style: none; margin: 0; padding: .25rem; }
.activity li { display: grid; gap: .1rem; padding: .55rem .6rem; border-left: 3px solid transparent; }
.activity li + li { border-top: 1px solid var(--line); }
.activity li.ext { border-left-color: #2563eb; }
.activity a { color: var(--ink); font-weight: 500; }

/* ---------- Dossier technique ---------- */
.ft-code { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ft-table td { vertical-align: middle; }
.statut-select { width: auto; min-height: 34px; padding: .2rem .5rem; font-size: .85rem; font-weight: 700; color: var(--c); border-color: color-mix(in srgb, var(--c) 40%, white); background: color-mix(in srgb, var(--c) 8%, white); }
.fiche-grid { display: grid; gap: 1rem; }
@media (min-width: 900px) { .fiche-grid { grid-template-columns: 1.3fr 1fr; align-items: start; } }
.input-prefix { display: flex; align-items: center; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: #fff; padding-left: .6rem; }
.input-prefix b { color: var(--muted); }
.input-prefix input { border: 0; padding-left: .2rem; }
.versions-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.versions-list li { padding: .5rem .6rem; border-radius: var(--radius-sm); background: #f8fafc; border-left: 3px solid var(--line-2); }
.versions-list li.current { border-left-color: #16a34a; background: #f0fdf4; }
.ft-pick { display: grid; gap: .35rem; max-height: 420px; overflow-y: auto; padding: .25rem; }
.ft-pick label.check { align-items: flex-start; padding: .35rem .4rem; border-radius: var(--radius-sm); }
.ft-pick label.check:hover { background: #f8fafc; }
.result-card h2 { color: #166534; }
.dossier-summary { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.note-form.readonly .photo-del, .note-form.readonly .photo-edit, .note-form.readonly .photo-add, .note-form.readonly .comment-add,
.note-form.readonly [data-act=delete], .note-form.readonly [data-act=move], .note-form.readonly [data-act=draw], .note-form.readonly button[type=submit] { display: none !important; }
.plain-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: .9rem; }

/* ---------- Rôles et droits ---------- */
.role-cards { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin-bottom: 1rem; }
.role-card { display: grid; gap: .2rem; border-top: 4px solid var(--rc, var(--brand)); }
.role-admin { --rc: #7c3aed; } .role-gestionnaire { --rc: #2563eb; } .role-chef_equipe { --rc: #ea580c; } .role-ouvrier { --rc: #16a34a; }
.role-tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: .05rem .45rem; border-radius: 999px; color: var(--rc); background: color-mix(in srgb, var(--rc) 12%, white); border: 1px solid color-mix(in srgb, var(--rc) 30%, white); white-space: nowrap; }
.perm-table th.c, .perm-table td.c { text-align: center; }
.perm-table td { vertical-align: middle; }
.perm-table tr.scope-row td { background: #f8fafc; }
.lvl { display: inline-flex; border: 1px solid var(--line-2); border-radius: 999px; overflow: hidden; background: #fff; }
.lvl label { position: relative; cursor: pointer; }
.lvl input { position: absolute; opacity: 0; pointer-events: none; }
.lvl span { display: block; padding: .35rem .7rem; font-size: .82rem; font-weight: 600; color: var(--muted); }
.lvl label + label span { border-left: 1px solid var(--line); }
.lvl input:checked + span { color: #fff; background: #475569; }
.lvl .l-aucun input:checked + span { background: #94a3b8; }
.lvl .l-voir input:checked + span { background: #2563eb; }
.lvl .l-modifier input:checked + span { background: #16a34a; }
.lvl input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: -2px; }
.fixed { font-size: .82rem; font-weight: 700; color: #7c3aed; }
.fixed.none { color: var(--muted); font-weight: 500; }
.perm-actions { padding: 1rem; position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); }
@media (max-width: 700px) {
    .perm-table thead { display: table-header-group; }
    .perm-table tr { display: table-row; padding: 0; }
    .perm-table td { display: table-cell; padding: .5rem .4rem; }
    .perm-table td::before { display: none; }
    .lvl span { padding: .3rem .45rem; font-size: .72rem; }
}
.team-grid { display: grid; gap: .4rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.assign-list { display: grid; gap: .3rem; max-height: 260px; overflow-y: auto; min-width: 260px; }
.inline-menu { display: inline-block; margin-left: .3rem; }
.menu-pop.floating { position: fixed; right: auto; z-index: 90; overflow-y: auto; max-width: calc(100vw - 16px); }
.menu-pop { text-align: left; }
.menu-pop label.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; font-size: .9rem; }
.assign-list label.check { padding: .3rem .2rem; border-radius: 6px; }
.assign-list label.check:hover { background: #f8fafc; }

/* ---------- Notifications ---------- */
.notif-menu { margin-left: auto; }
.notif-menu + .user-menu { margin-left: 0; }
.notif-btn { position: relative; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; color: #cbd5e1; cursor: pointer; list-style: none; border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.05); }
.notif-btn::-webkit-details-marker { display: none; }
.notif-btn:hover, .notif-menu[open] .notif-btn { color: #fff; background: rgba(255,255,255,.12); }
.notif-count { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: #ef4444; color: #fff; font-size: .72rem; font-weight: 800; display: grid; place-items: center; border: 2px solid #1e293b; }
.notif-pop { width: min(380px, calc(100vw - 16px)); padding: 0; color: var(--ink); gap: 0; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: .6rem .6rem .6rem .9rem; border-bottom: 1px solid var(--line); }
.notif-list { max-height: 60vh; overflow-y: auto; }
.notif-item { display: flex; gap: .6rem; padding: .7rem .9rem; color: var(--ink); border-bottom: 1px solid var(--line); }
.notif-item:hover { background: #f8fafc; text-decoration: none; }
.notif-item.unread { background: #fff7ed; }
.notif-dot { flex: none; width: 9px; height: 9px; margin-top: .4rem; border-radius: 50%; background: transparent; }
.notif-item.unread .notif-dot { background: var(--accent); }
.notif-text { display: grid; gap: .15rem; font-size: .9rem; }
.notif-text span { color: var(--ink-2); font-size: .85rem; }
.notif-text small { color: var(--muted); font-size: .75rem; }
.notif-empty { padding: 1rem; }
@media (max-width: 760px) { .notif-menu { margin-left: 0; } .brand { margin-right: auto; } }

/* ---------- Demandes de matériel ---------- */
.dm-form { margin-bottom: 6rem; }
.dm-head { margin-bottom: .6rem; }
.dm-head h1 { margin: .2rem 0 0; }
.dm-card { padding: .9rem; }
.dm-top { display: flex; align-items: flex-end; justify-content: space-between; gap: .8rem; margin-bottom: .7rem; }
.dm-when { display: grid; gap: .2rem; font-weight: 600; font-size: .85rem; min-width: 0; flex: 0 1 220px; }
.dm-form input[type=date] { -webkit-appearance: none; appearance: none; min-width: 0; width: 100%; max-width: 100%; box-sizing: border-box; min-height: 44px; text-align: left; }
.dm-form input[type=date]::-webkit-date-and-time-value { text-align: left; }
.dm-cols, .dm-row { display: grid; grid-template-columns: minmax(0, 1fr) 72px 64px 34px; gap: .35rem; align-items: center; }
.dm-cols { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 0 .1rem .25rem; }
.dm-cols span:nth-child(2) { text-align: right; padding-right: .5rem; }
.dm-lines { display: grid; gap: .35rem; }
.dm-line { border-left: 3px solid transparent; padding-left: .25rem; margin-left: -.35rem; border-radius: 4px; }
.dm-line.st-commande { border-left-color: #ea580c; } .dm-line.st-livre { border-left-color: #16a34a; } .dm-line.st-indisponible { border-left-color: #dc2626; }
.dm-row input { min-width: 0; width: 100%; box-sizing: border-box; padding: .55rem .5rem; min-height: 44px; font-size: 16px; }
.dm-des { font-weight: 600; }
.dm-qty { text-align: right; font-weight: 700; }
.dm-del { width: 34px; height: 44px; border: 0; background: none; color: var(--muted); font-size: 1rem; cursor: pointer; border-radius: 6px; }
.dm-del:hover { color: #dc2626; background: #fee2e2; }
.dm-line:last-child[data-id=""] .dm-des:placeholder-shown ~ .dm-del { visibility: hidden; }
.dm-extra { padding: .15rem .3rem 0; }
.dm-process { display: grid; grid-template-columns: 150px 1fr; gap: .35rem; margin: .3rem 0 .5rem; }
.dm-status-line { padding: .2rem .3rem .3rem; }
.dm-more { margin-top: .8rem; }
.dm-more summary { cursor: pointer; color: var(--ink-2); font-size: .88rem; font-weight: 600; padding: .3rem 0; }
.dm-more textarea { margin-top: .4rem; width: 100%; box-sizing: border-box; }
.lst { font-size: .78rem; font-weight: 700; padding: .1rem .5rem; border-radius: 999px; background: #e2e8f0; color: #334155; }
.lst-commande { background: #ffedd5; color: #9a3412; } .lst-livre { background: #dcfce7; color: #166534; } .lst-indisponible { background: #fee2e2; color: #991b1b; }
@media (max-width: 520px) {
    .dm-card { padding: .7rem .6rem; }
    .dm-cols, .dm-row { grid-template-columns: minmax(0, 1fr) 58px 52px 30px; gap: .25rem; }
    .dm-row input { padding: .5rem .4rem; }
    .dm-del { width: 30px; }
    .dm-process { grid-template-columns: 1fr; }
}
.dm-form input[readonly], .dm-form textarea[readonly] { background: #f1f5f9; border-color: transparent; color: var(--ink); cursor: default; }
