:root {
  --brand: #C2085A;
  --brand-strong: #9A0647;
  --brand-ink: #8A0540;
  --coral: #FF385C;
  --tint: #FFF0F4;
  --tint-line: #FFC9D7;
  --block: #FFE8EE;
  --block-line: #FFC2D1;
  --slot-line: #E79AB3;
  --ink: #222222;
  --ink-2: #4A4A4A;
  --muted: #6A6A6A;
  --line: #EBEBEB;
  --line-2: #DDDDDD;
  --field: #B0B0B0;
  --soft: #F7F7F7;
  --grey: #F2F2F2;
  --ok: #1F7A3A;
  --ok-bg: #E8F5EC;
  --warn: #8A4B00;
  --warn-bg: #FFF4E5;
  --bg: #FFFFFF;
  --shadow: 0 2px 12px rgba(0, 0, 0, .06);
  --r: 16px;
  --nav-h: 72px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
  font-size: 15px; line-height: 1.4;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid rgba(194, 8, 90, .35); outline-offset: 2px; }

/* Struttura */
.shell { max-width: 560px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.view {
  flex: 1; display: flex; flex-direction: column; gap: 18px;
  padding: calc(20px + env(safe-area-inset-top)) 20px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom));
}
.view.no-nav { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.head .sub { font-size: 13px; color: var(--muted); }
.h1 { font-size: 24px; font-weight: 700; line-height: 1.2; }
.h2 { font-size: 17px; font-weight: 700; }
.lead { font-size: 14px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack.s6 { gap: 6px; }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }

/* Bottoni */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line-2);
  background: #fff; color: var(--ink); font-size: 15px; font-weight: 600; text-decoration: none; cursor: pointer; text-align: center; line-height: 1.25;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:active { background: var(--brand-strong); }
.btn.outline { border: 1.5px solid var(--brand); color: var(--brand); }
.btn.dark { border: 1.5px solid var(--ink); }
.btn.block { width: 100%; }
.btn.sm { min-height: 40px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.link { border: none; background: none; min-height: 44px; padding: 0 4px; color: var(--brand); }
.btn.plain { border: none; background: none; text-decoration: underline; font-weight: 500; }
.pill-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid var(--line-2); background: #fff; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; color: var(--ink); }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line-2); background: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink); flex-shrink: 0; text-decoration: none; }
.btns { display: flex; gap: 10px; }
.btns > * { flex: 1; }

/* Card */
.card { padding: 16px; border-radius: var(--r); border: 1px solid var(--line); background: #fff; display: flex; flex-direction: column; gap: 10px; }
.card.raised { box-shadow: var(--shadow); }
.card.tint { background: var(--tint); border-color: var(--tint-line); }
.card.soft { background: var(--soft); border-color: var(--soft); }
.kicker { font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--brand); text-transform: uppercase; }
.kicker.warn { color: var(--warn); }
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 10px; background: var(--grey); color: var(--ink-2); font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.brand { background: var(--brand); color: #fff; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 18px; background: var(--grey); font-size: 14px; font-weight: 500; }
.chip button { width: 28px; height: 28px; margin-right: -6px; border: none; background: none; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink-2); }
.chip.add { background: #fff; border: 1px dashed var(--field); color: var(--brand); font-weight: 600; cursor: pointer; }
.info { display: flex; gap: 8px; font-size: 13px; color: var(--ink-2); }
.info svg { flex-shrink: 0; margin-top: 1px; }
.place { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.avatar { width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: var(--grey); color: var(--ink-2); font-weight: 700; font-size: 15px; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; background: var(--block); color: var(--brand-ink); }
.avatar.brand { background: #fff; color: var(--brand-ink); }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: none; }
.line-row { display: flex; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.line-row:last-child { border-bottom: none; }
.empty { padding: 24px 16px; text-align: center; border: 1px dashed var(--line-2); border-radius: var(--r); color: var(--muted); font-size: 14px; display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* Blocchi agenda */
.blockbox { padding: 12px; border-radius: 14px; background: var(--block); border: 1px solid var(--block-line); display: flex; flex-direction: column; gap: 8px; }
.blockbox .bh { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; color: var(--brand-ink); }
.slot { display: flex; gap: 10px; align-items: center; min-height: 40px; padding: 8px 10px; border-radius: 10px; background: #fff; font-size: 14px; border: none; width: 100%; text-align: left; cursor: pointer; }
.slot.free { background: transparent; border: 1px dashed var(--slot-line); color: var(--muted); }
.slot.done { opacity: .6; }
.slot .t { width: 46px; font-weight: 600; flex-shrink: 0; }
.eventbox { display: flex; justify-content: space-between; gap: 8px; padding: 12px; border-radius: 14px; background: var(--grey); border: 1px solid var(--line-2); font-size: 13px; color: var(--ink-2); }

/* Settimana */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.dayb { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0; min-height: 66px; border-radius: 12px; border: 1px solid transparent; background: #fff; cursor: pointer; }
.dayb .dn { font-size: 11px; color: var(--muted); }
.dayb strong { font-size: 16px; }
.dayb .dot { width: 6px; height: 6px; border-radius: 3px; }
.dayb .dot.b { background: var(--brand); }
.dayb .dot.g { background: #9A9A9A; }
.dayb .rq { font-size: 10px; font-weight: 700; color: var(--brand); }
.dayb.req { border: 1.5px dashed var(--brand); background: var(--tint); }
.dayb.sel { background: var(--ink); color: #fff; border-color: var(--ink); }
.dayb.sel .dn { color: #fff; }
.dayb.sel .rq { color: #FFB3C6; }
.dayb.today strong { text-decoration: underline; text-underline-offset: 3px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--ink-2); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -2px; }

/* Richieste */
.zonebox { padding: 12px; border-radius: 12px; border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.zonebox.hot { background: var(--tint); border-color: var(--tint-line); }
.req-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: #fff; font-size: 13px; }
.zonebox:not(.hot) .req-item { background: var(--soft); }

/* Form */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label, .lbl { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input, select.input {
  min-height: 48px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--field); background: #fff; font-size: 16px; width: 100%;
}
.input.search { border-radius: 24px; background: var(--soft); }
.choice { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line-2); font-size: 15px; font-weight: 600; cursor: pointer; }
.choice:has(input:checked) { border: 2px solid var(--brand); background: var(--tint); }
.choice input { width: 20px; height: 20px; accent-color: var(--brand); margin: 0; }
.choice.center { justify-content: center; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; color: var(--ink-2); }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--brand); flex-shrink: 0; }
.slots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.slots button { min-height: 44px; border-radius: 10px; border: 1px solid var(--line-2); background: #fff; font-weight: 600; cursor: pointer; }
.slots button[aria-pressed="true"] { border: 2px solid var(--brand); background: var(--tint); color: var(--brand-ink); }
.days { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.days > * { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 2px; min-height: 76px; border-radius: 12px; border: 1px solid var(--line-2); background: #fff; cursor: pointer; text-decoration: none; color: var(--ink); text-align: center; }
.days > * .dn { font-size: 12px; color: var(--muted); }
.days > * strong { font-size: 17px; }
.days > * .z { font-size: 11px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; padding: 0 4px; }
.days > .rq { border-style: dashed; border-color: var(--field); }
.days > .rq .z { color: var(--ink-2); }
.days > [aria-pressed="true"] { background: var(--ink); border: 2px solid var(--ink); color: #fff; }
.days > [aria-pressed="true"] .dn, .days > [aria-pressed="true"] .z { color: #fff; }
.form-err { color: #B3261E; font-size: 13px; font-weight: 600; }

/* Barra di navigazione */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center;
  border-top: 1px solid var(--line); background: rgba(255, 255, 255, .97);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-in { width: 100%; max-width: 560px; height: var(--nav-h); display: flex; justify-content: space-around; align-items: center; padding: 0 6px; }
.nav a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: 60px; min-height: 52px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 500; }
.nav a[aria-current="page"] { color: var(--brand); font-weight: 700; }
.nav .cnt { position: absolute; top: 2px; left: 50%; margin-left: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--brand); color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.fab { position: fixed; right: max(20px, calc(50% - 260px)); bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom)); z-index: 21; width: 56px; height: 56px; border-radius: 28px; border: none; background: var(--brand); color: #fff; box-shadow: 0 6px 18px rgba(194, 8, 90, .35); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.bottom-cta { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: #fff; border-top: 1px solid var(--line); padding: 12px 20px calc(18px + env(safe-area-inset-bottom)); display: flex; justify-content: center; }
.bottom-cta > * { width: 100%; max-width: 520px; }

/* Sheet */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, .35); opacity: 0; transition: opacity .2s; }
.sheet { position: relative; width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto; background: #fff; border-radius: 20px 20px 0 0; padding: 8px 20px calc(24px + env(safe-area-inset-bottom)); transform: translateY(24px); opacity: 0; transition: transform .2s, opacity .2s; }
.sheet-wrap.open .sheet-bg { opacity: 1; }
.sheet-wrap.open .sheet { transform: none; opacity: 1; }
.sheet-h { position: sticky; top: 0; background: #fff; display: flex; justify-content: space-between; align-items: center; padding: 8px 0; z-index: 1; }
.sheet-h h2 { font-size: 18px; font-weight: 700; }
.sheet-b { display: flex; flex-direction: column; gap: 14px; padding-top: 6px; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; z-index: 60; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 500; transition: all .2s; pointer-events: none; max-width: calc(100% - 40px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Login / avvio */
.brandmark { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; }
.brandmark .lg { width: 36px; height: 36px; border-radius: 50%; background: var(--coral); display: flex; align-items: center; justify-content: center; }
.brandmark .lg svg { width: 22px; height: 22px; }
.brandmark .c { color: var(--brand); }
.brandmini { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.brandmini .lg { width: 20px; height: 20px; border-radius: 50%; background: var(--coral); display: flex; align-items: center; justify-content: center; }
.brandmini .lg svg { width: 13px; height: 13px; }
.hero-t { font-size: 28px; line-height: 1.15; font-weight: 700; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.steps li { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border-radius: 16px; border: 1px solid var(--line); }
.steps li.cur { border: 2px solid var(--brand); background: var(--tint); }
.steps .n { width: 32px; height: 32px; flex-shrink: 0; border-radius: 16px; border: 1.5px solid var(--field); color: var(--muted); font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.steps li.done .n { background: var(--ink); border-color: var(--ink); color: #fff; }
.steps li.cur .n { background: var(--brand); border-color: var(--brand); color: #fff; }
.loading { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: gira .8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
.demo-flag { pointer-events: none; opacity: .9; position: fixed; top: calc(8px + env(safe-area-inset-top)); right: 8px; z-index: 30; background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 4px 10px; font-size: 11px; font-weight: 700; }
.qr { width: 180px; height: 180px; margin: 0 auto; }
.qr svg, .qr img { width: 100%; height: 100%; }
.success { width: 64px; height: 64px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); display: flex; align-items: center; justify-content: center; margin: 0 auto; }
.center { text-align: center; }

@media (min-width: 600px) {
  .view { padding-left: 24px; padding-right: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
