/* ============================================================
   BeerLab v2 — thème malt & mousse
   ============================================================ */

:root {
  --malt-900: #160f05;
  --malt-800: #1e1509;
  --malt-700: #2a1e0e;
  --malt-600: #38290f;

  --foam: #fdf3dc;
  --foam-dim: rgba(253, 243, 220, .60);
  --foam-faint: rgba(253, 243, 220, .34);

  --amber: #ffb02e;
  --amber-deep: #f5891f;
  --gold-soft: #ffd98a;

  --line: rgba(255, 190, 90, .16);
  --line-strong: rgba(255, 190, 90, .30);
  --card: rgba(255, 226, 170, .045);
  --card-hi: rgba(255, 226, 170, .085);

  --biere: #ffb02e;
  --vin: #d76a95;
  --spiritueux: #79b6cf;
  --autre: #b6a891;

  --ok: #7ad17f;
  --danger: #ff6b5e;

  --radius: 18px;
  --radius-lg: 26px;
  --shadow: 0 22px 55px -28px rgba(0, 0, 0, .9);

  --sans: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --round: "Fredoka", var(--sans);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--sans);
  color: var(--foam);
  background:
    radial-gradient(120% 80% at 50% -10%, #2c1e0c 0%, var(--malt-900) 55%) fixed,
    var(--malt-900);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

.glow {
  position: fixed;
  inset: -20% 0 auto 0;
  height: 60vh;
  background: radial-gradient(60% 100% at 50% 0%, rgba(255, 176, 46, .22), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ---------- Barre du haut ---------- */
.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px clamp(16px, 5vw, 40px);
  max-width: 1040px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--foam);
}
.brand-mark { font-size: 1.6rem; filter: drop-shadow(0 4px 10px rgba(255, 176, 46, .5)); }
.brand-name {
  font-family: var(--round);
  font-weight: 700;
  font-size: 1.45rem;
  letter-spacing: -.01em;
}
.brand-tag {
  font-size: .74rem;
  font-weight: 600;
  color: var(--malt-900);
  background: var(--amber);
  padding: 2px 9px;
  border-radius: 999px;
  transform: translateY(1px);
}

.btn-ghost {
  text-decoration: none;
  color: var(--gold-soft);
  font-weight: 500;
  font-size: .95rem;
  padding: 9px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  transition: background .18s, border-color .18s, color .18s;
}
.btn-ghost:hover { background: var(--card-hi); border-color: var(--amber); color: var(--foam); }

/* ---------- Conteneur ---------- */
.wrap {
  position: relative;
  z-index: 1;
  max-width: 1040px;
  margin: 0 auto;
  padding: 8px clamp(16px, 5vw, 40px) 64px;
}

/* ============================================================
   CONSULTATION — héros
   ============================================================ */
.hero {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: clamp(20px, 5vw, 48px);
  padding: clamp(20px, 4vw, 40px) 0 clamp(28px, 5vw, 48px);
}

.hero-kicker {
  margin: 0 0 6px;
  color: var(--gold-soft);
  font-weight: 600;
  font-size: .95rem;
}
.hero-number {
  margin: 0;
  font-family: var(--round);
  font-weight: 700;
  font-size: clamp(4rem, 17vw, 8.5rem);
  line-height: .86;
  color: var(--amber);
  letter-spacing: -.03em;
  text-shadow: 0 8px 40px rgba(255, 176, 46, .35);
  font-variant-numeric: tabular-nums;
}
.hero-unit {
  font-size: .4em;
  margin-left: .12em;
  color: var(--gold-soft);
}
.hero-sub { margin: 10px 0 2px; font-size: 1.05rem; color: var(--foam-dim); max-width: 24ch; }
.hero-refs { margin: 0; font-size: .92rem; color: var(--foam-faint); }

/* ---------- Le verre ---------- */
.glass {
  --glass-w: clamp(96px, 22vw, 140px);
  width: var(--glass-w);
  display: flex;
  flex-direction: column;
  align-items: center;
  filter: drop-shadow(0 20px 30px rgba(0, 0, 0, .5));
}
.glass-foam {
  width: calc(var(--glass-w) + 10px);
  height: 26px;
  background:
    radial-gradient(circle at 20% 60%, #fff 0 7px, transparent 8px),
    radial-gradient(circle at 45% 30%, #fff 0 9px, transparent 10px),
    radial-gradient(circle at 72% 55%, #fff 0 8px, transparent 9px),
    radial-gradient(circle at 90% 40%, #fff 0 6px, transparent 7px),
    var(--foam);
  border-radius: 16px 16px 8px 8px;
  order: -1;
  margin-bottom: -8px;
  z-index: 2;
  box-shadow: 0 4px 14px rgba(255, 240, 210, .25);
}
.glass-body {
  position: relative;
  width: 100%;
  height: clamp(150px, 34vw, 210px);
  border: 2px solid rgba(255, 224, 170, .5);
  border-top: none;
  border-radius: 8px 8px 26px 26px / 8px 8px 40px 40px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 176, 46, .10), rgba(255, 176, 46, .02));
}
.glass-fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 78%;
  background: linear-gradient(180deg, #ffcf6b 0%, var(--amber) 45%, var(--amber-deep) 100%);
  box-shadow: inset 0 6px 14px rgba(255, 255, 255, .35);
}
.glass-fill::before {
  content: "";
  position: absolute;
  top: -6px; left: 0; right: 0; height: 12px;
  background: rgba(255, 255, 255, .5);
  filter: blur(3px);
  animation: sway 4.5s ease-in-out infinite;
}
@keyframes sway { 0%,100% { transform: translateX(-6%); } 50% { transform: translateX(6%); } }

.bubble {
  position: absolute;
  bottom: 6%;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .75);
  animation: rise 4s linear infinite;
}
.bubble.b1 { left: 22%; animation-duration: 3.6s; animation-delay: .2s; }
.bubble.b2 { left: 42%; width: 6px; height: 6px; animation-duration: 4.4s; animation-delay: 1.1s; }
.bubble.b3 { left: 58%; width: 10px; height: 10px; animation-duration: 5s; animation-delay: .6s; }
.bubble.b4 { left: 72%; width: 5px; height: 5px; animation-duration: 3.9s; animation-delay: 1.7s; }
.bubble.b5 { left: 34%; width: 7px; height: 7px; animation-duration: 4.7s; animation-delay: 2.3s; }
@keyframes rise {
  0%   { transform: translateY(0) scale(.6); opacity: 0; }
  15%  { opacity: .9; }
  100% { transform: translateY(-150px) scale(1); opacity: 0; }
}

/* ---------- Ardoise (grille produits) ---------- */
.board-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 22px;
  margin-bottom: 18px;
}
.board-head h2 {
  margin: 0;
  font-family: var(--round);
  font-weight: 600;
  font-size: 1.5rem;
}
.live { display: inline-flex; align-items: center; gap: 7px; font-size: .85rem; color: var(--foam-dim); }
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(122, 209, 127, .6);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(122, 209, 127, .55); }
  70%  { box-shadow: 0 0 0 8px rgba(122, 209, 127, 0); }
  100% { box-shadow: 0 0 0 0 rgba(122, 209, 127, 0); }
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}
.tile {
  position: relative;
  padding: 16px 16px 14px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--card-hi), var(--card));
  border: 1px solid var(--line);
  overflow: hidden;
}
.tile::before {
  content: "";
  position: absolute;
  top: 0; left: 0; width: 4px; height: 100%;
  background: var(--tile-accent, var(--amber));
}
.tile-type {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .78rem; color: var(--foam-dim); margin-bottom: 10px;
}
.tile-type::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--tile-accent, var(--amber));
}
.tile-nom {
  font-weight: 600; font-size: 1.02rem; line-height: 1.25;
  margin-bottom: 12px; min-height: 2.5em;
}
.tile-bottom { display: flex; align-items: baseline; justify-content: space-between; }
.tile-qte {
  font-family: var(--round); font-weight: 700; font-size: 1.9rem;
  color: var(--amber); line-height: 1;
}
.tile-vol { font-size: .82rem; color: var(--foam-faint); }

.empty {
  text-align: center;
  color: var(--foam-dim);
  padding: 40px 0;
  font-size: 1.05rem;
}

/* ============================================================
   RÉGIE — onglets, cartes, formulaires
   ============================================================ */
.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 6px;
  margin: 4px 0 24px;
  background: var(--malt-800);
  border: 1px solid var(--line);
  border-radius: 999px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: var(--foam-dim);
  font-family: var(--sans);
  font-size: .95rem;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .18s, background .18s;
}
.tab:hover { color: var(--foam); }
.tab.is-active {
  color: var(--malt-900);
  background: linear-gradient(180deg, var(--gold-soft), var(--amber));
  font-weight: 600;
}

.panel { display: none; animation: fade .25s ease; }
.panel.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: linear-gradient(180deg, var(--malt-800), var(--malt-700));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(20px, 4vw, 32px);
  box-shadow: var(--shadow);
  max-width: 620px;
}
.card-title {
  margin: 0 0 4px;
  font-family: var(--round);
  font-weight: 600;
  font-size: 1.35rem;
}
.card-help { margin: 0 0 22px; color: var(--foam-dim); font-size: .95rem; }

.field { display: block; margin-bottom: 16px; }
.field-label { display: block; margin-bottom: 7px; font-size: .85rem; color: var(--gold-soft); font-weight: 500; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row .field { flex: 1 1 180px; }

.input {
  width: 100%;
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--foam);
  background: var(--malt-900);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 13px 15px;
  transition: border-color .18s, box-shadow .18s;
}
.input::placeholder { color: var(--foam-faint); }
.input:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(255, 176, 46, .18);
}
select.input { appearance: none; cursor: pointer; }

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--malt-900);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}
.seg {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--foam-dim);
  font-family: var(--sans);
  font-size: .95rem;
  font-weight: 500;
  padding: 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: background .18s, color .18s;
}
.seg.is-active { background: var(--amber); color: var(--malt-900); font-weight: 600; }

.btn-primary {
  width: 100%;
  margin-top: 8px;
  border: none;
  cursor: pointer;
  font-family: var(--round);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--malt-900);
  background: linear-gradient(180deg, var(--gold-soft), var(--amber-deep));
  padding: 15px;
  border-radius: var(--radius);
  transition: transform .12s, filter .18s;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:active { transform: scale(.985); }

/* ---------- Scan ---------- */
.scan-card .input-scan {
  font-family: var(--round);
  font-size: 1.4rem;
  padding: 20px;
  text-align: center;
  letter-spacing: .04em;
}
.scan-plus .input-scan:focus { border-color: var(--ok); box-shadow: 0 0 0 3px rgba(122, 209, 127, .2); }
.scan-moins .input-scan:focus { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(255, 107, 94, .2); }

.scan-log { list-style: none; margin: 20px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.scan-log li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 15px;
  background: var(--malt-900);
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: .95rem;
  animation: fade .2s ease;
}
.scan-log .li-nom { font-weight: 500; }
.scan-log .li-badge {
  font-family: var(--round); font-weight: 600; font-size: .9rem;
  padding: 3px 10px; border-radius: 999px;
}
.li-badge.plus { background: rgba(122, 209, 127, .16); color: var(--ok); }
.li-badge.moins { background: rgba(255, 107, 94, .16); color: var(--danger); }
.scan-log .li-err { color: var(--danger); border-color: rgba(255, 107, 94, .3); }

/* ---------- Liste stock (régie) ---------- */
.stock-list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.st-row {
  display: grid;
  grid-template-columns: 10px 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--malt-900);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.st-accent { width: 10px; height: 34px; border-radius: 4px; background: var(--amber); }
.st-info { min-width: 0; }
.st-nom { font-weight: 500; display: flex; align-items: center; gap: 8px; }
.st-meta { font-size: .82rem; color: var(--foam-faint); }
.st-qte {
  font-family: var(--round); font-weight: 700; font-size: 1.3rem;
  color: var(--amber); min-width: 48px; text-align: right;
}
.st-del {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--foam-dim);
  width: 38px; height: 38px;
  border-radius: 11px;
  cursor: pointer;
  font-size: 1rem;
  transition: background .18s, color .18s, border-color .18s;
}
.st-del:hover { background: rgba(255, 107, 94, .15); color: var(--danger); border-color: var(--danger); }
.badge-epuise {
  font-size: .7rem; font-weight: 600;
  background: rgba(255, 107, 94, .18); color: var(--danger);
  padding: 2px 8px; border-radius: 999px;
}

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(92vw, 420px);
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 17px;
  border-radius: 14px;
  background: var(--malt-700);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  font-size: .95rem;
  animation: toastin .25s ease;
}
.toast.ok { border-left: 4px solid var(--ok); }
.toast.err { border-left: 4px solid var(--danger); }
@keyframes toastin { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  .hero { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .hero-sub, .hero-refs { max-width: none; }
  .glass { order: 2; margin-top: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
