/* ===== Intendance — feuille de style ===== */
:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --ink: #1c2a31;
  --muted: #66737a;
  --line: #e3dfd8;
  --primary: #1f4e5f;
  --primary-2: #2b6a80;
  --accent: #f0a93b;
  --side: #17323d;
  --side-ink: #cfdde2;
  --ok: #2f8a5b;
  --danger: #c4442f;
  --c-new: #3567c8;  --c-new-bg: #e6eeff;
  --c-plan: #7a4fc4; --c-plan-bg: #f0e9ff;
  --c-quote: #b57509; --c-quote-bg: #fff2d9;
  --c-work: #0f7f8c; --c-work-bg: #dcf4f5;
  --c-done: #2f8a5b; --c-done-bg: #e1f4e8;
  --c-off: #6f777b;  --c-off-bg: #eceeee;
  --c-late: #c4442f; --c-late-bg: #fde6e1;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 35, 40, .06), 0 2px 8px rgba(20, 35, 40, .04);
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45; -webkit-font-smoothing: antialiased;
}
a { color: var(--primary-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.2; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.02rem; letter-spacing: .01em; }
h3 { font-size: .95rem; }
code { background: #f0ede7; padding: .1em .35em; border-radius: 5px; font-size: .92em; }
code.pw { font-size: 1.1em; font-weight: 700; letter-spacing: .05em; }
.muted { color: var(--muted); }
.small, small { font-size: .84rem; }
.block { display: block; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; margin: 0; }
.spacer { flex: 1; }
.late { color: var(--danger); font-weight: 600; }
.empty { color: var(--muted); padding: 1.2rem; text-align: center; margin: 0; }

/* ----- Structure ----- */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side {
  background: var(--side); color: var(--side-ink); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 18px 12px;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 18px; }
.brand strong { display: block; color: #fff; font-size: 1.05rem; }
.brand small { display: block; opacity: .7; }
.brand.big { padding: 0 0 8px; }
.brand.big strong { color: var(--ink); font-size: 1.3rem; }
.logo {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent); color: var(--side); font-size: 20px; font-weight: 700; flex: none;
}
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.side nav a {
  color: var(--side-ink); padding: 9px 10px; border-radius: 8px; display: flex; gap: 10px; align-items: center;
}
.side nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.side nav a.on { background: rgba(240,169,59,.16); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.ico { width: 20px; text-align: center; opacity: .85; }
.who { display: flex; gap: 10px; align-items: center; border-top: 1px solid rgba(255,255,255,.1); padding: 14px 6px 0; }
.who strong { display: block; color: #fff; font-size: .9rem; }
.who small { display: block; opacity: .7; font-size: .76rem; }
.who > div:nth-child(2) { flex: 1; min-width: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-2); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.logout { color: var(--side-ink); font-size: 1.2rem; padding: 4px; }
.main { padding: 22px 28px 60px; min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.top h1 { margin: 0; }
.burger { display: none; background: none; border: 0; font-size: 1.5rem; cursor: pointer; color: var(--ink); }
.solo { max-width: 520px; margin: 7vh auto; padding: 0 16px; }

/* ----- Cartes & grilles ----- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.card-h h2 { margin: 0; }
.card-h.pad { padding: 16px 18px 6px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack > .card { margin-bottom: 0; }
.narrow { max-width: 720px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.grid-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 16px; align-items: start; margin-bottom: 16px; }
.grid-main > .card { margin: 0; }
.grid-detail { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; align-items: start; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1 1 160px; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.login { padding: 28px; }
.notice { border-color: var(--accent); background: #fffaf0; }

/* ----- Formulaires ----- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-weight: 600; font-size: .86rem; }
.field.xs { flex: 0 0 90px; }
input, select, textarea {
  font: inherit; color: inherit; background: #fff; border: 1px solid #d4cfc6; border-radius: 8px; padding: 8px 10px; width: 100%;
}
input[type=checkbox], input[type=radio] { width: auto; }
input[type=range] { padding: 0; accent-color: var(--primary); }
input[type=file] { border-style: dashed; background: #faf9f6; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(43,106,128,.35); border-color: var(--primary-2); }
textarea { resize: vertical; }
.check { display: inline-flex; gap: 7px; align-items: center; cursor: pointer; font-size: .9rem; }
fieldset.staff-only { border: 1px dashed var(--line); border-radius: 10px; padding: 12px; }
fieldset legend { font-size: .82rem; color: var(--muted); padding: 0 6px; }
.checklist { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; padding: 4px 0; }
form.inline { display: inline-flex; gap: 6px; align-items: center; }
form.inline input[type=date] { width: auto; padding: 5px 8px; }
.inline-form { align-items: flex-end; margin: 10px 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
  background: var(--primary); color: #fff; border: 1px solid var(--primary); border-radius: 8px;
  padding: 9px 16px; font: inherit; font-weight: 600; text-decoration: none !important; white-space: nowrap;
}
.btn:hover { background: var(--primary-2); }
.btn.small { padding: 5px 11px; font-size: .85rem; }
.btn.big { padding: 14px 22px; font-size: 1.05rem; }
.btn.wide { width: 100%; }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.ghost { background: transparent; color: var(--primary); border-color: #cfd8da; }
.btn.ghost:hover { background: #eef4f5; }
.btn.danger, .linkbtn.danger { color: var(--danger); }
.btn.ghost.danger:hover { background: var(--c-late-bg); }
.linkbtn { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; text-decoration: underline; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex-wrap: wrap; }
.seg a { padding: 6px 12px; font-size: .86rem; color: var(--ink); border-right: 1px solid var(--line); }
.seg a:last-child { border-right: 0; }
.seg a.on { background: var(--primary); color: #fff; }
.seg a:hover { text-decoration: none; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px; }
.filters input[type=search] { flex: 1 1 220px; width: auto; }
.filters select { width: auto; max-width: 210px; padding: 6px 8px; }

/* ----- Messages flash ----- */
.flash { padding: 10px 14px; border-radius: 9px; margin: 0 0 14px; border: 1px solid; }
.flash-success { background: var(--c-done-bg); border-color: #b7e0c7; color: #1f5f3e; }
.flash-error { background: var(--c-late-bg); border-color: #f2bcb1; color: #8d2a19; }
.flash-info { background: var(--c-new-bg); border-color: #c6d6fa; color: #23468c; }

/* ----- Badges ----- */
.badge, .prio, .tag, .role, .chip {
  display: inline-flex; align-items: center; gap: 4px; border-radius: 99px; padding: 2px 9px; font-size: .76rem; font-weight: 600; white-space: nowrap;
}
.st-new { background: var(--c-new-bg); color: var(--c-new); }
.st-plan { background: var(--c-plan-bg); color: var(--c-plan); }
.st-quote { background: var(--c-quote-bg); color: var(--c-quote); }
.st-work { background: var(--c-work-bg); color: var(--c-work); }
.st-done { background: var(--c-done-bg); color: var(--c-done); }
.st-off { background: var(--c-off-bg); color: var(--c-off); }
.st-late { background: var(--c-late-bg); color: var(--c-late); }
.prio::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.prio { padding-left: 0; background: none; }
.pr-low { color: #7d8a90; } .pr-normal { color: #3567c8; } .pr-high { color: #d07a0a; } .pr-urgent { color: var(--danger); }
.tag { background: #f0ede7; color: var(--muted); font-weight: 500; }
.tag.warn { background: var(--c-quote-bg); color: var(--c-quote); }
.chip { background: #f0ede7; color: var(--ink); font-weight: 500; margin: 2px; }
.chip em { color: var(--muted); font-style: normal; }
.chip .x { background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 1rem; padding: 0 0 0 2px; }
.role { background: #eef1f2; color: var(--ink); }
.r-superviseur { background: #17323d; color: #fff; } .r-admin { background: var(--c-work-bg); color: var(--c-work); }
.r-enseignant { background: var(--c-plan-bg); color: var(--c-plan); } .r-entreprise { background: var(--c-quote-bg); color: var(--c-quote); }

/* ----- Indicateurs ----- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); color: var(--ink); }
a.kpi:hover { text-decoration: none; border-color: var(--primary-2); }
.kpi-v { font-size: 1.6rem; font-weight: 750; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi-l { font-size: .82rem; color: var(--muted); }
.kpi.tone-new { border-top: 3px solid var(--c-new); } .kpi.tone-quote { border-top: 3px solid var(--c-quote); } .kpi.tone-late { border-top: 3px solid var(--c-late); }
.kpi.tone-late .kpi-v { color: var(--c-late); }

.progress { display: inline-block; width: 80px; height: 7px; background: #e8e4dd; border-radius: 99px; overflow: hidden; vertical-align: middle; margin-right: 6px; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--c-work), #22a3a3); border-radius: 99px; }
.big-progress { margin-top: 14px; display: flex; align-items: center; gap: 10px; }
.big-progress .progress { width: 220px; height: 10px; }
.bar-row { display: grid; grid-template-columns: 1fr 90px 26px; gap: 8px; align-items: center; font-size: .86rem; margin: 6px 0; }
.bar { height: 8px; background: #efebe5; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--primary-2); border-radius: 99px; }

/* ----- Tableaux ----- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #faf9f6; }
.table td { padding: 10px 12px; border-bottom: 1px solid #efece6; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table.rows tbody tr { cursor: pointer; }
.table.rows tbody tr:hover { background: #f8f6f2; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.ref { white-space: nowrap; }
.table td.ref a, .ref { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; color: var(--muted); }
.table input { padding: 5px 8px; }
.table td.xs { width: 80px; }
.table tr.inactive td { opacity: .55; }
.card > .table-wrap { margin: 0 -18px; }
.card:not(.flush) > .table-wrap .table th:first-child, .card:not(.flush) > .table-wrap .table td:first-child { padding-left: 18px; }

/* ----- Plan des locaux ----- */
.plan { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(170px, 1fr); gap: 10px; overflow-x: auto; padding: 12px 18px 6px; }
.plan-col { background: #faf9f6; border: 1px solid var(--line); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.plan-col header { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 6px; font-size: .84rem; border-bottom: 1px solid var(--line); margin-bottom: 2px; }
.plan-col .count { background: var(--primary); color: #fff; border-radius: 99px; font-size: .72rem; padding: 0 7px; font-weight: 700; }
.room { display: flex; align-items: center; gap: 7px; padding: 4px 6px; border-radius: 6px; color: var(--ink); font-size: .8rem; line-height: 1.2; }
.room:hover { background: #fff; text-decoration: none; box-shadow: 0 0 0 1px var(--line); }
.room .rn { flex: 1; min-width: 0; }
.room small { display: block; color: var(--muted); font-size: .7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room b { font-size: .72rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: #c9d6c9; }
.room.ok .dot { background: #bcd8c4; }
.room.p1 .dot { background: #8f9ca2; } .room.p2 .dot { background: #3567c8; } .room.p3 .dot { background: #e08a12; } .room.p4 .dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(196,68,47,.2); }
.room.p3, .room.p4 { font-weight: 600; }
.legend { display: flex; gap: 6px; flex-wrap: wrap; padding: 6px 18px 14px; }
.legend .room { padding: 0 6px; color: var(--muted); }

/* ----- Kanban ----- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.kcol { background: #ebe8e2; border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.kcol header { display: flex; justify-content: space-between; align-items: center; padding: 0 2px 4px; }
.kcard { background: #fff; border-radius: 9px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow); }
.kcard:hover { text-decoration: none; border-color: var(--primary-2); }
.kc-top, .kc-bot { display: flex; justify-content: space-between; align-items: center; gap: 6px; }

/* ----- Détail intervention ----- */
.head-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.stepper { list-style: none; padding: 0; margin: 0 0 16px; display: flex; gap: 6px; counter-reset: s; flex-wrap: wrap; }
.stepper li { flex: 1 1 110px; display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 9px; background: #ebe8e2; color: var(--muted); font-size: .86rem; font-weight: 600; }
.stepper li span { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: #fff; font-size: .76rem; }
.stepper li.past { background: var(--c-done-bg); color: var(--c-done); }
.stepper li.past span { background: var(--c-done); color: #fff; }
.stepper li.now { background: var(--primary); color: #fff; }
.stepper li.now span { background: var(--accent); color: var(--side); }
dl.info { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: .88rem; }
dl.info dt { color: var(--muted); }
dl.info dd { margin: 0; font-weight: 500; }
.files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.file { background: #f3f1ec; border: 1px solid var(--line); border-radius: 7px; padding: 4px 9px; font-size: .82rem; color: var(--ink); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details > summary { cursor: pointer; font-weight: 600; padding: 6px 0; color: var(--primary); }
details[open] > summary { margin-bottom: 8px; }
details.card > summary { color: var(--ink); }

.timeline { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 10px; }
.timeline li { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; }
.timeline li.mine { background: #f5fafb; border-color: #d2e5ea; }
.timeline li.t-systeme { background: transparent; border-style: dashed; color: var(--muted); font-size: .86rem; padding: 6px 12px; }
.timeline li.t-avancement { border-left: 3px solid var(--c-work); }
.timeline li.internal { background: #fffaf0; border-color: #f3dfb5; }
.t-h { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; margin-bottom: 3px; }
.t-h .when { margin-left: auto; }
.comment-form { border-top: 1px solid var(--line); padding-top: 12px; }
.comment-form input[type=file] { flex: 1 1 200px; width: auto; }

.devis { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.devis.d-valide { border-color: #9fd2b3; background: #f5fbf7; }
.devis.d-refuse, .devis.d-retire { opacity: .65; }
.devis-h { display: flex; justify-content: space-between; gap: 12px; }
.amount { text-align: right; font-weight: 750; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.devis-f { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.devis-form { border-top: 1px solid var(--line); padding-top: 12px; }

/* ----- Tableau de bord ----- */
.mini { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.mini li a { display: block; color: var(--ink); font-size: .88rem; }
.feed { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.feed li { padding: 7px 0; border-bottom: 1px solid #efece6; }
.feed li:last-child { border: 0; }
.feed li.sys { color: var(--muted); }
.feed .when { display: inline-block; min-width: 92px; color: var(--muted); font-size: .8rem; }
.hero { display: flex; align-items: center; justify-content: space-between; gap: 20px; background: linear-gradient(120deg, var(--primary), #27657a); color: #fff; border-radius: var(--radius); padding: 24px; margin-bottom: 16px; flex-wrap: wrap; }
.hero h2 { font-size: 1.3rem; }
.hero p { margin: 0; opacity: .9; max-width: 560px; }
.hero .btn { background: var(--accent); border-color: var(--accent); color: var(--side); }
ul.checks { padding-left: 1.1em; margin: 0; }
ul.checks li { margin: 6px 0; }

/* ----- Mobile ----- */
@media (max-width: 1100px) {
  .grid-detail, .grid-main { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .burger { display: block; }
  .main { padding: 14px 16px 50px; }
  .grid-2 { grid-template-columns: 1fr; }
  .filters select { max-width: none; flex: 1 1 140px; }
  .table.rows thead { display: none; }
  .table.rows tbody tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .table.rows td { border: 0; padding: 0; }
  .table.rows td:nth-child(2) { grid-column: 1 / -1; order: -1; }
  .kpi-v { font-size: 1.3rem; }
}

/* ----- Mode aperçu « voir comme » ----- */
.preview-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; background: #fff2d9; border: 1px solid #f0c77a; color: #6b4705; border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; position: sticky; top: 8px; z-index: 20; }
.preview-bar .btn { background: #b57509; border-color: #b57509; }
ul.pick { list-style: none; margin: 0; padding: 0; }
ul.pick li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid #efece6; }
ul.pick li:last-child { border: 0; }
.readonly-note { background: #eef4f5; border-radius: 9px; padding: 10px 12px; font-size: .88rem; color: var(--primary); }
