/* Font ospitati con l'app (niente Google Fonts: funzionano anche offline) */
@font-face { font-family: 'Fraunces'; font-style: normal; font-display: swap; font-weight: 100 900; src: url(fonts/fraunces-latin-full-normal.woff2) format('woff2'); }
@font-face { font-family: 'Fraunces'; font-style: italic; font-display: swap; font-weight: 100 900; src: url(fonts/fraunces-latin-full-italic.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-display: swap; font-weight: 100 900; src: url(fonts/inter-latin-wght-normal.woff2) format('woff2'); }
/* Ca' Valli · stile "Cantina moderna"
 * Tufo scuro, botte, granato, ambra. Fraunces per le parole importanti, Inter per tutto il resto.
 * L'unico elemento "forte" è la bottiglia che si riempie con la maturità: il resto resta sobrio. */
:root {
  --tufo: #16110F;      /* fondo */
  --botte: #211915;     /* superfici */
  --feccia: #2C221D;    /* superfici rialzate, campi */
  --ln: rgba(209, 168, 102, .13);
  --ln2: rgba(209, 168, 102, .26);
  --granato: #9A2C3E;
  --granato2: #B8455A;
  --ambra: #D1A866;
  --gesso: #EFE6DA;
  --mu: #A3958A;
  --mu2: #74675E;
  --ok: #8DB596;
  --ko: #E0735E;
  --urgente: #E3A04A;
  /* tipologie */
  --t-rosso: #A3304A; --t-bianco: #E3D184; --t-rosato: #E9A3A3; --t-bollicine: #EBD9A0;
  --t-dolce: #DB9A3E; --t-fortificato: #7B3420; --t-orange: #DE8B3B;
  --serif: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--tufo); color: var(--gesso); font-family: var(--sans); font-size: 15px; line-height: 1.5;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; font-feature-settings: 'cv11', 'ss01'; }
body::before { content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .07; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
#root { position: relative; z-index: 1; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--ambra); }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--ambra); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* --- tipografia --- */
.serif { font-family: var(--serif); font-optical-sizing: auto; }
h1, h2, h3 { font-family: var(--serif); font-optical-sizing: auto; font-weight: 500; font-variation-settings: 'SOFT' 50; margin: 0; letter-spacing: -.01em; line-height: 1.12; }
h1 { font-size: 34px; }
h2 { font-size: 24px; }
h3 { font-size: 18px; }
.mu { color: var(--mu); }
.small { font-size: 13px; }
.italic { font-style: italic; }

/* --- marchio --- */
.wordmark { font-family: var(--serif); font-weight: 600; font-size: 52px; line-height: 1; letter-spacing: -.02em; font-variation-settings: 'opsz' 144; }
.wordmark .apos { color: var(--granato2); }
.wordmark-sub { font-family: var(--serif); font-style: italic; color: var(--ambra); font-size: 17px; margin-top: 6px; }

/* --- struttura --- */
.shell { min-height: 100dvh; }
.main { padding: 0 18px calc(96px + var(--safe-b)); max-width: 860px; margin: 0 auto; }
.top { position: sticky; top: 0; z-index: 20; background: linear-gradient(var(--tufo) 70%, rgba(22,17,15,0)); padding: calc(env(safe-area-inset-top, 0px) + 14px) 18px 12px; max-width: 860px; margin: 0 auto; }
.top-row { display: flex; align-items: center; gap: 10px; }
.cellar-btn { background: none; border: 0; padding: 0; text-align: left; cursor: pointer; min-width: 0; flex: 1; }
.cellar-btn h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cellar-btn .mu { font-size: 13px; display: flex; gap: 6px; align-items: center; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--ln); background: var(--botte); display: grid; place-items: center; cursor: pointer; flex: none; }
.icon-btn svg { width: 19px; height: 19px; }

.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: space-around; align-items: flex-end;
  padding: 8px 6px calc(8px + var(--safe-b)); background: rgba(22, 17, 15, .92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--ln); }
.nav button { background: none; border: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--mu2); padding: 4px 8px; min-width: 60px; position: relative; }
.nav button svg { width: 22px; height: 22px; }
.nav button.on { color: var(--gesso); }
.nav button.on::after { content: ''; position: absolute; top: -9px; width: 18px; height: 2px; border-radius: 2px; background: var(--granato2); }
.nav .badge { position: absolute; top: 0; right: 14px; background: var(--urgente); color: var(--tufo); font-size: 10px; font-weight: 700; border-radius: 9px; padding: 0 5px; line-height: 16px; }
.nav .add { width: 54px; height: 54px; border-radius: 50%; background: var(--granato); color: var(--gesso); display: grid; place-items: center; margin-top: -22px; box-shadow: 0 6px 22px rgba(154, 44, 62, .45); min-width: 0; padding: 0; }
.nav .add svg { width: 24px; height: 24px; }
.side { display: none; }

@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 250px 1fr; }
  .nav { display: none; }
  .side { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100dvh; padding: 28px 18px; border-right: 1px solid var(--ln); }
  .side .wordmark { font-size: 34px; margin: 0 8px 26px; }
  .side button { background: none; border: 0; cursor: pointer; display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 10px; color: var(--mu); text-align: left; font-size: 15px; }
  .side button svg { width: 20px; height: 20px; }
  .side button.on { background: var(--botte); color: var(--gesso); }
  .side .side-add { margin-top: 14px; background: var(--granato); color: var(--gesso); justify-content: center; font-weight: 600; }
  .side .side-foot { margin-top: auto; font-size: 12px; color: var(--mu2); padding: 0 12px; }
  .main { padding-bottom: 60px; max-width: 980px; }
  .top { max-width: 980px; }
}

/* --- campi e pulsanti --- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--ln2); background: var(--feccia); border-radius: 12px; padding: 11px 16px; cursor: pointer; font-weight: 500; font-size: 15px; }
.btn svg { width: 18px; height: 18px; }
.btn.pri { background: var(--granato); border-color: var(--granato); color: #fff; }
.btn.pri:active { background: var(--granato2); }
.btn.ghost { background: none; }
.btn.danger { color: var(--ko); border-color: rgba(224, 115, 94, .35); background: none; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.fld { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--mu); min-width: 0; }
.inp { width: 100%; background: var(--feccia); border: 1px solid var(--ln); border-radius: 11px; padding: 11px 12px; font-size: 16px; color: var(--gesso); outline: none; }
.inp:focus { border-color: var(--ambra); }
textarea.inp { min-height: 84px; resize: vertical; line-height: 1.45; }
select.inp { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--mu) 50%), linear-gradient(135deg, var(--mu) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.search { position: relative; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--mu2); }
.search .inp { padding-left: 40px; border-radius: 999px; }

/* chip tipologie */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; margin: 0 -18px; padding-left: 18px; padding-right: 18px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--ln); background: none; border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 13px; color: var(--mu); display: inline-flex; gap: 7px; align-items: center; white-space: nowrap; }
.chip.on { border-color: var(--ambra); color: var(--gesso); background: rgba(209, 168, 102, .08); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* --- riepilogo in testa alla lista --- */
.summary { display: flex; align-items: baseline; gap: 18px; padding: 14px 0 6px; flex-wrap: wrap; }
.summary b { font-family: var(--serif); font-weight: 500; font-size: 22px; color: var(--gesso); font-variant-numeric: tabular-nums; }
.summary span { color: var(--mu); font-size: 13px; }
.alert { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; margin: 10px 0 4px; padding: 12px 14px; border-radius: var(--r); border: 1px solid rgba(227, 160, 74, .35);
  background: linear-gradient(100deg, rgba(227, 160, 74, .14), rgba(227, 160, 74, .03)); cursor: pointer; }
.alert svg { width: 22px; height: 22px; color: var(--urgente); flex: none; }

/* --- carta dei vini: righe, non card --- */
.list { margin-top: 6px; }
.wrow { display: grid; grid-template-columns: 34px 1fr auto; gap: 14px; align-items: center; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--ln); padding: 14px 2px; cursor: pointer; }
.wrow:hover { background: rgba(255, 255, 255, .015); }
.wrow .prod { font-size: 13px; color: var(--mu); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wrow .name { font-family: var(--serif); font-size: 18px; line-height: 1.2; font-weight: 500; }
.wrow .name .yr { color: var(--ambra); font-weight: 400; margin-left: 6px; }
.wrow .meta { font-size: 13px; color: var(--mu2); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.wrow .right { text-align: right; }
.wrow .qty { font-family: var(--serif); font-size: 20px; font-variant-numeric: tabular-nums; }
.wrow .qty small { font-family: var(--sans); font-size: 12px; color: var(--mu); margin-left: 1px; }
.wrow .val { font-size: 13px; color: var(--mu); font-variant-numeric: tabular-nums; }
.wrow.out { opacity: .45; }
.state { font-size: 12px; display: inline-flex; gap: 5px; align-items: center; }
.state i { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.st-giovane { color: var(--mu); } .st-giovane i { background: var(--mu2); }
.st-pronto { color: var(--ok); } .st-pronto i { background: var(--ok); }
.st-picco { color: var(--ambra); } .st-picco i { background: var(--ambra); box-shadow: 0 0 8px var(--ambra); }
.st-ora { color: var(--urgente); } .st-ora i { background: var(--urgente); box-shadow: 0 0 8px var(--urgente); }
.st-oltre { color: var(--ko); } .st-oltre i { background: var(--ko); }
.st-nd { color: var(--mu2); } .st-nd i { background: var(--mu2); }
@media (min-width: 960px) { .list { columns: 2; column-gap: 34px; } .wrow { break-inside: avoid; } }

/* --- bottiglia --- */
.bottle { display: block; overflow: visible; }
.bottle .liquid { transition: y .9s cubic-bezier(.2, .7, .2, 1), height .9s cubic-bezier(.2, .7, .2, 1); }

/* --- pannelli --- */
.sheet-bg { position: fixed; inset: 0; z-index: 50; background: rgba(8, 6, 5, .62); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: fade .2s ease; }
.sheet { position: fixed; z-index: 51; left: 0; right: 0; bottom: 0; max-height: 94dvh; overflow-y: auto; overscroll-behavior: contain; background: var(--botte);
  border-radius: 22px 22px 0 0; border-top: 1px solid var(--ln2); padding: 0 0 calc(24px + var(--safe-b)); animation: up .28s cubic-bezier(.2, .8, .2, 1); }
.sheet.full { top: env(safe-area-inset-top, 0px); max-height: none; }
.sheet-head { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 10px; padding: 14px 18px 10px; background: linear-gradient(var(--botte) 75%, rgba(33, 25, 21, 0)); }
.sheet-head h2 { flex: 1; font-size: 21px; }
.sheet-body { padding: 4px 18px 0; }
.grab { width: 38px; height: 4px; border-radius: 3px; background: var(--ln2); margin: 8px auto 0; }
@media (min-width: 960px) {
  .sheet { left: auto; top: 0; width: 560px; max-height: none; border-radius: 0; border-top: 0; border-left: 1px solid var(--ln2); animation: side .28s cubic-bezier(.2, .8, .2, 1); }
  .sheet.small { top: 50%; left: 50%; right: auto; bottom: auto; transform: translate(-50%, -50%); width: 480px; max-height: 88dvh; border-radius: 20px; border: 1px solid var(--ln2); animation: fade .2s ease; }
  .grab { display: none; }
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes side { from { transform: translateX(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* --- scheda vino --- */
.hero { position: relative; display: grid; grid-template-columns: 112px 1fr; gap: 18px; align-items: end; padding: 8px 18px 22px; }
.hero::before { content: ''; position: absolute; inset: -60px 0 0; background: radial-gradient(ellipse at 18% 40%, var(--glow, rgba(154, 44, 62, .35)), transparent 62%); pointer-events: none; }
.hero > * { position: relative; }
.hero .pic { width: 112px; height: 170px; display: grid; place-items: center; border-radius: 16px; }
.hero .pic img { width: 100%; height: 100%; object-fit: cover; border-radius: 16px; }
.hero .prod { color: var(--mu); font-size: 14px; }
.hero h2 { font-size: 30px; line-height: 1.08; margin: 2px 0 6px; font-variation-settings: 'opsz' 96; }
.hero .yr { font-family: var(--serif); font-size: 20px; color: var(--ambra); }
.hero .where { font-size: 13px; color: var(--mu); margin-top: 4px; }
.actions { display: flex; gap: 10px; padding: 0 18px 18px; }
.actions .btn { flex: 1; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--ln); border-bottom: 1px solid var(--ln); margin: 0 18px; }
.stats div { padding: 12px 4px; text-align: center; border-right: 1px solid var(--ln); }
.stats div:last-child { border-right: 0; }
.stats b { display: block; font-family: var(--serif); font-weight: 500; font-size: 19px; font-variant-numeric: tabular-nums; }
.stats span { font-size: 11.5px; color: var(--mu); }
.sec { padding: 20px 18px 0; }
.sec h3 { font-size: 17px; margin-bottom: 8px; display: flex; align-items: center; gap: 10px; }
.sec h3 .sp { flex: 1; }
.sec p { margin: 0; color: #DCD1C4; line-height: 1.6; max-width: 64ch; }
.sec .lnk { background: none; border: 0; color: var(--ambra); cursor: pointer; font-size: 13px; padding: 2px 0; font-family: var(--sans); }
.grapes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.grape { border: 1px solid var(--ln2); border-radius: 999px; padding: 3px 10px; font-size: 13px; }
.grape b { color: var(--ambra); font-weight: 500; margin-left: 4px; font-variant-numeric: tabular-nums; }
.line { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--ln); font-size: 14px; }
.line:last-child { border-bottom: 0; }
.line .x { background: none; border: 0; color: var(--mu2); cursor: pointer; padding: 4px; }
.line .x svg { width: 16px; height: 16px; }
.horses { color: var(--ambra); letter-spacing: 1px; }

/* timeline della finestra di consumo */
.tl { position: relative; height: 64px; margin: 6px 4px 0; }
.tl .bar { position: absolute; top: 18px; left: 0; right: 0; height: 6px; border-radius: 6px; overflow: hidden; display: flex; background: var(--feccia); }
.tl .bar i { display: block; height: 100%; }
.tl .tick { position: absolute; top: 30px; transform: translateX(-50%); font-size: 11.5px; color: var(--mu); white-space: nowrap; font-variant-numeric: tabular-nums; text-align: center; }
.tl .tick b { display: block; color: var(--gesso); font-weight: 500; }
.tl .now { position: absolute; top: 8px; width: 2px; height: 26px; background: var(--gesso); border-radius: 2px; transform: translateX(-50%); }
.tl .now::before { content: 'oggi'; position: absolute; top: -12px; left: 50%; transform: translateX(-50%); font-size: 10.5px; color: var(--gesso); }

/* stelle-cavallo */
.rate { display: flex; gap: 4px; }
.rate button { background: none; border: 0; font-size: 28px; line-height: 1; cursor: pointer; color: var(--mu2); padding: 2px; }
.rate button.on { color: var(--ambra); }
.seg { display: flex; background: var(--feccia); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; background: none; border: 0; padding: 8px 6px; border-radius: 9px; cursor: pointer; font-size: 14px; color: var(--mu); }
.seg button.on { background: var(--botte); color: var(--gesso); box-shadow: 0 0 0 1px var(--ln2); }

/* --- da bere --- */
.group { margin-top: 22px; }
.group > h2 { font-size: 22px; display: flex; align-items: baseline; gap: 10px; }
.group > h2 small { font-family: var(--sans); font-size: 13px; color: var(--mu); font-weight: 400; }
.group > p { margin: 4px 0 4px; color: var(--mu); font-size: 14px; }
.year { display: grid; grid-template-columns: 64px 1fr; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--ln); }
.year > b { font-family: var(--serif); font-size: 24px; font-weight: 500; color: var(--ambra); font-variant-numeric: tabular-nums; line-height: 1.1; }
.year .ev { display: flex; gap: 10px; align-items: baseline; padding: 3px 0; font-size: 14px; cursor: pointer; background: none; border: 0; text-align: left; width: 100%; }
.year .ev .k { font-size: 12px; min-width: 74px; }

/* --- valore --- */
.bigval { padding: 18px 0 8px; }
.bigval .v { font-family: var(--serif); font-size: 52px; line-height: 1; font-weight: 500; letter-spacing: -.02em; font-variant-numeric: tabular-nums; font-variation-settings: 'opsz' 144; }
.bigval .d { margin-top: 8px; font-size: 15px; }
.up { color: var(--ok); } .down { color: var(--ko); }
.chart { width: 100%; height: 150px; display: block; margin: 12px 0 6px; }
.bars .b { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 8px 0; font-size: 14px; }
.bars .b .track { grid-column: 1 / -1; height: 5px; background: var(--feccia); border-radius: 5px; overflow: hidden; }
.bars .b .track i { display: block; height: 100%; border-radius: 5px; }
.panel { background: var(--botte); border: 1px solid var(--ln); border-radius: 18px; padding: 16px 16px 8px; margin-top: 16px; }
.panel > h3 { margin-bottom: 6px; }
.panel .seg { margin-bottom: 6px; }

/* --- altro --- */
.menu-sec { margin-top: 22px; }
.menu-sec > h3 { margin-bottom: 8px; }
.card { background: var(--botte); border: 1px solid var(--ln); border-radius: 16px; padding: 14px; }
.card + .card { margin-top: 10px; }
.drop { border: 1.5px dashed var(--ln2); border-radius: 16px; padding: 22px; text-align: center; cursor: pointer; display: block; color: var(--mu); }
.drop input { display: none; }
.prog { height: 6px; border-radius: 6px; background: var(--feccia); overflow: hidden; margin: 10px 0; }
.prog i { display: block; height: 100%; background: var(--ambra); transition: width .3s; }
.role { font-size: 12px; border: 1px solid var(--ln2); border-radius: 999px; padding: 1px 8px; color: var(--mu); }

/* --- accesso --- */
.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 40px 24px calc(40px + var(--safe-b)); max-width: 420px; margin: 0 auto; }
.login .seal { width: 76px; height: 76px; margin-bottom: 22px; }
.login form { display: flex; flex-direction: column; gap: 12px; margin-top: 32px; }
.login .err { color: var(--ko); font-size: 14px; min-height: 20px; }
.switch { background: none; border: 0; color: var(--ambra); cursor: pointer; margin-top: 8px; font-size: 14px; }

/* --- avvisi --- */
.toast { position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); transform: translateX(-50%); z-index: 80; background: var(--gesso); color: var(--tufo); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500; box-shadow: 0 8px 30px rgba(0, 0, 0, .45); animation: up .25s ease; max-width: calc(100vw - 32px); }
.toast.err { background: var(--ko); color: #fff; }
@media (min-width: 960px) { .toast { bottom: 30px; } }
.empty { text-align: center; padding: 50px 20px; color: var(--mu); }
.empty h2 { color: var(--gesso); margin: 14px 0 6px; }
.empty .btn { margin-top: 16px; }
.loading { display: grid; place-items: center; min-height: 60dvh; color: var(--mu); }
.dropdown { position: absolute; z-index: 40; top: 100%; left: 18px; right: 18px; max-width: 420px; background: var(--feccia); border: 1px solid var(--ln2); border-radius: 16px; padding: 6px; box-shadow: 0 18px 50px rgba(0, 0, 0, .5); }
.dropdown button { display: flex; width: 100%; gap: 10px; align-items: center; background: none; border: 0; padding: 11px 12px; border-radius: 10px; cursor: pointer; text-align: left; }
.dropdown button:hover, .dropdown button.on { background: var(--botte); }
.hr { height: 1px; background: var(--ln); margin: 4px 0; }
.sheet-head.bare { background: none; }
.lnk-btn { background: none; border: 0; color: var(--ambra); cursor: pointer; padding: 0; font-size: 13px; }
