@font-face {
  font-family: 'Century Gothic';
  src: url('fonts/CenturyGothic.woff2') format('woff2'),
       url('fonts/CenturyGothic.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Century Gothic';
  src: url('fonts/CenturyGothicBold.woff2') format('woff2'),
       url('fonts/CenturyGothicBold.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  --deep: #2F342D;
  --oliva: #5D6C53;
  --oliva-d: #52614A;
  --salvia: #BEC8B7;
  --cream: #F2F3EF;
  --card: #FFFFFF;
  --card-premuta: #F6F7F3;
  --ok: #3F7D4E;
  --ambra: #8A6420;
  --perso: #9A5B55;
  --grigio: #6E7369;
  --grigio-tenue: #8A8F86;
  --bordo: #E4E7E0;
  --velo: rgba(20, 24, 18, .42);
  --r: 14px;
  --sp: 12px;
  --tab: 64px;
  --tocco: 44px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--deep);
  font-family: 'Century Gothic', Jost, system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

body { padding-bottom: calc(var(--tab) + env(safe-area-inset-bottom, 0px)); }
body.senza-tab { padding-bottom: 0; }

#app { max-width: 720px; margin: 0 auto; padding: 0 var(--sp) 24px; }

h1, h2, h3 { margin: 0 0 8px; font-weight: 700; line-height: 1.2; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 8px; }
a { color: var(--oliva-d); }

.scheda h2 { font-size: 15px; }
.scheda h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--grigio);
  margin-top: 14px;
}
.scheda h3:first-of-type { margin-top: 0; }

svg { width: 20px; height: 20px; flex: none; }

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

.nascosto-vista {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.barra {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 0 calc(var(--sp) * -1) var(--sp);
  padding: calc(10px + env(safe-area-inset-top, 0px)) var(--sp) 10px;
  background: var(--cream);
  border-bottom: 1px solid var(--bordo);
}
.barra-riga { display: flex; align-items: center; gap: 10px; min-height: 34px; }
.barra-titolo {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  overflow-wrap: anywhere;
}
.barra-sotto { font-size: 13px; color: var(--grigio); margin-top: 2px; }
.cresci { flex: 1; min-width: 0; }

.scheda {
  display: block;
  background: var(--card);
  border: 1px solid var(--bordo);
  border-radius: var(--r);
  padding: var(--sp);
  margin-bottom: 10px;
  color: inherit;
  text-align: left;
  font: inherit;
  width: 100%;
}
a.scheda, a.striscia, a.riga-fra, a.scheda-titolo { text-decoration: none; color: inherit; }
.scheda.premibile { cursor: pointer; }
.scheda.premibile:active { background: var(--card-premuta); }
.scheda-testa { display: flex; align-items: flex-start; gap: 10px; }
.scheda-titolo { display: block; font-weight: 700; font-size: 16px; overflow-wrap: anywhere; }
.scheda-riga { font-size: 13px; color: var(--grigio); overflow-wrap: anywhere; }
a.scheda-titolo:hover { text-decoration: underline; }

.spazio-sopra { margin-top: 8px; }
.spazio-sotto { margin-bottom: 10px; }
.riga-piccola { margin-top: 6px; }
.immagine-piena { width: 100%; border-radius: 10px; margin-bottom: 8px; }

.tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  background: var(--salvia);
  color: var(--deep);
}
.tag.da_chiamare { background: #E2E4DF; color: #4A4E44; }
.tag.da_visitare { background: #D9E2D3; color: #35412F; }
.tag.preventivo { background: #F2E4C9; color: #6B4E14; }
.tag.venduto { background: #D5E8D8; color: #244C2F; }
.tag.perso { background: #EFD9D6; color: #6D3833; }
.tag.grigio { background: #E9EBE6; color: #4E5249; }
.tag.ambra { background: #F2E4C9; color: #6B4E14; }

button, .bottone {
  font: inherit;
  font-weight: 700;
  border: 1px solid var(--oliva);
  background: var(--oliva);
  color: #fff;
  border-radius: 10px;
  padding: 11px 14px;
  min-height: var(--tocco);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}
button.secondario { background: transparent; color: var(--oliva-d); }
button.tenue, .bottone.tenue { background: var(--card); color: var(--deep); border-color: var(--bordo); }
button.rosso, .bottone.rosso { background: var(--perso); border-color: var(--perso); color: #fff; }
button.piena, .bottone.piena { width: 100%; }
button:disabled { opacity: .5; cursor: default; }
button:active:not(:disabled) { background: var(--oliva-d); }
button.tenue:active:not(:disabled) { background: var(--card-premuta); }

button.scheda:active, button.scheda:hover {
  background: var(--card-premuta);
  border-color: var(--salvia);
  color: inherit;
}

@media (hover: hover) {
  button:hover:not(:disabled), .bottone:hover { background: var(--oliva-d); border-color: var(--oliva-d); }
  button.tenue:hover:not(:disabled), .bottone.tenue:hover {
    background: var(--card-premuta); color: var(--deep); border-color: var(--salvia);
  }
  button.rosso:hover:not(:disabled), .bottone.rosso:hover { background: #86504B; border-color: #86504B; }
  .scheda.premibile:hover { border-color: var(--salvia); }
  .striscia:hover { border-color: var(--salvia); }
}

.azioni { display: flex; gap: 8px; flex-wrap: wrap; }
.azioni > * { flex: 1 1 auto; }
.azioni > *:only-child { flex: 0 1 auto; }
.azioni.colonna { flex-direction: column; }
.azioni.colonna > * { flex: none; width: 100%; }

.campo { display: block; margin-bottom: 10px; }
.campo > label { display: block; font-size: 13px; color: var(--grigio); margin-bottom: 4px; }
.campo input, .campo select, .campo textarea {
  font: inherit;
  width: 100%;
  padding: 11px 12px;
  min-height: var(--tocco);
  border: 1px solid var(--bordo);
  border-radius: 10px;
  background: var(--card);
  color: var(--deep);
}
.campo textarea { min-height: 88px; resize: vertical; }
.campo input:focus, .campo select:focus, .campo textarea:focus { border-color: var(--oliva); }
.campo.errato input, .campo.errato select, .campo.errato textarea { border-color: var(--perso); }
.campo-errore { color: var(--perso); font-size: 12px; margin-top: 3px; }
.doppia { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.vuoto { text-align: center; color: var(--grigio); padding: 28px 12px; }
.vuoto strong { display: block; color: var(--deep); margin-bottom: 4px; }

.scheletro {
  border-radius: var(--r);
  background: #E9EBE6;
  height: 74px;
  margin-bottom: 10px;
  animation: pulsa 1.1s ease-in-out infinite;
}
@keyframes pulsa { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--bordo);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabs a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: var(--tab);
  font-size: 11px;
  font-weight: 700;
  color: var(--grigio);
  text-decoration: none;
}
.tabs a.attiva { color: var(--oliva-d); }
.tabs svg { width: 22px; height: 22px; }

.avvisi {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--tab) + 8px);
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.avviso {
  background: var(--deep);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  max-width: 92%;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
}
.avviso.errore { background: var(--perso); }
.avviso.ok { background: var(--ok); }

.velo {
  position: fixed;
  inset: 0;
  background: var(--velo);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: sfuma .16s ease-out;
}
.foglio {
  background: var(--card);
  width: 100%;
  max-width: 720px;
  border-radius: 18px 18px 0 0;
  padding: 16px var(--sp) calc(16px + env(safe-area-inset-bottom, 0px));
  max-height: 88vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: sali .18s ease-out;
}
.foglio h2 { margin-bottom: 12px; }
.foglio form > button[type="submit"] {
  position: sticky;
  bottom: 0;
  box-shadow: 0 -8px 12px -8px rgba(20, 24, 18, .3);
}
.foglio .maniglia {
  width: 40px;
  height: 4px;
  border-radius: 4px;
  background: var(--bordo);
  margin: 0 auto 12px;
}
@keyframes sfuma { from { opacity: 0; } to { opacity: 1; } }
@keyframes sali { from { transform: translateY(16px); } to { transform: none; } }

.striscia {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 13px var(--sp);
  background: var(--card);
  border: 1px solid var(--bordo);
  border-radius: var(--r);
  margin-bottom: 10px;
  font-weight: 700;
  text-align: left;
  color: var(--deep);
}
.striscia .numero {
  margin-left: auto;
  background: var(--salvia);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 13px;
}
.striscia .numero.allarme { background: var(--ambra); color: #fff; }

.tappa { display: flex; gap: 10px; }
.tappa .indice {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--oliva);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex: none;
}
.tappa.fatta .indice { background: var(--ok); }
.tappa.saltata .indice { background: var(--grigio-tenue); }
.tappa-scheda.fatta .scheda-titolo { text-decoration: line-through; color: var(--grigio); }

.linea { list-style: none; margin: 0; padding: 0; }
.linea li { position: relative; padding: 0 0 14px 20px; border-left: 2px solid var(--bordo); }
.linea li:last-child { border-left-color: transparent; }
.linea li::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--salvia);
}
.linea li.vendita::before { background: var(--ok); }
.linea li.perso::before { background: var(--perso); }
.linea .quando { font-size: 12px; color: var(--grigio); }

.griglia { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.griglia .scheda { margin: 0; }
.prodotto img {
  width: 100%;
  height: 92px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 8px;
  background: var(--cream);
}
.prezzo { font-weight: 700; }
.prezzo.nascosto { filter: blur(6px); user-select: none; }

.numeri { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.numero-grande { font-size: 26px; font-weight: 700; line-height: 1.1; }
.numero-sotto { font-size: 12px; color: var(--grigio); }
.confronto.su { color: var(--ok); }
.confronto.giu { color: var(--perso); }

.imbuto div { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 14px; }
.imbuto .sbarra { height: 10px; border-radius: 999px; background: var(--oliva); min-width: 4px; }
.imbuto .etichetta { width: 104px; flex: none; font-size: 13px; }
.imbuto .conteggio { margin-left: auto; font-weight: 700; }

.tabella { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabella th, .tabella td {
  text-align: left;
  padding: 7px 6px;
  border-bottom: 1px solid var(--bordo);
  vertical-align: top;
}
.tabella th { color: var(--grigio); font-size: 12px; font-weight: 700; }
.tabella td.destra, .tabella th.destra { text-align: right; }
.scorri { overflow-x: auto; }

.mappa-box { position: relative; width: 100%; max-width: 260px; }
.mappa {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--bordo);
}
.mappa-punto {
  position: absolute;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 999px;
  background: var(--perso);
  border: 2px solid #fff;
}

.riga-fra { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
a.riga-fra.premibile { padding: 6px 4px; border-radius: 8px; }
a.riga-fra.premibile:active { background: var(--card-premuta); }
.piccolo { font-size: 13px; color: var(--grigio); }
.grassetto { font-weight: 700; }
.destra { text-align: right; }
.sep { height: 1px; background: var(--bordo); margin: 12px 0; }
.fuori-orario { color: var(--ambra); font-weight: 700; }

.accesso { max-width: 380px; margin: 12vh auto 0; }
.accesso .marchio { text-align: center; margin-bottom: 20px; }
.accesso .marchio b { display: block; font-size: 20px; }
.accesso .marchio span { color: var(--grigio); font-size: 13px; }

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--deep);
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 14px;
}
.banner button {
  min-height: 36px;
  padding: 6px 12px;
  background: #fff;
  color: var(--deep);
  border-color: #fff;
  margin-left: auto;
}
.banner.coda { background: var(--ambra); }
.banner.aggiornamento { position: sticky; top: 0; z-index: 40; margin: 0 0 10px; }

.interruttore { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.interruttore input { width: 20px; height: 20px; }

@media (min-width: 800px) {
  #app { padding-top: 4px; }
  .griglia { grid-template-columns: repeat(3, 1fr); }
  .numeri { grid-template-columns: repeat(3, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .scheletro { animation: none; }
  .velo, .foglio { animation: none; }
  * { scroll-behavior: auto; }
}

@media print {
  .tabs, .avvisi, .velo, .banner, .azioni, .scheletro { display: none !important; }
  body { padding-bottom: 0; background: #fff; }
  .barra { position: static; border-bottom: 1px solid #999; }
  .scheda { break-inside: avoid; border-color: #999; }
  #app { max-width: none; }
}
