[hidden] { display: none !important; }

:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --fg: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #0f766e;
  --primary-fg: #ffffff;
  --primary-soft: #ccfbf1;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --info: #1d4ed8;
  --info-soft: #dbeafe;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 1px 3px rgba(0, 0, 0, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f14;
    --card: #151b23;
    --fg: #e5e7eb;
    --muted: #9ca3af;
    --line: #263041;
    --primary: #2dd4bf;
    --primary-fg: #04201d;
    --primary-soft: #0f3a36;
    --danger: #f87171;
    --danger-soft: #3b1515;
    --warn: #fbbf24;
    --warn-soft: #3a2a0a;
    --ok: #4ade80;
    --ok-soft: #0f2e1a;
    --info: #93c5fd;
    --info-soft: #172554;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}
a { color: var(--primary); }
h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 10px; }
h3 { font-size: 1rem; margin: 0 0 6px; }
p { margin: 0 0 8px; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: var(--card); border-bottom: 1px solid var(--line);
}
.topbar .brand { white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; font-weight: 800; color: var(--fg); text-decoration: none; letter-spacing: -.01em; }
.topbar .brand img { border-radius: 7px; }
.topbar .company { padding-left: 12px; border-left: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.topbar .who { display: inline-flex; align-items: center; gap: 8px; color: var(--fg); font-size: .9rem; white-space: nowrap; min-width: 0; }
.who-name { overflow: hidden; text-overflow: ellipsis; }

main.page { max-width: 1100px; margin: 0 auto; padding: 16px 16px 96px; }
.page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { flex: 1; min-width: 160px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.card.tight { padding: 12px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.right { margin-left: auto; }
.stack > * + * { margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 800px) { .grid2 { grid-template-columns: 1fr 1fr; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--fg); font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 34px; padding: 0 10px; font-size: .88rem; }
.btn.big { min-height: 58px; font-size: 1.1rem; width: 100%; border-radius: 14px; }
.btn.block { width: 100%; }
.btn.wa { background: #25d366; border-color: #25d366; color: #05361b; }

label.field, div.field { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 42px; width: 100%;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--primary); }
.checkline { display: flex; align-items: center; gap: 8px; color: var(--fg); font-size: .95rem; }
.checkline.small { align-items: flex-start; font-size: .85rem; line-height: 1.45; }
.checkline.small input { margin-top: 3px; flex: none; }
form .actions, .modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px;
  font-size: .8rem; font-weight: 600; white-space: nowrap;
}
.st-scheduled { background: var(--info-soft); color: var(--info); }
.st-in_progress { background: var(--warn-soft); color: var(--warn); }
.st-completed { background: var(--ok-soft); color: var(--ok); }
.st-cancelled { background: var(--line); color: var(--muted); text-decoration: line-through; }
.st-overdue { background: var(--danger-soft); color: var(--danger); }
/* Toni generici per le etichette (un colore, un significato): informazione, attenzione, neutro */
.tone-info { background: var(--info-soft); color: var(--info); }
.tone-danger { background: var(--danger-soft); color: var(--danger); }
.tone-neutral { background: var(--line); color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.person { display: inline-flex; align-items: center; gap: 5px; font-size: .88rem; }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.tiles .tile:last-child { grid-column: 1 / -1; }
@media (min-width: 700px) {
  .tiles { grid-template-columns: repeat(5, 1fr); }
  .tiles .tile:last-child { grid-column: auto; }
}
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.tile .n { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.tile .l { color: var(--muted); font-size: .85rem; }
.tile.alert { border-color: var(--danger); }
.tile.alert .n { color: var(--danger); }

.jobrow {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); margin-bottom: 8px; cursor: pointer; text-decoration: none; color: inherit;
}
.jobrow:hover { border-color: var(--primary); }
.jobrow.overdue { border-color: var(--danger); background: linear-gradient(0deg, var(--danger-soft), var(--danger-soft)) padding-box; }
.jobrow .time { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 52px; }
.jobrow .title { font-weight: 600; }

.daybar { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 12px; scrollbar-width: none; }
.daybar button {
  flex: none; min-width: 58px; padding: 8px 6px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--fg); font: inherit; cursor: pointer; text-align: center;
}
.daybar button .d { font-size: .75rem; color: var(--muted); text-transform: uppercase; }
.daybar button .n { font-size: 1.2rem; font-weight: 700; }
.daybar button .c { font-size: .72rem; color: var(--primary); min-height: 1em; }
.daybar button.on { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
.daybar button.on .d, .daybar button.on .c { color: var(--primary-fg); }

.week { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 900px) { .week { grid-template-columns: repeat(7, minmax(0, 1fr)); } }
.week .day { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px; min-height: 80px; }
.week .day.today { border-color: var(--primary); }
.week .day h3 { font-size: .85rem; color: var(--muted); text-transform: capitalize; display: flex; justify-content: space-between; }
.week .ev {
  display: block; border-left: 4px solid var(--primary); background: var(--bg); border-radius: 8px;
  padding: 6px 8px; margin-top: 6px; font-size: .85rem; cursor: pointer; color: inherit; text-decoration: none;
}
.week .ev.cancelled { opacity: .5; text-decoration: line-through; }
.week .ev.completed { opacity: .75; }
.week .ev.overdue { background: var(--danger-soft); }
.week .ev b { font-variant-numeric: tabular-nums; }

.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.checklist label { display: flex; align-items: center; gap: 14px; padding: 14px 4px; cursor: pointer; font-size: 1.05rem; }
.checklist input { width: 28px; height: 28px; flex: none; }
.checklist .done span { text-decoration: line-through; color: var(--muted); }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.photos .ph { position: relative; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; display: block; background: var(--line); }
.photos .del {
  position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, .6); color: #fff; cursor: pointer; display: grid; place-items: center; padding: 0;
}

.timer { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; text-align: center; }
.address { font-size: 1.05rem; }
.note { background: var(--warn-soft); color: var(--fg); border-radius: 10px; padding: 10px 12px; white-space: pre-wrap; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex;
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1; text-align: center; padding: 8px 2px 10px; color: var(--muted); text-decoration: none; font-size: .75rem;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tabs a .i { line-height: 1; }
.tabs a .i .ic svg { width: 22px; height: 22px; }
.tabs a.on { color: var(--primary); font-weight: 700; }
@media (min-width: 900px) {
  .tabs { position: sticky; top: 0; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line); justify-content: center; }
  .tabs a { flex: none; flex-direction: row; gap: 6px; padding: 12px 18px; font-size: .95rem; }
  .tabs a .i .ic svg { width: 18px; height: 18px; }
  main.page { padding-bottom: 32px; }
}

.list-item { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }

.modal-back {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .45);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 700px) { .modal-back { align-items: center; } }
.modal {
  background: var(--card); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}
@media (min-width: 700px) { .modal { border-radius: 18px; } }
.modal h2 { margin-bottom: 14px; }

.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 100;
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600;
  max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
}
.toast.err { background: var(--danger); color: #fff; }
.banner { background: var(--warn-soft); color: var(--warn); padding: 8px 16px; text-align: center; font-size: .9rem; }

.auth { max-width: 440px; margin: 7vh auto 32px; padding: 0 16px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth-brand img { flex: none; border-radius: 10px; }
.auth .logo { font-size: 1.3rem; font-weight: 800; color: var(--fg); letter-spacing: -.01em; line-height: 1.2; }
.auth .tagline { font-size: .85rem; color: var(--muted); line-height: 1.3; }
.auth-card { padding: 24px; }
.auth-card form { margin-top: 16px; }
.auth-title { font-size: 1.25rem; margin: 0 0 4px; }
.auth-sub { font-size: .92rem; margin: 0; }
.auth-note {
  margin-top: 18px; padding: 12px 14px; border-radius: 10px; background: var(--bg);
  border: 1px solid var(--line); font-size: .88rem; color: var(--muted);
}
.auth-note b { color: var(--fg); display: block; margin-bottom: 2px; }
.auth-switch { margin: 16px 0 0; text-align: center; }
.auth-foot { text-align: center; font-size: .8rem; color: var(--muted); margin-top: 16px; }
.empty { text-align: center; color: var(--fg); padding: 32px 16px; }
.empty p { margin: 6px auto 0; max-width: 380px; }
.empty-ic { width: 48px; height: 48px; margin: 0 auto 10px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.empty-ic .ic svg { width: 24px; height: 24px; }
.weekdays { display: flex; gap: 6px; flex-wrap: wrap; }
.weekdays label {
  display: inline-flex; align-items: center; justify-content: center; min-width: 44px; height: 40px; border-radius: 10px;
  border: 1px solid var(--line); cursor: pointer; font-weight: 600; color: var(--fg); padding: 0 6px;
}
.weekdays input { display: none; }
.weekdays label:has(input:checked) { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.people { display: flex; gap: 6px; flex-wrap: wrap; }
.people label {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; cursor: pointer; color: var(--fg); font-size: .92rem;
}
.people input { display: none; }
.people label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); }
.spinner { text-align: center; color: var(--muted); padding: 40px 0; }

/* Icone e componenti informativi */
.ic { display: inline-flex; flex: none; line-height: 0; }
.ic svg { width: 18px; height: 18px; }
.btn.small .ic svg { width: 16px; height: 16px; }
.btn.big .ic svg { width: 22px; height: 22px; }
.photos .del .ic svg { width: 14px; height: 14px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none; display: inline-grid; place-items: center;
  color: #fff; font-weight: 700; font-size: .85rem;
}
.topbar .avatar { width: 30px; height: 30px; }
.page-head h1 .sub { font-weight: 400; margin-top: 2px; }
.info-list { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.info-row { display: flex; gap: 12px; align-items: flex-start; }
.info-row > .ic { color: var(--muted); margin-top: 2px; }
.info-label { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 1px; }
.info-row .grow > div:last-child { white-space: pre-wrap; }
.meta-item { display: inline-flex; align-items: center; gap: 4px; }
.meta-item .ic svg { width: 14px; height: 14px; }
.meta-item.ok { color: var(--ok); margin-top: 4px; }
.card.center { text-align: center; }
.timer { margin-top: 4px; }
.checklist.readonly li { display: flex; align-items: center; gap: 12px; padding: 10px 2px; }
.mark {
  width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--line); flex: none;
  display: grid; place-items: center; color: #fff;
}
.mark.on { background: var(--ok); border-color: var(--ok); }
.mark .ic svg { width: 14px; height: 14px; stroke-width: 3; }
.subpanel { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.week .day h3 .add { min-height: 26px; padding: 0 4px; }
.st-cancelled-soft { background: var(--line); color: var(--muted); }
.list-item > .ic { color: var(--muted); }
.warn-note { margin-bottom: 12px; font-size: .9rem; border: 1px solid var(--warn); }

/* In fondo al file: deve prevalere sulle regole di display dei componenti */
@media (max-width: 640px) { .hide-sm, .who-name, .topbar .company { display: none !important; } }

/* Codici di recupero della verifica in due passaggi */
.codes { font: 600 1.05rem/1.7 ui-monospace, Consolas, monospace; background: var(--line); padding: 12px 16px; border-radius: 10px; column-count: 2; margin: 0; }

/* Imprevisti */
.btn.warn { color: var(--warn); border-color: var(--warn); }
.btn.big { justify-content: flex-start; text-align: left; padding: 14px 16px; gap: 12px; width: 100%; }
.btn.big b { display: block; }
.btn-row { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; text-align: left; font: inherit; color: inherit; }
.absent-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; margin-bottom: 14px; }
.warn-box { border-color: var(--warn); background: var(--warn-soft); padding: 10px 14px; margin: 0; }
.ok-text { color: var(--ok); margin: 0; }

/* Titolare da telefono (4.2) */
.item-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 640px) {
  .team-item { flex-wrap: wrap; }
  .team-item .grow { flex: 1 1 calc(100% - 52px); min-width: 0; }
  .team-item .item-actions { width: 100%; }
  .tiles { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .tiles .tile:last-child { grid-column: span 2; }
  .tile { padding: 8px 10px; }
  .tile .n { font-size: 1.35rem; }
  .tile .l { font-size: .75rem; line-height: 1.2; }
  .dash-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-actions .btn { justify-content: center; text-align: center; white-space: normal; min-width: 0; line-height: 1.2; }
  .week .day:not(:has(.ev)) { min-height: 0; padding: 4px 8px; }
}

/* Fine della prova */
.banner-ro { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; border-color: var(--warn); background: var(--warn-soft); margin-bottom: 14px; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-bottom: 12px; }
.plans .card { margin: 0; }
.plans .price { font-size: 1.4rem; font-weight: 700; }

/* Impostazioni */
.logo-preview { max-height: 48px; max-width: 180px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }

/* Primi passi e aiuto */
.onboarding { border-color: var(--primary); margin-bottom: 14px; }
.step-dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.step-done .step-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.step-done b { color: var(--muted); text-decoration: line-through; font-weight: 500; }
.step-dot svg { width: 14px; height: 14px; }
.faq { border-bottom: 1px solid var(--line); padding: 10px 0; }
.faq:last-child { border-bottom: 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { margin: 8px 0 0; }

/* sezioni dentro i moduli lunghi (impostazioni) */
.form-section { font-size: .95rem; margin: 10px 0 -4px; padding-top: 10px; border-top: 1px solid var(--line); }
.hint { margin: 4px 0 0; }

/* suggerimento per installare l'app sul telefono */
.install-hint { border-color: var(--primary); }
.install-hint ol { margin: 6px 0 10px; padding-left: 20px; }
.install-hint li { margin: 2px 0; }

/* Riassegnazione per assenza: testo sopra, sostituto sotto, a ogni larghezza
   (sul computer il menu schiacciava il testo in una colonna stretta: collaudo T3, D.4) */
.reassign-item { flex-direction: column; align-items: stretch; gap: 6px; }
.reassign-item select { width: 100%; }

/* archivio di clienti e sedi */
.archived-sites { margin-top: 8px; }
.archived-sites summary { cursor: pointer; }
.danger-text { color: var(--danger); }
/* nome sopra, pulsanti sotto: sul telefono il nome veniva schiacciato */
.archive-item { flex-wrap: wrap; }
.archive-item > .grow { flex: 1 1 100%; }
/* email lunghe nei riquadri di avviso: vanno a capo invece di finire sotto i pulsanti */
.banner-ro .grow { overflow-wrap: anywhere; }
/* le date non vengono mai tagliate (sul telefono si leggeva "19/09/202"): se non c'è posto vanno a capo */
input[type="date"] { min-width: 10.5em; }
.row > .grow:has(input[type="date"]) { min-width: 10.5em; }
.row > .grow:has(input[type="time"]) { min-width: 7.5em; }
.row > .grow:has(select[name="duration_minutes"]) { min-width: 7.5em; }
/* registro comunicazioni: sul computer data a destra, sul telefono sotto al testo (prima si schiacciavano) */
.notif-item .grow { overflow-wrap: anywhere; }
.notif-when { text-align: right; flex: none; }
@media (max-width: 640px) {
  .notif-item { flex-wrap: wrap; }
  .notif-item .grow { flex: 1 1 100%; }
  .notif-when { text-align: left; }
}
