:root {
  --wine: #722f37;
  --wine-2: #8e3b45;
  --gold: #b8913f;
  --bg: #faf7f4;
  --surface: #ffffff;
  --surface-2: #f3eee9;
  --text: #2b2325;
  --muted: #7a6e70;
  --border: #e8e0da;
  --ok: #2e7d4f;
  --warn: #b5651d;
  --danger: #b3261e;
  --shadow: 0 2px 10px rgba(60, 20, 25, .07);
  --radius: 14px;
  --t-rouge: #8b1e2d;
  --t-blanc: #e3c770;
  --t-rose: #e79aa6;
  --t-bulles: #d9c38a;
  --t-liquoreux: #c98a1a;
  --t-autre: #9a8f91;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --wine: #c4606c;
    --wine-2: #d57782;
    --gold: #d6b26a;
    --bg: #161213;
    --surface: #211b1c;
    --surface-2: #2b2425;
    --text: #f1e9e7;
    --muted: #a99c9d;
    --border: #3a3133;
    --ok: #6cc28f;
    --warn: #e39a55;
    --danger: #ef6f66;
    --shadow: 0 2px 10px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; color: var(--wine); font-weight: 600; }
h2 { font-size: 1.25rem; margin: 1.5rem 0 .75rem; }
.muted { color: var(--muted); }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Champs & boutons ---------- */
input, select, textarea {
  width: 100%;
  padding: .7rem .8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--wine); outline-offset: 1px; border-color: transparent; }
label { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-top: .7rem; }
label > input, label > select, label > textarea { margin-top: .3rem; font-weight: 400; color: var(--text); font-size: 1rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: .55rem 1rem;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font-weight: 600; font-size: .95rem; cursor: pointer; text-decoration: none;
  transition: transform .1s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--wine); border-color: var(--wine); color: #fff; }
.btn.primary:hover { background: var(--wine-2); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: .35rem .75rem; font-size: .85rem; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: var(--surface-2); cursor: pointer; font-size: 1rem;
}
.form-error { color: var(--danger); font-size: .9rem; min-height: 1.2em; margin: .6rem 0 0; }
.hint { font-size: .85rem; color: var(--muted); margin: .4rem 0 0; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; color: var(--text); font-size: .95rem; }
.check input { width: auto; min-height: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.card p:first-child { margin-top: 0; }
.actions-row { display: flex; flex-wrap: wrap; gap: .6rem; }
.actions-row.end { justify-content: flex-end; margin: 2rem 0; }

/* ---------- Connexion ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px; text-align: center;
  background: var(--surface); padding: 2rem 1.5rem; border-radius: 20px; box-shadow: var(--shadow); border: 1px solid var(--border);
}
.login-card h1 { margin: .3rem 0; }
.login-card input { margin: 1rem 0 .7rem; text-align: center; }
.login-card .btn { width: 100%; }
.login-logo { font-size: 3rem; }

/* ---------- Structure ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--wine); color: #fff;
  padding: .7rem 16px calc(.7rem) ;
  padding-top: max(.7rem, env(safe-area-inset-top));
}
@media (prefers-color-scheme: dark) { .topbar { background: #3a1a1f; } }
.brand { font-family: Georgia, serif; font-size: 1.2rem; font-weight: 600; }
main { max-width: 920px; margin: 0 auto; padding: 12px 16px calc(96px + env(safe-area-inset-bottom)); }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: 0; padding: .5rem 0 .45rem; cursor: pointer;
  font-size: .72rem; color: var(--muted);
}
.tab .ico { font-size: 1.25rem; line-height: 1; }
.tab[aria-current="page"] { color: var(--wine); font-weight: 700; }
.tab.add .ico {
  width: 44px; height: 44px; margin-top: -18px; border-radius: 50%;
  display: grid; place-items: center; background: var(--wine); color: #fff; font-size: 1.6rem;
  box-shadow: 0 4px 12px rgba(114, 47, 55, .4);
}
@media (min-width: 760px) {
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: .4rem 24px; }
  .tabs { position: static; display: flex; gap: .25rem; background: none; border: 0; padding: 0; }
  .tab { flex-direction: row; gap: .4rem; color: rgba(255,255,255,.8); font-size: .9rem; padding: .55rem .8rem; border-radius: 10px; }
  .tab .ico { font-size: 1rem; }
  .tab[aria-current="page"] { color: #fff; background: rgba(255,255,255,.15); }
  .tab.add .ico { width: auto; height: auto; margin: 0; background: none; box-shadow: none; font-size: 1.1rem; color: inherit; }
  .tab.add { background: #fff; color: var(--wine); font-weight: 700; margin-left: .5rem; }
  @media (prefers-color-scheme: dark) { .tab.add { background: var(--wine); color: #fff; } }
  main { padding-bottom: 40px; }
}

/* ---------- Recherche & filtres ---------- */
.search input { font-size: 1rem; padding-left: 2.3rem; background: var(--surface) no-repeat .8rem center / 1rem url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a6e70' stroke-width='2.5'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); }
.search { display: flex; gap: .5rem; }
.search input { flex: 1; min-width: 0; }
.scan-btn { flex: none; padding: .5rem .8rem; }
@media (max-width: 420px) { .scan-btn span { display: none; } }
.input-btn { display: flex; gap: .4rem; margin-top: .3rem; }
.input-btn input { margin-top: 0 !important; flex: 1; min-width: 0; font-weight: 400; color: var(--text); font-size: 1rem; }
.input-btn .btn { flex: none; }

/* Scanner */
.scan-view { position: relative; margin-top: .8rem; border-radius: 14px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; }
.scan-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame {
  position: absolute; inset: 30% 10%; border: 3px solid rgba(255,255,255,.9); border-radius: 12px;
  box-shadow: 0 0 0 100vmax rgba(0,0,0,.35);
}
.scan-frame::after {
  content: ''; position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: #ff4d4d;
  box-shadow: 0 0 8px #ff4d4d; animation: scanline 1.6s ease-in-out infinite alternate;
}
@keyframes scanline { from { transform: translateY(-28px); } to { transform: translateY(28px); } }
.scan-manual { display: flex; gap: .5rem; margin-top: .6rem; }
.scan-manual input { flex: 1; min-width: 0; }
.scan-list { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: .6rem; }
.scan-item { display: grid; grid-template-columns: 56px 1fr; gap: .75rem; align-items: start; background: var(--surface-2); border-radius: 12px; padding: .6rem; }
.scan-item .actions-row { margin-top: .45rem; gap: .4rem; }

.chips { display: flex; gap: .4rem; overflow-x: auto; padding: .7rem 0 .2rem; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: .4rem .85rem; font-size: .88rem; cursor: pointer; white-space: nowrap; min-height: 36px;
}
.chip[aria-pressed="true"] { background: var(--wine); border-color: var(--wine); color: #fff; }
.chip small { opacity: .75; margin-left: .25rem; }
.filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; margin-top: .5rem; }
.filters select { font-size: .85rem; padding: .5rem; min-height: 40px; }
.count { color: var(--muted); font-size: .85rem; margin: .8rem 0 .4rem; }
.filters.one { grid-template-columns: 1fr; }

/* ---------- Bascule Liste / Plan ---------- */
.mode-row { display: flex; justify-content: flex-end; margin-top: .5rem; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: none; border-radius: 8px; padding: .4rem .9rem; min-height: 36px;
  font-size: .88rem; font-weight: 600; color: var(--muted); cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--wine); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* ---------- Plan visuel ---------- */
:root { --wood: #a8784a; --wood-2: #8a5f37; }
@media (prefers-color-scheme: dark) { :root { --wood: #6e4c2e; --wood-2: #553a22; } }
.plan { display: grid; gap: 1rem; }
@media (min-width: 760px) { .plan { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); align-items: start; } }
.cab {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .9rem; box-shadow: var(--shadow);
}
.cab-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; flex-wrap: wrap; margin-bottom: .4rem; }
.cab-head h3 { margin: 0; font-size: 1.1rem; }
.cab-head .muted { font-size: .82rem; }
.shelf { padding: .55rem 0 .5rem; border-bottom: 5px solid var(--wood); box-shadow: 0 2px 0 var(--wood-2); margin-bottom: .55rem; }
.shelf.loose { border-bottom: 1px dashed var(--border); box-shadow: none; }
.shelf.over { border-bottom-color: var(--danger); }
.shelf-head { display: flex; justify-content: space-between; font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.shelf.over .shelf-n { color: var(--danger); }
.slots { display: flex; flex-wrap: wrap; gap: 5px; padding: .45rem 0 .35rem; }
.btl, .slot-free {
  width: 24px; height: 24px; border-radius: 50%; padding: 0; cursor: pointer; flex: none;
  transition: transform .12s, opacity .15s;
}
.btl {
  border: 2px solid color-mix(in srgb, var(--c) 60%, #000);
  background: radial-gradient(circle at 35% 35%, color-mix(in srgb, var(--c) 55%, #fff) 0 18%, var(--c) 45%);
}
.btl:hover, .slot-free:hover { transform: scale(1.18); }
.btl.dim { opacity: .18; }
.btl.hl { outline: 3px solid var(--gold); outline-offset: 1px; transform: scale(1.12); }
.slot-free { border: 2px dashed var(--border); background: transparent; }
.slot-free:hover { border-color: var(--wine); }
.shelf-wines { display: flex; flex-wrap: wrap; gap: .15rem .7rem; }
.link {
  background: none; border: 0; padding: .1rem 0; cursor: pointer; font-size: .82rem; color: var(--text);
  text-align: left; text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px;
}
.link b { color: var(--wine); }
.link.dim { opacity: .35; }
.cab .hint a { color: var(--wine); }

/* Grille d'emplacements précis */
.slots.grid {
  display: grid; grid-template-columns: repeat(var(--cols), minmax(18px, 1fr)); gap: 4px;
  overflow-x: auto; justify-items: center;
}
.slots.grid .btl, .slots.grid .slot-free { width: 100%; max-width: 30px; height: auto; aspect-ratio: 1; }
/* Double profondeur : rang arrière (au-dessus, plus « loin ») et rang avant */
.rang { display: flex; align-items: center; gap: 6px; }
.rang .slots.grid { flex: 1; min-width: 0; }
.rang-lab { flex: none; width: 2.1rem; font-size: .66rem; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.rang.back { background: color-mix(in srgb, var(--wood) 12%, transparent); border-radius: 8px; padding: 0 4px; margin-bottom: 2px; }
.rang.back .slots.grid { padding: .3rem 0 .25rem; }
.rang.back .btl, .rang.back .slot-free { max-width: 24px; }
.rang.back .btl:not(.hl):not(.sel) { filter: brightness(.85); }
.rang.front .slots.grid { padding-top: .2rem; }
.btl.sel {
  outline: 3px solid var(--wine); outline-offset: 2px; transform: scale(1.15);
  animation: pulse 1.2s ease-in-out infinite;
}
.btl.dim.sel { opacity: 1; }
.slot-free.target { border-color: var(--wine); background: color-mix(in srgb, var(--wine) 7%, transparent); }
.drop { background: color-mix(in srgb, var(--wine) 30%, transparent) !important; transform: scale(1.2); }
.btl[draggable="true"] { cursor: grab; }
.tray {
  border: 1px dashed var(--gold); border-radius: 12px; padding: .55rem .7rem; margin: .3rem 0 .8rem;
  background: color-mix(in srgb, var(--gold) 6%, transparent);
}
.tray .shelf-head { align-items: center; gap: .5rem; }
.tray .shelf-lab { color: var(--gold); }

/* Choix de l'emplacement dans le formulaire */
.slot-picker { margin-top: .8rem; background: var(--surface-2); border-radius: 12px; padding: .7rem .8rem; }
.pk-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .92rem; }
.pk-head .check { margin: 0; font-size: .85rem; }
.pk-sum { margin: .35rem 0 .5rem; font-size: .9rem; font-weight: 600; color: var(--wine); }
.warn-txt { color: var(--warn); font-weight: 500; }
.pk-grid { display: grid; gap: 4px; overflow-x: auto; }
.pk-row { display: flex; align-items: center; gap: 6px; }
.pk-lab { width: 1.2rem; flex: none; font-size: .72rem; font-weight: 700; color: var(--muted); text-align: right; }
.pk-cells { flex: 1; display: grid; grid-template-columns: repeat(var(--cols), minmax(16px, 26px)); gap: 3px; padding-bottom: 3px; border-bottom: 3px solid var(--wood); }
.pk {
  aspect-ratio: 1; border-radius: 50%; border: 1.5px dashed var(--border); background: var(--surface);
  padding: 0; font-size: .62rem; font-weight: 800; color: #fff; cursor: pointer; display: grid; place-items: center;
}
.pk-row.double { align-items: stretch; }
.pk-pair { flex: 1; display: grid; gap: 2px; min-width: 0; }
.pk-sub { display: flex; align-items: center; gap: 4px; }
.pk-r { flex: none; width: 1.7rem; font-size: .6rem; font-weight: 700; color: var(--muted); }
.pk-cells.back { border-bottom: 0; padding-bottom: 0; }
.pk-cells.back .pk { transform: scale(.88); }
.pk:hover { border-color: var(--wine); }
.pk.on { background: var(--gold); border: 2px solid color-mix(in srgb, var(--gold) 65%, #000); }
.pk.occ { background: var(--c); opacity: .35; border: 0; cursor: default; }

/* Barre d'action de la bouteille sélectionnée */
.selbar {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30;
  bottom: calc(72px + env(safe-area-inset-bottom)); width: calc(100% - 24px); max-width: 620px;
  background: var(--surface); border: 1px solid var(--wine); border-radius: 14px;
  box-shadow: 0 8px 28px rgba(0,0,0,.25); padding: .6rem .7rem;
  display: flex; flex-wrap: wrap; gap: .5rem .8rem; align-items: center; justify-content: space-between;
}
.selbar-txt { font-size: .88rem; min-width: 0; flex: 1 1 220px; }
.selbar-txt b { display: block; color: var(--wine); }
.selbar-txt span { color: var(--muted); }
.selbar-btns { display: flex; gap: .4rem; align-items: center; }
@media (min-width: 760px) { .selbar { bottom: 20px; } }
body.has-sel main { padding-bottom: calc(220px + env(safe-area-inset-bottom)); }
.emplacements { background: var(--surface-2); border-radius: 10px; padding: .6rem .8rem; margin: 0 0 1rem; font-size: .92rem; }
.emplacements ul { margin: .3rem 0; padding-left: 1.2rem; }

/* ---------- Liste des vins ---------- */
.vins { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
@media (min-width: 760px) { .vins { grid-template-columns: 1fr 1fr; } }
.vin {
  display: grid; grid-template-columns: 56px 1fr auto; gap: .75rem; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .65rem; box-shadow: var(--shadow); cursor: pointer;
}
.vin.empty { opacity: .6; }
.thumb {
  width: 56px; height: 72px; border-radius: 9px; object-fit: cover; background: var(--surface-2);
  display: grid; place-items: center; font-size: 1.6rem;
}
.vin-main { min-width: 0; }
.vin-nom { font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vin-nom .mill { color: var(--muted); font-weight: 500; }
.vin-sub { font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vin-sub.wrap { white-space: normal; }
.vin-tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .3rem; }
.tag { font-size: .72rem; padding: .1rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.tag.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.tag.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.tag.danger { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .3rem; vertical-align: baseline; }
.vin-side { display: flex; flex-direction: column; align-items: center; gap: .35rem; }
.qty { font-weight: 800; font-size: 1.05rem; color: var(--wine); }
.qty small { font-weight: 500; font-size: .7rem; color: var(--muted); }
.empty-state { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
.empty-state .big { font-size: 2.5rem; }

/* ---------- Dialogues (feuilles) ---------- */
dialog.sheet {
  border: 0; padding: 0; width: 100%; max-width: 600px; max-height: 92dvh;
  border-radius: 20px 20px 0 0; margin: auto auto 0;
  background: var(--surface); color: var(--text);
  box-shadow: 0 -10px 40px rgba(0,0,0,.25);
}
dialog.sheet.small { max-width: 440px; }
@media (min-width: 640px) { dialog.sheet { margin: auto; border-radius: 20px; } }
dialog::backdrop { background: rgba(20, 8, 10, .5); }
dialog[open] { animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet-body { padding: 1rem 16px calc(1rem + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.sheet-head h2 { margin: 0; }
.sheet-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1.2rem; flex-wrap: wrap; }
.sheet-actions .btn { flex: 1 1 auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .6rem; }
.grid3 { display: grid; grid-template-columns: 1.3fr 1fr .8fr; gap: 0 .6rem; }
@media (max-width: 340px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.photo-pick { display: flex; gap: .8rem; align-items: center; margin-top: .8rem; }
.photo-pick img { width: 84px; height: 110px; object-fit: cover; border-radius: 10px; }
.photo-btns { display: flex; flex-direction: column; gap: .4rem; }
.btn.ia { border-color: var(--gold); color: var(--gold); }
.btn.ia.busy { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.ia-status:empty { display: none; }
.ia-status.error { color: var(--danger); }
.ai-filled { border-color: var(--gold) !important; background: color-mix(in srgb, var(--gold) 8%, var(--surface)); }
.photo-btns label.btn { margin: 0; color: var(--text); font-size: .95rem; }

/* Fiche détaillée */
.detail-photo { width: 100%; max-height: 50dvh; object-fit: contain; border-radius: 12px; background: var(--surface-2); margin-top: .8rem; }
.detail-title { margin: .2rem 0 0; font-size: 1.4rem; }
.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; margin: 1rem 0; }
.fact { background: var(--surface-2); border-radius: 10px; padding: .5rem .7rem; }
.fact b { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.big-qty { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: 1rem 0; }
.big-qty .n { font-size: 2rem; font-weight: 800; color: var(--wine); min-width: 3ch; text-align: center; }
.big-qty .n small { display: block; font-size: .75rem; font-weight: 500; color: var(--muted); }
.notes { white-space: pre-wrap; background: var(--surface-2); border-radius: 10px; padding: .7rem; }

/* Étoiles */
.stars { border: 0; padding: 0; margin: .8rem 0 0; }
.stars legend { font-size: .8rem; font-weight: 600; padding: 0; }
.stars-row { display: flex; gap: .3rem; margin-top: .3rem; }
.star { font-size: 2rem; background: none; border: 0; cursor: pointer; color: var(--border); padding: 0 .1rem; line-height: 1; }
.star.on { color: var(--gold); }
.boire-nom { font-weight: 700; margin: .8rem 0 0; }

/* ---------- Historique ---------- */
.histo { list-style: none; padding: 0; margin: 0; }
.histo-day { font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; margin: 1.2rem 0 .4rem; }
.histo-item {
  display: flex; gap: .7rem; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .65rem .8rem; margin-bottom: .45rem;
}
.histo-item .ico { font-size: 1.3rem; }
.histo-item .txt { flex: 1; min-width: 0; }
.histo-item .meta { font-size: .8rem; color: var(--muted); }
.histo-item .gold { color: var(--gold); letter-spacing: .05em; }

/* ---------- Stats ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem; box-shadow: var(--shadow); }
.kpi .v { font-size: 1.6rem; font-weight: 800; color: var(--wine); }
.kpi .l { font-size: .8rem; color: var(--muted); }
.bars { display: grid; gap: .45rem; }
.bar { display: grid; grid-template-columns: 7.5rem 1fr 2.5rem; gap: .5rem; align-items: center; font-size: .88rem; }
.bar .track, .bar .fill { display: block; }
.bar .track { height: 12px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--wine); border-radius: 6px; }
.bar .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.bar .lab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.months { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; align-items: end; height: 140px; padding-top: 1rem; }
.month { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: .65rem; color: var(--muted); }
.month .col { width: 100%; background: var(--gold); border-radius: 4px 4px 0 0; min-height: 2px; }
.month .val { font-size: .7rem; color: var(--text); }

/* ---------- Réglages ---------- */
.caves-list { list-style: none; padding: 0; margin: 0 0 .7rem; display: grid; gap: .45rem; }
.cave-row {
  display: grid; grid-template-columns: 1fr 4.6rem 4.6rem 9.5rem auto auto; gap: .4rem; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .5rem;
}
.cave-row .info { grid-column: 1 / -1; font-size: .8rem; color: var(--muted); padding-left: .2rem; }
.inline-form { display: grid; grid-template-columns: 1fr 4.6rem 4.6rem 9.5rem auto; gap: .4rem; }
.cave-row input[type=number], .inline-form input[type=number] { padding-left: .5rem; padding-right: .3rem; }
.cave-row select, .inline-form select { padding: .5rem; font-size: .88rem; }
@media (max-width: 640px) {
  .cave-row { grid-template-columns: 1fr 1fr 1fr; }
  .cave-row > [name=nom] { grid-column: 1 / -1; }
  .cave-row > .btn { justify-self: start; }
  .inline-form { grid-template-columns: 1fr 1fr; }
  .inline-form > [name=nom], .inline-form > select, .inline-form > .btn { grid-column: 1 / -1; }
}
/* Types de vins */
.types-list { list-style: none; padding: 0; margin: 0 0 .7rem; display: grid; gap: .45rem; }
.type-row {
  display: grid; grid-template-columns: auto 2.6rem 3rem 1fr 5.2rem auto auto; gap: .4rem; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .5rem;
}
.type-row.type-new { grid-template-columns: 2.6rem 3rem 1fr 5.2rem auto; }
.type-row .info { grid-column: 1 / -1; font-size: .8rem; color: var(--muted); padding-left: .2rem; }
.type-row input[type=color] { padding: 2px; min-height: 40px; height: 40px; cursor: pointer; }
.type-emoji { text-align: center; padding: .5rem .2rem; }
.type-garde { display: flex; align-items: center; gap: .3rem; margin: 0; font-size: .85rem; font-weight: 500; color: var(--muted); }
.type-garde input { margin: 0; padding: .5rem .4rem; }
.type-move { display: flex; flex-direction: column; gap: 2px; }
.icon-btn.mini { width: 26px; height: 18px; border-radius: 5px; font-size: .6rem; line-height: 1; }
.icon-btn[disabled] { opacity: .3; cursor: default; }
@media (max-width: 640px) {
  .type-row { grid-template-columns: auto 2.6rem 3rem 1fr; }
  .type-row .type-garde { grid-column: 1 / 3; }
  .type-row > .btn { justify-self: start; }
  .type-row.type-new { grid-template-columns: 2.6rem 3rem 1fr; }
  .type-row.type-new .type-garde { grid-column: 1 / 3; }
}

.import-result { white-space: pre-wrap; background: var(--surface-2); padding: .7rem; border-radius: 10px; font-size: .85rem; max-height: 240px; overflow: auto; }
.card label.btn { margin-top: .4rem; color: var(--text); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 100;
  background: #2b2325; color: #fff; padding: .7rem 1rem; border-radius: 12px;
  display: flex; gap: 1rem; align-items: center; max-width: calc(100% - 32px);
  box-shadow: 0 6px 24px rgba(0,0,0,.3); font-size: .92rem;
}
.toast button { background: none; border: 0; color: var(--gold); font-weight: 700; cursor: pointer; padding: .2rem; }
.toast.error { background: var(--danger); }
@media (min-width: 760px) { .toast { bottom: 24px; } }

/* Réglages → Mot de passe */
.password-form { max-width: 30rem; }
.password-form label:first-of-type { margin-top: 0; }
.password-form .form-error:empty { display: none; }
.password-form .btn { margin-top: .8rem; }

/* Connexion Google + accès administrateur */
.google-btn { display: flex; align-items: center; justify-content: center; gap: .6rem; margin-top: 1rem; text-decoration: none; }
.g-logo { display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: #fff; color: #4285f4; font-weight: 800; font-family: Arial, sans-serif; }
.pwd-login { margin-top: 1.2rem; text-align: left; }
.pwd-login summary { cursor: pointer; color: var(--muted); font-size: .85rem; text-align: center; }
.pwd-login input { margin: .8rem 0 .6rem; }

/* Réglages → Utilisateurs */
.users-list { list-style: none; padding: 0; margin: 0 0 .6rem; display: grid; gap: .4rem; }
.user-row { display: flex; align-items: center; gap: .6rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .8rem; }
.user-main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.user-main .info { display: block; font-size: .8rem; color: var(--muted); margin-top: .15rem; }
.invite-form { display: grid; grid-template-columns: 1fr auto; gap: .4rem; }
.account-row { align-items: center; gap: .8rem; flex-wrap: wrap; }
