:root {
  --blue: #1c3a5c;
  --blue-dark: #122b45;
  --brass: #b1863f;
  --brass-light: #d4ac6e;
  --stone: #efe7d6;
  --paper: #f8f4ea;
  --white: #fdfbf6;
  --ink: #221e17;
  --muted: #6f685b;
  --iron: #3d3a34;
  --line: rgba(34, 30, 23, .13);
  --ok: #3f6646;
  --bad: #8f3b2e;
  --s-idee: #8a8374;
  --s-devis: #b1863f;
  --s-vote: #4b6a8f;
  --s-encours: #1c3a5c;
  --s-termine: #3f6646;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: 'Public Sans', system-ui, sans-serif; font-size: 15px;
       line-height: 1.5; background: var(--paper); color: var(--ink); }
h1, h2, h3, .street { font-family: 'Fraunces', Georgia, serif; font-weight: 500; }
a { color: var(--blue); }
mark { background: #f3dfae; color: inherit; padding: 0 2px; }

/* --- Plaque de rue --- */
.plaque { background: linear-gradient(180deg, var(--blue), var(--blue-dark)); color: var(--white);
          border-bottom: 5px solid var(--brass); }
.plaque-inner { max-width: 1080px; margin: 0 auto; padding: 14px 16px; display: flex;
                align-items: center; gap: 14px; }
.door { width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0; display: flex;
        align-items: center; justify-content: center; text-decoration: none;
        font-family: 'Fraunces', serif; font-size: 22px; font-weight: 600; color: #2a1d08;
        background: radial-gradient(circle at 32% 28%, var(--brass-light), var(--brass) 60%, #8a662c);
        border: 2px solid #7a5a24; box-shadow: inset 0 2px 3px rgba(255,255,255,.35), inset 0 -3px 5px rgba(0,0,0,.3); }
.plaque-text { flex: 1; min-width: 0; }
.street { font-size: 21px; line-height: 1.1; }
.plaque .sub { font-size: 12.5px; color: rgba(253,251,246,.7); }
.who { display: flex; align-items: center; gap: 10px; margin: 0; }
.linkbtn { background: none; border: none; color: rgba(253,251,246,.75); font: inherit;
           font-size: 13px; cursor: pointer; padding: 0; text-decoration: underline; }
.linkbtn:hover { color: var(--white); }

@media (max-width: 480px) {
  .plaque .sub { display: none; }
  .who .avatar { display: none; }
}

.rail { background: var(--iron); position: sticky; top: 0; z-index: 5; }
.rail-inner { max-width: 1080px; margin: 0 auto; display: flex; overflow-x: auto; scrollbar-width: none; }
.rail a { color: rgba(253,251,246,.65); text-decoration: none; font-weight: 600; font-size: 14px;
          padding: 13px 16px; white-space: nowrap; border-bottom: 3px solid transparent; }
.rail a:hover { color: var(--white); }
.rail a.on { color: var(--white); border-bottom-color: var(--brass); }

main { max-width: 1080px; margin: 0 auto; padding: 26px 16px 70px; }

/* --- Titres de page --- */
.head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between;
        align-items: flex-end; border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 20px; }
.head h1 { font-size: 26px; margin: 0; line-height: 1.15; }
.head .meta { color: var(--muted); font-size: 13.5px; }
.crumb { font-size: 13px; margin-bottom: 6px; display: inline-block; text-decoration: none; color: var(--muted); }
.crumb:hover { color: var(--blue); }

/* --- Boutons et formulaires --- */
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; font-size: 14px;
       padding: 9px 16px; border-radius: 3px; border: 1.5px solid var(--blue); background: var(--blue);
       color: var(--white); cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--blue-dark); }
.btn.ghost { background: transparent; color: var(--blue); }
.btn.ghost:hover { background: rgba(28,58,92,.07); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: 13px; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 5px; }
.hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
input[type=text], input[type=email], input[type=date], input[type=search], select, textarea {
  width: 100%; font: inherit; padding: 9px 11px; border: 1px solid rgba(34,30,23,.22);
  background: var(--white); border-radius: 3px; color: var(--ink); }
textarea { min-height: 110px; resize: vertical; }
input[type=file] { font: inherit; font-size: 14px; }
.field { margin-bottom: 16px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .row2 { grid-template-columns: 1fr; } }
.checks { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto;
          border: 1px solid var(--line); background: var(--white); padding: 10px 12px; border-radius: 3px; }
.checks label { font-weight: 400; font-size: 14px; display: flex; gap: 8px; align-items: flex-start; margin: 0; }
.checks input { margin-top: 4px; accent-color: var(--blue); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

.flash { padding: 11px 14px; margin-bottom: 18px; border-left: 4px solid var(--ok);
         background: #e8efe6; font-size: 14px; }
.flash.error { border-color: var(--bad); background: #f5e5e1; }

/* --- Panneaux --- */
.panel { background: var(--white); border: 1px solid var(--line); border-top: 3px solid var(--brass);
         padding: 18px 20px; margin-bottom: 20px; }
.panel h2 { font-size: 18px; margin: 0 0 12px; }
.panel h2 small { font-family: 'Public Sans', sans-serif; font-size: 13px; color: var(--muted); font-weight: 400; }
.grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 820px) { .grid { grid-template-columns: 1fr; } }
.empty { color: var(--muted); font-size: 14px; padding: 6px 0; }

/* --- Pipeline des statuts --- */
.pipeline { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; margin-bottom: 20px;
            border: 1px solid var(--line); background: var(--white); }
.pipeline a { text-decoration: none; color: inherit; padding: 14px 14px 12px; border-right: 1px solid var(--line);
              border-top: 4px solid var(--c); }
.pipeline a:last-child { border-right: none; }
.pipeline .n { font-family: 'Fraunces', serif; font-size: 30px; line-height: 1; }
.pipeline .l { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
@media (max-width: 600px) {
  .pipeline { grid-template-columns: repeat(5, minmax(84px, 1fr)); overflow-x: auto; }
  .pipeline .n { font-size: 24px; }
}

.s-idee { --c: var(--s-idee); } .s-devis { --c: var(--s-devis); } .s-vote { --c: var(--s-vote); }
.s-encours { --c: var(--s-encours); } .s-termine { --c: var(--s-termine); }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 20px;
        color: var(--c); border: 1px solid var(--c); white-space: nowrap; }

/* --- Listes --- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: none; }
.item { display: flex; gap: 12px; align-items: flex-start; }
.item .main { flex: 1 1 0; min-width: 0; }
.item .t { font-weight: 600; text-decoration: none; color: var(--ink); }
.item a.t:hover { color: var(--blue); text-decoration: underline; }
.item .m { font-size: 12.5px; color: var(--muted); }
.ext { flex-shrink: 0; width: 42px; height: 42px; border: 1px solid var(--line); background: var(--stone);
       display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700;
       color: var(--blue); letter-spacing: .02em; }
.snip { font-size: 13.5px; color: #4a453b; margin-top: 4px; line-height: 1.45; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 5px; }
.tag { font-size: 12px; padding: 1px 8px; border: 1px solid var(--line); background: var(--paper);
       color: var(--muted); text-decoration: none; border-radius: 2px; }
a.tag:hover { border-color: var(--blue); color: var(--blue); }
.tag.chantier { border-color: rgba(28,58,92,.3); color: var(--blue); }

.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--blue); color: var(--white);
          display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; background: var(--brass); color: #2a1d08; }

/* --- Budget --- */
.money { display: flex; gap: 20px; margin-bottom: 14px; flex-wrap: wrap; }
.money div .v { font-family: 'Fraunces', serif; font-size: 24px; }
.money div .k { font-size: 12.5px; color: var(--muted); }
.bar { height: 8px; background: var(--stone); position: relative; margin-top: 6px; }
.bar > span { position: absolute; inset: 0 auto 0 0; background: var(--blue); max-width: 100%; }
.bar.over > span { background: var(--bad); }

/* --- Recherche --- */
.searchbar { display: flex; gap: 8px; margin-bottom: 12px; }
.searchbar input { flex: 1; font-size: 16px; padding: 11px 13px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.filters select { width: auto; min-width: 160px; font-size: 14px; padding: 7px 9px; }
.count { font-size: 13px; color: var(--muted); margin-bottom: 6px; }

/* --- Chantiers (colonnes) --- */
.board { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
@media (max-width: 900px) { .board { grid-template-columns: 1fr; } }
.col h3 { font-family: 'Public Sans', sans-serif; font-size: 13.5px; font-weight: 700; margin: 0 0 10px;
          padding-bottom: 6px; border-bottom: 3px solid var(--c); display: flex; justify-content: space-between; }
.card { display: block; background: var(--white); border: 1px solid var(--line); padding: 12px 13px; margin-bottom: 10px;
        text-decoration: none; color: inherit; }
.card:hover { border-color: var(--blue); }
.card .t { font-weight: 600; font-size: 14.5px; line-height: 1.3; }
.card .m { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }
.desc { white-space: pre-wrap; font-size: 14.5px; }
.apercu { white-space: pre-wrap; font-size: 13px; background: var(--paper); border: 1px solid var(--line);
          padding: 12px; max-height: 340px; overflow: auto; color: #3c372e; }

table.members { width: 100%; border-collapse: collapse; font-size: 14px; }
table.members td, table.members th { text-align: left; padding: 9px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.members th { font-size: 12.5px; color: var(--muted); font-weight: 600; }
table.members tr.off td { opacity: .5; }
.inline { display: inline; }
@media (max-width: 640px) { table.members .hide-sm { display: none; } }

/* --- Connexion --- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
              background: linear-gradient(180deg, var(--blue), var(--blue-dark)); }
.login { background: var(--white); max-width: 420px; width: 100%; padding: 30px 28px; border-top: 5px solid var(--brass); }
.login .door { width: 60px; height: 60px; font-size: 28px; margin-bottom: 14px; }
.login h1 { margin: 0 0 4px; font-size: 26px; }
.login p { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.devlink { margin-top: 18px; padding: 12px; background: #fff6df; border: 1px dashed var(--brass); font-size: 13px; word-break: break-all; }

.journal li { font-size: 13.5px; padding: 7px 0; }
.journal .m { color: var(--muted); font-size: 12.5px; }

/* ===================================================================
   Adaptation téléphone et tablette
   =================================================================== */

/* Libellé court du menu (affiché sur petit écran) */
.rail .short { display: none; }

/* Liste des membres */
.member { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.member .main { flex: 1; min-width: 180px; }
.member .t { font-weight: 600; }
.member .m { font-size: 12.5px; color: var(--muted); }
.member .email { word-break: break-all; }
.member.off { opacity: .55; }
.member-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 0; }

/* Zone de dépôt de fichiers */
.label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 5px; }
.drop { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
        text-align: center; gap: 4px; padding: 26px 16px; border: 2px dashed rgba(28,58,92,.35);
        background: var(--white); border-radius: 4px; cursor: pointer; font-weight: 400; margin: 0; }
.drop:hover, .drop.over { border-color: var(--blue); background: #f1f4f8; }
.drop.filled { border-style: solid; border-color: var(--ok); }
.drop input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.drop:focus-within { outline: 2px solid var(--brass); outline-offset: 2px; }
.drop-title { font-weight: 700; color: var(--blue); font-size: 15px; }
.drop-sub { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.drop-list { font-size: 13px; color: var(--ok); font-weight: 600; word-break: break-word; }
.drop-list:empty { display: none; }

/* Cases à cocher plus faciles à toucher */
.checks label { padding: 5px 0; }
.checks input { width: 18px; height: 18px; flex-shrink: 0; }

/* Écrans tactiles : cibles d'au moins 44 px */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn.small { min-height: 40px; padding: 8px 12px; }
  .rail a { padding-top: 14px; padding-bottom: 14px; }
  .linkbtn { padding: 10px 0; }
}

/* Tablette (portrait et paysage) */
@media (max-width: 1100px) {
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; }
}
@media (min-width: 601px) and (max-width: 1100px) {
  main, .plaque-inner { padding-left: 24px; padding-right: 24px; }
  .rail-inner { padding-left: 8px; padding-right: 8px; }
}

/* Téléphone et petite tablette */
@media (max-width: 820px) {
  .grid.side-first > div:last-child { order: -1; }
}

/* Téléphone */
@media (max-width: 600px) {
  body { font-size: 15.5px; }
  main { padding: 18px 14px 60px; }
  .plaque-inner { padding: 10px 14px; gap: 12px; }
  .door { width: 40px; height: 40px; font-size: 19px; }
  .street { font-size: 19px; }

  /* Menu : 4 onglets qui tiennent sur la largeur */
  .rail-inner { overflow: visible; }
  .rail a { flex: 1; text-align: center; padding-left: 4px; padding-right: 4px; font-size: 13.5px; }
  .rail .long { display: none; }
  .rail .short { display: inline; }

  /* Titres et boutons d'action */
  .head { flex-direction: column; align-items: stretch; }
  .head h1 { font-size: 23px; }
  .head .actions { width: 100%; }
  .head .actions .btn { flex: 1; justify-content: center; }
  .head > .btn { justify-content: center; }

  /* Recherche */
  .searchbar input { min-width: 0; }
  .filters select { flex: 1; min-width: 0; width: 100%; }

  /* Compteurs de chantiers : 5 cases compactes sans défilement */
  .pipeline { grid-template-columns: repeat(5, minmax(0, 1fr)); overflow: visible; }
  .pipeline a { padding: 10px 6px 9px; }
  .pipeline .n { font-size: 22px; }
  .pipeline .l { font-size: 11px; line-height: 1.25; }

  .panel { padding: 16px 14px; }
  .board { grid-template-columns: 1fr; }
  .money { gap: 16px; }
  .money div .v { font-size: 21px; }

  .item .main { flex: 1 1 0; }
  form.panel > .btn[type=submit] { width: 100%; justify-content: center; }

  .member-actions { width: 100%; padding-left: 44px; }
  .member-actions .btn { flex: 1; justify-content: center; }

  .actions .btn { flex: 1; justify-content: center; }
  .login { padding: 26px 20px; }
}

/* Évite le zoom automatique d'iOS sur les champs de saisie */
@media (max-width: 1100px) {
  input[type=text], input[type=email], input[type=date], input[type=search], select, textarea { font-size: 16px; }
}

/* Encoches et coins arrondis des téléphones récents */
@media (max-width: 600px) {
  @supports (padding: max(0px)) {
    .plaque-inner, main { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
  }
}

/* Connexion */
main.login-main { max-width: none; padding: 0; }
.code-input { font-size: 26px !important; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; padding: 12px; }
.login-alt { font-size: 13px !important; margin: 16px 0 0 !important; }
.login strong { color: var(--ink); }
