/* ===== Tokens ===== */
:root {
  --bg: #f5f6fa; --surface: #fff; --surface-2: #f0f2f7; --border: #e3e6ee; --border-2: #d3d8e3;
  --text: #0f172a; --text-2: #334155; --muted: #64748b;
  --accent: #4f46e5; --accent-h: #4338ca; --accent-soft: #eef0ff; --on-accent: #fff;
  --ok: #16a34a; --warn: #d97706; --err: #dc2626; --info: #2563eb; --gray: #64748b;
  --violet: #7c3aed; --teal: #0d9488; --orange: #ea580c; --star: #f59e0b;
  --r: 14px;
  --shadow: 0 1px 2px rgb(15 23 42 / .04), 0 2px 8px rgb(15 23 42 / .04);
  --shadow-lg: 0 12px 32px rgb(15 23 42 / .10);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0e14; --surface: #131824; --surface-2: #1b2232; --border: #242c3d; --border-2: #323c50;
    --text: #e6e9f0; --text-2: #c2c9d6; --muted: #8b95a8;
    --accent: #818cf8; --accent-h: #a5b4fc; --accent-soft: #1f2250; --on-accent: #0b0e14;
    --ok: #4ade80; --warn: #fbbf24; --err: #f87171; --info: #60a5fa; --gray: #94a3b8;
    --violet: #a78bfa; --teal: #2dd4bf; --orange: #fb923c;
    --shadow: 0 1px 2px rgb(0 0 0 / .3); --shadow-lg: 0 12px 32px rgb(0 0 0 / .45);
    color-scheme: dark;
  }
}

/* ===== Base ===== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.015em; }
p { margin: 0; }
img { display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.i { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.push { margin-left: auto; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.pad { padding: 4px 0 14px; }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }
.link { font-weight: 600; }
.link:hover { color: var(--accent); }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ===== Layout ===== */
.app { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100dvh; }
.side {
  position: sticky; top: 0; height: 100dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px; padding: 18px 14px 12px;
  background: var(--surface); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 12px; }
.brand img { border-radius: 9px; }
.brand strong { display: block; font-size: 15px; letter-spacing: -.01em; }
.brand small { display: block; color: var(--muted); font-size: 12px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
  color: var(--text-2); font-weight: 500; font-size: 14px; transition: background .15s, color .15s;
}
.nav a:hover { background: var(--surface-2); }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a small { color: var(--muted); font-weight: 400; }
.nav a.faint { color: var(--muted); }
.nav .pill {
  margin-left: auto; font-style: normal; font-size: 11.5px; font-weight: 700; min-width: 22px; text-align: center;
  padding: 1px 7px; border-radius: 99px; background: var(--accent); color: var(--on-accent);
}
.nav-label {
  margin: 18px 10px 6px; font-size: 11px; font-weight: 650; letter-spacing: .07em;
  text-transform: uppercase; color: var(--muted);
}
.dot {
  width: 9px; height: 9px; border-radius: 50%; flex: none; margin: 0 4px;
  background: var(--c, var(--muted)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c, var(--muted)) 22%, transparent);
}
.me { display: flex; align-items: center; gap: 10px; padding: 12px 6px 2px; border-top: 1px solid var(--border); }
.me-name { flex: 1; min-width: 0; }
.me-name b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-name small { color: var(--muted); font-size: 12px; }

.main { padding: 30px clamp(16px, 3vw, 44px) 64px; width: 100%; max-width: 1400px; }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px 20px; flex-wrap: wrap; margin-bottom: 24px; }
.top h1 { font-size: 27px; font-weight: 750; }
.sub { margin-top: 8px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tabbar { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .main { padding: 18px 16px calc(96px + env(safe-area-inset-bottom)); }
  .top { margin-bottom: 18px; }
  .top h1 { font-size: 23px; }
  .tabbar {
    display: flex; position: fixed; inset: auto 0 0 0; z-index: 20;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
  }
  .tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0;
    font-size: 11px; font-weight: 600; color: var(--muted); border-radius: 12px;
  }
  .tabbar a.on { color: var(--accent); }
  .tabbar .i { width: 23px; height: 23px; }
  input, select, textarea { font-size: 16px !important; } /* évite le zoom iOS */
}

/* ===== Boutons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border-2);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .06s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn .i { width: 17px; height: 17px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 1px 2px rgb(79 70 229 / .25); }
.btn.primary:hover { background: var(--accent-h); border-color: var(--accent-h); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: transparent; color: var(--err); border-color: color-mix(in srgb, var(--err) 35%, transparent); }
.btn.danger:hover { background: color-mix(in srgb, var(--err) 10%, transparent); }
.btn.block { width: 100%; }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none;
  border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm .i { width: 16px; height: 16px; }

/* ===== Badges / statuts ===== */
.b {
  --c: var(--gray);
  display: inline-flex; align-items: center; gap: 6px; height: 23px; padding: 0 9px; border-radius: 99px;
  font-size: 12px; font-weight: 650; white-space: nowrap;
  background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c);
}
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; color: var(--text-2); white-space: nowrap; }
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }

.st-nouvelle { --c: var(--info); } .st-en_cours { --c: var(--warn); } .st-attente { --c: var(--gray); }
.st-terminee { --c: var(--ok); } .st-rejetee { --c: var(--err); }
.pr-basse { --c: var(--gray); } .pr-normale { --c: var(--info); } .pr-haute { --c: var(--orange); } .pr-urgente { --c: var(--err); }
.fs-identifie { --c: var(--gray); } .fs-contacte { --c: var(--info); } .fs-echange { --c: var(--violet); } .fs-devis { --c: var(--teal); }
.fs-negociation { --c: var(--warn); } .fs-retenu { --c: var(--ok); } .fs-ecarte { --c: var(--err); }
.sg-idee { --c: var(--gray); } .sg-partenaire { --c: var(--warn); } .sg-etude { --c: var(--violet); } .sg-dev { --c: var(--info); }
.sg-tests { --c: var(--teal); } .sg-indus { --c: var(--accent); } .sg-termine { --c: var(--ok); }
.role-admin { --c: var(--accent); }
.b.best { --c: var(--ok); margin-left: 6px; }

/* ===== Cartes & sections ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); }
.h2 { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; margin: 30px 0 12px; }
.h2 .i { color: var(--muted); }
.h2.flush { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow);
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.stat:hover { transform: translateY(-2px); border-color: var(--border-2); box-shadow: var(--shadow-lg); }
.stat-ico {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; flex: none;
  background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c);
}
.stat-ico .i { width: 21px; height: 21px; }
.stat b { display: block; font-size: 26px; font-weight: 750; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); font-size: 13px; }

.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.pcard {
  position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 14px; padding: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow);
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.pcard::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--c); }
.pcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--border-2); }
.pcard-head { display: flex; align-items: center; gap: 12px; }
.pcard-head strong { display: block; font-size: 16px; }
.pcard-head small { color: var(--muted); font-size: 13px; }
.pico {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; flex: none;
  background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--c); font-weight: 800; font-size: 14px; letter-spacing: .02em;
}
.steps { display: flex; gap: 4px; }
.steps i { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-2); }
.steps i.done { background: color-mix(in srgb, var(--c) 50%, transparent); }
.steps i.now { background: var(--c); }
.pcard-progress { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.pcard-progress b { font-variant-numeric: tabular-nums; min-width: 42px; text-align: right; }
.progress { flex: 1; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--accent)); transition: width .4s; }
.pcard-foot {
  display: flex; flex-direction: column; gap: 6px; padding-top: 12px; margin-top: auto;
  border-top: 1px dashed var(--border); font-size: 13px; color: var(--text-2);
}
.pcard-foot span { display: inline-flex; align-items: center; gap: 7px; }
.pcard-foot .i { width: 15px; height: 15px; color: var(--muted); }
.pcard-foot .ok-text .i, .pcard-foot .warn-text .i { color: currentColor; }

.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.panel { padding: 4px 18px 8px; }
.panel .h2 { margin: 16px 0 6px; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; align-items: flex-start; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.feed li:last-child { border-bottom: 0; }
.feed a:hover b { color: var(--accent); }
.feed .meta { margin-top: 4px; }

/* ===== Projet ===== */
.hero { padding: 22px; display: flex; flex-direction: column; gap: 22px; margin-bottom: 20px; border-top: 3px solid var(--c); }
.hero .desc { color: var(--text-2); max-width: 85ch; white-space: pre-wrap; }
.hero-meta { display: flex; align-items: center; gap: 12px 28px; flex-wrap: wrap; }
.stepper { list-style: none; margin: 0; padding: 0 0 4px; display: flex; overflow-x: auto; scrollbar-width: thin; }
.stepper li {
  position: relative; flex: 1; min-width: 104px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--muted); text-align: center; padding: 0 4px;
}
.stepper li::before { content: ""; position: absolute; top: 15px; left: -50%; right: 50%; height: 2px; background: var(--border); }
.stepper li:first-child::before { display: none; }
.stepper li span {
  position: relative; z-index: 1; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border-2); font-weight: 700; font-size: 12.5px;
}
.stepper li.done { color: var(--text-2); }
.stepper li.done span { background: var(--c); border-color: var(--c); color: #fff; }
.stepper li.done::before, .stepper li.now::before { background: var(--c); }
.stepper li.now { color: var(--text); font-weight: 700; }
.stepper li.now span { border-color: var(--c); color: var(--c); box-shadow: 0 0 0 5px color-mix(in srgb, var(--c) 18%, transparent); }

.tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs a {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; margin-bottom: -1px; white-space: nowrap;
  font-size: 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent;
}
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--accent); border-color: var(--accent); }
.tabs em, .seg em {
  font-style: normal; font-size: 11.5px; font-weight: 700; padding: 0 7px; border-radius: 99px;
  background: var(--surface-2); color: var(--text-2);
}

/* ===== Listes de demandes ===== */
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: 14px; padding: 13px 16px; border-bottom: 1px solid var(--border); transition: background .12s; }
.row:last-child { border-bottom: 0; }
.row:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.prio { width: 4px; align-self: stretch; border-radius: 4px; background: var(--c); flex: none; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.row-main strong { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main:hover strong { color: var(--accent); }
.row.is-done strong { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--border-2); }
.meta { display: flex; align-items: center; gap: 5px 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.who { display: inline-flex; align-items: center; gap: 7px; }
.due { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.due .i { width: 14px; height: 14px; }
.due.late { color: var(--err); font-weight: 650; }
.due.soon { color: var(--warn); font-weight: 650; }
@media (max-width: 640px) {
  .row { flex-wrap: wrap; row-gap: 10px; }
  .row-main { flex-basis: calc(100% - 20px); }
  .row-main strong { white-space: normal; }
  .row-act { margin-left: 18px; }
}

/* Select « pilule » coloré selon statut */
select { -webkit-appearance: none; appearance: none; }
select, .pill-sel {
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%;
  background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px !important;
}
.pill-sel {
  width: auto; height: 30px; padding: 0 12px; border-radius: 99px; font: inherit; font-size: 12.5px; font-weight: 650; cursor: pointer;
  color: var(--c); background-color: color-mix(in srgb, var(--c) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
}
.pill-sel option { color: var(--text); background: var(--surface); }

/* ===== Filtres ===== */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters select { width: auto; height: 40px; padding-block: 0; }
.search { position: relative; flex: 1 1 240px; display: block; }
.search .i { position: absolute; left: 12px; top: 50%; translate: 0 -50%; color: var(--muted); pointer-events: none; }
.search input { height: 40px; padding-left: 38px; }
.seg { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.seg a {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 99px;
  border: 1px solid var(--border); background: var(--surface); font-size: 13.5px; font-weight: 600; color: var(--text-2);
}
.seg a:hover { border-color: var(--border-2); }
.seg a.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.seg a.on em { background: color-mix(in srgb, var(--bg) 20%, transparent); color: var(--bg); }

/* ===== Tableau Kanban bureaux d'étude ===== */
.board {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 12px;
  overflow-x: auto; padding-bottom: 10px; scroll-snap-type: x proximity; scrollbar-width: thin;
}
.col { scroll-snap-align: start; display: flex; flex-direction: column; gap: 10px; min-height: 140px; padding: 10px; border-radius: var(--r); background: var(--surface-2); }
.col header { display: flex; align-items: center; gap: 6px; padding: 4px 4px 2px; font-size: 13px; font-weight: 700; }
.count { margin-left: auto; font-size: 12px; font-weight: 650; color: var(--muted); background: var(--surface); padding: 1px 8px; border-radius: 99px; }
.fcard {
  display: flex; flex-direction: column; gap: 8px; padding: 12px 12px 10px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--c); box-shadow: var(--shadow);
}
.fcard-title { font-weight: 700; font-size: 14.5px; line-height: 1.3; }
.fcard-title:hover { color: var(--accent); }
.kv { display: flex; gap: 18px; flex-wrap: wrap; }
.kv small { display: block; font-size: 10.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kv b { font-size: 14px; font-variant-numeric: tabular-nums; }
.stars { color: var(--star); letter-spacing: 1px; font-size: 14px; }
.next { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); background: var(--surface-2); padding: 6px 8px; border-radius: 8px; }
.next .i { width: 15px; height: 15px; color: var(--muted); }
.fcard-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; padding-top: 2px; }
.fcard-foot .row-act { margin-left: auto; }
.contacts { display: flex; gap: 2px; }
.fcard .pill-sel { height: 28px; font-size: 12px; }

/* ===== Tableaux ===== */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); margin-bottom: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  padding: 11px 14px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--border);
  font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: color-mix(in srgb, var(--surface-2) 50%, transparent);
}
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.is-out td { opacity: .5; }

/* ===== Journal ===== */
.note-form { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.note-form textarea { border: 0; padding: 6px 8px; box-shadow: none !important; min-height: 70px; background: transparent; }
.note-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.timeline { list-style: none; margin: 18px 0 0; padding: 0; }
.timeline li { position: relative; display: flex; gap: 12px; padding: 10px 0 14px; }
.timeline li::before { content: ""; position: absolute; left: 15px; top: 46px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.tl-body { flex: 1; min-width: 0; padding-top: 4px; }
.tl-body header { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.tl-body header form { margin-left: auto; }
.tl-body p { margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline li:not(.auto) .tl-body p { background: var(--surface); border: 1px solid var(--border); padding: 10px 14px; border-radius: 4px 12px 12px 12px; }
.timeline li.auto .tl-body p { color: var(--muted); font-size: 13.5px; margin-top: 0; }
.tl-ico { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; flex: none; background: var(--surface-2); color: var(--muted); }
.tl-ico .i { width: 16px; height: 16px; }

/* ===== Avatars ===== */
.av {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; flex: none;
  font-size: 12px; font-weight: 750; color: hsl(var(--h) 55% 32%); background: hsl(var(--h) 75% 90%);
}
.av.sm { width: 20px; height: 20px; font-size: 9px; }
@media (prefers-color-scheme: dark) { .av { color: hsl(var(--h) 80% 82%); background: hsl(var(--h) 35% 24%); } }

/* ===== Formulaires ===== */
.form { padding: 24px; max-width: 900px; }
.form.narrow { max-width: 640px; }
.form + .form { margin-top: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.full { grid-column: 1 / -1; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.grid { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--border); }
form > input[type=hidden] + fieldset.grid { margin-top: 0; padding-top: 0; border-top: 0; }
legend { float: left; width: 100%; padding: 0; margin-bottom: -2px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.hint { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); font-size: 12px; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 14.5px; color: var(--text); background-color: var(--surface);
  border: 1px solid var(--border-2); border-radius: 10px; padding: 9px 12px; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
input[type=color] { height: 42px; padding: 4px; cursor: pointer; }
input[type=range] { padding: 0; border: 0; accent-color: var(--accent); box-shadow: none !important; }
.range { display: flex; align-items: center; gap: 12px; height: 42px; }
.range output { min-width: 48px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text); }
.form-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--border); }

/* ===== Pièces jointes ===== */
.files { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.files li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.files li:last-child { border-bottom: 0; }
.files li:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.files a.grow { display: flex; flex-direction: column; }
.files b { font-size: 14px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files a.grow:hover b { color: var(--accent); }
.files small { font-size: 12px; font-weight: 400; }
.ext {
  --c: var(--accent);
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; flex: none;
  font-size: 10px; font-weight: 800; letter-spacing: .03em;
  background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c);
}
.x-pdf { --c: var(--err); }
.x-doc, .x-docx, .x-odt, .x-rtf, .x-txt { --c: var(--info); }
.x-xls, .x-xlsx, .x-ods, .x-csv { --c: var(--ok); }
.x-ppt, .x-pptx, .x-odp { --c: var(--orange); }
.x-png, .x-jpg, .x-jpeg, .x-webp { --c: var(--violet); }
.x-step, .x-stp, .x-iges, .x-igs, .x-stl, .x-dxf, .x-dwg { --c: var(--teal); }
.x-zip, .x-7z { --c: var(--warn); }
.drop {
  position: relative; flex-direction: row; align-items: center; gap: 14px; padding: 18px;
  border: 1.5px dashed var(--border-2); border-radius: 12px; background: var(--surface-2);
  color: var(--text-2); font-weight: 400; cursor: pointer; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over, .drop:focus-within { border-color: var(--accent); background: var(--accent-soft); }
.drop > .i { width: 26px; height: 26px; color: var(--accent); }
.drop small { color: var(--muted); font-size: 12.5px; }
.drop input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.clip {
  display: inline-flex; align-items: center; gap: 3px; height: 28px; padding: 0 7px; border-radius: 9px;
  font-size: 12px; font-weight: 650; color: var(--muted);
}
.clip:hover { background: var(--surface-2); color: var(--text); }
.clip .i { width: 15px; height: 15px; }

/* ===== États vides, toasts ===== */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 44px 20px; text-align: center;
  color: var(--muted); background: var(--surface); border: 1px dashed var(--border-2); border-radius: var(--r);
}
.empty p { max-width: 46ch; }
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50; translate: -50% 0;
  display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 32px);
  padding: 12px 18px; border-radius: 12px; background: var(--text); color: var(--bg);
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg);
  animation: toast 4.8s ease forwards; pointer-events: none;
}
.toast.err { background: var(--err); color: #fff; animation-duration: 7s; }
@keyframes toast {
  0% { opacity: 0; translate: -50% 14px; }
  6%, 88% { opacity: 1; translate: -50% 0; }
  100% { opacity: 0; translate: -50% 14px; visibility: hidden; }
}

/* ===== Connexion ===== */
.auth {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(900px 500px at 15% -10%, color-mix(in srgb, var(--accent) 20%, transparent), transparent),
              radial-gradient(700px 400px at 100% 110%, color-mix(in srgb, var(--teal) 14%, transparent), transparent), var(--bg);
}
.auth-card { width: min(410px, 100%); padding: 30px; display: flex; flex-direction: column; gap: 16px; box-shadow: var(--shadow-lg); }
.auth-card .brand { padding: 0 0 6px; }
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card .btn { height: 44px; margin-top: 4px; }

/* ===== Responsive ===== */
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1000px) { .cols { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) {
  .stats { gap: 10px; }
  .stat { padding: 14px; gap: 12px; }
  .stat b { font-size: 22px; }
  .hero { padding: 18px; }
  .form { padding: 18px; }
  /* Mobile : colonnes empilées, colonnes vides masquées */
  .board { display: flex; flex-direction: column; overflow: visible; padding-bottom: 0; }
  .col { min-height: 0; }
  .col:not(:has(.fcard)) { display: none; }
  .seg { flex-wrap: nowrap; overflow-x: auto; margin-inline: -16px; padding-inline: 16px; scrollbar-width: none; }
  .seg a { flex: none; }
  .toast { bottom: calc(86px + env(safe-area-inset-bottom)); }
  .form-foot .push { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { *, *::before { transition: none !important; animation-duration: .01s !important; } }
