/* ============================================================
   Prime Zone Tracking · pagine PC
   Pulito, denso il giusto, nero + oro Prime. Colore solo per i dati.
   ============================================================ */
:root {
  --ink: #141311; --ink-soft: #2b2925; --ink-2: #4a463f; --muted: #8a857b; --faint: #b9b4a9;
  --gold: #d4a017; --gold-deep: #9c7409; --gold-hi: #f2c94c; --gold-tint: #fbf3dc; --gold-ink: #5b4300;
  --green: #1f9d5c; --green-tint: #e6f5ec; --green-ink: #0f5a33;
  --dia: #27c3f0; --dia-violet: #8b6cf0; --dia-tint: #e4f7fe; --dia-ink: #053d57;
  --bianco: #d6d1c4;
  --bg: #f6f5f1; --card: #fff; --line: #e9e6df; --line-2: #f2f0eb;
  --err-bg: #fdeeec; --err-ink: #a8322a;
  --r: 16px; --r-s: 10px;
  --shadow: 0 1px 2px rgba(20, 19, 17, .04), 0 0 0 1px var(--line);
  --shadow-m: 0 12px 32px -12px rgba(20, 19, 17, .25), 0 0 0 1px var(--line);
  --maxw: 1240px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.5; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 1, "cv11" 1; letter-spacing: -.006em;
}
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.025em; line-height: 1.2; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1rem; letter-spacing: -.015em; }
p { margin: 0; }
a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.link { color: var(--ink-2); font-weight: 600; text-decoration: none; font-size: .84rem; }
.link:hover { color: var(--ink); }

/* ---------- effetti diamante (come la Telemarketing Dashboard) ---------- */
@keyframes dia-shimmer { from { background-position: 0% 50%; } to { background-position: 250% 50%; } }
@keyframes dia-text { from { background-position: 0% 50%; } to { background-position: 200% 50%; } }
@keyframes dia-glint { 0% { left: -45%; } 55%, 100% { left: 125%; } }
@keyframes dia-twinkle { 0%, 100% { opacity: 0; transform: scale(.3) rotate(0deg); } 50% { opacity: 1; transform: scale(1) rotate(45deg); } }
.dia-testo {
  display: inline-block; color: transparent;
  background: linear-gradient(100deg, #7fe3ff, #ffffff 25%, #c4b5ff 50%, #7fe3ff 75%, #ffffff 100%);
  background-size: 200% 100%; -webkit-background-clip: text; background-clip: text;
  animation: dia-text 3.2s linear infinite;
}
.spk {
  position: absolute; width: 8px; height: 8px; background: #d8f6ff; pointer-events: none; opacity: 0;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: dia-twinkle 2.2s ease-in-out infinite;
}
.spk.s2 { animation-delay: .7s; width: 6px; height: 6px; }
.spk.s3 { animation-delay: 1.4s; width: 5px; height: 5px; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; gap: 14px;
  background: rgba(246, 245, 241, .82); backdrop-filter: saturate(1.8) blur(14px);
  border-bottom: 1px solid var(--line); padding: 0 24px; height: 60px;
}
.topbar .logo img { height: 26px; display: block; }
.topbar .tag { font-size: .68rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); padding-left: 14px; border-left: 1px solid var(--line); }
.topbar nav { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.topbar nav a { text-decoration: none; color: var(--muted); padding: 7px 12px; border-radius: 9px; font-weight: 550; font-size: .88rem; transition: background .15s, color .15s; display: inline-flex; align-items: center; gap: 6px; }
.topbar nav a:hover { color: var(--ink); background: rgba(20, 19, 17, .04); }
.topbar nav a.active { color: var(--ink); background: #fff; box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(20, 19, 17, .05); }
.topbar nav a.cta { background: var(--ink); color: #fff; margin-left: 8px; }
.topbar nav a.cta:hover { background: var(--ink-soft); }
.utente { display: flex; align-items: center; gap: 10px; padding-left: 14px; border-left: 1px solid var(--line); font-size: .84rem; font-weight: 550; }
.utente a { color: var(--muted); text-decoration: none; }
.utente a:hover { color: var(--ink); }
@media (max-width: 760px) {
  .topbar { gap: 6px; padding: 0 10px; height: 54px; }
  .topbar .tag, .utente span { display: none; }
  .topbar .logo img { height: 20px; }
  .topbar nav a { padding: 6px 8px; font-size: .8rem; }
  .topbar nav a.cta span { display: none; }
  .topbar nav a.cta { margin-left: 2px; }
  .utente { padding-left: 6px; font-size: .78rem; }
}

/* ---------- hero ---------- */
.hero { position: relative; color: #fff; background: #151412; }
.hero::before { content: none; }
.hero::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: rgba(255, 255, 255, .08); }
.hero-inner { position: relative; z-index: 20; max-width: var(--maxw); margin: 0 auto; padding: 30px 24px 28px; }
.hero-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.eyebrow { font-size: .7rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-hi); margin-bottom: 6px; }
.hero h1 { font-size: clamp(1.35rem, 2.6vw, 1.75rem); font-weight: 600; max-width: 26ch; color: rgba(255, 255, 255, .92); }
.kpi-main { display: grid; grid-template-columns: auto 1fr; gap: 32px; align-items: stretch; margin-top: 24px; }
.kpi-big { display: flex; flex-direction: column; justify-content: flex-end; padding-right: 8px; }
.kpi-num { font-size: clamp(3.2rem, 7vw, 4.8rem); font-weight: 700; letter-spacing: -.055em; line-height: .95; color: #fff; }
.kpi-lab { margin-top: 8px; color: rgba(255, 255, 255, .55); font-weight: 500; font-size: .86rem; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: rgba(255, 255, 255, .08); border-radius: 14px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08); }
.kpi-grid > div { position: relative; overflow: hidden; background: rgba(255, 255, 255, .025); padding: 16px 18px; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; }
.kpi-grid span { font-size: 1.65rem; font-weight: 650; letter-spacing: -.035em; line-height: 1.1; }
.kpi-grid span.gold { color: var(--gold-hi); }
.kpi-grid small { color: rgba(255, 255, 255, .5); font-weight: 500; font-size: .78rem; }
.kpi-grid .k-dia {
  background: linear-gradient(135deg, rgba(39, 195, 240, .2), rgba(139, 108, 240, .14)), rgba(20, 18, 15, .5);
  box-shadow: inset 0 0 0 1px rgba(39, 195, 240, .3), inset 0 0 26px rgba(39, 195, 240, .12);
}
.kpi-grid .k-dia .spk.s1 { top: 14px; right: 18px; }
.kpi-grid .k-dia .spk.s2 { top: 38px; right: 44px; }
.kpi-grid .k-dia .spk.s3 { top: 20px; right: 66px; }
@media (max-width: 820px) { .kpi-main { grid-template-columns: 1fr; gap: 18px; } .kpi-grid { grid-template-columns: repeat(2, 1fr); } }

/* ---------- filtri ---------- */
.filtri { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.seg-mini { display: inline-flex; padding: 3px; border-radius: 10px; background: rgba(20, 19, 17, .05); gap: 2px; }
.seg-mini button { border: 0; background: none; font: inherit; font-size: .8rem; font-weight: 550; padding: 5px 10px; border-radius: 7px; cursor: pointer; color: var(--muted); transition: background .15s, color .15s; }
.seg-mini button:hover { color: var(--ink); }
.seg-mini button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 0 0 1px var(--line); }
.hero .seg-mini { background: rgba(255, 255, 255, .07); }
.hero .seg-mini button { color: rgba(255, 255, 255, .6); }
.hero .seg-mini button:hover { color: #fff; }
.hero .seg-mini button.on { background: rgba(255, 255, 255, .14); color: #fff; box-shadow: none; }
.filtri select, select.input, .side-head select {
  font: inherit; font-size: .82rem; font-weight: 550; padding: 6px 30px 6px 11px; border-radius: 9px; border: 0;
  box-shadow: inset 0 0 0 1px var(--line); background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238a857b' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 11px center;
  color: var(--ink); -webkit-appearance: none; appearance: none; cursor: pointer;
}
.hero .filtri select { background-color: rgba(255, 255, 255, .07); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); }
.hero .filtri select option { color: var(--ink); }

/* ---------- layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 22px 24px 64px; display: grid; gap: 16px; }
.wrap-narrow { max-width: 820px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } .wrap { padding: 16px 12px 48px; } }
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); min-width: 0; }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: .95rem; }
.card-head .muted { font-size: .78rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding-top: 8px; }
.page-head p { margin-top: 4px; font-size: .88rem; }
.input { font: inherit; padding: 9px 12px; border-radius: 10px; border: 0; box-shadow: inset 0 0 0 1px var(--line); background: #fff; width: 100%; color: var(--ink); }
.input:focus, .filtri select:focus { outline: none; box-shadow: inset 0 0 0 1.5px var(--ink), 0 0 0 4px rgba(20, 19, 17, .05); }

/* ---------- imbuto ---------- */
.imbuto { display: grid; gap: 10px; }
.imb-riga { display: grid; grid-template-columns: 160px 1fr 64px; gap: 14px; align-items: center; }
.imb-nome { font-weight: 550; font-size: .86rem; display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.imb-barra { height: 26px; border-radius: 7px; background: var(--line-2); overflow: hidden; }
.imb-barra i { display: block; height: 100%; border-radius: 7px; transition: width .7s var(--ease); }
.imb-val { text-align: right; font-weight: 650; font-size: .95rem; }
.imb-val small { display: block; font-weight: 500; color: var(--muted); font-size: .72rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.c-tutti { background: var(--ink); }
.c-bianco { background: var(--bianco); }
.c-verde { background: var(--green); }
.c-oro { background: linear-gradient(90deg, var(--gold), var(--gold-hi)); }
.c-diamante { background: linear-gradient(110deg, #27c3f0, #7fe3ff, #c4b5ff, #8b6cf0, #27c3f0); background-size: 250% 100%; animation: dia-shimmer 4s linear infinite; }
.imb-nota { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line-2); color: var(--muted); font-size: .84rem; }
.imb-nota b { color: var(--ink); font-weight: 650; }

/* ---------- andamento ---------- */
.andamento { display: flex; align-items: flex-end; gap: 8px; height: 200px; padding-top: 16px; }
.and-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; }
.and-pila { flex: 1; width: 100%; max-width: 30px; display: flex; flex-direction: column-reverse; justify-content: flex-start; position: relative; gap: 1px; }
.and-pila i { display: block; width: 100%; border-radius: 2px; }
.and-pila i:last-of-type { border-radius: 5px 5px 2px 2px; }
.and-pila .tot { position: absolute; left: 50%; transform: translateX(-50%); font-size: .7rem; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.and-lab { font-size: .68rem; color: var(--muted); font-weight: 500; white-space: nowrap; }
.vuoto { color: var(--muted); padding: 28px 0; text-align: center; font-size: .88rem; }

/* ---------- tabelle ---------- */
.tab-wrap { overflow-x: auto; }
.tab { width: 100%; border-collapse: collapse; font-size: .86rem; }
.tab th { text-align: left; font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tab td { padding: 11px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tab tr:last-child td { border-bottom: 0; }
.tab .num { text-align: right; white-space: nowrap; }
.tab tbody tr { transition: background .12s; }
.tab tbody tr:hover td { background: #faf9f6; }
.tab .forte { font-weight: 650; white-space: nowrap; }
.mini-barra { display: flex; height: 6px; border-radius: 99px; overflow: hidden; background: var(--line-2); min-width: 90px; gap: 1px; }
.mini-barra i { display: block; height: 100%; }
.badge { position: relative; overflow: hidden; display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 650; white-space: nowrap; }
.badge-oro { background: var(--gold-tint); color: var(--gold-ink); box-shadow: inset 0 0 0 1px #f0e1b0; }
.badge-dia {
  color: var(--dia-ink); font-weight: 750;
  background: linear-gradient(110deg, #7fe3ff 0%, #e3fbff 18%, #7cc8ff 36%, #c4b5ff 54%, #7fe3ff 72%, #e9fcff 90%, #7fe3ff 100%);
  background-size: 250% 100%; animation: dia-shimmer 3.4s linear infinite;
  box-shadow: 0 0 0 1px rgba(39, 195, 240, .55), 0 0 12px rgba(39, 195, 240, .4);
}
.badge-dia::after {
  content: ""; position: absolute; top: -40%; bottom: -40%; left: -45%; width: 32%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .95), transparent);
  transform: skewX(-20deg); pointer-events: none; animation: dia-glint 2.6s ease-in-out infinite;
}
.badge-ok { background: var(--green-tint); color: var(--green-ink); }
.badge-parz { background: var(--line-2); color: var(--ink-2); }
.eta { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; white-space: nowrap; }

/* ---------- vie da rifare ---------- */
.lista-vie { list-style: none; margin: 0 -8px; padding: 0; display: grid; gap: 1px; max-height: 440px; overflow: auto; }
.lista-vie li { display: grid; grid-template-columns: 8px 1fr auto; gap: 12px; align-items: center; padding: 9px 8px; border-radius: 10px; }
.lista-vie li:hover { background: var(--line-2); }
.lista-vie .nome { font-weight: 600; font-size: .9rem; }
.lista-vie .sotto { font-size: .76rem; color: var(--muted); }
.lista-vie .giorni { font-weight: 650; text-align: right; font-size: .9rem; }
.lista-vie .giorni small { display: block; font-weight: 500; color: var(--muted); font-size: .7rem; }

/* ---------- mappa (chiara, stile Google Maps) ---------- */
.mappa-layout { position: relative; display: grid; grid-template-columns: 360px 1fr; height: calc(100dvh - 60px); }
.mappa-side { background: #fff; border-right: 1px solid var(--line); padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; z-index: 2; }
.side-head { display: grid; gap: 10px; }
.side-head h1 { font-size: 1.2rem; }
.seg-pieno { display: grid; grid-template-columns: repeat(3, 1fr); }
.cerca-box { position: relative; }
.cerca-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.cerca-box input { width: 100%; font: inherit; font-size: .9rem; padding: 10px 12px 10px 36px; border: 0; border-radius: 999px; background: var(--line-2); color: var(--ink); }
.cerca-box input:focus { outline: none; background: #fff; box-shadow: inset 0 0 0 1.5px var(--ink), 0 0 0 4px rgba(20, 19, 17, .05); }
.mappa { height: 100%; background: #f2efe9; }
.maplibregl-map { font-family: var(--font); }
.maplibregl-ctrl-group { border-radius: 12px !important; box-shadow: 0 2px 10px rgba(0, 0, 0, .15) !important; }
.pop-via .maplibregl-popup-content { padding: 8px 11px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0, 0, 0, .18); font-size: .8rem; display: grid; gap: 1px; pointer-events: none; }
.pop-via .maplibregl-popup-content span { color: var(--muted); }
.pop-via .maplibregl-popup-tip { display: none; }
.legenda { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: .76rem; color: var(--ink-2); padding: 10px 12px; border-radius: 12px; background: var(--line-2); }
.legenda div { display: flex; align-items: center; gap: 8px; }
.legenda i { width: 18px; height: 5px; border-radius: 3px; flex: none; }
.legenda i.tratto { background: repeating-linear-gradient(90deg, var(--ink-2) 0 4px, transparent 4px 7px) !important; }
.dettaglio { display: grid; gap: 10px; align-content: start; }
.det-titolo { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.dettaglio h2 { font-size: 1.15rem; }
.indietro-lista { justify-self: start; border: 0; background: none; font: inherit; font-size: .82rem; font-weight: 600; color: var(--muted); cursor: pointer; padding: 4px 0; }
.indietro-lista:hover { color: var(--ink); }
.cop { display: inline-block; vertical-align: middle; width: 54px; height: 5px; border-radius: 9px; background: var(--line); overflow: hidden; margin: 0 4px; }
.cop i { display: block; height: 100%; background: var(--ink); border-radius: 9px; }
.lista-zone { list-style: none; margin: 0 -8px; padding: 0; display: grid; gap: 1px; }
.lista-zone button { width: 100%; display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 12px; padding: 9px 8px; border: 0; background: none; border-radius: 10px; text-align: left; font: inherit; cursor: pointer; color: var(--ink); }
.lista-zone button:hover { background: var(--line-2); }
.lista-zone .dot { width: 10px; height: 10px; }
.lz-nome { font-weight: 600; font-size: .9rem; display: grid; }
.lz-nome small { font-weight: 500; color: var(--muted); font-size: .74rem; }
.lz-gg { font-weight: 650; font-size: .86rem; white-space: nowrap; }
.lz-gg small { color: var(--muted); font-weight: 500; }
.lista-zone.compatta button { padding: 6px 8px; }
.lista-zone.compatta .lz-nome { font-weight: 500; font-size: .84rem; color: var(--ink-2); }
.det-kpi { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.det-kpi div { background: var(--line-2); border-radius: 10px; padding: 8px 6px; text-align: center; }
.det-kpi b { display: block; font-size: 1.1rem; font-weight: 650; }
.det-kpi small { font-size: .68rem; color: var(--muted); font-weight: 500; }
.storico { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.storico li { box-shadow: inset 0 0 0 1px var(--line); border-radius: 11px; padding: 10px 12px; font-size: .83rem; }
.storico .r1 { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.storico .r2 { color: var(--muted); margin-top: 3px; }
.mappa-fab { display: none; }
.mappa-maniglia { display: none; }
.punto-me { width: 18px; height: 18px; border-radius: 50%; background: #2563eb; border: 3px solid #fff; box-shadow: 0 0 0 7px rgba(37, 99, 235, .22), 0 2px 6px rgba(0, 0, 0, .3); }

/* mappa su telefono: mappa a tutto schermo + pannello a scomparsa dal basso */
@media (max-width: 800px) {
  .mappa-pagina .topbar, .mappa-pagina .tabbar { display: none; }
  .mappa-layout { display: block; height: 100dvh; }
  .mappa { position: absolute; inset: 0; }
  .mappa-side {
    position: absolute; left: 0; right: 0; bottom: 0; max-height: 78dvh; border-right: 0;
    border-radius: 22px 22px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, .18); padding: 4px 16px calc(env(safe-area-inset-bottom) + 14px);
    transform: translateY(calc(100% - 178px - env(safe-area-inset-bottom))); transition: transform .3s var(--ease); z-index: 5;
  }
  .mappa-side.aperto { transform: none; }
  .mappa-maniglia { display: block; width: 100%; padding: 8px 0 6px; border: 0; background: none; cursor: pointer; }
  .mappa-maniglia::before { content: ""; display: block; width: 36px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto; }
  .side-head h1, .legenda { display: none; }
  .mappa-side.aperto .legenda { display: grid; }
  .mappa-fab {
    position: absolute; z-index: 6; top: calc(env(safe-area-inset-top) + 12px); display: inline-flex; align-items: center; gap: 6px;
    height: 42px; padding: 0 15px; border-radius: 999px; border: 0; font: inherit; font-weight: 600; font-size: .88rem;
    background: #fff; color: var(--ink); box-shadow: 0 2px 12px rgba(0, 0, 0, .2); text-decoration: none; cursor: pointer;
  }
  .mappa-fab.indietro { left: 12px; }
  .mappa-fab.posizione { right: 12px; padding: 0; width: 42px; justify-content: center; }
  .maplibregl-ctrl-bottom-right { bottom: calc(190px + env(safe-area-inset-bottom)); }
}

/* ---------- bottoni ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; font-size: .86rem; padding: 9px 15px; border-radius: 10px; border: 0; cursor: pointer; text-decoration: none; transition: background .15s, transform .1s, box-shadow .15s; white-space: nowrap; }
.btn:active { transform: scale(.98); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: var(--ink-soft); }
.btn-gold { background: var(--gold-hi); color: #2a2000; }
.btn-gold:hover { background: var(--gold); }
.btn-ghost { background: #fff; box-shadow: inset 0 0 0 1px var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--line-2); }
.btn-danger-ghost { background: #fff; box-shadow: inset 0 0 0 1px #f0cdc8; color: var(--err-ink); }
.btn-danger-ghost:hover { background: var(--err-bg); }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 11px; font-size: .78rem; }
.err { color: var(--err-ink); font-weight: 550; font-size: .84rem; min-height: 1.2em; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 550; white-space: nowrap; }
.check input { width: 17px; height: 17px; accent-color: var(--ink); }
.riga-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 12px 0 4px; }
.riga-form .input { flex: 1; min-width: 200px; }
.spacer { flex: 1; }
code { font-size: .82rem; background: var(--line-2); padding: 2px 6px; border-radius: 6px; }

/* ---------- dialogo modifica ---------- */
.dialogo { border: 0; border-radius: 20px; padding: 0; width: min(480px, calc(100vw - 24px)); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .45); }
.dialogo::backdrop { background: rgba(12, 11, 10, .4); backdrop-filter: blur(3px); }
.dialogo form { padding: 22px; display: grid; gap: 14px; }
.dialogo h2 { font-size: 1.1rem; }
.dialogo label { display: grid; gap: 5px; font-weight: 550; font-size: .8rem; color: var(--muted); }
.dialogo label.check { display: inline-flex; color: var(--ink); font-size: .86rem; }
.dialogo input:not([type=checkbox]) { font: inherit; padding: 9px 12px; border-radius: 10px; border: 0; box-shadow: inset 0 0 0 1px var(--line); width: 100%; color: var(--ink); }
.dialogo input:focus { outline: none; box-shadow: inset 0 0 0 1.5px var(--ink); }
.riga2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.riga2[hidden] { display: none; }
.conteggi { border: 0; box-shadow: inset 0 0 0 1px var(--line); border-radius: 14px; padding: 12px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0; }
.conteggi legend { font-weight: 600; font-size: .72rem; padding: 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.conteggi label::before { content: ""; display: block; height: 3px; border-radius: 3px; margin-bottom: 4px; }
.conteggi label.c-bianco::before { background: var(--bianco); }
.conteggi label.c-verde::before { background: var(--green); }
.conteggi label.c-oro::before { background: var(--gold); }
.conteggi label.c-diamante::before { background: linear-gradient(90deg, var(--dia), var(--dia-violet)); }
.conteggi label { background: none !important; animation: none !important; }
.dialogo-azioni { display: flex; gap: 8px; align-items: center; }

/* ---------- login ---------- */
.login-body { min-height: 100dvh; display: grid; place-items: center; background: #151412; padding: 20px; position: relative; overflow: hidden; }
.login-body::before { content: none; }
.login { position: relative; width: min(380px, 100%); text-align: center; }
.login-logo { height: 46px; width: auto; display: block; margin: 0 auto; }
.login-tag { color: var(--gold-hi); font-size: .7rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; margin: 14px 0 22px; }
.login-card { background: #fff; border-radius: 22px; padding: 22px; display: grid; gap: 14px; text-align: left; box-shadow: 0 30px 70px -20px rgba(0, 0, 0, .6); }
.login-card label { display: grid; gap: 6px; font-weight: 550; font-size: .8rem; color: var(--muted); }
.login-card input { font: inherit; font-size: 1.02rem; padding: 13px 14px; border-radius: 12px; border: 0; box-shadow: inset 0 0 0 1px var(--line); background: var(--bg); color: var(--ink); }
.login-card input:focus { outline: none; background: #fff; box-shadow: inset 0 0 0 1.5px var(--ink), 0 0 0 4px rgba(20, 19, 17, .06); }
.login-card .btn { padding: 14px; font-size: 1rem; border-radius: 13px; margin-top: 4px; background: var(--ink); color: #fff; }
.login-card .btn:hover { background: var(--ink-soft); }
.login-err { background: var(--err-bg); color: var(--err-ink); padding: 10px 12px; border-radius: 10px; font-weight: 550; font-size: .86rem; }
.login-nota { color: rgba(255, 255, 255, .45); font-size: .78rem; margin-top: 16px; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 2000; transform: translate(-50%, 16px); opacity: 0; pointer-events: none; background: var(--ink); color: #fff; padding: 10px 15px; border-radius: 12px; font-weight: 500; font-size: .88rem; box-shadow: 0 12px 28px -8px rgba(0, 0, 0, .4); transition: opacity .2s, transform .25s var(--ease); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

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

/* ---------- menu a tendina su misura ---------- */
.tendina { position: relative; display: inline-block; }
.tendina-btn {
  display: inline-flex; align-items: center; gap: 10px; height: 32px; padding: 0 12px; border: 0; border-radius: 9px; cursor: pointer;
  font: inherit; font-size: .82rem; font-weight: 550; color: var(--ink); background: #fff; box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow .15s, background .15s; white-space: nowrap;
}
.tendina-btn svg { color: var(--muted); transition: transform .2s var(--ease); }
.tendina-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.tendina-btn:hover { background: #faf9f6; }
.tendina-btn:focus-visible { outline: none; box-shadow: inset 0 0 0 1.5px var(--ink), 0 0 0 4px rgba(20, 19, 17, .06); }
.tendina.scura .tendina-btn { background: rgba(255, 255, 255, .07); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); }
.tendina.scura .tendina-btn:hover { background: rgba(255, 255, 255, .12); }
.tendina.scura .tendina-btn svg { color: rgba(255, 255, 255, .6); }
.tendina-lista {
  position: absolute; z-index: 1100; top: calc(100% + 6px); right: 0; min-width: 100%; max-height: 300px; overflow: auto;
  margin: 0; padding: 5px; list-style: none; background: #fff; border-radius: 12px;
  box-shadow: 0 0 0 1px var(--line), 0 16px 36px -12px rgba(20, 19, 17, .3); animation: tendina-in .14s var(--ease);
}
.side-head .tendina, .side-head .tendina-btn { width: 100%; justify-content: space-between; }
.side-head .tendina-lista { left: 0; right: auto; }
@keyframes tendina-in { from { opacity: 0; transform: translateY(-4px); } }
.tendina-lista li {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 10px; border-radius: 8px;
  font-size: .85rem; font-weight: 500; color: var(--ink); cursor: pointer; white-space: nowrap;
}
.tendina-lista li.attivo { background: var(--line-2); }
.tendina-lista li[aria-selected="true"] { font-weight: 650; }
.tendina-lista li svg { color: var(--ink); flex: none; }

/* ---------- gestione contatti (Attività) ---------- */
.btn-link { background: none; color: var(--muted); }
.btn-link:hover { color: var(--ink); background: var(--line-2); }
.dialogo-largo { width: min(640px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); }
.dialogo-largo form { gap: 0; padding: 0; }
.dlg-testa { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 22px 16px; border-bottom: 1px solid var(--line-2); position: sticky; top: 0; background: #fff; z-index: 2; }
.dlg-testa h2 { font-size: 1.15rem; }
.dlg-x { border: 0; background: var(--line-2); width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); flex: none; }
.dlg-x:hover { background: var(--line); }
.dlg-sez { display: grid; gap: 12px; padding: 18px 22px; }
.dlg-sez + .dlg-sez { border-top: 1px solid var(--line-2); }
.dlg-h { font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.dlg-h-riga { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.dialogo input:disabled { background: var(--line-2); color: var(--ink-2); }
.aggiungi { display: flex; align-items: center; gap: 6px; }
.aggiungi[hidden] { display: none; }
.liv-mini { width: 28px; height: 28px; border-radius: 8px; border: 0; cursor: pointer; font: inherit; font-weight: 700; font-size: 1rem; line-height: 1; transition: transform .1s; }
.liv-mini:active { transform: scale(.92); }
.l-bianco.liv-mini { background: var(--line-2); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line); }
.l-verde.liv-mini { background: var(--green); color: #fff; }
.l-oro.liv-mini { background: linear-gradient(145deg, var(--gold-hi), var(--gold)); color: #3a2c00; }
.l-diamante.liv-mini { background: linear-gradient(110deg, #7fe3ff, #e3fbff, #c4b5ff, #7fe3ff); background-size: 250% 100%; animation: dia-shimmer 3.4s linear infinite; color: var(--dia-ink); }

.lista-contatti { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 46dvh; overflow: auto; }
.lista-contatti li[data-id] { display: grid; grid-template-columns: 22px 44px 1fr auto; align-items: center; gap: 10px; padding: 6px 6px 6px 8px; border-radius: 12px; transition: background .12s, opacity .18s, transform .18s; }
.lista-contatti li[data-id]:hover { background: #faf9f6; }
.lista-contatti li.via { opacity: 0; transform: translateX(12px); }
.lc-n { font-size: .74rem; color: var(--faint); font-weight: 600; text-align: right; }
.lc-ora { font-size: .82rem; color: var(--muted); font-weight: 500; }
.lc-livelli { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; padding: 3px; border-radius: 10px; background: var(--line-2); }
.lc-liv { position: relative; overflow: hidden; border: 0; background: none; font: inherit; font-size: .76rem; font-weight: 600; color: var(--muted); padding: 5px 4px; border-radius: 7px; cursor: pointer; transition: background .15s, color .15s; }
.lc-liv:not(:disabled):hover { color: var(--ink); background: rgba(255, 255, 255, .7); }
.lc-liv:disabled { cursor: default; }
.lc-liv.on.l-bianco { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 0 0 1px var(--line); }
.lc-liv.on.l-verde { background: var(--green); color: #fff; }
.lc-liv.on.l-oro { background: linear-gradient(145deg, var(--gold-hi), var(--gold)); color: #3a2c00; }
.lc-liv.on.l-diamante {
  color: var(--dia-ink); font-weight: 750;
  background: linear-gradient(110deg, #7fe3ff 0%, #e3fbff 18%, #7cc8ff 36%, #c4b5ff 54%, #7fe3ff 72%, #e9fcff 90%, #7fe3ff 100%);
  background-size: 250% 100%; animation: dia-shimmer 3.4s linear infinite; box-shadow: 0 0 10px rgba(39, 195, 240, .45);
}
.lc-del { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px; border: 0; border-radius: 9px; background: none; color: var(--faint); cursor: pointer; font: inherit; font-size: .78rem; font-weight: 650; transition: background .15s, color .15s; }
.lc-del span { display: none; }
.lc-del:hover { color: var(--err-ink); background: var(--err-bg); }
.lc-del.conferma { color: #fff; background: var(--err-ink); }
.lc-del.conferma span { display: inline; }
@media (max-width: 560px) {
  .lista-contatti li[data-id] { grid-template-columns: 38px 1fr auto; }
  .lc-n { display: none; }
  .lc-liv { font-size: .7rem; padding: 6px 2px; }
}

/* ---------- barra in basso (solo telefono) ---------- */
.tabbar { display: none; }
@media (max-width: 760px) {
  .topbar nav { display: none; }
  .topbar .utente { margin-left: auto; border-left: 0; }
  .topbar .utente span { display: inline; color: var(--muted); }
  body { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .tabbar {
    position: fixed; z-index: 1000; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
    padding: 6px 6px calc(env(safe-area-inset-bottom) + 6px); background: rgba(255, 255, 255, .94); backdrop-filter: saturate(1.8) blur(14px);
    border-top: 1px solid var(--line);
  }
  .tab { display: grid; justify-items: center; gap: 3px; padding: 6px 0 2px; text-decoration: none; color: var(--muted); font-size: .68rem; font-weight: 600; }
  .tab.active { color: var(--ink); }
  .tab-zona { display: grid; justify-items: center; gap: 4px; text-decoration: none; color: var(--ink); font-size: .7rem; font-weight: 700; margin-top: -26px; }
  .tab-zona-btn {
    width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center; color: #2a2000;
    background: linear-gradient(150deg, var(--gold-hi), var(--gold)); border: 4px solid #fff;
    box-shadow: 0 10px 24px -6px rgba(212, 160, 23, .75), 0 2px 6px rgba(0, 0, 0, .12);
    transition: transform .12s;
  }
  .tab-zona-btn svg { margin-left: 3px; }
  .tab-zona:active .tab-zona-btn { transform: scale(.94); }
}
@media (max-width: 560px) {
  .imb-riga { grid-template-columns: 1fr auto; gap: 4px 12px; }
  .imb-barra { grid-column: 1 / -1; grid-row: 2; height: 10px; }
  .imb-val { display: flex; gap: 6px; align-items: baseline; }
  .imb-val small { display: inline; }
}
