/* Ma Cave — thème "cave de nuit" : fond prune profond, le vin apporte la couleur. */
:root {
  --cave: #1a0a11;
  --cave-2: #24101a;
  --panel: #2d1522;
  --panel-2: #3a1c2c;
  --line: rgba(255, 214, 230, .12);
  --cream: #fbefe6;
  --cream-2: #d9bfc9;
  --muted: #9f7f8f;
  --accent: #ff4f7b;
  --accent-2: #ff8fb0;
  --rouge: #d61e55;
  --blanc: #f4c84a;
  --rose: #ff7aa2;
  --effervescent: #e9d8a6;
  --doux: #f28c28;
  --ok: #4fd18b;
  --warn: #ffb74a;
  --danger: #ff5c5c;
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 10px;
  --ui: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--cave); color: var(--cream); font: 16px/1.45 var(--ui); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); min-height: 100vh; background: radial-gradient(120% 60% at 50% -10%, #4a1a30 0%, var(--cave) 60%); }
h1, h2, h3 { margin: 0; font-family: var(--display); font-weight: 700; letter-spacing: -.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- connexion ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; background: radial-gradient(80% 50% at 50% 0%, #6a1f44 0%, var(--cave) 70%); }
.login-card { width: 100%; max-width: 380px; text-align: center; }
.login-glass { width: 120px; height: 120px; margin: 0 auto 18px; border-radius: 50%; background: conic-gradient(var(--rouge), var(--doux), var(--blanc), var(--effervescent), var(--rose), var(--rouge)); filter: blur(.3px); box-shadow: 0 20px 60px rgba(255, 79, 123, .35); animation: spin 18s linear infinite; }
.login h1 { font-size: 44px; font-style: italic; font-weight: 500; }
.login p { color: var(--cream-2); margin: 6px 0 22px; }
.login-msg { margin-top: 10px; color: var(--danger); font-size: 14px; min-height: 20px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- en-tête / navigation ---------- */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: calc(14px + env(safe-area-inset-top)) 18px 12px; background: linear-gradient(var(--cave) 70%, transparent); }
.topbar h1 { font-size: 34px; font-style: italic; font-weight: 500; line-height: 1; }
.topsub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.fab { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 30px; line-height: 1; display: grid; place-items: center; box-shadow: 0 8px 24px rgba(255, 79, 123, .4); }
.fab:active { transform: scale(.94); }

main { padding: 4px 18px 24px; max-width: 760px; margin: 0 auto; }

.tabbar { position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); display: flex; background: rgba(45, 21, 34, .92); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--line); border-radius: 24px; padding: 6px; z-index: 5; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.tabbar button { flex: 1; border: 0; background: none; padding: 7px 0 5px; font-size: 11px; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; border-radius: 18px; }
.tabbar button .ico { font-size: 20px; }
.tabbar button.active { color: var(--cream); background: var(--panel-2); }

/* ---------- composants ---------- */
.search { margin: 6px 0 10px; }
input[type=text], input[type=number], input[type=date], input[type=search], input[type=password], select, textarea { width: 100%; padding: 13px 14px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel); color: var(--cream); }
input::placeholder, textarea::placeholder { color: var(--muted); }
input[type=search] { padding-left: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%239f7f8f' stroke-width='2.2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 13px center; }
textarea { min-height: 72px; resize: vertical; }
select { appearance: none; -webkit-appearance: none; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; margin-bottom: 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-size: 13px; font-weight: 600; color: var(--cream-2); display: flex; align-items: center; gap: 7px; }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; }
.chip.active { background: var(--cream); color: var(--cave); border-color: var(--cream); }

/* barre de cave : composition par couleur */
.rack { display: flex; height: 14px; border-radius: 8px; overflow: hidden; gap: 2px; margin: 4px 0 6px; }
.rack span { display: block; height: 100%; min-width: 4px; }
.rack-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--cream-2); margin-bottom: 12px; }
.rack-legend b { font-family: var(--display); font-weight: 700; color: var(--cream); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px; margin-bottom: 10px; }
.wine { display: grid; grid-template-columns: 54px 1fr auto; gap: 12px; align-items: center; cursor: pointer; }
.wine:active { background: var(--panel-2); }
.bottle { width: 54px; height: 64px; border-radius: 12px 12px 14px 14px; display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 17px; color: #1a0a11; position: relative; overflow: hidden; }
.bottle::before { content: ""; position: absolute; left: 6px; top: 6px; width: 10px; height: 40px; border-radius: 6px; background: rgba(255,255,255,.28); }
.bottle.rouge { background: var(--rouge); color: #fff; }
.bottle.blanc { background: var(--blanc); }
.bottle.rose { background: var(--rose); }
.bottle.effervescent { background: var(--effervescent); }
.bottle.doux { background: var(--doux); }
.bottle small { font: 600 10px/1 var(--ui); opacity: .8; position: absolute; bottom: 7px; }
.wine .title { font-weight: 700; font-size: 16px; line-height: 1.25; }
.wine .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.wine .qty { text-align: right; font-family: var(--display); font-weight: 700; font-size: 26px; line-height: 1; }
.wine .qty small { display: block; font: 500 11px/1.3 var(--ui); color: var(--muted); }
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; margin-top: 6px; }
.badge.ok { background: rgba(79, 209, 139, .18); color: var(--ok); }
.badge.warn { background: rgba(255, 183, 74, .18); color: var(--warn); }
.badge.danger { background: rgba(255, 92, 92, .2); color: var(--danger); }
.badge.wait { background: rgba(255, 143, 176, .16); color: var(--accent-2); }

.btn { padding: 14px 18px; border-radius: var(--r-md); border: 0; background: var(--accent); color: #fff; font-weight: 700; width: 100%; box-shadow: 0 8px 20px rgba(255, 79, 123, .28); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--panel-2); color: var(--cream); box-shadow: none; border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--muted); box-shadow: none; }
.btn.danger { background: var(--danger); }
.btn:disabled { opacity: .45; box-shadow: none; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label.f { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 10px 0 5px; }
.empty { text-align: center; color: var(--muted); padding: 48px 12px; line-height: 1.6; }
.empty b { color: var(--cream); font-family: var(--display); font-size: 20px; display: block; margin-bottom: 6px; }
.section-title { font-family: var(--display); font-style: italic; font-weight: 500; font-size: 20px; margin: 20px 0 10px; }
.section-title small { font: 500 13px var(--ui); color: var(--muted); margin-left: 8px; font-style: normal; }
.small { font-size: 13px; color: var(--cream-2); }
.muted { color: var(--muted); }

/* ---------- fiche (modal) ---------- */
.modal { position: fixed; inset: 0; background: rgba(10, 3, 7, .6); backdrop-filter: blur(4px); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.modal-card { background: var(--cave-2); width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: 26px 26px 0 0; padding: 14px 18px calc(18px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
@media (min-width: 700px) { .modal { align-items: center; } .modal-card { border-radius: 26px; } }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 6px; }
.modal-head h2 { font-size: 26px; font-style: italic; font-weight: 500; line-height: 1.15; }
.close { border: 0; background: var(--panel-2); color: var(--cream); border-radius: 50%; width: 34px; height: 34px; flex: 0 0 auto; }
.hero-wine { display: flex; gap: 14px; align-items: center; margin: 12px 0; }
.hero-wine .bottle { width: 68px; height: 86px; font-size: 21px; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.fact { background: var(--panel); border-radius: var(--r-md); padding: 10px 8px; text-align: center; }
.fact .v { font-family: var(--display); font-weight: 700; font-size: 22px; line-height: 1.1; }
.fact .l { font-size: 11px; color: var(--muted); margin-top: 3px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 14px; margin: 10px 0; }
.kv dt { color: var(--muted); margin: 0; }
.kv dd { margin: 0; }

.toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--cream); color: var(--cave); padding: 11px 18px; border-radius: 999px; z-index: 30; font-size: 14px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: 90vw; }

/* ---------- scanner ---------- */
.scan-hero { text-align: center; padding: 26px 16px 18px; border-radius: var(--r-lg); background: linear-gradient(160deg, #5a1a3a, #2d1522 70%); border: 1px solid var(--line); }
.scan-hero h2 { font-size: 26px; font-style: italic; font-weight: 500; }
.scan-hero p { color: var(--cream-2); margin: 6px 0 16px; font-size: 14px; }
.scan-hero input { display: none; }
.thumbs { display: flex; gap: 8px; margin: 12px 0 4px; justify-content: center; flex-wrap: wrap; }
.thumbs img { width: 76px; height: 76px; object-fit: cover; border-radius: 12px; border: 2px solid var(--line); }
.spinner { width: 30px; height: 30px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 18px auto; }
.scan-result { margin-top: 12px; }
.conf { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--panel-2); color: var(--cream-2); margin-bottom: 8px; }

/* ---------- bilan ---------- */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 8px; text-align: center; }
.kpi .v { font-family: var(--display); font-weight: 700; font-size: 26px; line-height: 1.05; }
.kpi .l { font-size: 11px; color: var(--muted); margin-top: 4px; }
.hbar { display: grid; grid-template-columns: 110px 1fr 36px; gap: 10px; align-items: center; font-size: 13px; margin: 7px 0; }
.hbar .track { height: 12px; background: var(--panel); border-radius: 6px; overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 6px; background: var(--accent); }
.hbar .n { text-align: right; font-family: var(--display); font-weight: 700; font-size: 15px; }
.stars { font-size: 30px; letter-spacing: 4px; cursor: pointer; user-select: none; color: var(--muted); }
.stars span.on { color: var(--blanc); }
.tasting { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.tasting:last-child { border-bottom: 0; }
.tasting .d { color: var(--muted); font-size: 12px; }
.tasting .s { color: var(--blanc); letter-spacing: 1px; white-space: nowrap; }

/* ---------- facture ---------- */
.wine .qty em { display: block; font: 600 12px/1.3 var(--ui); color: var(--accent-2); font-style: normal; margin-top: 2px; }
.pdf-thumb { width: 76px; height: 76px; border-radius: 12px; border: 2px solid var(--line); background: var(--panel-2); display: grid; place-items: center; font-weight: 700; color: var(--cream-2); cursor: pointer; }
.flines { display: flex; flex-direction: column; gap: 8px; }
.fline { display: grid; grid-template-columns: 22px 44px 1fr; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.fline:last-child { border-bottom: 0; }
.fline.off { opacity: .4; }
.fline input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
.fline .title { font-weight: 700; font-size: 14px; line-height: 1.25; }
.fline .sub { color: var(--muted); font-size: 12px; }
.fedit { display: flex; gap: 10px; margin-top: 6px; }
.fedit label { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.fedit input { width: 64px; padding: 6px 8px; border-radius: 8px; }
