/* Fisiclean · app a colonna singola, mobile first; su schermi larghi resta centrata a 560px */
:root {
  --bg: #F2F6F8;
  --surface: #FFFFFF;
  --line: #DAE4EA;
  --fg: #0E2A3A;
  --muted: #4C6372;
  --brand: #0A6496;
  --brand-ink: #FFFFFF;
  --brand-soft: #DCEBF4;
  --teal: #0B7A6C;
  --teal-soft: #DDF0EC;
  --amber: #9A4507;
  --amber-soft: #FBEADB;
  --danger: #B42318;
  --danger-soft: #FCE4E1;
  --hero: #0A6496;
  --hero-ink: #FFFFFF;
  --font-display: 'Dosis', 'Arial Narrow', sans-serif;
  --font-body: 'Nunito Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r: 14px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 15px; line-height: 1.4; -webkit-tap-highlight-color: transparent; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
a { color: var(--brand); }
h1, h2 { font-family: var(--font-display); font-weight: 700; margin: 0; text-wrap: balance; }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
:focus-visible { outline: 2.5px solid var(--brand); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; margin: 0; }
.pad { margin: 0; padding: 4px 2px; }
.num, .amt, .big, .time { font-variant-numeric: tabular-nums; }
body.loading .view { opacity: .55; transition: opacity .2s .15s; }
/* Barra sottile in alto durante il caricamento: si vede subito che il tocco è arrivato */
body.loading::after { content: ""; position: fixed; z-index: 40; top: env(safe-area-inset-top, 0px); left: 0; height: 3px; width: 40%; background: var(--brand); border-radius: 0 3px 3px 0; animation: carica 1s ease-in-out infinite; }
@keyframes carica { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* Barra in alto */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); display: flex; align-items: center; gap: 6px;
  padding: 10px max(12px, env(safe-area-inset-right, 0px)) 6px max(16px, env(safe-area-inset-left, 0px)); min-height: 60px; }
.top .logo { width: 44px; height: 30px; object-fit: contain; }
.top .wordmark { height: 20px; width: auto; }
.spacer { flex: 1; }
.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--brand); border-radius: 12px; cursor: pointer; text-decoration: none; flex: none; }
.icon-btn:hover { background: var(--brand-soft); }
.demo { margin: 0 max(16px, env(safe-area-inset-right, 0px)) 4px max(16px, env(safe-area-inset-left, 0px)); padding: 6px 10px; border-radius: 10px; background: var(--amber-soft); color: var(--amber); font-size: 12px; font-weight: 700; }

.view { flex: 1; display: flex; flex-direction: column; gap: 14px; padding-block: 6px 24px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* Navigazione in basso */
.tabs { position: sticky; bottom: 0; z-index: 5; display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding: 4px max(4px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(4px, env(safe-area-inset-left, 0px)); }
.tabs a { flex: 1; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 700; }
.tabs a[aria-current="page"] { color: var(--brand); }

/* Blocchi */
.hero { background: var(--hero); color: var(--hero-ink); border-radius: 20px; padding: 18px 20px; display: flex; flex-direction: column; gap: 2px; }
.hero .lbl { font-size: 13px; font-weight: 600; opacity: .85; }
.hero .late-line { align-self: flex-start; margin-top: 8px; padding: 3px 10px; border-radius: 999px; background: rgb(255 255 255 / .2); font-weight: 800; opacity: 1; }
.alert { display: block; padding: 12px 16px; border-radius: var(--r); background: var(--danger-soft); color: var(--danger); font-weight: 800; text-decoration: none; }
.big { font-family: var(--font-display); font-weight: 700; font-size: 40px; line-height: 1.1; }
.hero .big.neg { color: var(--hero-ink); text-decoration: underline wavy; text-underline-offset: 6px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.sum { display: flex; flex-direction: column; gap: 8px; }
.sum .lbl { font-size: 13px; font-weight: 600; color: var(--muted); }
.sum .big { font-size: 34px; }
.pos { color: var(--teal); }
.neg { color: var(--amber); }
.bar { height: 10px; border-radius: 999px; background: var(--brand-soft); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--teal); border-radius: inherit; }
.split { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; font-size: 13px; font-weight: 700; }
.cats { display: flex; flex-wrap: wrap; gap: 6px; }
.cats span { font-size: 12px; padding: 4px 9px; border-radius: 999px; background: var(--bg); color: var(--muted); }
.cats b { color: var(--fg); }
.block { display: flex; flex-direction: column; gap: 8px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.block-head a { font-weight: 700; font-size: 14px; text-decoration: none; padding: 10px 0; }
.note p { margin: 6px 0 10px; color: var(--muted); font-size: 14px; }
.warn { margin: 0; font-size: 13px; font-weight: 600; color: var(--amber); }

/* Liste */
.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; min-height: 60px; text-decoration: none; color: var(--fg); }
.row + .row { border-top: 1px solid var(--line); }
a.row:hover, .split-row a.grow:hover strong { background: color-mix(in srgb, var(--brand-soft) 45%, transparent); }
.row svg { color: var(--muted); flex: none; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; text-decoration: none; color: var(--fg); }
.grow strong { font-size: 15px; }
.grow small { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.time { font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--brand); min-width: 50px; line-height: 1.2; }
.row .time { width: 92px; }
.num { font-weight: 700; font-size: 14px; white-space: nowrap; }
.amt { font-family: var(--font-display); font-weight: 700; font-size: 20px; white-space: nowrap; }
.col-r { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

.chip, .chip-btn { font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.chip.ok, .chip-btn.ok { background: var(--teal-soft); color: var(--teal); }
.chip.wait, .chip-btn.wait { background: var(--amber-soft); color: var(--amber); }
.chip.late { background: var(--danger-soft); color: var(--danger); }
.chip.off { background: var(--bg); color: var(--muted); }
.chip-btn { border: 0; font-family: inherit; cursor: pointer; min-height: 32px; }

.pay { display: flex; flex-direction: column; gap: 8px; }
.pay-head { display: flex; align-items: flex-start; gap: 10px; text-decoration: none; color: var(--fg); }
.pay-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }

/* Mese e calendario */
.month { display: flex; align-items: center; justify-content: space-between; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 2px; }
.month strong { font-size: 15px; }
.cal { padding: 10px 8px 8px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; text-align: center; }
.cal-grid.wd { font-size: 11px; font-weight: 700; color: var(--muted); padding-bottom: 4px; }
.day { height: 46px; border: 1.5px solid transparent; border-radius: 12px; background: transparent; color: var(--fg); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; padding: 0; font-variant-numeric: tabular-nums; }
.day i { font-style: normal; font-size: 10px; line-height: 8px; height: 8px; letter-spacing: 1px; color: var(--teal); }
.day.today { border-color: var(--brand); font-weight: 800; }
.day.sel { background: var(--brand); color: var(--brand-ink); }
.day.sel i { color: var(--brand-ink); }
.cal-foot { margin: 6px 6px 0; font-size: 12px; color: var(--muted); text-align: right; }

/* Moduli */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { position: relative; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 13px; font-weight: 700; color: var(--muted); }
.hint { margin: 0; font-size: 12.5px; color: var(--muted); }
input, select, textarea { width: 100%; min-height: 50px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--fg); font: inherit; font-size: 16px; }
textarea { padding: 12px; resize: vertical; min-height: 88px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }

/* Menu a tendina personalizzato */
.native-select { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; opacity: 0; pointer-events: none; }
.select-btn { width: 100%; min-height: 50px; padding: 0 12px 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--fg); font: inherit; font-size: 16px; cursor: pointer; }
.select-btn span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-btn span.ph { color: var(--muted); }
.select-btn svg { flex: none; color: var(--brand); }
.select-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
body.sheet-open { overflow: hidden; }
.sheet-backdrop { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; background: rgb(14 42 58 / .45); animation: fade .15s ease-out; }
.sheet { width: 100%; max-width: 560px; max-height: 72vh; max-height: 72dvh; overflow-y: auto; background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 8px max(12px, env(safe-area-inset-right, 0px)) calc(14px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px)); animation: rise .2s ease-out; }
.sheet h2 { font-size: 18px; padding: 6px 6px 8px; color: var(--muted); }
.sheet-grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 8px; }
.opt { width: 100%; min-height: 52px; padding: 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 0; border-radius: 12px; background: transparent;
  color: var(--fg); font: inherit; font-size: 16px; text-align: left; cursor: pointer; }
.opt + .opt { margin-top: 2px; }
.opt:hover { background: var(--bg); }
.opt[aria-selected="true"] { background: var(--brand-soft); color: var(--brand); font-weight: 800; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: .6; } }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 48px; font-weight: 600; cursor: pointer; }
.check input { width: 22px; height: 22px; min-height: 0; accent-color: var(--brand); }
.calc { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--teal-soft); border-radius: 12px; font-weight: 600; }
.calc strong { font-family: var(--font-display); font-size: 22px; color: var(--teal); }
.danger-zone { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 6px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 12px; font: inherit; font-weight: 700; font-size: 15px; text-decoration: none; cursor: pointer; border: 1.5px solid transparent; }
.btn.big { min-height: 52px; width: 100%; }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.ghost { background: var(--surface); color: var(--brand); border-color: var(--brand); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn[data-armed] { background: var(--danger); color: var(--surface); }
.btn:disabled { opacity: .6; cursor: progress; }

.empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 22px 16px; border: 1.5px dashed var(--line); border-radius: 16px; text-align: center; color: var(--muted); }
.empty p { margin: 0; }

/* Accesso */
.login { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding-block: 32px; padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); }
.login-logo { width: 120px; }
.login-word { width: 200px; }
.login .form { width: 100%; max-width: 360px; margin-top: 12px; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom, 0px)); z-index: 20; background: var(--fg); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgb(0 0 0 / .2); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Calendario: interruttore Mese/Settimana e vista settimanale */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.cal-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.seg { flex: 1; display: flex; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.seg button { flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: inherit; font-weight: 700; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }
.wk-day { display: flex; flex-direction: column; gap: 6px; }
.wk-head { display: flex; align-items: center; gap: 8px; padding-left: 2px; }
.wk-head h3 { flex: 1; margin: 0; font-family: var(--font-display); font-size: 18px; }
.wk-head.today h3 { color: var(--brand); }
.wk-head .icon-btn, .wk-off .icon-btn { margin-block: -6px; }
.tag { margin-left: 6px; padding: 2px 8px; border-radius: 999px; background: var(--brand); color: var(--brand-ink); font-family: var(--font-body); font-size: 11px; font-weight: 800; vertical-align: 2px; }
.wk-off { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; padding: 0 4px 0 14px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); font-size: 14px; }

/* Calendario a griglia (settimana: giorni × clienti · mese: strutture × dipendenti) */
.gwrap { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.grid { border-collapse: separate; border-spacing: 0; min-width: 100%; font-variant-numeric: tabular-nums; }
.grid th, .grid td { border-bottom: 1px solid var(--line); padding: 0; }
.grid tfoot th, .grid tfoot td { border-bottom: 0; background: #FBF4F4; }
.grid thead th { font-size: 12px; font-weight: 800; text-align: center; padding: 10px 6px 8px; white-space: nowrap; }
.grid thead th small { display: block; font-size: 10.5px; font-weight: 600; color: var(--muted); margin-top: 1px; }
.gdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; flex: none; }
.gd { position: sticky; left: 0; z-index: 1; background: var(--surface); text-align: left; padding: 0 10px; min-width: 70px; border-right: 1px solid var(--line); }
.gd b { display: block; font-size: 13px; }
.gd span { font-size: 11.5px; color: var(--muted); }
.grid tfoot .gd b { color: var(--danger); font-family: var(--font-display); font-size: 16px; letter-spacing: .03em; }
.grid tr.we .gd b, .grid tr.we .gd span { color: #8AA0AD; }
.grid tr.oggi .gd { box-shadow: inset 3px 0 0 var(--brand); }
.grid tr.oggi .gd b { color: var(--brand); }
.gc { min-width: 88px; height: 54px; padding: 5px !important; text-align: center; }
.gc button { width: 100%; min-height: 44px; height: 100%; border: 1.5px dashed transparent; border-radius: 10px; background: transparent; color: var(--muted); font: inherit; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2px 4px; }
.gc button:hover { border-color: var(--line); }
.gc button:active { transform: scale(.96); }
.gc button i { font-style: normal; font-size: 18px; opacity: .35; }
.gc button.on { border: 0; }
.gc button.on b { font-size: 13px; line-height: 1.15; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gc button.on span { font-size: 11px; font-weight: 700; opacity: .85; }
.gc button.sel { outline: 2.5px solid currentColor; outline-offset: -2.5px; }
.gc .zero { color: #A9BAC4; }
.gt { text-align: center; padding: 10px 6px !important; color: var(--danger); font-weight: 800; font-size: 13.5px; white-space: nowrap; }
.gr { text-align: center; padding: 0 10px !important; font-weight: 800; font-size: 13.5px; white-space: nowrap; border-left: 1px solid var(--line); }
.gm .gs { min-width: 120px; max-width: 150px; }
.gm .gs b { display: inline; white-space: normal; }
.gm .gc button.on b { font-size: 14.5px; }
.gm thead th { min-width: 84px; }
.std { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px 14px; margin: 0; display: flex; flex-direction: column; gap: 12px; background: var(--surface); }
.std legend { font-weight: 800; padding: 0 6px; }
a.opt { text-decoration: none; }
.add-opt { color: var(--brand); font-weight: 700; justify-content: flex-start; }
.grid thead th { white-space: normal; line-height: 1.2; max-width: 120px; vertical-align: bottom; }
.grid thead th small { white-space: nowrap; }
.gd { padding-left: 12px; }
.gm .gc { min-width: 74px; }

/* Turni programmati (dopo oggi) e copertura del contratto */
.gc button.on.prog { background: transparent !important; border: 1.5px dashed currentColor; opacity: .75; }
.gm .gc button.on span { font-size: 10.5px; }
.gd span { display: block; }
.cop { display: inline-block; margin-top: 4px; padding: 1px 7px; border-radius: 999px; font-style: normal; font-size: 11px; font-weight: 800; }
.cop.ok { background: var(--teal-soft); color: var(--teal); }
.cop.ko { background: var(--danger-soft); color: var(--danger); }
.flabel { font-size: 13px; font-weight: 700; color: var(--muted); }
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.dchip { position: relative; cursor: pointer; }
.dchip input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.dchip span { display: grid; place-items: center; height: 44px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); font-weight: 800; color: var(--muted); }
.dchip input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.dchip input:focus-visible + span { outline: 2.5px solid var(--brand); outline-offset: 2px; }
.gd { padding-left: 14px; }
