/* Materia Schede — stile della vecchia "Schede cliente": chiaro, testata scura, fucsia */
:root {
  --bg: #f4f4f7; --panel: #fff; --ink: #18181b; --ink-2: #3f3f46; --ink-3: #71717a; --line: #e4e4e7; --line-2: #f0f0f3;
  --brand: #c2185b; --brand-ink: #fff; --brand-soft: #fce7f0; --head: #16161a; --bad: #b42318; --ok: #15803d;
  --radius: 14px; --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--sans); -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
.muted { color: var(--ink-3); }
.hidden { display: none !important; }

/* testata */
.head { background: var(--head); color: #fff; display: flex; align-items: center; gap: 14px; padding: 14px 24px; padding-top: calc(14px + env(safe-area-inset-top)); position: sticky; top: 0; z-index: 10; }
.head .logo { width: 46px; height: 46px; border-radius: 50%; background: #fff; display: grid; place-items: center; flex: none; }
.head .logo img { width: 30px; height: 30px; }
.head b { display: block; letter-spacing: .18em; font-size: 14px; }
.head small { color: #d4d4d8; font-size: 14px; }
.head .sp { flex: 1; }
.head .btn { background: transparent; color: #fff; border-color: #3f3f46; }

/* struttura: rubrica a sinistra, scheda a destra */
.layout { display: grid; grid-template-columns: 340px 1fr; min-height: calc(100vh - 74px); }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 22px 20px; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 74px; height: calc(100vh - 74px); }
.side .eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .14em; color: var(--ink-3); text-transform: uppercase; }
.side h2 { font-size: 30px; display: flex; align-items: center; gap: 10px; }
.count { font-size: 13px; background: var(--line-2); color: var(--ink-2); border-radius: 7px; padding: 2px 8px; font-weight: 600; }
.letters { display: flex; flex-wrap: wrap; gap: 2px; }
.letters button { all: unset; cursor: pointer; min-width: 30px; height: 32px; display: grid; place-items: center; border-radius: 8px; font-size: 14px; color: var(--ink-2); padding: 0 6px; }
.letters button.on { background: var(--ink); color: #fff; }
.clist { overflow: auto; flex: 1; margin: 0 -8px; border-top: 1px solid var(--line); padding-top: 8px; }
.crow { display: flex; gap: 12px; align-items: center; padding: 12px 10px; border-radius: 12px; cursor: pointer; }
.crow:hover { background: var(--line-2); }
.crow.on { background: var(--brand-soft); }
.av { width: 44px; height: 44px; border-radius: 50%; background: var(--line-2); display: grid; place-items: center; font-weight: 700; color: var(--ink-2); flex: none; }
.crow.on .av { background: #fff; color: var(--brand); border: 1px solid #f3c1d6; }
.crow b { display: block; }
.crow small { color: var(--ink-3); }
.main { padding: 28px 40px 80px; min-width: 0; }
.main-inner { max-width: 980px; margin: 0 auto; }

/* elementi comuni */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: #d4d4d8; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--bad); }
.btn.link { border: 0; background: none; padding: 0 4px; height: auto; font-weight: 500; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 14px; }
.btn.icon { width: 52px; height: 52px; padding: 0; font-size: 26px; border-radius: 12px; }
.input, select.input, textarea.input { width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); outline: none; }
textarea.input { min-height: 70px; resize: vertical; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
select.input.ask { background: #fdf2f7; }
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.field > span { font-weight: 700; font-size: 14px; }
.row { display: flex; gap: 16px; }
.row > * { flex: 1; min-width: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .14em; color: var(--ink-3); text-transform: uppercase; }
.hint { color: var(--ink-3); font-size: 14px; margin: 4px 0 14px; }

/* pagina vuota */
.empty { text-align: center; padding: 120px 20px 40px; }
.empty .big { width: 96px; height: 96px; border-radius: 22px; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; margin: 0 auto 30px; color: var(--brand); }
.empty h1 { font-size: 40px; margin: 10px 0 14px; }

/* pagina cliente */
.chead { display: flex; gap: 20px; align-items: center; }
.chead .av { width: 76px; height: 76px; font-size: 24px; background: var(--ink); color: #fff; }
.chead h1 { font-size: 34px; }
.cactions { display: flex; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); margin-top: 20px; flex-wrap: wrap; }
.shead { display: flex; align-items: flex-end; gap: 12px; margin: 26px 0 18px; flex-wrap: wrap; }
.shead h2 { font-size: 24px; }
.shead .sp { flex: 1; }
.scard { display: flex; gap: 24px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 28px; margin-bottom: 12px; cursor: pointer; }
.scard:hover { border-color: #f3c1d6; }
.scard .date { text-align: center; min-width: 74px; padding-right: 22px; border-right: 1px solid var(--line); }
.scard .date b { font-size: 32px; display: block; line-height: 1.1; }
.scard .date small { font-size: 13px; color: var(--ink-2); }
.scard h3 { font-size: 19px; }
.scard .meta { color: var(--brand); font-size: 14px; margin-top: 6px; }
.scard .grow { flex: 1; min-width: 0; }

/* editor della scheda */
.ebar { display: flex; align-items: center; gap: 14px; padding: 14px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 74px; background: var(--panel); z-index: 5; border-radius: var(--radius) var(--radius) 0 0; }
.ebar .sp { flex: 1; }
.ebody { padding: 28px 32px; }
.ebody h2 { font-size: 26px; margin-bottom: 22px; }
.ebody h3 { font-size: 20px; margin-bottom: 6px; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 22px 0 26px; }
.photos { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pbox { border: 1px solid var(--line); border-radius: 12px; padding: 18px; background: #fafafb; }
.pbox > b { display: block; margin-bottom: 12px; }
.pbtn { display: flex; align-items: center; gap: 10px; width: 100%; height: 50px; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 0 16px; margin-bottom: 10px; cursor: pointer; font-weight: 600; color: var(--ink-2); }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.thumb { position: relative; width: 96px; height: 96px; border-radius: 10px; overflow: hidden; background: var(--line-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.thumb button { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; }
.steps { display: grid; grid-template-columns: repeat(5, 1fr); border-bottom: 1px solid var(--line); margin: 6px 0 24px; }
.steps button { all: unset; cursor: pointer; padding: 10px 6px 14px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); border-bottom: 3px solid transparent; }
.steps button i { font-style: normal; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; font-size: 12px; }
.steps button.on { color: var(--ink); font-weight: 700; border-color: var(--brand); }
.steps button.on i { background: var(--brand); border-color: var(--brand); color: #fff; }
.steps button.done i { background: var(--brand-soft); color: var(--brand); border-color: #f3c1d6; }
.rtable { width: 100%; border-collapse: collapse; margin-bottom: 22px; }
.rtable td { padding: 8px 0; vertical-align: top; }
.rtable td:first-child { width: 120px; font-weight: 700; padding-top: 20px; }
.stepnav { display: flex; justify-content: space-between; margin: 6px 0 24px; }
.summary { background: #f4f4f5; border-radius: 12px; padding: 22px 24px; margin-bottom: 24px; }
.summary h3 { margin: 6px 0 8px; }
.summary .state { color: var(--brand); margin-bottom: 10px; }
.summary .zone { display: flex; gap: 10px; padding: 4px 0; }
.summary .zone b { min-width: 90px; }
.summary small { color: var(--ink-3); display: block; margin-top: 12px; font-size: 12px; }
.pdfbox { border: 1px dashed var(--line); border-radius: 12px; padding: 22px 24px; margin-bottom: 18px; }
.pdfrow { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.pdfrow a { flex: 1; color: var(--ink); }
.foot { display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap; }

/* finestre */
.modal-bg { position: fixed; inset: 0; background: rgba(20,20,25,.5); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border-radius: 20px; width: min(820px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 32px 36px; }
.modal header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.modal header h3 { font-size: 26px; }
.modal header button { all: unset; cursor: pointer; font-size: 26px; padding: 4px 8px; }
.modal footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 60; display: grid; place-items: center; cursor: zoom-out; }
.viewer img { max-width: 96vw; max-height: 92vh; }
.toast { position: fixed; bottom: calc(24px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px; z-index: 70; max-width: 90vw; }
.toast.bad { background: var(--bad); }
.login { max-width: 400px; margin: 12vh auto; padding: 0 20px; }

/* telefono: una colonna, prima la rubrica poi la scheda */
@media (max-width: 860px) {
  .head { padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); }
  .head .logo { width: 38px; height: 38px; }
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; border-right: 0; padding: 18px 16px; }
  .clist { max-height: none; overflow: visible; }
  body.detail .side { display: none; }
  body:not(.detail) .main { display: none; }
  .main { padding: 16px 12px 60px; }
  .ebody { padding: 20px 16px; }
  .ebar { padding: 10px 12px; top: 58px; gap: 8px; }
  .ebar .btn.primary { height: 38px; padding: 0 12px; font-size: 14px; }
  .ebar .muted { display: none; }
  .photos, .row { grid-template-columns: 1fr; flex-direction: column; gap: 0; }
  .photos { gap: 12px; }
  .steps { grid-template-columns: repeat(5, minmax(64px, 1fr)); overflow-x: auto; }
  .chead h1 { font-size: 26px; }
  .scard { padding: 16px; gap: 14px; }
  .scard .date { min-width: 56px; padding-right: 14px; }
  .modal { padding: 22px 18px; }
  .rtable td:first-child { width: 90px; }
}
