/* Inter (SIL Open Font License), inclusa nell'app: nessun servizio esterno */
@font-face { font-family: "Inter"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 500; font-style: normal; font-display: swap; src: url("fonts/inter-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-style: normal; font-display: swap; src: url("fonts/inter-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 700; font-style: normal; font-display: swap; src: url("fonts/inter-latin-700-normal.woff2") format("woff2"); }

:root {
  /* Palette ISI (Brand Book v1.0) */
  --black: #0B0B0C;          /* ISI Black: intestazione, marchio */
  --slate: #0B0B0C;
  --brand: #465FFF;          /* Accent Blue: azioni principali, link, focus */
  --brand-strong: #465FFF;
  --accent: #465FFF;
  --bg: #F6F7F8;             /* Cloud */
  --card: #FFFFFF;
  --text: #0B0B0C;
  --muted: #667085;          /* Slate */
  --line: #E5E7EB;           /* Border */
  --ok: #16845B;             /* Success */
  --warn: #B7791F;           /* Warning */
  --danger: #C83D4D;         /* Error */
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.35;
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
}
body.noscroll { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { color: var(--text); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); min-height: 1.2em; }

/* Login */
.login { max-width: 380px; margin: 0 auto; padding: calc(10vh + env(safe-area-inset-top)) 24px 24px; text-align: center; }
.login .logo { display: block; width: 132px; height: auto; margin: 0 auto 10px; }
.login .payoff { margin: 0 0 26px; color: var(--muted); font-size: 14px; }
.login h1 { margin: 0 0 4px; font-size: 20px; font-weight: 600; color: var(--text); }
.login form { text-align: left; }
.login form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
input, select, textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
textarea { min-height: 80px; resize: vertical; }
label.f { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Header + nav */
.top {
  position: sticky; top: 0; z-index: 20; background: var(--slate); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(30px + env(safe-area-inset-top)) 14px 14px;
}
.top strong { font-size: 17px; display: block; }
.top small { opacity: .8; }
.top .brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.top .wm { height: 20px; width: auto; flex: none; margin-right: 2px; }
.top .sep { width: 1px; align-self: stretch; background: rgba(255,255,255,.22); flex: none; }
.top select { background: rgba(255,255,255,.12); color: #fff; border: 0; padding: 6px 8px; font-weight: 600; width: auto; }
.top select option { color: #000; }
.top-r { display: flex; gap: 6px; }
.icon { background: rgba(255,255,255,.14); color: #fff; border: 0; border-radius: 8px; width: 38px; height: 38px; font-size: 18px; }
.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: #fff; border-top: 1px solid var(--line);
  display: flex; padding-bottom: env(safe-area-inset-bottom); overflow-x: auto; scrollbar-width: none;
}
.bottom::-webkit-scrollbar { display: none; }
.bottom button {
  flex: 1 0 auto; min-width: 0; border: 0; background: none; padding: 9px 5px 8px; color: var(--muted); font-size: 11.5px; font-weight: 600; display: flex;
  flex-direction: column; align-items: center; gap: 3px; white-space: nowrap;
}
.bottom button span { position: relative; }
.bottom button span { font-size: 21px; line-height: 1; }
.bottom button.active { color: var(--brand-strong); font-weight: 700; box-shadow: inset 0 2px 0 var(--brand); }

main { padding: 12px; max-width: 760px; margin: 0 auto; }
h2 { margin: 6px 0 10px; font-size: 20px; font-weight: 600; }
h3 { margin: 16px 0 8px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* Buttons */
.btn { border: 1px solid var(--line); background: #fff; padding: 11px 14px; border-radius: 8px; font-weight: 600; }
.btn.primary { background: var(--brand-strong); color: #fff; border-color: var(--brand-strong); }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: #fff; }
.btn.big { width: 100%; padding: 15px; font-size: 17px; margin-top: 10px; }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }

/* Chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; }
.chip { white-space: nowrap; border: 1px solid var(--line); background: #fff; padding: 7px 12px; border-radius: 999px; font-size: 14px; }
.chip.active { background: var(--brand-strong); color: #fff; border-color: var(--brand-strong); }

/* Cards */
.card {
  display: block; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 10px;
}
.card .t { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card .code { font-size: 22px; font-weight: 600; }
.badge { display: inline-block; color: #fff; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* Rooms grid */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(4, 1fr); } }
.room {
  background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 8px 6px; text-align: center; position: relative;
}
.room b { display: block; font-size: 20px; }
.room small { display: block; color: var(--muted); font-size: 11px; min-height: 14px; }
.room .st { display: block; font-size: 11px; font-weight: 700; margin-top: 2px; }
.room .tag { position: absolute; top: 3px; right: 5px; font-size: 12px; }

/* Summary */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat b { font-size: 26px; display: block; }
.stat span { color: var(--muted); font-size: 13px; }

/* Bottom sheet */
.sheet { display: none; }
.sheet.open { display: block; position: fixed; inset: 0; z-index: 50; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.sheet-body {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto; background: #fff;
  border-radius: 18px 18px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  max-width: 760px; margin: 0 auto;
}
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; }
.x { border: 0; background: var(--bg); width: 36px; height: 36px; border-radius: 50%; font-size: 18px; flex: none; }

/* Checklist + photos */
.chk { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.chk input { width: 24px; height: 24px; flex: none; }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }
.pick { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.pick input { width: 22px; height: 22px; flex: none; }
.pick.dis { opacity: .45; }

#toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--black); color: #fff; padding: 10px 16px; border-radius: 12px; opacity: 0; pointer-events: none;
  transition: .2s; z-index: 80; max-width: 90vw; text-align: center; font-size: 14px;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- v4: servizi e via libera ---- */
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pill { background: #F2F4F7; color: var(--black); border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; }
.taskrow { display: flex; align-items: stretch; gap: 10px; padding: 0; }
.taskrow .rowmain { flex: 1; text-align: left; background: none; border: 0; padding: 14px; font: inherit; color: inherit; cursor: pointer; }
.taskrow .btn { align-self: center; margin-right: 12px; }
.genrow { border-bottom: 1px solid var(--line); }
.genrow .opts { padding: 4px 4px 12px 36px; }
.genrow .opts[hidden] { display: none; }
.optgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pick2 { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 15px; }
.pick2 input { width: 20px; height: 20px; flex: none; }

/* ---- v5: chat ---- */
.bdg { position: absolute; top: -6px; right: -12px; background: var(--danger, var(--danger)); color: #fff; font-style: normal; font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; line-height: 18px; border-radius: 9px; text-align: center; padding: 0 5px; }
.bdg[hidden] { display: none; }
.bdg.inl { position: static; display: inline-block; margin-top: 4px; }
.chatrow { display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--black); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 18px; flex: none; }
.cr-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cr-main b { font-size: 16px; }
.cr-main .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-side { display: flex; flex-direction: column; align-items: flex-end; flex: none; }
.thread-head { display: flex; align-items: center; gap: 10px; position: sticky; top: calc(82px + env(safe-area-inset-top)); background: var(--bg); padding: 6px 0; z-index: 5; }
.thread-head h2 { margin: 0; }
.thread { display: flex; flex-direction: column; gap: 6px; padding: 8px 0 12px; }
.bub { max-width: 82%; padding: 8px 12px; border-radius: 16px; font-size: 16px; word-wrap: break-word; }
.bub.them { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bub.me { align-self: flex-end; background: #E8ECFF; border-bottom-right-radius: 4px; }
.bub.sys { background: #fff8e1; border-color: #ffe082; max-width: 100%; }
.btext { white-space: pre-wrap; }
.btime { font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; }
.bphoto img { display: block; max-width: 100%; max-height: 260px; border-radius: 8px; margin-bottom: 4px; }
.composer { position: sticky; bottom: calc(66px + env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: flex-end; background: var(--bg); padding: 8px 0; }
.composer textarea { flex: 1; min-height: 44px; max-height: 120px; resize: none; margin: 0; }
.composer .btn { height: 44px; padding: 0 14px; }
.composer .ico { font-size: 20px; padding: 0 12px; }

/* ---- v6: griglia camere, lettere, biancheria ---- */
.room { position: relative; }
.room .lts { position: absolute; top: 4px; left: 4px; display: flex; gap: 2px; }
.lt { display: inline-block; font-style: normal; font-weight: 700; font-size: 11px; line-height: 16px; min-width: 16px; text-align: center; color: #fff; border-radius: 4px; padding: 0 3px; }
.room .who { color: var(--black); font-weight: 600; font-size: 11px; min-height: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend { font-size: 13px; margin: 4px 0 8px; line-height: 22px; }
.twocol { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.twocol .btn.big { margin-top: 0; }
.btn.sel-ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.sel-no { background: var(--danger); color: #fff; border-color: var(--danger); }
.notebox { background: #fff8e1; border: 1px solid #ffe082; border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
.linen { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.linen label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.linen input { font-size: 22px; font-weight: 700; text-align: center; padding: 10px 6px; }
.linen input.bad { border-color: var(--danger); background: #FBEAEC; }
.room { padding-top: 24px; }

/* ---- biancheria: tasti meno/piu' ---- */
.linen { grid-template-columns: 1fr; gap: 12px; }
.lrow { display: flex; flex-direction: column; gap: 4px; }
.lname { font-size: 14px; color: var(--muted); font-weight: 600; }
.stepper { display: grid; grid-template-columns: 64px 1fr 64px; gap: 8px; align-items: stretch; }
.stepper .sb { border: 1px solid var(--line); background: #fff; border-radius: 12px; font-size: 32px; font-weight: 700; line-height: 1; color: var(--brand-strong); min-height: 56px; touch-action: manipulation; }
.stepper .sb:active { background: #EEF1FF; }
.stepper input { font-size: 26px; font-weight: 700; text-align: center; padding: 8px 4px; min-height: 56px; }
.linen input::-webkit-outer-spin-button, .linen input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.linen input { -moz-appearance: textfield; }

.btn.sel-bip { background: #8e24aa; color: #fff; border-color: #8e24aa; }
.btn.sel-man { background: #607d8b; color: #fff; border-color: #607d8b; }

/* ---- icone nere su bianco ---- */
.ico { display: inline-flex; align-items: center; vertical-align: -0.2em; }
.ico svg { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bottom button span { color: #111; }
.icon { background: #fff; color: #111; }
.icon .ico svg { width: 20px; height: 20px; }
.x .ico svg, button.x .ico svg { width: 20px; height: 20px; }
.btn .ico { margin-right: 6px; }
.twocol .wide { grid-column: auto; }
.avatar .ico svg { width: 22px; height: 22px; stroke: #fff; }
.steps { padding-left: 22px; line-height: 1.55; }
.steps li { margin: 8px 0; }

/* Pagina di accesso: sfondo ISI Black con logo bianco */
body:has(.login) {
  background: #0B0B0C url("bg-login-phone.jpg") center / cover no-repeat; color: #fff; min-height: 100vh; min-height: 100dvh; padding-bottom: 0;
}
@media (min-width: 700px) and (max-aspect-ratio: 1/1) { body:has(.login) { background-image: url("bg-login-tablet.jpg"); } }
@media (min-aspect-ratio: 1/1) { body:has(.login) { background-image: url("bg-login-wide.jpg"); } }
.login h1 { color: #fff; }
.login .muted, .login .payoff { color: #A0A6B1; }
.login .error { color: #FF8A97; }
.login .btn:not(.primary) { background: transparent; color: #fff; border-color: rgba(255,255,255,.3); }
.login input:focus { outline-color: #fff; border-color: #fff; }

/* Riepilogo */
.dash-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.dash-head h2 { margin: 6px 0 10px; }
.dash-head .muted { text-transform: capitalize; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.kpi > span { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi b { font-size: 32px; font-weight: 600; line-height: 1.1; letter-spacing: -.02em; }
.kpi b em { font-size: 14px; font-style: normal; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.kpi small { font-size: 12px; color: var(--muted); }
.kpi small.up { color: var(--ok); font-weight: 600; }
.kpi small.down { color: var(--danger); font-weight: 600; }
.panels { display: grid; grid-template-columns: 1fr; gap: 12px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; min-width: 0; }
.panels .panel { margin-bottom: 0; }
.panel h4 { margin: 0 0 12px; font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.ok-line { margin: 0; color: var(--ok); font-weight: 600; }
.attn { display: flex; flex-direction: column; gap: 6px; }
.attn button { display: flex; align-items: center; gap: 12px; text-align: left; background: #FBF3E4; border: 1px solid #F0DDB5; border-radius: 8px; padding: 10px 12px; }
.attn button b { font-size: 20px; font-weight: 600; min-width: 28px; color: var(--warn); }
.attn button span { flex: 1; font-weight: 500; }
.attn button i { font-style: normal; font-size: 20px; color: var(--muted); }
.donut { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.donut svg { width: 150px; height: 150px; flex: none; }
.dn-big { font-size: 26px; font-weight: 600; fill: var(--text); }
.dn-small { font-size: 9px; fill: var(--muted); }
.dn-seg { transition: stroke-width .2s; }
.dn-seg:hover { stroke-width: 18; }
.lg { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 140px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.lg li { display: flex; align-items: center; gap: 8px; }
.lg li span { flex: 1; }
.lg i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.lg.inline { flex-direction: row; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.cols { width: 100%; height: auto; display: block; }
.col { fill: #C9CED6; transition: fill .2s; }
.col.today { fill: var(--brand); }
.cv { font-size: 11px; font-weight: 600; fill: var(--text); }
.cl { font-size: 10px; fill: var(--muted); text-transform: capitalize; }
.cl.today { fill: var(--text); font-weight: 600; }
.hb { display: flex; flex-direction: column; gap: 9px; }
.hb-row, .ld-row { display: grid; grid-template-columns: minmax(90px, 38%) 1fr 34px; align-items: center; gap: 10px; font-size: 13px; }
.hb-row b, .ld-row b { text-align: right; font-weight: 600; }
.hb-t, .ld-bar { height: 10px; background: #EEF0F3; border-radius: 5px; overflow: hidden; display: flex; }
.hb-f { display: block; height: 100%; border-radius: 5px; transition: width .22s ease-out; }
.load { display: flex; flex-direction: column; gap: 9px; }
.ld-n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ld-bar i { display: block; height: 100%; transition: width .22s ease-out; }
.ld-bar .d { background: var(--ok); } .ld-bar .p { background: var(--brand); } .ld-bar .t { background: #C9CED6; }
@media (min-width: 620px) {
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .panels { grid-template-columns: 1fr 1fr; }
  .panels .wide { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { .hb-f, .ld-bar i, .col, .dn-seg { transition: none; } }

/* Avviso di nuovo messaggio: nome in grassetto e testo sotto */
#toast.rich { text-align: left; min-width: 220px; display: flex; flex-direction: column; gap: 2px; }
#toast .tt { font-weight: 700; font-size: 14px; }
#toast .tb { font-weight: 400; font-size: 14px; opacity: .92; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }

/* Account disattivati: sezione a scomparsa */
.fold { display: flex; align-items: center; justify-content: space-between; width: 100%; margin: 18px 0 10px; padding: 12px 14px; background: transparent; border: 1px dashed #C9CED6; border-radius: 12px; color: var(--muted); font-weight: 600; font-size: 14px; }
.fold i { font-style: normal; font-size: 20px; transition: transform .2s; }
.fold.open i { transform: rotate(90deg); }

/* iPhone: la zona della fotocamera/orologio resta nera, in linea con l'intestazione */
body:not(:has(.login))::before { content: ""; position: fixed; top: 0; left: 0; right: 0; height: env(safe-area-inset-top); background: var(--black); z-index: 60; pointer-events: none; }
