:root {
  --bg: #F7F3E8;
  --card: #FFFFFF;
  --line: #E6DFCF;
  --ink: #3B302B;
  --muted: #6B5F57;
  --brown: #5E351B;
  --brown-dark: #3F1D0E;
  --brown-soft: #EFE4D6;
  --cream: #FDF2CF;
  --green: #3F7A3A;
  --orange: #9A4A12;
  --orange-soft: #FBEDE3;
  --red: #A3261F;
  --radius: 18px;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: Inter, system-ui, -apple-system, sans-serif;
  --tabbar-h: 68px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 15px; -webkit-tap-highlight-color: transparent; }
a { color: var(--brown); }
button { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); margin: 0; line-height: 1.15; }
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 700; }
[hidden] { display: none !important; }

.app { min-height: 100vh; }
.main { max-width: 640px; margin: 0 auto; padding: 16px 18px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 18px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- Barre du bas (mobile) ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: #fff; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr); z-index: 20; }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 500; }
.tabbar a.active { color: var(--brown); font-weight: 700; }
.tabbar svg, .sidebar svg { width: 22px; height: 22px; }

/* ---------- Menu latéral (PC) ---------- */
.sidebar { display: none; }
@media (min-width: 900px) {
  .app { display: flex; }
  .tabbar { display: none !important; }
  .sidebar:not([hidden]) { display: flex; flex-direction: column; gap: 24px; width: 260px; flex-shrink: 0; min-height: 100vh; position: sticky; top: 0; align-self: flex-start; background: var(--brown-dark); color: var(--cream); padding: 24px 18px; }
  .sidebar .brand { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
  .sidebar .brand img { width: 150px; }
  .sidebar .brand span { font-size: 12px; color: #D9C9A8; }
  .sidebar nav { display: flex; flex-direction: column; gap: 4px; }
  .sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; color: var(--cream); text-decoration: none; font-size: 15px; }
  .sidebar nav a:hover { background: rgba(253,242,207,0.08); }
  .sidebar nav a.active { background: var(--brown); font-weight: 600; }
  .sidebar .today { margin-top: auto; background: rgba(253,242,207,0.08); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--cream); }
  .sidebar .today small { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #D9C9A8; }
  .sidebar .today strong { font-family: var(--display); font-size: 20px; color: #F2C48D; }
  .main { max-width: 1100px; flex: 1; padding: 32px 40px 48px; }
  .hide-desktop { display: none !important; }
  .grid-desktop { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
}
@media (max-width: 899px) { .hide-mobile { display: none !important; } }

/* ---------- Éléments communs ---------- */
.topbar { display: flex; align-items: center; gap: 12px; padding-top: 6px; }
.topbar .logo { width: 64px; flex-shrink: 0; }
.topbar .titles { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.topbar .titles strong { font-family: var(--display); font-size: 18px; }
.topbar .titles span { font-size: 12px; color: var(--muted); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding-top: 6px; flex-wrap: wrap; }
.page-head .sub { font-size: 14px; color: var(--muted); margin-top: 4px; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; text-decoration: none; color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card-link { text-decoration: none; color: inherit; display: flex; align-items: center; gap: 14px; }
.card-link .grow { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card-link .t { font-weight: 600; font-size: 15px; }
.card-link .s { font-size: 13px; color: var(--muted); }
.chev { width: 18px; height: 18px; flex-shrink: 0; color: var(--muted); }
.dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.section { display: flex; flex-direction: column; gap: 10px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; }
.section-head a { font-size: 13px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tag { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.empty { text-align: center; color: var(--muted); padding: 24px 12px; font-size: 14px; line-height: 1.5; }

.btn { height: 48px; padding: 0 18px; border-radius: 14px; border: none; background: var(--brown); color: #fff; font-weight: 600; font-size: 15px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn:hover { background: #4E2C16; color: #fff; }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.secondary:hover { background: #FBF8F0; }
.btn.danger { background: #fff; color: var(--red); border: 1px solid #E8C9C5; }
.btn.small { height: 38px; font-size: 13px; padding: 0 12px; border-radius: 10px; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn svg { width: 18px; height: 18px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Statut boutique */
.status .dot { background: var(--muted); }
.status.open .dot { background: var(--green); }
.status.closed .dot { background: var(--red); }
.status.exception { background: var(--orange-soft); border-color: #F0D5C0; }

/* Carte lune */
.moon-card { background: var(--brown-dark); color: var(--cream); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 10px; text-decoration: none; }
.moon-card .k { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: #D9C9A8; display: flex; justify-content: space-between; align-items: center; }
.moon-card .k svg { width: 20px; height: 20px; color: #F2C48D; }
.moon-card .big { font-family: var(--display); font-weight: 700; font-size: 30px; }
.moon-card .row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.moon-card .s { font-size: 13px; color: #D9C9A8; }
.moon-card p { margin: 0; font-size: 14px; line-height: 1.45; color: #F3EBDA; }

.news-cave { background: var(--brown-soft); border: none; }
.news-cave .ico { width: 44px; height: 44px; border-radius: 12px; background: var(--brown); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--cream); }
.news-cave .ico svg { width: 22px; height: 22px; }

/* Événements à venir */
.event { display: flex; gap: 12px; align-items: flex-start; }
.event .date { width: 52px; flex-shrink: 0; border-radius: 12px; background: var(--bg); text-align: center; padding: 6px 0; }
.event .date b { display: block; font-family: var(--display); font-size: 20px; }
.event .date span { font-size: 11px; text-transform: uppercase; color: var(--muted); }
.event .grow { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.event .t { font-weight: 600; }
.event.fermeture .tag { color: var(--red); }
.event.commande .tag { color: var(--orange); }
.event.evenement .tag { color: var(--green); }
.event.horaires .tag { color: var(--brown); }
.events-list { display: flex; flex-direction: column; gap: 14px; }

/* Actus */
.news { display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: inherit; overflow: hidden; padding: 0; }
.news img { width: 100%; height: 150px; object-fit: cover; display: block; background: var(--brown-soft); }
.news .in { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; }
.news .t { font-weight: 600; font-size: 15px; }
.news .e { font-size: 13px; color: var(--muted); line-height: 1.45; white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.news .d { font-size: 12px; color: var(--muted); }

/* Cave */
.shelves { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 900px) { .shelves { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.shelf { text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; }
.shelf.on { border: 2px solid var(--brown); padding: 11px 13px; background: #FFFCF5; }
.shelf .n { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.shelf .n .dot { width: 10px; height: 10px; }
.shelf b { font-family: var(--display); font-size: 24px; }
.search { display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 14px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.search svg { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.search input { border: none; outline: none; background: transparent; font: inherit; flex: 1; min-width: 0; color: var(--ink); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 13px; font-weight: 500; }
.chip.on { background: var(--brown); border-color: var(--brown); color: #fff; }
.bottle { display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit; padding: 14px; }
.bottle .bar { width: 6px; align-self: stretch; border-radius: 3px; flex-shrink: 0; }
.bottle .grow { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.bottle .t { font-weight: 600; font-size: 15px; }
.bottle .s { font-size: 13px; color: var(--muted); }
.bottle .st { font-size: 12px; font-weight: 600; }
.qty { background: var(--bg); border-radius: 10px; padding: 6px 10px; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.pret { color: var(--green); }
.attendre { color: var(--orange); }
.list { display: flex; flex-direction: column; gap: 10px; }
.fab { position: fixed; right: 20px; bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom)); width: 60px; height: 60px; border-radius: 50%; border: none; background: var(--brown); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 6px 18px rgba(94,53,27,.35); z-index: 15; text-decoration: none; }
.fab svg { width: 26px; height: 26px; }

/* Fiche bouteille */
.detail-head { display: flex; gap: 14px; align-items: center; }
.detail-head .bar { width: 8px; height: 64px; border-radius: 4px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper button { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-size: 22px; cursor: pointer; }
.stepper b { font-family: var(--display); font-size: 26px; min-width: 36px; text-align: center; }

/* Formulaires */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .lbl { font-size: 13px; font-weight: 600; }
.field input, .field select { height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font: inherit; color: var(--ink); width: 100%; }
.field input:focus, .field select:focus, .search:focus-within { outline: 2px solid var(--brown); outline-offset: 1px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button { height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 14px; display: inline-flex; align-items: center; gap: 8px; }
.seg button.on { background: var(--brown); border-color: var(--brown); color: #fff; }
.seg .dot { width: 10px; height: 10px; }
.error { background: #FBE9E7; color: var(--red); border-radius: 12px; padding: 10px 14px; font-size: 14px; }
.back { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-weight: 600; font-size: 14px; color: var(--muted); }
.back svg { width: 18px; height: 18px; }

/* Connexion */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login .box { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 20px; }
.login .box img { width: 190px; align-self: center; }
.login .box p { margin: 0; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.5; }

/* Biodynamie */
.days { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; }
.day { flex: 0 0 auto; width: 52px; height: 78px; border-radius: 14px; border: 1px solid var(--line); background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; scroll-snap-align: start; padding: 0; }
.day span { font-size: 11px; font-weight: 500; }
.day b { font-family: var(--display); font-size: 18px; }
.day i { width: 8px; height: 8px; border-radius: 50%; }
.day.on { color: #fff; border-width: 2px; }
.day.on i { background: #fff !important; }
.day-card { border-radius: 20px; padding: 20px; color: #fff; display: flex; flex-direction: column; gap: 10px; }
.day-card .k { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; opacity: .9; }
.day-card .big { font-family: var(--display); font-weight: 700; font-size: 34px; line-height: 1; }
.day-card p { margin: 0; font-size: 15px; line-height: 1.45; }
.day-card .segs { display: flex; flex-direction: column; gap: 4px; font-size: 13px; background: rgba(255,255,255,.14); border-radius: 12px; padding: 10px 12px; }
.warn { background: var(--orange-soft); color: #7A3A10; border-radius: 12px; padding: 10px 12px; font-size: 13px; line-height: 1.4; }
.legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.legend div { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.legend b { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.legend span { font-size: 12px; color: var(--muted); line-height: 1.35; }

/* Boutique */
.hours { display: flex; flex-direction: column; gap: 8px; }
.hours div { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.hours div.today { font-weight: 700; }
.hours div span:last-child { color: var(--muted); text-align: right; }
.hours div.today span:last-child { color: var(--ink); }
.contact { display: flex; flex-direction: column; gap: 6px; font-size: 14px; line-height: 1.5; }

/* Admin */
.hrow { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
@media (min-width: 600px) { .hrow { grid-template-columns: 100px 1fr; align-items: center; } }
.hrow:first-of-type { border-top: none; }
.hrow .pl { display: flex; flex-direction: column; gap: 6px; }
.hrow .p { display: flex; gap: 6px; align-items: center; }
.hrow input[type=time] { height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 0 8px; font: inherit; background: #fff; min-width: 0; width: 0; flex: 1; }
.hrow .x { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; flex-shrink: 0; }
.link-box { display: flex; gap: 8px; align-items: center; background: var(--bg); border-radius: 12px; padding: 10px 12px; font-size: 13px; word-break: break-all; }
.users div { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.users div:first-child { border-top: none; }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 24px); transform: translateX(-50%) translateY(20px); background: var(--brown-dark); color: var(--cream); padding: 12px 18px; border-radius: 14px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 50; max-width: calc(100% - 40px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.modal-bg { position: fixed; inset: 0; background: rgba(40,25,15,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 40; }
.modal { background: var(--bg); width: 100%; max-width: 480px; border-radius: 22px 22px 0 0; padding: 22px 20px calc(22px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px; }
@media (min-width: 600px) { .modal-bg { align-items: center; } .modal { border-radius: 22px; } }
