/* ===========================================================================
   ATELIER D'ARRAKIS — feuille de style
   Direction artistique « Dune » : sables d'Arrakis, épice, maison Atréides.
   Thème clair/sombre automatique (prefers-color-scheme). Rail de navigation à
   gauche ≥900px, barre d'onglets en bas sur mobile. Mobile soigné (cibles
   ≥44px, aucun défilement horizontal, tableaux repliés en cartes).
   =========================================================================== */

:root {
  --bg: #e9dcc0; --bg2: #f6efe0; --fg: #2a211a; --muted: #6f6353; --line: #cdbfa3;
  --accent: #a84a1b; --accent-fg: #fff8ee; --card: #faf5ea; --chip: #e2d6bd;
  --ok: #2f6b4f; --warn: #8a2a2a; --spice: #b0702a; --atreides: #0f3b2e;
  --shadow: 0 1px 2px rgba(60,40,10,.08), 0 10px 28px rgba(60,40,10,.10);
  --display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --body: "Alegreya Sans", "Gill Sans", "Segoe UI", system-ui, sans-serif;
  --r: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15131a; --bg2: #1f1c24; --fg: #ece2cf; --muted: #a69a85; --line: #3a3442;
    --accent: #e08a4c; --accent-fg: #1a110a; --card: #221f2a; --chip: #2f2a37;
    --ok: #7fc29b; --warn: #e07070; --spice: #e0a060; --atreides: #6fcaa3;
    --shadow: 0 1px 2px rgba(0,0,0,.45), 0 10px 28px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--body); font-size: 16.5px; line-height: 1.5;
  /* Atmosphère : halo d'épice en haut + dunes très discrètes au fond. */
  background-image:
    radial-gradient(ellipse 120% 70% at 18% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 55%),
    radial-gradient(ellipse 90% 60% at 100% 0%, color-mix(in srgb, var(--spice) 12%, transparent), transparent 50%),
    repeating-linear-gradient(115deg, color-mix(in srgb, var(--fg) 2.5%, transparent) 0 2px, transparent 2px 26px);
  background-attachment: fixed;
}
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.12; margin: 0; text-wrap: balance; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
input, select { font: inherit; }
.eyebrow { font-size: .74rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.muted { color: var(--muted); }
.mini { font-size: .8rem; }
.num { font-variant-numeric: tabular-nums; }
.spice-txt { color: var(--spice); }

/* ---------- Cadre général ---------- */
.app { display: grid; grid-template-rows: auto auto 1fr; min-height: 100%; }
header.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10;
  display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-seal {
  flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, var(--spice), var(--accent));
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.3), var(--shadow);
}
.brand-seal svg { width: 24px; height: 24px; stroke: var(--accent-fg); fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.brand-txt { display: flex; flex-direction: column; min-width: 0; }
.brand-h1 { font-family: var(--display); font-size: 1.5rem; font-weight: 700; white-space: nowrap; }
.sub { color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acts { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.import-form { display: inline; }
@media (max-width: 620px) { .sub { display: none; } .brand-h1 { font-size: 1.3rem; } }

main { width: 100%; max-width: 1060px; margin: 0 auto; padding: 20px 16px 104px; min-width: 0; }

/* ---------- Navigation ---------- */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around; gap: 2px;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg2) 94%, transparent); backdrop-filter: blur(10px);
}
nav.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 6px 4px; border-radius: 10px; font-size: .66rem; color: var(--muted);
  min-width: 0; flex: 1; min-height: 46px;
}
nav.tabs a svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
nav.tabs a[aria-current="page"] { color: var(--accent); }
nav.tabs .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
nav.tabs .sep { display: none; }
.nav-seal {
  flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--c, var(--accent)); color: #fff; font-family: var(--display);
  font-weight: 700; font-size: .62rem; box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.3);
}

/* --- Menu déroulant des véhicules (mobile : barre du bas) --- */
nav.tabs .nav-veh { position: relative; flex: 1; display: flex; }
nav.tabs .nav-veh-toggle {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 6px 4px; border-radius: 10px; font-size: .66rem; color: var(--muted); width: 100%; min-height: 46px;
}
nav.tabs .nav-veh-toggle > svg:first-child { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
nav.tabs .nav-veh-toggle .chevron { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; position: absolute; top: 4px; right: 50%; margin-right: -26px; transition: transform .15s; }
nav.tabs .nav-veh.open .nav-veh-toggle .chevron { transform: rotate(180deg); }
nav.tabs .nav-veh.cur .nav-veh-toggle { color: var(--accent); }
nav.tabs .nav-veh-menu {
  position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  width: min(82vw, 264px); flex-direction: column; gap: 2px; display: none; z-index: 20;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px;
}
nav.tabs .nav-veh.open .nav-veh-menu { display: flex; }
nav.tabs .nav-veh.open .nav-veh-toggle { color: var(--accent); background: var(--chip); }
nav.tabs .nav-veh-menu a {
  flex-direction: row; align-items: center; justify-content: flex-start; gap: 12px;
  padding: 11px 12px; border-radius: 9px; font-size: .98rem; color: var(--fg); width: 100%; min-height: 46px;
}
nav.tabs .nav-veh-menu a .lbl { font-size: .98rem; }
nav.tabs .nav-veh-menu a[aria-current="page"] { color: var(--accent); background: var(--chip); }

@media (min-width: 900px) {
  .app { grid-template-columns: 224px 1fr; grid-template-rows: auto 1fr; }
  header.top { grid-column: 1 / -1; }
  nav.tabs {
    position: sticky; top: 61px; align-self: start; height: calc(100vh - 61px);
    flex-direction: column; justify-content: flex-start; gap: 4px;
    padding: 20px 12px; border-top: 0; border-right: 1px solid var(--line);
    background: transparent; backdrop-filter: none;
  }
  nav.tabs a { flex: none; flex-direction: row; gap: 12px; font-size: .96rem; padding: 10px 12px; width: 100%; justify-content: flex-start; }
  nav.tabs a[aria-current="page"] { background: var(--chip); }
  nav.tabs .sep { display: block; height: 1px; background: var(--line); margin: 8px 4px; }
  nav.tabs .nav-seal { width: 24px; height: 24px; font-size: .66rem; }
  /* Sur grand écran : pas de bouton déroulant, les véhicules s'affichent dans le rail. */
  nav.tabs .nav-veh-toggle { display: none; }
  nav.tabs .nav-veh, nav.tabs .nav-veh-menu { display: contents; }
  main { padding: 28px 36px 48px; }
}

/* ---------- Composants ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.stack { display: grid; gap: 16px; }
.grid2 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(290px, 100%), 1fr)); }
.grid3 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); }
.page-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 18px; margin-bottom: 16px; }
.page-head h2 { font-size: clamp(1.7rem, 7vw, 2.15rem); }
.sec-title { margin: 24px 0 8px; }
.note { font-size: .88rem; color: var(--muted); margin: 0 0 10px; max-width: 72ch; }
.list { display: grid; gap: 10px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 17px; border-radius: 10px; background: var(--accent); color: var(--accent-fg); font-weight: 700; font-size: .92rem; min-height: 44px; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.sm { padding: 7px 13px; font-size: .84rem; min-height: 38px; }
.btn.mini { padding: 5px 9px; font-size: .8rem; min-height: 32px; background: none; color: var(--muted); border: 1px solid var(--line); border-radius: 7px; }
.btn.mini:hover { border-color: var(--accent); color: var(--accent); }
.card-actions { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; background: var(--chip); font-size: .84rem; }
.chip.strong { background: color-mix(in srgb, var(--accent) 18%, var(--chip)); font-weight: 700; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.tag.don { background: color-mix(in srgb, var(--ok) 22%, transparent); color: var(--ok); }
.tag.pret { background: color-mix(in srgb, var(--spice) 24%, transparent); color: var(--spice); }

/* Barre de progression */
.bar { height: 9px; border-radius: 5px; background: var(--chip); overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, color-mix(in srgb, var(--ok) 80%, #000 0%), var(--ok)); transition: width .3s; }
.bar.spice i { background: linear-gradient(90deg, var(--accent), var(--spice)); }

/* Cartes statistiques */
.stat { padding: 16px; display: flex; gap: 12px; align-items: center; min-width: 0; }
.stat b { font-family: var(--display); font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat .frac { color: var(--muted); font-size: 1rem; font-weight: 400; }
.stat .t { min-width: 0; }
.stat .t span { display: block; color: var(--muted); font-size: .85rem; }

/* Sceaux */
.seal {
  flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: var(--c, var(--accent)); color: #fff; font-family: var(--display); font-weight: 700;
  font-size: 1rem; letter-spacing: .04em;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.35), 0 0 0 1px rgba(0,0,0,.18), var(--shadow);
}
.seal.lg { width: 66px; height: 66px; font-size: 1.35rem; }

/* Cartes véhicule (accueil) */
.vcard { padding: 15px 16px; display: flex; gap: 14px; align-items: center; text-align: left; transition: transform .12s, border-color .12s; }
.vcard:hover { transform: translateY(-2px); border-color: var(--accent); }
.vcard .t { flex: 1; min-width: 0; }
.vcard .t b { display: block; font-family: var(--display); font-size: 1.3rem; font-weight: 600; }
.vcard .t span { display: block; color: var(--muted); font-size: .84rem; margin-bottom: 7px; }
.vcard .pct { font-family: var(--display); font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ok); flex: none; }

.vehicule-head { align-items: center; }
.vehicule-head .vh-txt { min-width: 0; flex: 1; }
.progress-card { padding: 15px 16px; margin-bottom: 18px; }
.progress-legend { display: flex; justify-content: space-between; font-size: .88rem; color: var(--muted); margin-top: 8px; }

/* Sections pliables */
details.sec { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
details.sec > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 14px 16px; user-select: none; min-height: 44px; }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary::before { content: "›"; color: var(--muted); font-size: 1.4rem; transition: transform .15s; flex: none; }
details.sec[open] > summary::before { transform: rotate(90deg); }
details.sec > summary h3 { font-size: 1.2rem; flex: 1; min-width: 0; }
details.sec > summary .n { font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
details.sec > summary .n.done { color: var(--ok); font-weight: 700; }
details.sec > summary .n.credit { color: var(--spice); font-weight: 700; }
details.sec .body { border-top: 1px solid var(--line); padding: 8px; }

/* Rangées à cocher (formulaires) */
.row { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: 8px; cursor: pointer; margin: 0; min-height: 44px; }
.row:hover { background: var(--chip); }
.row input[type=checkbox] { width: 24px; height: 24px; flex: none; accent-color: var(--ok); cursor: pointer; margin: 0; }
.row span { flex: 1; min-width: 0; }
.row:has(input:checked) span { color: var(--muted); text-decoration: line-through; }

.solde-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 8px 12px; }

/* Tableaux */
.twrap { overflow-x: auto; padding: 4px 8px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
td.num, th.num { text-align: right; white-space: nowrap; }
.ok { color: var(--ok); font-weight: 700; }
.ko { color: var(--warn); font-weight: 700; }
.recette { margin-top: 4px; }
td input[type=number] {
  width: 110px; max-width: 40vw; text-align: right; background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 7px; padding: 8px; min-height: 40px;
}

/* Journal : remboursement en ligne */
.inline-rb { display: inline-flex; flex-wrap: wrap; gap: 5px; align-items: center; margin-top: 4px; }
.mini-input { width: 72px; background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 7px; padding: 6px; min-height: 32px; }

/* Formulaire d'apport */
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; padding: 16px; align-items: end; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: .74rem; color: var(--muted); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.form label.wide { grid-column: 1 / -1; }
.form label.chk { flex-direction: row; align-items: center; text-transform: none; letter-spacing: 0; font-size: .95rem; font-weight: 500; color: var(--fg); min-height: 44px; }
.form input, .form select { background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; width: 100%; text-transform: none; letter-spacing: 0; min-height: 44px; }
.form .chk input { width: 22px; height: 22px; accent-color: var(--ok); }
.type-choice { border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; display: flex; gap: 16px; align-items: center; }
.type-choice legend { font-size: .74rem; color: var(--muted); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 0 4px; }
.type-choice .radio { flex-direction: row; align-items: center; gap: 6px; text-transform: none; letter-spacing: 0; font-size: .98rem; font-weight: 500; color: var(--fg); min-height: 40px; }
.type-choice .radio input { width: 20px; height: 20px; accent-color: var(--accent); }

.empty { padding: 30px 18px; text-align: center; color: var(--muted); }
.empty b { display: block; font-family: var(--display); font-size: 1.45rem; color: var(--fg); margin-bottom: 4px; }
.danger-zone { padding: 16px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--fg); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: .9rem;
  opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 20;
  display: flex; flex-direction: column; gap: 2px; max-width: 90vw; text-align: center; box-shadow: var(--shadow);
}
.toast.on { opacity: 1; }
@media (min-width: 900px) { .toast { bottom: 26px; } }

/* ---------- Page Ressources (codex / encyclopédie) ---------- */
.filtres { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-bottom: 16px; }
.rech {
  flex: 1 1 240px; min-width: 0; padding: 10px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--fg);
}
.rech::placeholder { color: var(--muted); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--chip); border-radius: 999px; padding: 4px; }
.seg button, .seg a { display: inline-flex; align-items: center; justify-content: center; padding: 7px 14px; border-radius: 999px; font-size: .86rem; font-weight: 600; color: var(--muted); min-height: 38px; }
.seg button.on, .seg a.on { background: var(--card); color: var(--fg); box-shadow: var(--shadow); }
.seg button .n { opacity: .55; font-weight: 700; margin-left: 2px; font-size: .82em; }

/* Sélecteur de palier Mk5 | Mk6 sur la page véhicule */
.mk-switch { margin-bottom: 16px; }
.mk-switch a { min-width: 68px; letter-spacing: .02em; }
.mk-badge { display: inline-block; vertical-align: middle; margin-left: 6px; padding: 2px 10px; border-radius: 999px; background: var(--chip); color: var(--muted); font-family: var(--body); font-size: .82rem; font-weight: 700; }
.info-mk { padding: 14px 16px; margin-bottom: 18px; border-left: 3px solid var(--spice); font-size: .92rem; }
.info-mk code { background: color-mix(in srgb, var(--fg) 8%, transparent); padding: 1px 5px; border-radius: 5px; font-size: .9em; }

.res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 12px; align-items: stretch; }
.res-card { padding: 14px 16px; display: flex; flex-direction: column; gap: 9px; color: inherit; text-decoration: none;
  transition: transform .12s, border-color .12s, box-shadow .12s; }
.res-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow-lg, var(--shadow)); }
.res-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.res-card[hidden] { display: none; }
.res-hint { margin: 0; font-size: .85rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.res-hint .k { color: var(--muted); font-weight: 700; }
.res-go { margin-top: auto; font-size: .82rem; font-weight: 700; color: var(--accent); }
.retour { margin: 0 0 12px; }
.retour a { color: var(--muted); text-decoration: none; font-size: .9rem; font-weight: 600; }
.retour a:hover { color: var(--accent); }
.res-detail { padding: 18px 20px; display: flex; flex-direction: column; gap: 16px; }
.res-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; }
.res-head h3 { font-size: 1.18rem; }
.res-head .u { font-size: .84rem; font-family: var(--body); font-weight: 400; }
.res-badges { display: flex; flex-wrap: wrap; gap: 5px; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .73rem; font-weight: 700; }
.cat-brute { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.cat-fabriquee { background: color-mix(in srgb, var(--atreides) 20%, transparent); color: var(--atreides); }
.cat-trouvee { background: color-mix(in srgb, var(--spice) 24%, transparent); color: var(--spice); }
.fia-estime { background: color-mix(in srgb, var(--spice) 15%, transparent); color: var(--spice); }
.fia-incertain { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }

.res-row { display: flex; gap: 8px; margin: 0; font-size: .9rem; }
.res-row .k { color: var(--muted); font-weight: 700; flex: 0 0 auto; }
.res-sec { display: flex; flex-direction: column; gap: 6px; }
.res-sec .eyebrow { font-size: .68rem; }
.recette { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: .92rem; }
.recette li { display: flex; gap: 8px; }
.recette .q { flex: 0 0 auto; min-width: 3.1em; font-weight: 700; color: var(--accent); }
.ou { margin: 0; font-size: .91rem; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip.sm { padding: 3px 10px; font-size: .78rem; }
.src { margin: 2px 0 0; font-size: .76rem; color: var(--muted); font-style: italic; }
.vide { text-align: center; color: var(--muted); padding: 40px 16px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.vide p { margin: 0; }
.add-res { margin-left: auto; white-space: nowrap; }

/* Formulaire d'ajout / modification d'une ressource */
.form-ressource { padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.form-ressource .field { display: flex; flex-direction: column; gap: 5px; }
.form-ressource label { font-size: .82rem; font-weight: 700; letter-spacing: .02em; color: var(--muted); }
.form-ressource .req { color: var(--accent); }
.form-ressource input[type=text], .form-ressource input[type=url], .form-ressource input[type=number],
.form-ressource select, .form-ressource textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--fg); font-size: .95rem;
}
.form-ressource textarea { resize: vertical; min-height: 64px; line-height: 1.45; }
.form-ressource input[type=file] { font-size: .88rem; color: var(--muted); }
.form-ressource .help { margin: 0; font-size: .78rem; color: var(--muted); }
.form-ressource .err { margin: 0; font-size: .82rem; color: var(--warn); font-weight: 600; }
.form-ressource .field.has-error input, .form-ressource .field.has-error select,
.form-ressource .field.has-error textarea { border-color: var(--warn); }
.form-err { padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); font-size: .88rem; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* Carte du lieu (fiche détail) */
.carte-img { display: block; width: 100%; max-width: 640px; height: auto; border-radius: 10px; border: 1px solid var(--line); }
.carte-lien { color: var(--accent); font-weight: 700; }
.detail-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; }
.detail-actions .danger { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); }
.detail-actions .danger:hover { border-color: var(--warn); }
.detail-actions .protege { font-size: .82rem; }

/* ---------- Page « À faire » (liste de tâches) ---------- */
.tache-form { align-items: end; margin-bottom: 20px; }
.tache-form .tache-aide { margin: 0; }

.taches-layout { display: grid; gap: 16px; align-items: start; }
.taches-liste { gap: 8px; }

.tache {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 6px 10px 6px 6px; box-shadow: var(--shadow); min-height: 52px;
}
.tache.cur { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent), var(--shadow); }
.tache-chk { display: flex; margin: 0; }
.tache-chk input[type=checkbox] { width: 24px; height: 24px; flex: none; accent-color: var(--ok); cursor: pointer; margin: 0; }

.tache-txt { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; color: var(--fg); padding: 6px 2px; }
.tache-lien { border-radius: 8px; }
.tache-lien:hover .tache-titre { color: var(--accent); }
.tache-titre { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tache .nav-seal { width: 26px; height: 26px; font-size: .66rem; }
.tache-voir { margin-left: auto; font-size: .78rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.tache-lien:hover .tache-voir { color: var(--accent); }
.tache.done { opacity: .62; }
.tache.done .tache-titre { text-decoration: line-through; color: var(--muted); }
.tache .btn.mini { flex: none; min-width: 34px; }

.carte-taches { min-width: 0; }
.carte-fab { overflow: hidden; }
.carte-head { display: flex; align-items: center; gap: 12px; padding: 16px 16px 4px; }
.carte-head h3 { font-size: 1.25rem; }
.carte-note { padding: 0 16px; margin: 6px 0 2px; }
.carte-vide { padding: 18px; }
.carte-vide p { margin: 0; }

/* Mobile : quand une tâche est focalisée, sa carte passe au-dessus de la liste
   (le rechargement ramène en haut de page → la carte est vue tout de suite). */
@media (max-width: 899px) {
  .taches-layout.has-focus .carte-taches { order: -1; }
}

@media (min-width: 900px) {
  .taches-layout { grid-template-columns: 1fr minmax(280px, 380px); gap: 22px; }
  .carte-taches { position: sticky; top: 81px; }
}

/* Carte de ressources : liste compacte sur mobile (nom … quantité sur 1 ligne,
   au lieu du dépliage en deux lignes des autres tableaux). */
@media (max-width: 640px) {
  .carte-fab table tr { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 12px; }
  .carte-fab table tr:has(> th) { display: none; }
  .carte-fab table td { display: block; border: 0; padding: 0; text-align: left; }
  .carte-fab table td.num { text-align: right; white-space: nowrap; }
  .carte-fab table td::before { content: none; }
}

/* ---------- Tableaux repliés en cartes sur mobile ---------- */
@media (max-width: 640px) {
  .twrap { overflow-x: visible; padding: 4px; }
  table, tbody { display: block; width: 100%; }
  table tr { display: block; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; padding: 4px 10px; background: color-mix(in srgb, var(--bg2) 50%, transparent); }
  table tr:last-child { margin-bottom: 0; }
  table th { display: none; }
  /* Ligne d'en-tête (uniquement des <th>) : masquée. */
  table tr:has(> th) { display: none; }
  table td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); padding: 9px 2px; text-align: right; }
  table tr td:last-child { border-bottom: 0; }
  table td::before { content: attr(data-th); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; text-align: left; flex: none; }
  table td[data-th=""]::before { content: ""; }
  table td.num { text-align: right; }
  td input[type=number] { max-width: 55vw; }
}

/* ---------- Authentification (connexion / 2FA) ---------- */
.auth-body { display: grid; min-height: 100dvh; }
.auth-wrap { width: 100%; max-width: 440px; margin: auto; padding: 28px 16px calc(28px + env(safe-area-inset-bottom, 0px)); }
.auth-card { padding: 24px 22px; display: grid; gap: 16px; }
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand .brand-h1 { font-size: 1.4rem; }
.auth-h1 { font-size: 1.5rem; margin: 2px 0 0; }
.auth-intro { margin: 0; color: var(--muted); font-size: .92rem; }
.auth-form { display: grid; gap: 14px; }
.auth-form .field { display: flex; flex-direction: column; gap: 6px; }
.auth-form .field > span { font-size: .78rem; font-weight: 700; letter-spacing: .04em; color: var(--muted); text-transform: uppercase; }
.auth-form input { width: 100%; background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 9px; padding: 12px; min-height: 46px; }
.auth-form input:focus-visible { border-color: var(--accent); outline: none; }
.auth-submit { width: 100%; margin-top: 2px; }
.code-input { text-align: center; font-size: 1.5rem; letter-spacing: .5em; font-variant-numeric: tabular-nums; padding-left: .5em !important; }
.auth-foot { margin: 2px 0 0; text-align: center; font-size: .86rem; }
.auth-foot a { color: var(--accent); font-weight: 600; }
.auth-msgs { display: grid; gap: 8px; }
.auth-msg { margin: 0; padding: 10px 12px; border-radius: 9px; font-size: .9rem; font-weight: 600; }
.auth-msg.error { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.auth-msg.success { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }

/* QR code de configuration 2FA (fond blanc pour rester scannable en sombre). */
.qr-box { display: grid; place-items: center; padding: 14px; background: #fff; border-radius: 12px; border: 1px solid var(--line); }
.qr-img { display: block; width: 220px; height: 220px; image-rendering: pixelated; }
.qr-manuel { font-size: .88rem; color: var(--muted); }
.qr-manuel summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.qr-manuel p { margin: 8px 0 6px; }
.secret { display: block; user-select: all; word-break: break-all; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 1rem; letter-spacing: .06em; background: var(--chip); color: var(--fg); padding: 10px 12px; border-radius: 8px; }

/* ---------- Profil ---------- */
.profil-card { padding: 4px 16px; }
.profil-ligne { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: space-between; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--line); }
.profil-ligne:last-child { border-bottom: 0; }
.profil-cle { font-size: .76rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.profil-val { font-size: 1.02rem; }
.badge-ok { display: inline-block; padding: 3px 11px; border-radius: 999px; background: color-mix(in srgb, var(--ok) 22%, transparent); color: var(--ok); font-weight: 700; font-size: .86rem; }
.badge-ko { display: inline-block; padding: 3px 11px; border-radius: 999px; background: var(--chip); color: var(--muted); font-weight: 700; font-size: .86rem; }
.profil-logout { display: inline; }

/* Bouton Admin (en-tête) : légèrement mis en avant. */
.btn-admin { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
.acts .btn.ghost.sm.on { background: var(--chip); }

/* ---------- Gestion des membres ---------- */
.page-sous { margin: 2px 0 0; color: var(--muted); font-size: .95rem; flex-basis: 100%; }
.gestion-grille { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.gestion-grille > .card { padding: 18px 18px; }
.gestion-grille .card-large { grid-column: 1 / -1; }
.card-titre { margin: 0 0 14px; font-size: 1.08rem; }

/* Formulaire d'invitation */
.form-inviter { display: grid; gap: 14px; }
.form-inviter .field { display: flex; flex-direction: column; gap: 6px; }
.form-inviter .field > span { font-size: .78rem; font-weight: 700; letter-spacing: .04em; color: var(--muted); text-transform: uppercase; }
.form-inviter input[type=email] { width: 100%; background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 9px; padding: 12px; min-height: 46px; }
.form-inviter input[type=email]:focus-visible { border-color: var(--accent); outline: none; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: .95rem; cursor: pointer; }
.check input[type=checkbox] { width: 22px; height: 22px; flex: none; accent-color: var(--accent); cursor: pointer; margin: 1px 0 0; }
.check em { font-style: normal; }

/* Encadré « lien d'invitation » */
.lien-box { padding: 16px 18px; margin-bottom: 16px; border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: color-mix(in srgb, var(--accent) 7%, var(--card)); }
.lien-box-tete { display: flex; align-items: center; gap: 8px; color: var(--accent); margin-bottom: 4px; }
.lien-row { display: flex; gap: 8px; margin-top: 10px; }
.lien-input { flex: 1 1 auto; min-width: 0; background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .85rem; }

/* Tables de gestion */
.table-wrap { overflow-x: auto; }
.table-gestion { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table-gestion th { text-align: left; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 6px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
.table-gestion td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table-gestion tr:last-child td { border-bottom: 0; }
.table-gestion .ligne-inactive { opacity: .55; }
.col-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form { display: inline; }
.lien-mini { background: none; border: 1px solid var(--line); border-radius: 7px; padding: 5px 10px; font-size: .82rem; font-weight: 600; color: var(--accent); cursor: pointer; min-height: 32px; white-space: nowrap; }
.lien-mini:hover { border-color: var(--accent); }
.lien-mini.danger { color: var(--warn); }
.lien-mini.danger:hover { border-color: var(--warn); }
.badge-attente { display: inline-block; padding: 3px 11px; border-radius: 999px; background: color-mix(in srgb, var(--spice) 22%, transparent); color: var(--spice); font-weight: 700; font-size: .84rem; white-space: nowrap; }

@media (max-width: 760px) {
  .gestion-grille { grid-template-columns: 1fr; }
  /* Tables → cartes empilées : chaque cellule porte son libellé (data-lbl). */
  .table-gestion thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-gestion, .table-gestion tbody, .table-gestion tr, .table-gestion td { display: block; width: 100%; }
  .table-gestion tr { border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; margin-bottom: 10px; }
  .table-gestion td { border: 0; padding: 7px 0; display: flex; justify-content: space-between; gap: 14px; text-align: right; }
  .table-gestion td::before { content: attr(data-lbl); font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); font-weight: 700; text-align: left; }
  .table-gestion td.col-actions { justify-content: flex-end; }
  .table-gestion td.col-actions::before { content: ""; }
}

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