/* Casi'Lib — thème sombre repris de l'app Glide */
:root {
  --bg: #1A1A1A;
  --bg-elev: #232323;
  --bg-input: #2C2C2E;
  --border: #333333;
  --text: #F2F2F7;
  --muted: #8E8E93;
  --primary: #3D6584;
  --primary-hover: #4A7699;
  --accent: #5E8DB3;
  --green: #73C95D;
  --orange: #F0A23B;
  --red: #E5544B;
  --warn: #F5C451;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
img { max-width: 100%; display: block; }

.app { max-width: 520px; margin: 0 auto; min-height: 100vh; padding-bottom: 90px; }
.app.admin { max-width: 1100px; }

/* Barre du haut */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  height: 56px; padding: 0 16px; background: var(--bg);
}
.topbar .back { position: absolute; left: 12px; top: 0; height: 56px; display: flex; align-items: center; padding: 0 6px; color: var(--accent); }
.topbar .title { font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 70%; }
.topbar .right { position: absolute; right: 16px; top: 0; height: 56px; display: flex; align-items: center; gap: 12px; font-size: 14px; }

.page { padding: 0 16px 24px; }
h1.big { font-size: 30px; margin: 4px 0 14px; font-weight: 700; }
h2 { font-size: 20px; margin: 22px 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Messages */
.flash { margin: 8px 16px; padding: 12px 14px; border-radius: var(--radius); font-size: 15px; border: 1px solid var(--border); background: var(--bg-elev); }
.flash.ok { border-color: #3c6b33; background: #1f2d1c; }
.flash.erreur { border-color: #7a2f2a; background: #2d1b1a; }
.flash.info { border-color: #2e4b63; background: #1b2631; }

/* Recherche */
.search { position: relative; margin-bottom: 16px; }
.search input { padding-left: 42px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }

/* Grille catalogue */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.card-tool { color: var(--text); display: block; background: none; border: 0; padding: 0; text-align: left; font: inherit; cursor: pointer; }
.card-tool .img { aspect-ratio: 1 / 1; background: #fff; border-radius: 10px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.card-tool .img img { width: 100%; height: 100%; object-fit: contain; }
.card-tool .meta { padding: 8px 12px 0; }
.card-tool .badge { color: var(--accent); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .2px; }
.card-tool .name { font-weight: 700; font-size: 18px; line-height: 1.2; margin-top: 2px; }
.card-tool .sub { color: var(--muted); font-size: 17px; }
.card-tool.suggest .img { background: #F4F4F4; color: #111; }

/* Fiche outil */
.hero { background: #fff; margin: 0 -16px; }
.hero img { width: 100%; max-height: 320px; object-fit: contain; margin: 0 auto; }
.tool-title { font-size: 30px; font-weight: 700; margin: 18px 0 2px; }
.tool-sub { color: var(--muted); font-size: 18px; margin-bottom: 20px; }
.specs h3 { display: flex; align-items: center; gap: 8px; text-transform: uppercase; font-size: 14px; letter-spacing: .5px; margin-bottom: 14px; }
.spec { margin-bottom: 12px; }
.spec .k { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.spec .v { font-size: 16px; }
.rows { border-top: 1px solid var(--border); margin-top: 16px; }
.row { display: flex; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid var(--border); font-size: 17px; }
.row .k { color: var(--muted); }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

/* Boutons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 50px; padding: 12px 16px; margin: 14px 0 0;
  border-radius: 10px; border: 1px solid transparent;
  background: var(--primary); color: #fff; font-size: 18px; font-weight: 600; font-family: inherit;
  cursor: pointer; text-align: center;
}
.btn:hover { background: var(--primary-hover); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.outline { background: transparent; border-color: #444; }
.btn.ghost { background: transparent; color: var(--text); }
.btn.danger { background: #8c2f2a; }
.btn.green { background: #3f7a35; }
.btn.small { min-height: 38px; font-size: 15px; padding: 8px 12px; margin: 6px 0 0; width: auto; display: inline-flex; }
.btn.unlock { font-size: 19px; min-height: 58px; }
.linkbtn { display: flex; justify-content: center; align-items: center; gap: 8px; color: var(--text); font-weight: 600; font-size: 18px; padding: 16px 0; border-bottom: 1px solid var(--border); }
form.inline { display: inline; }

/* Encadrés */
.box { border: 1px solid var(--border); border-radius: 14px; padding: 18px; margin: 16px 0; background: transparent; }
.box.inner { background: var(--bg-elev); border-radius: 10px; padding: 14px 18px; }
.box h3.center { text-align: center; font-size: 20px; }
.steps { list-style: none; padding: 0; margin: 0; }
.steps li { margin: 6px 0; font-size: 16px; }
.steps b.n { color: var(--green); }
.notice { display: flex; gap: 12px; align-items: flex-start; background: #1F262D; border-radius: 12px; padding: 14px 16px; margin: 16px 0; font-size: 17px; }
.warn { color: var(--warn); }
.return-box h4 { margin: 0 0 12px; color: #bbb; text-transform: uppercase; font-size: 14px; letter-spacing: .4px; }
.return-box p { margin: 0 0 14px; }

/* Formulaires */
label { display: block; font-weight: 600; margin: 16px 0 8px; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=url], input[type=search], textarea, select {
  width: 100%; padding: 14px; border-radius: 10px; border: 1px solid transparent;
  background: var(--bg-input); color: var(--text); font-size: 17px; font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 110px; resize: vertical; }
.code-input { text-align: center; letter-spacing: 10px; font-size: 28px !important; font-weight: 700; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 16px 0; }
.check input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--primary); flex-shrink: 0; }
.photo-pick { display: flex; align-items: center; gap: 12px; background: var(--bg-input); border-radius: 10px; padding: 14px; color: var(--muted); font-size: 17px; cursor: pointer; margin-top: 14px; font-weight: 400; }
.photo-pick input { display: none; }
.photo-preview { margin-top: 10px; border-radius: 10px; max-height: 260px; object-fit: contain; }

/* Feuille modale (CGL, proposer un outil) */
dialog.sheet {
  width: 100%; max-width: 520px; max-height: 88vh; margin: auto auto 0; padding: 0;
  border: 0; border-radius: 18px 18px 0 0; background: #232323; color: var(--text);
}
dialog.sheet::backdrop { background: rgba(0,0,0,.6); }
.sheet-head { position: sticky; top: 0; background: #232323; display: flex; align-items: center; justify-content: center; padding: 18px 56px 14px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 20px; }
.sheet-close { position: absolute; right: 14px; top: 12px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: #3a3a3c; color: #ddd; font-size: 20px; cursor: pointer; }
.sheet-body { padding: 4px 20px 24px; overflow-y: auto; }

.cgl h4 { display: flex; align-items: center; gap: 10px; margin: 22px 0 6px; padding-bottom: 8px; border-bottom: 1px solid var(--border); text-transform: uppercase; font-size: 16px; }
.cgl h4 span { background: #333; color: #ddd; font-size: 12px; padding: 3px 8px; border-radius: 5px; }
.cgl ul { padding-left: 20px; margin: 8px 0; }
.cgl li { margin: 8px 0; }

/* FAQ */
details.faq { border-bottom: 1px solid var(--border); padding: 14px 0; }
details.faq summary { cursor: pointer; font-weight: 600; font-size: 17px; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
details.faq summary::after { content: "+"; color: var(--muted); font-size: 22px; line-height: 1; }
details.faq[open] summary::after { content: "–"; }
details.faq .a { color: #d0d0d5; margin-top: 10px; }

/* Listes */
.list-item { display: flex; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); color: var(--text); }
.list-item img { width: 64px; height: 64px; object-fit: contain; background: #fff; border-radius: 10px; flex-shrink: 0; }
.list-item .t { font-weight: 600; font-size: 17px; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #333; color: #ddd; }
.pill.green { background: #23401e; color: #9fe08f; }
.pill.orange { background: #4a3413; color: #f5c27a; }
.pill.red { background: #4a1d1a; color: #f39a93; }
.pill.blue { background: #1d3447; color: #9cc4e4; }

/* Barre de navigation du bas */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: #222; border-top: 1px solid #2c2c2c;
  display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom);
}
.tabbar .inner { display: flex; width: 100%; max-width: 520px; }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 0 12px; color: #9a9a9f; font-size: 13px; }
.tabbar a.active { color: var(--accent); }

/* Admin */
.admin-nav { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 16px 12px; }
.admin-nav a { padding: 8px 12px; border-radius: 8px; background: var(--bg-elev); color: var(--text); font-size: 14px; }
.admin-nav a.active { background: var(--primary); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.table-wrap { overflow-x: auto; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.verif-photo { width: 100%; max-height: 420px; object-fit: contain; background: #000; border-radius: 10px; }
.calc { font-size: 15px; }
.calc .row { padding: 8px 0; font-size: 15px; }
.calc .total { font-weight: 700; font-size: 17px; }
.banner { margin: 0 16px 12px; padding: 10px 14px; border-radius: 10px; background: #4a3413; color: #f5d7a8; font-size: 14px; }
details.faq .a h5 { margin: 4px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); color: var(--text); text-transform: uppercase; font-size: 14px; }
details.faq .a p { margin: 6px 0; }
details.faq .a ul { padding-left: 20px; margin: 6px 0; }
details.faq .a li { margin: 6px 0; }
.cgl p { margin: 8px 0; }
