/* Colori del marchio Portiamo Tutto Sgomberi (come i siti) */
:root {
  --brand: #c62832;
  --brand-d: #a51f28;
  --brand-l: #fdecee;
  --navy: #1c2733;
  --wa: #1fa855;
  --bg: #f4f6f8;
  --card: #fff;
  --text: #1c2733;
  --body: #44515e;
  --muted: #6b7682;
  --line: #e2e6ea;
  --red: #c62832;
  --radius: 14px;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--brand-d); }
h1, h2, h3, h4 { margin: 0 0 .6rem; line-height: 1.2; }
h1, h2, h3 { color: var(--navy); font-weight: 800; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.05rem; margin-top: .4rem; }
h4 { font-size: .95rem; margin-top: 1rem; color: var(--muted); }
code { background: #eef2f0; padding: 1px 5px; border-radius: 5px; font-size: .9em; }
.loading { padding: 40vh 0; text-align: center; color: var(--muted); }

/* layout */
.topbar {
  position: sticky; top: 0; z-index: 1000;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: rgba(255,255,255,.97); color: var(--navy);
  border-bottom: 1px solid var(--line); box-shadow: 0 2px 10px rgba(28,39,51,.06);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { width: 44px; height: 44px; object-fit: contain; flex: none; }
.brand b { display: block; font-weight: 800; font-size: 1.02rem; line-height: 1.1; }
.brand small { display: block; color: var(--body); font-size: .8rem; }
.who { text-align: right; font-size: .82rem; font-weight: 600; line-height: 1.15; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who small { display: block; color: var(--brand); font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
#main { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(90px + env(safe-area-inset-bottom)); }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px; font-size: .72rem; color: var(--muted); text-decoration: none;
}
.tabbar a span { font-size: 1.35rem; }
.tabbar a.active { color: var(--brand); font-weight: 600; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--red); }

.card {
  background: var(--card); border-radius: var(--radius); padding: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 1px 8px rgba(0,0,0,.04);
  margin-bottom: 12px;
}
.stack > .card { margin-bottom: 0; }
.card.order { display: block; color: inherit; text-decoration: none; }
.card.order:active { transform: scale(.99); }
.card.order > div + div { margin-top: 4px; }
.card.empty { text-align: center; color: var(--muted); padding: 28px 14px; }
.hint { margin-top: 8px; font-size: .85rem; font-weight: 600; color: var(--brand-d); background: var(--brand-l); padding: 6px 10px; border-radius: 8px; }
.back { display: inline-block; margin-bottom: 8px; text-decoration: none; font-weight: 600; }

/* form */
label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; font-weight: 500; margin-top: 8px; }
label.check { flex-direction: row; align-items: center; gap: 8px; }
input, select, textarea {
  font: inherit; width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 10px; background: #fff; color: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
input[type=checkbox], input[type=radio] { width: auto; }
input[type=search] { margin-bottom: 10px; }
.row > input { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 700; padding: 10px 18px; border-radius: 999px; cursor: pointer;
  border: 1px solid #c3ccd4; background: #fff; color: var(--text); text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(198,40,50,.25); }
.btn.primary:hover { background: var(--brand-d); }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn.danger { color: var(--red); border-color: #ffd2d5; }
.btn.ghost { background: var(--brand-l); border-color: transparent; color: var(--brand-d); }
.btn.block { width: 100%; margin-top: 8px; }
.btn.lg { padding: 14px; font-size: 1.05rem; }
.btn.small { padding: 6px 10px; font-size: .85rem; }
.link { background: none; border: 0; color: var(--brand-d); font: inherit; margin-top: 12px; cursor: pointer; text-decoration: underline; }

/* chip selezionabili */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { margin: 0; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips span, .chips.filter button {
  display: inline-block; padding: 7px 12px; border-radius: 999px; border: 1px solid #d1d5db;
  background: #fff; font-size: .88rem; font-weight: 500; cursor: pointer; font-family: inherit; color: inherit;
}
.chips input:checked + span, .chips.filter button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chips input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.chips.filter { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; }
.chips.filter button { white-space: nowrap; }

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, white);
}

/* mappe */
.map { height: 260px; border-radius: 10px; margin: 10px 0; z-index: 0; }
.map.tall { height: 58vh; min-height: 320px; }
.pin span {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--c); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35);
}
.pin b { transform: rotate(45deg); color: #fff; font-size: 12px; }
.truck { font-size: 26px; text-align: center; line-height: 34px; background: #fff; border-radius: 50%; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.truck.stale { filter: grayscale(1); opacity: .6; }
.me-dot span { display: block; width: 18px; height: 18px; border-radius: 50%; background: #2563eb; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(37,99,235,.25); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .82rem; color: var(--muted); margin-bottom: 14px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; }

.results { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.results button { text-align: left; font: inherit; font-size: .88rem; padding: 8px 10px; border: 1px solid var(--line); background: #fafafa; border-radius: 8px; cursor: pointer; }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; margin-top: 8px; }
.thumbs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
.thumb { position: relative; }
.thumb button {
  position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%;
  border: 0; background: rgba(28,39,51,.8); color: #fff; font-size: 18px; line-height: 1; cursor: pointer;
}
.photo-add {
  flex-direction: row; justify-content: center; align-items: center; gap: 8px; margin: 6px 0 0;
  padding: 18px; border: 2px dashed #c3ccd4; border-radius: 12px; background: #fafbfc;
  font-weight: 700; color: var(--brand); cursor: pointer;
}
.photo-add:hover { border-color: var(--brand); background: var(--brand-l); }

/* dettaglio */
.info { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; font-size: .92rem; }
.info dt { color: var(--muted); }
.info dd { margin: 0; }
.desc { background: #f9fafb; border-radius: 8px; padding: 10px; white-space: pre-wrap; }
.price { font-size: 2rem; font-weight: 800; color: var(--brand-d); margin: 0 0 8px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 12px 22px; display: flex; flex-direction: column; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.timeline li:not(:last-child)::after { content: ""; position: absolute; left: 8px; top: 17px; bottom: 0; width: 2px; background: var(--line); }

/* statistiche admin */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { font: inherit; background: #fff; border: 0; border-radius: 12px; padding: 10px 4px; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.stat b { display: block; font-size: 1.5rem; color: var(--brand-d); }
.stat span { font-size: .72rem; color: var(--muted); }

/* interruttore */
.switch { position: relative; width: 50px; height: 28px; margin: 0; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #d1d5db; border-radius: 99px; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::before { transform: translateX(22px); }

/* login */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 16px;
  background: radial-gradient(circle at 20% 0%, rgba(198,40,50,.35), transparent 55%), linear-gradient(160deg, #2a3540 0%, var(--navy) 60%, #141c24 100%); }
.auth-card { width: 100%; max-width: 400px; text-align: center; padding: 24px 20px; }
.auth-logo { width: 110px; height: auto; display: block; margin: 0 auto 6px; }
.auth .kicker { color: var(--brand); font-weight: 700; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; margin: 0; }
.auth h1 { font-size: 1.5rem; font-weight: 800; color: var(--navy); }
.auth-contact { display: flex; gap: 10px; width: 100%; max-width: 400px; }
.auth-contact .btn { flex: 1; }
.auth-contact .btn.primary { box-shadow: none; }
.auth-card form { text-align: left; margin-top: 12px; }
.auth-card.setup { text-align: left; }
.auth-card.setup ol { padding-left: 20px; }
.auth-card.setup li { margin-bottom: 8px; }
.logo { font-size: 3rem; text-align: center; }
.setup h1 { text-align: center; }
.seg { display: flex; background: #f3f4f6; border-radius: 10px; padding: 4px; margin-top: 14px; }
.seg button { flex: 1; font: inherit; font-weight: 600; border: 0; background: none; padding: 8px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.seg button.on { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

.send-quote { background: #f0faf4; border: 1px solid #c8ecd6; border-radius: 12px; padding: 10px 12px; margin-top: 10px; }
.send-quote p { margin: 0 0 6px; }

/* header: logo cliccabile e icona profilo */
a.brand { color: inherit; text-decoration: none; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; text-decoration: none; font-size: 1.2rem; flex: none; }

/* badge numerico (messaggi non letti) */
.tabbar a { position: relative; }
.tabbar .count, .thread .count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--brand); color: #fff;
  font-size: .72rem; font-weight: 800; display: inline-grid; place-items: center;
}
.tabbar .count { position: absolute; top: 4px; left: calc(50% + 6px); }

/* home a menu (stile Iren) */
.home-hero { text-align: center; padding: 8px 0 14px; }
.home-hero img { width: 120px; height: auto; }
.home-hero h1 { font-size: 1.5rem; margin: 6px 0 2px; }
.home-hero p { margin: 0; color: var(--body); }
.menu { background: var(--card); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 1px 8px rgba(0,0,0,.04); overflow: hidden; }
.menu a { display: flex; align-items: center; gap: 12px; padding: 14px; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--line); }
.menu a:last-child { border-bottom: 0; }
.menu a:active { background: var(--brand-l); }
.menu .mi { width: 44px; height: 44px; flex: none; display: grid; place-items: center; font-size: 1.4rem; background: var(--brand-l); border-radius: 12px; }
.menu .mt { flex: 1; min-width: 0; }
.menu .mt b { display: block; }
.menu .mt small { color: var(--muted); }
.menu .chev { color: var(--brand); font-size: 1.6rem; font-weight: 700; }
.alert { display: block; margin-bottom: 10px; padding: 12px 14px; border-radius: 12px; background: var(--brand); color: #fff; font-weight: 700; text-decoration: none; }

/* casella evidenziata (merce in strada) */
label.check.highlight { align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: #f0faf4; border: 1px solid #c8ecd6; font-weight: 400; }
label.check.highlight input { margin-top: 4px; }
.ok { color: #15803d; }

/* chat */
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow-y: auto; padding: 4px 2px 8px; }
.bubble { max-width: 85%; align-self: flex-start; background: #eef1f4; border-radius: 14px 14px 14px 4px; padding: 8px 12px; }
.bubble.mine { align-self: flex-end; background: var(--brand); color: #fff; border-radius: 14px 14px 4px 14px; }
.bubble small { display: block; margin-top: 3px; font-size: .72rem; opacity: .75; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; margin-top: 6px; }
.chat-form textarea { resize: none; min-height: 44px; }
.chat-form .btn { padding: 10px 16px; }
.thread.unread { border-left: 4px solid var(--brand); }
.thread .preview { margin-top: 4px; color: var(--body); font-size: .9rem; }

/* dizionario */
.dict { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.dict-item { background: var(--card); border-radius: 12px; padding: 0 14px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.dict-item summary { padding: 13px 0; font-weight: 600; cursor: pointer; list-style: none; display: flex; justify-content: space-between; }
.dict-item summary::after { content: '›'; color: var(--brand); font-size: 1.4rem; line-height: 1; transition: .2s; }
.dict-item[open] summary::after { transform: rotate(90deg); }
.dict-item p { margin: 0 0 10px; color: var(--body); }
.dict-item .btn { margin-bottom: 12px; }

/* scelta foto / sopralluogo */
.choice { display: grid; gap: 8px; }
.choice label { flex-direction: row; align-items: flex-start; gap: 10px; margin: 0; padding: 12px; border: 2px solid var(--line); border-radius: 12px; cursor: pointer; font-weight: 400; }
.choice label:has(input:checked) { border-color: var(--brand); background: var(--brand-l); }
.choice input { margin-top: 4px; accent-color: var(--brand); }
.choice b { display: block; }
.choice small { color: var(--body); }

/* stima prezzo */
.estimate { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--navy); color: #fff; display: grid; gap: 2px; }
.estimate span { font-size: .8rem; opacity: .8; text-transform: uppercase; letter-spacing: .05em; }
.estimate b { font-size: 1.5rem; }
.estimate small { opacity: .8; }
label.check.highlight.gold { background: #fff8e6; border-color: #f5dfa0; }

/* giorni disponibili */
.chips.days button { font: inherit; font-size: .85rem; padding: 7px 12px; border-radius: 999px; border: 1px solid #c3ccd4; background: #fff; cursor: pointer; }
.chips.days button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chips.days button:disabled { opacity: .45; text-decoration: line-through; cursor: not-allowed; }

/* privacy */
label.check.privacy { align-items: flex-start; font-weight: 400; font-size: .88rem; margin: 4px 2px; }
label.check.privacy input { margin-top: 3px; }
.legal h3 { margin-top: 1rem; }
.legal p { color: var(--body); }

/* recensione */
.review { margin-top: 10px; padding: 14px; border-radius: 12px; background: #fff8e6; border: 1px solid #f5dfa0; text-align: center; }
.review p { margin: 4px 0 10px; color: var(--body); }

/* calendario */
.cal { display: grid; gap: 10px; }
.cal-day { background: var(--card); border-radius: 12px; padding: 10px 12px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.cal-day.today { outline: 2px solid var(--brand); }
.cal-day h4 { margin: 0 0 6px; color: var(--navy); text-transform: capitalize; display: flex; justify-content: space-between; }
.cal-job { display: grid; gap: 1px; padding: 8px 10px; margin-top: 6px; border-radius: 10px; border-left: 4px solid var(--c);
  background: color-mix(in srgb, var(--c) 8%, white); color: var(--text); text-decoration: none; font-size: .88rem; }
.cal-job span { color: var(--body); }
.alert.soft { background: #fff8e6; color: var(--text); border: 1px solid #f5dfa0; font-weight: 600; }
.alert.soft a { color: var(--brand-d); }

/* statistiche */
.bar { display: grid; grid-template-columns: 90px 1fr auto; align-items: center; gap: 8px; margin: 6px 0; font-size: .88rem; }
.bar span { color: var(--body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar i { display: block; height: 12px; min-width: 2px; border-radius: 6px; background: var(--brand); }
.bar b { font-variant-numeric: tabular-nums; }
div.stat { background: #fff; border-radius: 12px; padding: 10px 4px; text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
div.stat b { display: block; font-size: 1.2rem; color: var(--brand-d); }
div.stat span { font-size: .72rem; color: var(--muted); }

/* preventivo stampabile */
.sheet { background: #fff; padding: 28px; border-radius: 8px; box-shadow: 0 1px 8px rgba(0,0,0,.08); color: #1c2733; }
.sheet-head { display: flex; gap: 16px; align-items: center; border-bottom: 3px solid var(--brand); padding-bottom: 12px; font-size: .85rem; }
.sheet-head img { width: 80px; }
.sheet h1 { margin-top: 18px; }
.sheet table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.sheet th { text-align: left; width: 38%; color: var(--body); font-weight: 600; }
.sheet th, .sheet td { padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.sheet .total { display: flex; justify-content: space-between; align-items: center; margin: 18px 0; padding: 14px; background: var(--brand-l); border-radius: 8px; font-size: 1.2rem; }
.sheet .total b { font-size: 1.6rem; color: var(--brand-d); }
.sheet .terms p { font-size: .8rem; color: var(--body); }
.sheet .sign { display: flex; justify-content: space-between; margin-top: 30px; font-size: .9rem; }
@media print {
  .topbar, .tabbar, .no-print, #toast { display: none !important; }
  body { background: #fff; }
  #main { padding: 0; max-width: none; }
  .sheet { box-shadow: none; padding: 0; }
}

/* ingresso cliente senza registrazione */
.hero {
  margin: -16px -16px 16px; padding: 22px 16px 20px; color: #fff;
  background: radial-gradient(circle at 15% 0%, rgba(198,40,50,.45), transparent 60%), linear-gradient(160deg, #2a3540, var(--navy));
}
.hero h1 { color: #fff; font-size: 1.6rem; margin-bottom: .5rem; }
.hero p { margin: 0; color: #e2e6ea; }
.hero .kicker { color: #ff9aa1; font-weight: 700; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 6px; }
.guest-contact { margin-top: 16px; }
.guest-contact .btn { flex: 1; }
.staff-link { text-align: center; margin: 18px 0 0; }
.staff-link .link { color: var(--muted); font-size: .85rem; }

/* notifiche */
#toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  max-width: calc(100% - 32px); background: #111827; color: #fff; padding: 12px 16px; border-radius: 12px;
  font-size: .92rem; opacity: 0; pointer-events: none; transition: .25s; z-index: 2000; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--red); }

@media (max-width: 380px) {
  .grid2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
