/* Casa Manutenzione v2 – stile dal mockup */
@font-face { font-family: Inter; font-weight: 400; font-display: swap; src: url(fonts/inter-400.woff2) format('woff2'); }
@font-face { font-family: Inter; font-weight: 500; font-display: swap; src: url(fonts/inter-500.woff2) format('woff2'); }
@font-face { font-family: Inter; font-weight: 600; font-display: swap; src: url(fonts/inter-600.woff2) format('woff2'); }
@font-face { font-family: Inter; font-weight: 700; font-display: swap; src: url(fonts/inter-700.woff2) format('woff2'); }

:root {
  --bg: #F3F6FB;
  --card: #FFFFFF;
  --line: #E1E7F2;
  --line-soft: #EEF2F8;
  --ink: #0E1B33;
  --navy: #0E2F73;
  --blue: #1F5BD8;
  --blue-soft: #E7EEFC;
  --muted: #5C6B85;
  --late: #8A3409;
  --late-soft: #FDF1E8;
  --late-line: #F6D2B8;
  --red: #B42318;
  --red-soft: #FDECEA;
  --green: #17734A;
  --green-soft: #E3F4EA;
  --info: #3C4860;
  --info-soft: #EEF2F8;
  --radius: 16px;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font: 16px/1.4 Inter, system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; }
.ic { flex: none; }
h2 { font-size: 17px; font-weight: 700; margin: 22px 0 10px; }
h3 { font-size: 17px; font-weight: 700; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.right { text-align: right; }
.blue { color: var(--blue); }
.hidden, [hidden] { display: none !important; }

.page {
  max-width: 640px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 20px calc(env(safe-area-inset-bottom) + 32px);
}

/* ---------- Barre superiori ---------- */
.topbar.main { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; min-height: 44px; }
.topbar .spacer { flex: 1; }
.circle {
  width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line); background: var(--card);
  color: var(--navy); display: inline-flex; align-items: center; justify-content: center; position: relative; flex: none;
}
.circle.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.bell .dot { position: absolute; top: 9px; right: 10px; width: 9px; height: 9px; border-radius: 50%; background: #E8590C; border: 2px solid #fff; }
.pill-back {
  display: inline-flex; align-items: center; gap: 2px; height: 44px; padding: 0 14px 0 8px; border-radius: 22px;
  background: var(--card); border: 1px solid var(--line); color: var(--navy); font-weight: 600;
}
.pill-primary { display: inline-flex; align-items: center; gap: 4px; height: 44px; padding: 0 14px 0 10px; border-radius: 22px; background: var(--blue); color: #fff; font-weight: 600; }
.link { color: var(--blue); font-weight: 500; font-size: 16px; padding: 6px 4px; }
.link.strong { font-weight: 600; }
h1.big { font-size: 32px; line-height: 1.1; letter-spacing: -0.02em; margin: 0 0 16px; font-weight: 700; }
.topbar.sub {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  margin: calc(-12px - env(safe-area-inset-top)) -20px 16px; padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: rgba(243, 246, 251, .92); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar.sub h1 { margin: 0; font-size: 17px; font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.topbar.sub .right { justify-self: end; display: flex; gap: 6px; }
.link-back { display: inline-flex; align-items: center; color: var(--blue); font-size: 17px; font-weight: 500; justify-self: start; min-height: 40px; }
.link-back .ic { margin-left: -4px; }
h1.title { font-size: 26px; line-height: 1.15; margin: 0 0 8px; letter-spacing: -0.01em; }
h2.title { font-size: 20px; margin: 0 0 10px; }

/* ---------- Home ---------- */
.home-head small { color: var(--muted); font-size: 15px; }
.home-head h1.big { margin: 4px 0 10px; }
.offline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--navy); background: var(--blue-soft); padding: 6px 12px; border-radius: 999px; }
.home-head .offline { margin-bottom: 16px; }
.hero { display: block; background: var(--navy); color: #fff; border-radius: 20px; padding: 18px 20px; margin: 4px 0 14px; }
.hero-top { display: flex; justify-content: space-between; align-items: center; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; opacity: .9; }
.hero-pill { background: var(--blue); color: #fff; padding: 3px 10px; border-radius: 999px; text-transform: none; letter-spacing: 0; font-size: 13px; }
.hero-body { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.hero-body b { display: block; font-size: 19px; }
.hero-body small { opacity: .85; font-size: 14px; }
.hero-ic { width: 48px; height: 48px; border-radius: 14px; background: rgba(255,255,255,.12); display: flex; align-items: center; justify-content: center; flex: none; }
.alert-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--late-soft); border: 1px solid var(--late-line); color: var(--late); margin-bottom: 14px; }
.alert-card span { flex: 1; min-width: 0; }
.alert-card b { display: block; }
.alert-card small { color: var(--late); opacity: .9; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 6px; }
.stats > * { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; color: var(--ink); }
.stats b { display: block; font-size: 26px; color: var(--blue); font-weight: 700; }
.stats span { font-size: 13px; color: var(--muted); }
.bottom-cta { margin-top: 24px; }
.notice { background: var(--blue-soft); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 14px; font-size: 14px; }
.notice.warn { background: var(--late-soft); color: var(--late); }

/* ---------- Liste e card ---------- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.section-head h2 { margin-bottom: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card.list { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; }
.list .row, .card.list > .row-wrap > .row { border-top: 1px solid var(--line-soft); }
.list > .row:first-child, .list > .row-wrap:first-child > .row { border-top: none; }
.row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; color: var(--ink); width: 100%; text-align: left; }
.row-main { flex: 1; min-width: 0; display: block; }
.row-main b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main small.validity { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }
.row-date { font-weight: 600; font-size: 14px; color: var(--navy); white-space: nowrap; }
.row-wrap { position: relative; display: flex; align-items: center; }
.row-wrap + .row-wrap { border-top: 1px solid var(--line-soft); }
.card.list > .row-wrap > .row { border-top: none; }
.row-wrap > .row { flex: 1; min-width: 0; }
.row-wrap > .card { flex: 1; }
.del-btn { width: 36px; height: 36px; margin-left: 10px; border-radius: 18px; background: var(--red-soft); color: var(--red); display: flex; align-items: center; justify-content: center; flex: none; }
.row-action { margin-right: 12px; white-space: nowrap; }
.ic-box { width: 40px; height: 40px; border-radius: 12px; background: var(--blue-soft); color: var(--blue); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.ic-box.green { background: var(--green-soft); color: var(--green); }
.av { width: 44px; height: 44px; border-radius: 12px; background: var(--blue-soft); color: var(--blue); display: inline-flex; align-items: center; justify-content: center; flex: none; overflow: hidden; }
.av.lg { width: 84px; height: 84px; border-radius: 20px; }
.av img { width: 100%; height: 100%; object-fit: cover; }
.badge { font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 999px; white-space: nowrap; flex: none; }
.badge.late { background: var(--late-soft); color: var(--late); }
.badge.soon { background: var(--blue-soft); color: var(--blue); }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.off, .badge.done { background: var(--info-soft); color: var(--info); }
.empty { text-align: center; color: var(--muted); padding: 22px 12px; font-size: 15px; }
.empty.dashed { border: 1.5px dashed var(--line); border-radius: var(--radius); margin: 12px 0; }
.empty.big { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 40px 10px; }
.empty.big .ic { color: var(--green); }
.empty.big b { color: var(--ink); font-size: 18px; }
.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }

dl.info { display: grid; grid-template-columns: max-content 1fr; gap: 10px 16px; margin: 0; font-size: 15px; }
dl.info dt { color: var(--muted); }
dl.info dd { margin: 0; overflow-wrap: anywhere; font-weight: 500; }
.notes { white-space: pre-wrap; margin: 14px 0 0; color: var(--ink); font-size: 15px; }

.asset-hero { display: flex; gap: 16px; align-items: center; margin: 6px 0 16px; }
.asset-hero > div { min-width: 0; }

/* Timeline storico */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.tl-item { display: block; position: relative; color: var(--ink); }
.tl-item > i { position: absolute; left: -22px; top: 18px; width: 12px; height: 12px; border-radius: 50%; background: var(--blue); border: 2px solid var(--bg); }
.tl-item .card { padding: 14px; }
.tl-item .card > b, .tl-item .card > small { display: block; }
.tl-top { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.tl-item p { margin: 4px 0 6px; font-size: 14px; color: var(--muted); }

/* ---------- Chip, segmenti, ricerca ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; margin: 0 -20px 12px; padding: 0 20px 2px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 36px; padding: 0 14px; border-radius: 18px;
  border: 1px solid var(--line); background: var(--card); color: var(--navy); font-size: 14px; font-weight: 500; white-space: nowrap; cursor: pointer;
}
.chip input { display: none; }
.chip.on { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); font-weight: 600; }
.chip.add { border-style: dashed; border-color: #9DB4E6; color: var(--blue); background: transparent; }
.chip.sm { height: 26px; padding: 0 10px; font-size: 12px; font-weight: 600; background: var(--info-soft); border: none; color: var(--navy); }
.chip.sm.off { background: var(--late-soft); color: var(--late); }
.chips.static { gap: 6px; }
.seg { display: flex; background: #E4EAF5; border-radius: 12px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; height: 36px; border-radius: 10px; font-size: 14px; font-weight: 500; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(14,27,51,.12); }
.search { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; margin-bottom: 12px; color: var(--muted); }
.search input { border: none; padding: 0; min-height: 44px; background: transparent; }
.search input:focus { outline: none; }
.check-line { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); margin: -2px 0 6px; }

/* ---------- Pulsanti ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 20px;
  border-radius: 14px; font-weight: 600; font-size: 16px; background: var(--blue-soft); color: var(--blue); text-align: center; cursor: pointer;
}
.btn.primary { background: var(--blue); color: #fff; }
.btn.soft { background: var(--blue-soft); color: var(--blue); }
.btn.danger-soft { background: transparent; color: var(--red); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn.tiny { min-height: 30px; padding: 0 10px; font-size: 13px; border-radius: 9px; }
.btn.block { display: flex; width: 100%; }
.icon-btn { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; color: var(--blue); }

/* ---------- Form ---------- */
.form-page form { display: flex; flex-direction: column; gap: 4px; }
.form-page form > .btn { margin-top: 10px; }
.field { display: block; margin: 6px 0 10px; }
.field > span { display: block; font-size: 14px; font-weight: 600; margin: 0 2px 7px; color: var(--ink); }
.field > span em { float: right; font-style: normal; font-weight: 400; color: var(--muted); font-size: 13px; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-height: 48px; -webkit-appearance: none; appearance: none;
}
input:disabled { background: var(--info-soft); color: var(--muted); }
textarea { resize: vertical; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
input[type=date], input[type=time] { display: block; min-height: 48px; }
input[type=checkbox]:not(.switch) { width: 20px; height: 20px; min-height: 0; padding: 0; -webkit-appearance: auto; appearance: auto; accent-color: var(--blue); flex: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 > * { min-width: 0; }
.inline { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.inline select { flex: 1; }
.w80 { width: 84px !important; flex: none; }
.small-select { min-height: 40px; font-size: 14px; padding: 8px 32px 8px 12px; margin-bottom: 14px; }
.form-page .card { margin: 8px 0; }

.switch { -webkit-appearance: none; appearance: none; width: 51px; height: 31px; min-height: 0; padding: 0; border-radius: 16px; background: #D5DCE8; border: none; position: relative; transition: .2s; flex: none; cursor: pointer; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: .2s; }
.switch:checked { background: var(--blue); }
.switch:checked::after { left: 22px; }
.switch:focus { outline: none; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; }
.toggle-row b { display: block; font-weight: 600; font-size: 15px; }
.toggle-row small { color: var(--muted); font-size: 13px; }
.rec-fields { margin-top: 14px; }
.mini-switch { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.mini-switch small { font-size: 11px; color: var(--muted); }

.picker-row { display: flex; align-items: center; gap: 12px; width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 6px 0 10px; text-align: left; color: var(--muted); }
.pr-text { flex: 1; min-width: 0; }
.pr-text small { display: block; font-size: 12px; color: var(--muted); }
.pr-text b { display: block; color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pr-text b.ph { color: var(--muted); font-weight: 500; }

.name-block { display: flex; gap: 12px; margin-bottom: 8px; }
.photo-slot { width: 104px; height: 104px; border-radius: 18px; background: var(--blue-soft); color: var(--blue); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; flex: none; overflow: hidden; font-size: 12px; font-weight: 600; }
.photo-slot img { width: 100%; height: 100%; object-fit: cover; }
.name-fields { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.name-fields input { min-height: 48px; }
.name-fields input[name=name] { font-weight: 600; }

dl.attrs { margin: 0 0 12px; }
dl.attrs > div { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
dl.attrs dt { color: var(--muted); flex: 0 0 40%; }
dl.attrs dd { margin: 0; flex: 1; font-weight: 500; overflow-wrap: anywhere; }
.rm-sm { width: 28px; height: 28px; border-radius: 14px; background: var(--info-soft); color: var(--muted); font-size: 18px; line-height: 1; flex: none; }
#attrSug { margin: 4px 0 10px; }
#attrSug .chip.sm { background: var(--card); border: 1px dashed var(--line); color: var(--blue); }
.card .grid2 + .btn, .card .list + .btn, .card #plans + .btn { margin-top: 10px; }
.row.sugg { background: #FAFCFF; }
#plans .list .row { padding: 10px 0; }
#plans .list .row:first-child { border-top: none; }

.amount { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 8px 0; }
.amount > span { font-size: 13px; color: var(--muted); font-weight: 600; }
.amount div { display: flex; align-items: center; gap: 6px; }
.amount b { font-size: 28px; color: var(--muted); }
.amount input { border: none; padding: 0; font-size: 32px; font-weight: 700; min-height: 44px; }
.amount input:focus { outline: none; }

/* Allegati */
.attach-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.attach-head small { color: var(--muted); font-size: 12px; }
.attach-btns { display: flex; gap: 8px; }
.attach-btns .btn { flex: 1; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; margin-bottom: 10px; }
.thumbs:empty { display: none; }
.thumbs.large { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.thumbs.mini { grid-template-columns: repeat(4, 56px); margin: 10px 0 0; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--blue-soft); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.thumb.doc a { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; padding: 6px; color: var(--blue); gap: 4px; }
.thumb.doc small { font-size: 10px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.thumb.more { display: flex; align-items: center; justify-content: center; font-weight: 600; color: #fff; background: #7E98D6; }
.thumb .rm { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; background: rgba(14,27,51,.65); color: #fff; font-size: 16px; line-height: 1; z-index: 2; }
#lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 100; display: flex; align-items: center; justify-content: center; }
#lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ---------- Costi ---------- */
.sum-card { background: var(--navy); color: #fff; border-radius: 20px; padding: 18px 20px; margin: 4px 0 8px; }
.sum-top { display: flex; justify-content: space-between; font-size: 13px; opacity: .8; }
.sum-total { display: block; font-size: 36px; margin: 6px 0 12px; letter-spacing: -0.02em; }
.bar { height: 6px; background: #E0A579; border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: #8FB2FF; width: 0; }
.sum-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; margin-top: 12px; opacity: .9; }
.sum-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.sum-legend .d1 { background: #8FB2FF; } .sum-legend .d2 { background: #E0A579; }
.day-box { width: 40px; height: 40px; border-radius: 12px; background: var(--info-soft); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--navy); flex: none; }
.row-amount { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.row-amount b { font-size: 15px; }
.kind { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.kind.ord { background: var(--blue-soft); color: var(--blue); }
.kind.str { background: #EFE7FC; color: #5B32B4; }
.kind.gua { background: var(--late-soft); color: var(--late); }
.kind.ext { background: var(--info-soft); color: var(--info); }
#costOut > .btn { margin-top: 16px; }

/* ---------- Calendario ---------- */
.cal-card { padding: 12px; }
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.cal-head b { font-size: 17px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dow { text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px 0; }
.day { aspect-ratio: 1; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 15px; font-weight: 500; }
.day.blank { pointer-events: none; }
.day.today span { color: var(--blue); font-weight: 700; }
.day.sel { background: var(--navy); color: #fff; }
.day.sel span { color: #fff; }
.day i { display: flex; gap: 3px; height: 6px; }
.day i b, .legend b { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
b.due { background: var(--blue); } b.late { background: #E8590C; } b.done { background: #2E9D63; }
.day.sel i b { box-shadow: 0 0 0 1.5px #fff; }
.legend { display: flex; gap: 14px; justify-content: center; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.export-card { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.export-card > span:nth-child(2) { flex: 1; min-width: 0; }
.export-card b { display: block; font-size: 15px; }
.export-card small { color: var(--muted); font-size: 13px; }
.event-head { display: flex; gap: 14px; align-items: center; margin: 6px 0 16px; }
.date-tile { width: 70px; height: 76px; border-radius: 18px; background: var(--navy); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; flex: none; }
.date-tile small { text-transform: uppercase; font-size: 12px; font-weight: 600; letter-spacing: .06em; opacity: .85; }
.date-tile b { font-size: 30px; line-height: 1; }

/* ---------- Aziende ---------- */
.company { padding: 14px; margin-bottom: 10px; }
.company-top { display: flex; gap: 12px; align-items: center; color: var(--ink); }
.company-actions { display: flex; gap: 8px; margin-top: 12px; }
.company-actions .btn { flex: 1; }
.company-actions:empty { display: none; }
.initials { width: 48px; height: 48px; border-radius: 14px; background: var(--blue-soft); color: var(--navy); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.initials.lg { width: 72px; height: 72px; border-radius: 20px; font-size: 24px; }
.stars { color: #F2A900; letter-spacing: 1px; }
.stars .off { color: #D5DCE8; }
.rating { display: flex; gap: 4px; }
.rating button { font-size: 34px; color: #D5DCE8; line-height: 1; padding: 2px; }
.rating button.on { color: #F2A900; }
.add-line { display: flex; gap: 8px; margin-bottom: 14px; }
.add-line .btn { flex: none; min-height: 48px; }

/* ---------- Dati ---------- */
.info-card { display: flex; gap: 12px; align-items: center; }
.info-card b { display: block; }
.info-card small { color: var(--muted); font-size: 13px; }
.opt-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.opt { display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 12px; border: 1px solid var(--line); border-radius: 14px; }
.opt.on { border-color: var(--blue); background: #F7FAFF; }
.opt i { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); flex: none; margin-top: 2px; }
.opt.on i { border: 6px solid var(--blue); }
.opt b { display: block; font-size: 15px; }
.opt small { color: var(--muted); font-size: 13px; }

/* ---------- Notifiche ---------- */
.notif { display: flex; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.notif.unread { border-left: 4px solid var(--blue); }
.notif.late.unread { border-left-color: #E8590C; }
.n-ic { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex: none; }
.notif.late .n-ic { background: var(--late-soft); color: var(--late); }
.notif.soon .n-ic { background: var(--blue-soft); color: var(--blue); }
.notif.info .n-ic { background: var(--info-soft); color: var(--info); }
.n-body { flex: 1; min-width: 0; }
.n-body p { margin: 4px 0; font-size: 14px; color: var(--muted); }
.n-body small { color: var(--muted); font-size: 12px; }
.n-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- Menu laterale ---------- */
.drawer { position: fixed; inset: 0; z-index: 60; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(14,27,51,.35); opacity: 0; transition: opacity .2s; }
.drawer-panel {
  position: absolute; top: 0; bottom: 0; left: 0; width: min(86vw, 330px); background: var(--card);
  border-radius: 0 28px 28px 0; padding: calc(env(safe-area-inset-top) + 20px) 16px calc(env(safe-area-inset-bottom) + 16px);
  display: flex; flex-direction: column; transform: translateX(-100%); transition: transform .22s ease; overflow-y: auto;
}
.drawer.open .drawer-backdrop { opacity: 1; }
.drawer.open .drawer-panel { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 0 8px 18px; }
.drawer-head > span:nth-child(2) { flex: 1; }
.drawer-head b { display: block; }
.drawer-head small { color: var(--muted); font-size: 13px; }
.logo { width: 44px; height: 44px; border-radius: 12px; background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: center; }
.drawer-head .icon-btn { color: var(--ink); }
.drawer-items a { display: flex; align-items: center; gap: 14px; padding: 13px 14px; border-radius: 14px; color: var(--ink); font-size: 17px; font-weight: 500; }
.drawer-items a .ic { color: var(--navy); }
.drawer-items a span { flex: 1; }
.drawer-items a.on { background: var(--blue-soft); font-weight: 600; }
.count-badge { font-style: normal; min-width: 22px; height: 22px; border-radius: 11px; background: #C2410C; color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; }
.drawer-sep { height: 1px; background: var(--line); margin: 14px 8px; }
.drawer-label { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 0 10px 6px; }
.drawer-add a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; font-weight: 500; }
.drawer-foot { margin-top: auto; padding-top: 16px; }
.drawer-foot .offline { width: 100%; justify-content: center; }

/* ---------- Fogli dal basso ---------- */
.sheet-layer { position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column; justify-content: flex-end; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(14,27,51,.4); }
.sheet-box { position: relative; max-height: 88vh; overflow-y: auto; transform: translateY(30px); opacity: 0; transition: .2s ease; }
.sheet-layer.open .sheet-box { transform: none; opacity: 1; }
.sheet-layer.panel .sheet-box { background: var(--card); border-radius: 24px 24px 0 0; padding: 10px 20px calc(env(safe-area-inset-bottom) + 20px); }
.sheet-layer.actions .sheet-box { padding: 0 10px calc(env(safe-area-inset-bottom) + 10px); }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet-title b { font-size: 18px; }
.sheet-form .btn { margin-top: 8px; }
.pick-list { display: flex; flex-direction: column; }
.pick { display: grid; grid-template-columns: 1fr auto; align-items: center; text-align: left; padding: 12px 10px; border-radius: 12px; }
.pick small { grid-column: 1; color: var(--muted); font-size: 13px; }
.pick .ic { grid-row: 1 / span 2; grid-column: 2; color: var(--blue); }
.pick.on { background: var(--blue-soft); }
.pick.add { display: flex; gap: 8px; color: var(--blue); font-weight: 600; }
.as-group { background: var(--card); border-radius: 16px; overflow: hidden; margin-bottom: 8px; }
.as-head { padding: 16px 18px; text-align: center; border-bottom: 1px solid var(--line-soft); }
.as-head b { display: block; font-size: 15px; }
.as-head span { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }
.as-btn { display: block; width: 100%; min-height: 56px; font-size: 18px; color: var(--blue); border-top: 1px solid var(--line-soft); background: var(--card); }
.as-group .as-btn:first-child { border-top: none; }
.as-btn.danger { color: var(--red); }
.as-cancel { border-radius: 16px; font-weight: 600; border: none; }

#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translateX(-50%) translateY(20px);
  opacity: 0; pointer-events: none; background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 14px; font-size: 15px;
  transition: .25s; z-index: 120; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
