/* HUP · pagina di controllo (solo soci)
   Colori: blu #0046FF · blu notte #242038 · bianco · corallo #FE5F55 — Font: Rethink Sans */

:root {
  --blue: #0046FF;
  --navy: #242038;
  --coral: #FE5F55;
  --white: #FFFFFF;
  --bg: #F3F4F8;
  --grey: #6B6885;
  --grey-2: #8A87A0;
  --line: #EBEBF2;
  --soft: #E8EEFF;
  --field: #F3F4F8;
  --shadow: 0 2px 10px rgba(36, 32, 56, .06);
  --radius: 20px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Rethink Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--navy);
  font-size: 15px; line-height: 1.4; -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
[hidden] { display: none !important; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- barra ---------- */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--white); box-shadow: 0 1px 6px rgba(0, 0, 0, .06);
  padding: calc(12px + env(safe-area-inset-top, 0px)) 20px 12px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 22px; color: var(--navy); text-decoration: none; }
.brand img { border-radius: 8px; }
.brand em { font-style: normal; font-size: 12px; font-weight: 700; color: var(--blue); background: var(--soft); padding: 4px 9px; border-radius: 10px; margin-left: 2px; }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--grey); min-width: 0; }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ghost { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 12px; background: var(--field); color: var(--navy); font-weight: 600; font-size: 13px; }
.ghost:hover { background: var(--soft); color: var(--blue); }

/* ---------- accesso ---------- */
.gate { min-height: calc(100vh - 70px); display: grid; place-items: center; padding: 24px; }
.gate-card { background: var(--white); border-radius: 28px; box-shadow: var(--shadow); padding: 36px 28px; max-width: 420px; width: 100%; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.gate-card h1 { margin: 6px 0 0; font-size: 24px; font-weight: 800; }
.gate-card p { margin: 0; color: var(--grey); }
.dot { width: 18px; height: 18px; border-radius: 50%; background: var(--coral); animation: pulse 1.2s ease-in-out infinite; }
.dot.still { animation: none; }
@keyframes pulse { 50% { transform: scale(.6); opacity: .6; } }
.gate-actions { display: flex; flex-direction: column; gap: 12px; width: 100%; margin-top: 10px; }
.btn { height: 50px; border-radius: 16px; background: var(--blue); color: var(--white); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 18px; }
.link { color: var(--blue); font-size: 13px; font-weight: 600; text-decoration: none; }

/* ---------- contenuto ---------- */
.adm { max-width: 1100px; margin: 0 auto; padding: 18px 20px 60px; }
.tabs { display: flex; align-items: center; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.tab { height: 36px; padding: 0 16px; border-radius: 18px; font-weight: 700; font-size: 14px; background: var(--white); color: var(--grey); box-shadow: var(--shadow); }
.tab.on { background: var(--blue); color: var(--white); }
.refresh { margin-left: auto; background: var(--white); box-shadow: var(--shadow); }
.refresh.spin .ic { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.panel { display: flex; flex-direction: column; gap: 16px; animation: in .2s ease; }
@keyframes in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.tile { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.t-label { color: var(--coral); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.tile strong { font-size: 34px; font-weight: 800; line-height: 1.1; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.t-sub { color: var(--grey); font-size: 13px; }
.meter { height: 8px; border-radius: 4px; background: var(--field); overflow: hidden; margin: 4px 0 2px; }
.meter span { display: block; height: 100%; width: 0; background: var(--blue); border-radius: 4px; transition: width .4s; }
.meter span.warn { background: var(--coral); }

.grid2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; }
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-h h2 { margin: 0; font-size: 17px; font-weight: 800; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--grey); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.blue { background: var(--blue); }
.sw.coral { background: var(--coral); }
.note { margin: 0; font-size: 13px; color: var(--navy); }
.note.muted { color: var(--grey-2); font-size: 12px; }
.stamp { margin: 0; text-align: right; font-size: 12px; color: var(--grey-2); }

/* grafico a barre */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis { fill: var(--grey-2); font-size: 11px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .hit { fill: transparent; }
.chart .col:hover .hit { fill: rgba(0, 70, 255, .05); }
.tablev summary { font-size: 12px; color: var(--grey); cursor: pointer; }
.tablev table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 8px; font-variant-numeric: tabular-nums; }
.tablev th, .tablev td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: right; }
.tablev th:first-child, .tablev td:first-child { text-align: left; }

/* imbuto */
.funnel { display: flex; flex-direction: column; gap: 8px; }
.f-row { display: grid; grid-template-columns: 128px 1fr 74px; align-items: center; gap: 10px; font-size: 13px; }
.f-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.f-name b { color: var(--grey-2); font-weight: 700; margin-right: 4px; }
.f-track { height: 22px; border-radius: 6px; background: var(--field); overflow: hidden; }
.f-bar { height: 100%; border-radius: 0 4px 4px 0; background: var(--blue); min-width: 2px; transition: width .4s; }
.f-row.end .f-bar { background: var(--navy); }
.f-row.drop .f-name { color: var(--coral); }
.f-val { text-align: right; font-variant-numeric: tabular-nums; }
.f-val small { color: var(--grey-2); margin-left: 4px; }

/* clienti */
.search { display: flex; align-items: center; gap: 10px; background: var(--white); border-radius: 16px; box-shadow: var(--shadow); padding: 0 16px; height: 50px; color: var(--grey); }
.search input { flex: 1; border: 0; outline: 0; background: none; height: 100%; color: var(--navy); min-width: 0; }
.count { font-size: 13px; white-space: nowrap; }
.list { display: flex; flex-direction: column; gap: 8px; }
.row { background: var(--white); border-radius: 18px; box-shadow: var(--shadow); padding: 14px 16px; display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) 96px minmax(0, 1fr) auto; gap: 14px; align-items: center; }
.r-who { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.r-mail { display: flex; align-items: center; gap: 8px; font-weight: 700; min-width: 0; }
.r-mail span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini { font-size: 12px; font-weight: 700; color: var(--blue); }
.r-sub { font-size: 12px; color: var(--grey); }
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 8px; background: var(--soft); color: var(--blue); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 13px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.chip.ok { background: #E7F6EE; color: #157347; }
.chip.mid { background: #FFF1EF; color: #B23A31; }
.chip.zero { background: var(--field); color: var(--grey); }
.r-code { font-weight: 800; letter-spacing: .08em; font-variant-numeric: tabular-nums; }
.r-code.none { color: var(--grey-2); font-weight: 600; letter-spacing: 0; font-size: 13px; white-space: nowrap; }
.r-dates { font-size: 12px; color: var(--grey); }
.r-act { display: flex; gap: 6px; justify-content: flex-end; }
.act { height: 34px; padding: 0 12px; border-radius: 12px; font-size: 13px; font-weight: 700; background: var(--soft); color: var(--blue); white-space: nowrap; }
.act.del { background: var(--field); color: var(--grey); }
.act.del:hover { color: #D2372C; }
.act.del.armed { background: #D2372C; color: var(--white); }
.act:disabled { opacity: .5; cursor: default; }
.empty { text-align: center; color: var(--grey); padding: 30px 0; }

/* registro */
.log { display: flex; flex-direction: column; }
.l-row { display: grid; grid-template-columns: 130px 1fr auto; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.l-row:last-child { border-bottom: 0; }
.l-when { color: var(--grey); font-variant-numeric: tabular-nums; }
.l-what b { font-weight: 700; }
.l-who { color: var(--grey-2); font-size: 12px; }

/* ---------- anteprima rider ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; }
.sheet-bg { position: absolute; inset: 0; background: rgba(36, 32, 56, .55); }
.phone { position: relative; width: 390px; max-width: 100%; height: min(820px, calc(100vh - 32px)); background: var(--bg); border-radius: 34px; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); border: 6px solid var(--navy); }
.phone-top { display: flex; align-items: center; gap: 8px; padding: 14px 14px 12px 18px; background: var(--white); box-shadow: 0 1px 6px rgba(0, 0, 0, .06); }
.tag { font-size: 11px; font-weight: 700; color: var(--coral); text-transform: uppercase; letter-spacing: .08em; }
.code { font-weight: 800; letter-spacing: .08em; margin-right: auto; }
.x { width: 34px; height: 34px; border-radius: 12px; background: var(--field); display: grid; place-items: center; }
.phone-body { flex: 1; overflow-y: auto; padding: 14px 14px 100px; display: flex; flex-direction: column; gap: 12px; }
.r-card { background: var(--white); border-radius: 22px; padding: 14px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); }
.r-label { color: var(--coral); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.r-addr { font-size: 20px; font-weight: 800; line-height: 1.2; margin: 0; }
.maps { display: flex; align-items: center; justify-content: center; gap: 8px; height: 44px; border-radius: 14px; background: var(--soft); color: var(--blue); font-weight: 700; text-decoration: none; }
.photos { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.photos::-webkit-scrollbar { display: none; }
.photos .ph { flex: none; width: 100%; aspect-ratio: 4 / 3; border-radius: 16px; background: var(--field) center / cover no-repeat; scroll-snap-align: start; }
.photos.small .ph { width: 46%; }
.ph.loading, .ic-box.loading { background: linear-gradient(90deg, var(--field), #fafafe, var(--field)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.ic-box { border-radius: 16px; overflow: hidden; aspect-ratio: 33 / 20; background: var(--field); }
.ic-box canvas { display: block; width: 100%; height: 100%; }
.r-name { font-size: 24px; font-weight: 800; margin: 0; }
.r-facts { display: flex; gap: 8px; flex-wrap: wrap; }
.fact { background: var(--soft); color: var(--blue); font-weight: 700; padding: 8px 12px; border-radius: 12px; font-size: 14px; }
.r-notes { margin: 0; font-size: 16px; white-space: pre-wrap; }
.r-meta { font-size: 12px; color: var(--grey); text-align: center; margin: 4px 0 0; }
.call { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 14px 16px; background: linear-gradient(transparent, var(--bg) 30%); }
.btn-call { width: 100%; height: 56px; border-radius: 18px; background: var(--blue); color: var(--white); font-weight: 800; font-size: 17px; display: flex; align-items: center; justify-content: center; gap: 10px; box-shadow: 0 8px 20px rgba(0, 70, 255, .3); }
.btn-call .ic { width: 22px; height: 22px; }

/* tooltip e avvisi */
.tip { position: fixed; z-index: 60; pointer-events: none; background: var(--navy); color: var(--white); border-radius: 10px; padding: 8px 10px; font-size: 12px; line-height: 1.5; box-shadow: 0 6px 18px rgba(0, 0, 0, .2); font-variant-numeric: tabular-nums; }
.tip b { display: block; margin-bottom: 2px; }
.tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.toast { position: fixed; z-index: 70; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--navy); color: var(--white); padding: 12px 18px; border-radius: 14px; font-size: 14px; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); max-width: calc(100% - 32px); }

/* ---------- telefono / tablet ---------- */
@media (max-width: 900px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1fr auto; grid-template-areas: "who state" "code dates" "act act"; gap: 10px; }
  .r-who { grid-area: who; } .r-state { grid-area: state; justify-self: end; }
  .r-code { grid-area: code; } .r-dates { grid-area: dates; text-align: right; }
  .r-act { grid-area: act; justify-content: stretch; }
  .r-act .act { flex: 1; }
}
@media (max-width: 520px) {
  .adm { padding: 14px 14px 50px; }
  .tile strong { font-size: 28px; }
  .who span { display: none; }
  .f-row { grid-template-columns: 112px 1fr 60px; font-size: 12px; gap: 8px; }
  .refresh { font-size: 0; gap: 0; width: 36px; justify-content: center; padding: 0; }
  .tab { padding: 0 13px; }
  .l-row { grid-template-columns: 1fr; gap: 2px; }
  .sheet { padding: 0; }
  .phone { width: 100%; height: 100%; border-radius: 0; border: 0; }
}

/* suggerimenti */
.tab .badge { margin-left: 4px; background: var(--coral); color: var(--white); }
.sug { display: flex; flex-direction: column; }
.s-row { padding: 14px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.s-row:last-child { border-bottom: 0; }
.s-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; width: 100%; font-size: 13px; }
.s-who { font-weight: 600; }
.s-when { margin-left: auto; color: var(--grey); }
.s-text { margin: 0; font-size: 15px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 70ch; }
.s-row.letto .s-text { color: var(--grey); }

/* controlli */
.ctl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: start; }
.ctl .note { line-height: 1.5; color: var(--grey); }
.state { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 12px; }
.state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.state.on { background: #E7F6EE; color: #157347; }
.state.off { background: #FFF1EF; color: #B23A31; }
.ctl-label { font-size: 13px; font-weight: 600; }
.ctl textarea { font: inherit; color: var(--navy); border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; resize: vertical; background: var(--field); }
.ctl textarea:focus { outline: 0; border-color: var(--blue); background: var(--white); }
.ctl-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn.danger { background: var(--white); color: #D2372C; box-shadow: inset 0 0 0 1.5px #F2C2BE; }
.btn.armed { background: #D2372C; color: var(--white); box-shadow: none; }
.btn:disabled { opacity: .5; }
.badge.warn { background: #F5A524; color: var(--white); }
.chip.blk { background: #2E2A45; color: var(--white); }
@media (max-width: 900px) { .ctl-grid { grid-template-columns: 1fr; } }

/* ristoranti */
.badge.rist { background: #FFF1EF; color: #B23A31; }
.ri-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
.ri-fld { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.ri-fld input { height: 46px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--field); padding: 0 12px; font-size: 15px; outline: 0; }
.ri-fld input:focus { border-color: var(--blue); background: var(--white); }
.ri-form .btn { height: 46px; }
.row.ri { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1.2fr) auto; }
@media (max-width: 900px) {
  .ri-form { grid-template-columns: 1fr; }
  .row.ri { grid-template-columns: 1fr auto; grid-template-areas: "who state" "dates dates" "act act"; }
}
