/* Poche regole sopra Pico: colori sobri, spazi ampi, niente decorazioni. */
:root {
  --pico-border-radius: 0.5rem;
  --app-danger: #c62828;       /* rosso pieno (sfondo al passaggio del mouse, testo bianco 5.6:1) */
  --app-danger-text: #c62828;  /* rosso per bordo e testo su fondo chiaro */
}
@media (prefers-color-scheme: dark) { :root:not([data-theme]) { --app-danger-text: #ff8a80; } }
[data-theme="dark"] { --app-danger-text: #ff8a80; }

/* Titoli: una scala sola e compatta in tutte le pagine */
h1 { --pico-font-size: 1.6rem; }
h2 { --pico-font-size: 1.3rem; }
h3 { --pico-font-size: 1.1rem; }
@media (max-width: 640px) { h1 { --pico-font-size: 1.4rem; } h2 { --pico-font-size: 1.2rem; } }

/* Barra in alto */
body > header.topbar { border-bottom: 1px solid var(--pico-muted-border-color); padding-block: 0.5rem; margin-bottom: 1.5rem; }
.topbar nav { gap: 1rem; justify-content: flex-start; }
.topbar nav > ul:last-child { margin-left: auto; }
.topbar .brand { font-weight: 700; text-decoration: none; color: var(--pico-color); }
.topbar a[aria-current="page"] { font-weight: 600; text-decoration: underline; text-underline-offset: 0.4em; }
.topbar .org { color: var(--pico-muted-color); font-size: 0.85rem; white-space: nowrap; }
.topbar .nav-brand, .topbar nav > ul:last-child { flex-shrink: 0; }
.topbar details.dropdown summary:not([role]) { display: flex; align-items: center; gap: 0.35rem; white-space: nowrap; border-color: transparent; background-color: transparent; }
.topbar details.dropdown summary:not([role])::after { float: none; margin: 0; }
@media (max-width: 1199px) { .topbar .org { display: none; } }
/* Telefono: riga 1 nome e menu utente, riga 2 le pagine in due righe compatte */
@media (max-width: 767px) {
  .topbar nav { flex-wrap: wrap; gap: 0; }
  .topbar .nav-brand { order: 1; }
  .topbar nav > ul:last-child { order: 2; }
  .topbar .nav-links { order: 3; flex: 1 0 100%; flex-wrap: wrap; gap: 0.1rem 1rem; margin: 0 0 0.25rem; padding: 0; }
  .topbar .nav-links li { padding: 0.15rem 0; font-size: 0.9rem; }
}

/* Intestazione di pagina: titolo a sinistra, comandi a destra (sotto, sul telefono) */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head :is(h1, h2) { margin: 0; }
.page-head :is(form, select, [role="button"], button) { margin: 0; }
.page-head select { width: auto; }
.page-head :is(button, [role="button"]) { font-size: 0.9rem; padding: 0.45rem 0.9rem; }

/* Pulsanti: blu = conferma (Pico), bianco = secondario («secondary outline»), rosso = elimina («danger») */
:is(button, [role="button"]).danger {
  --pico-background-color: transparent;
  --pico-border-color: var(--app-danger-text);
  --pico-color: var(--app-danger-text);
}
:is(button, [role="button"]).danger:is(:hover, :active, :focus) {
  --pico-background-color: var(--app-danger);
  --pico-border-color: var(--app-danger);
  --pico-color: #fff;
}
:is(button, [role="button"]).danger:focus-visible { --pico-box-shadow: 0 0 0 var(--pico-outline-width) color-mix(in srgb, var(--app-danger) 40%, transparent); }

/* Fila di pulsanti: affiancati, stessa altezza, a capo se serve; «fill» = larghezze uguali */
.actions { display: flex; flex-wrap: wrap; align-items: stretch; gap: 0.75rem; margin-bottom: var(--pico-spacing); }
.page-head .actions { margin: 0; gap: 0.5rem; align-items: center; }
.actions > *, .actions form, .actions :is(button, [role="button"]) { margin: 0; }
.actions :is(button, [role="button"]) { width: auto; display: inline-flex; align-items: center; justify-content: center; }
.actions.fill > * { flex: 1 1 0; }
.actions.fill :is(button, [role="button"]), .actions form :is(button, [role="button"]) { width: 100%; height: 100%; }
@media (max-width: 640px) {
  .page-head > .actions { flex: 1 1 100%; }
  .actions > * { flex: 1 1 auto; }
}
.actions > [role="group"] { width: auto; }
.actions > [role="group"] > * { flex: 1 1 auto; }
/* Comandi «pericolosi» separati da quelli del modulo */
.form-actions { border-top: 1px solid var(--pico-muted-border-color); padding-top: var(--pico-spacing); margin-top: 0.5rem; }

/* Filtri (anno, alloggio): affiancati anche sul telefono */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0 0.75rem; }

/* Interruttori e caselle con una nota tra parentesi: la nota resta in linea */
:is([type="checkbox"], [type="radio"]) + small { display: inline; margin: 0; }

.muted { color: var(--pico-muted-color); }
.empty { text-align: center; padding: 3rem 1rem; }
.empty ol { display: inline-block; text-align: left; }

.messages { list-style: none; padding: 0; }
.messages li { list-style: none; padding: 0.75rem 1rem; border-radius: var(--pico-border-radius); margin-bottom: 0.5rem; background: var(--pico-card-sectioning-background-color); border-left: 4px solid var(--pico-primary); }
.messages li.warning, .messages li.error { border-left-color: #b4541a; }

.badge { display: inline-block; font-size: 0.75rem; padding: 0.1rem 0.5rem; border-radius: 1rem; background: var(--pico-secondary-background); color: var(--pico-secondary-inverse); vertical-align: middle; white-space: nowrap; }

main.narrow { max-width: 34rem; }
@media (max-width: 640px) { table { --pico-spacing: 0.6rem; font-size: 0.9rem; } }
table.log td:last-child { min-width: 14rem; }
article > :last-child { margin-bottom: 0; }

/* Panoramica: riquadri, indicatori e grafico */
.checks { border-left: 4px solid #b4541a; }
:is(.checks, .upcoming) ul { margin: 0.5rem 0 0; }
.upcoming .page-head { margin-bottom: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: 0.75rem; margin-block: 0 0.5rem; }
.kpis article { margin: 0; padding: 0.9rem 1rem; display: flex; flex-direction: column; gap: 0.2rem; }
.kpis strong { font-size: 1.5rem; line-height: 1.2; }
.delta { font-weight: 600; color: var(--pico-muted-color); }
.delta.up { color: #2e7d32; }
.delta.down { color: #b4541a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .delta.up { color: #66bb6a; } :root:not([data-theme]) .delta.down { color: #ef8a4f; } }
.chart { margin: 0.5rem 0 1rem; }
.chart svg { width: 100%; height: auto; max-height: 16rem; display: block; }
.chart rect.cur { fill: var(--pico-primary); }
.chart rect.prev { fill: var(--pico-muted-border-color); }
.chart .axis { stroke: var(--pico-muted-border-color); }
.chart text { font-size: 12px; fill: var(--pico-muted-color); }
.key { display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 2px; vertical-align: middle; margin-left: 0.5rem; }
.key.cur { background: var(--pico-primary); }
.key.prev { background: var(--pico-muted-border-color); }

/* Resoconti: riepilogo come un estratto conto, e stampa pulita (Salva come PDF) */
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.month-nav a { white-space: nowrap; }
@media (max-width: 640px) { .month-nav { flex-wrap: wrap; gap: 0.25rem 1rem; } .month-nav a:nth-child(2):not(:last-child) { order: 3; flex-basis: 100%; text-align: center; } }
.statement { width: 100%; max-width: 34rem; }
.statement td:last-child { text-align: right; white-space: nowrap; }
.statement tr.sum td { font-weight: 600; border-top: 2px solid var(--pico-muted-border-color); }
.statement tr.balance td { font-size: 1.15rem; font-weight: 700; }
table.num td.n, table.num th.n { text-align: right; white-space: nowrap; }
.comment { white-space: pre-line; }
.publish { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.publish p, .publish form, .publish button { margin: 0; }
.print-only { display: none; }
@media print {
  body > header.topbar, .no-print, .messages, .site-footer { display: none !important; }
  .print-only { display: block; }
  main.container { max-width: none; padding: 0; }
  body { font-size: 11pt; }
  table { font-size: 9.5pt; }
  .kpis article, article { box-shadow: none; border: 1px solid #ddd; }
}

/* Moduli in linea (etichetta + comando sulla stessa riga) */
.inline-form { display: flex; gap: 0 1rem; align-items: end; flex-wrap: wrap; margin-bottom: var(--pico-spacing); }
.inline-form label { flex: 1 1 9rem; margin: 0; }
.inline-form :is(input, select) { margin-bottom: 0; }
.inline-form button { width: auto; margin: 0; }
@media (max-width: 640px) { .inline-form { gap: 0.75rem; } .inline-form button { flex: 1 1 100%; } }
.link-button { all: unset; cursor: pointer; color: var(--pico-primary); text-decoration: underline; }

/* Adempimenti: tariffe affiancate */
.tax-rates { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 0 1rem; align-items: end; }
.tax-rates label small { display: block; }
.tax-rates button { grid-column: 1 / -1; width: auto; justify-self: start; }

/* Check-in online: titoli delle persone sobri anche sul telefono */
main.narrow article h2 { font-size: 1.15rem; }
.lang-switch { display: block; text-align: right; font-size: 0.9rem; margin: 0.5rem 0 1rem; }

/* Calendario globale: una colonna per notte, nome dell'alloggio fisso a sinistra, scorrimento orizzontale sul telefono */
.cal { --name: 9rem; --cell: 1.6rem; overflow-x: auto; border: 1px solid var(--pico-muted-border-color); border-radius: var(--pico-border-radius); margin-bottom: 0.5rem; }
.cal-row { display: grid; grid-template-columns: var(--name) repeat(var(--days), minmax(var(--cell), 1fr)); min-width: calc(var(--name) + var(--days) * var(--cell)); border-bottom: 1px solid var(--pico-muted-border-color); }
.cal-row:last-child { border-bottom: 0; }
.cal-name { grid-column: 1; position: sticky; left: 0; z-index: 2; background: var(--pico-background-color); padding: 0.35rem 0.5rem; font-size: 0.85rem; line-height: 1.2; overflow: hidden; display: flex; flex-direction: column; justify-content: center; border-right: 1px solid var(--pico-muted-border-color); }
.cal-name small { display: block; white-space: nowrap; font-size: 0.75rem; }
.cal-name .delta { font-size: 0.7rem; }
.cal-head .cal-day { text-align: center; font-size: 0.8rem; padding: 0.25rem 0; line-height: 1.1; display: flex; flex-direction: column; }
.cal-head .cal-day small { color: var(--pico-muted-color); font-size: 0.65rem; }
.cal-cell { border-left: 1px solid var(--pico-muted-border-color); }
a.cal-cell:hover { background: color-mix(in srgb, var(--pico-primary) 12%, transparent); }
.weekend { background: color-mix(in srgb, var(--pico-muted-border-color) 35%, transparent); }
.today { box-shadow: inset 0 0 0 2px var(--pico-primary); }
.cal-bar { z-index: 1; align-self: center; margin: 0.25rem 1px; border-radius: 0.4rem; padding: 0 0.4rem; font-size: 0.75rem; line-height: 1.6rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; text-decoration: none; }
.cal-bar.cont-before { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: 0; }
.cal-bar.cont-after { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: 0; }
.cal-bar.overlap { outline: 2px solid #b4541a; }
/* Prenotazione provvisoria (dal calendario della piattaforma, importi in arrivo) */
.cal-bar.provisional { opacity: 0.75; background-image: repeating-linear-gradient(-45deg, transparent 0 6px, rgba(255,255,255,.18) 6px 12px); }
.cal-block { background: repeating-linear-gradient(45deg, #8a8f98, #8a8f98 6px, #9aa0a8 6px, #9aa0a8 12px); color: #fff; }
.cal-price { opacity: 0.85; font-weight: 600; margin-left: 0.25rem; }
.p-airbnb { background: #d9534f; }
.p-booking { background: #2c5aa0; }
.p-direct { background: #2e7d32; }
.p-other { background: #6c757d; }
.cal-summary { margin-bottom: 0.75rem; }
.cal-legend { line-height: 1.8; }
.cal-legend small > span { white-space: nowrap; margin-right: 0.5rem; }
.cal-legend .key { margin: 0 0.15rem 0 0; }
@media (max-width: 767px) { .cal { --name: 6.5rem; --cell: 2rem; } }

/* Prenotazioni: sul telefono restano arrivo, alloggio, ospite, lordo e il pulsante del check-in */
table.bookings td:last-child { white-space: nowrap; }
@media (max-width: 640px) { table.bookings th:nth-child(2), table.bookings td:nth-child(2), table.bookings th:nth-child(5), table.bookings td:nth-child(5), table.bookings th:nth-child(7), table.bookings td:nth-child(7), table.bookings th:nth-child(8), table.bookings td:nth-child(8) { display: none; } }

.site-footer { margin-top: 3rem; padding-block: 1rem; border-top: 1px solid var(--pico-muted-border-color); }
.legal h2 { font-size: 1.1rem; margin-top: 1.5rem; }

/* Adempimenti: stato in tre riquadri cliccabili */
.status .tile { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.8rem 1rem; border-radius: var(--pico-border-radius); border: 1px solid var(--pico-muted-border-color); border-left-width: 4px; color: inherit; text-decoration: none; background: var(--pico-card-background-color); }
.status .tile:hover { border-color: var(--pico-primary); }
.status .tile span { font-size: 0.85rem; color: var(--pico-muted-color); }
.status .tile strong { font-size: 1.25rem; }
.status .tile.ok { border-left-color: #2e8540; }
.status .tile.warn { border-left-color: #b4541a; }
.status .tile.off { border-left-color: var(--pico-muted-border-color); }
.issues { list-style: none; padding: 0; }
.issues li { list-style: none; padding: 0.35rem 0; border-bottom: 1px solid var(--pico-muted-border-color); }
.issues li:last-child { border-bottom: 0; }
.issues details { margin: 0.25rem 0 0; }
.issues details summary { font-size: 0.85rem; }

/* Panoramica: confronto tra alloggi */
.compare .bar { display: block; height: 0.3rem; width: var(--w); min-width: 2px; margin-top: 0.25rem; border-radius: 1rem; background: var(--pico-primary); opacity: 0.7; }
.heat { font-size: 0.8rem; }
.heat th, .heat td { padding: 0.3rem 0.35rem; text-align: center; white-space: nowrap; }
.heat th[scope="row"] { text-align: left; max-width: 9rem; overflow: hidden; text-overflow: ellipsis; position: sticky; left: 0; background: var(--pico-background-color); }
.heat td { cursor: pointer; border: 2px solid var(--pico-background-color); border-radius: 0.3rem; }
.heat td.l0 { color: var(--pico-muted-color); }
.heat td.l1 { background: color-mix(in srgb, var(--pico-primary) 12%, transparent); }
.heat td.l2 { background: color-mix(in srgb, var(--pico-primary) 28%, transparent); }
.heat td.l3 { background: color-mix(in srgb, var(--pico-primary) 45%, transparent); }
.heat td.l4 { background: color-mix(in srgb, var(--pico-primary) 65%, transparent); color: #fff; }
.heat td.l5 { background: color-mix(in srgb, var(--pico-primary) 85%, transparent); color: #fff; }
.heat td.future { font-style: italic; opacity: 0.75; }
.heat td.picked { outline: 2px solid var(--pico-color); }
.heat-info { min-height: 1.5rem; font-size: 0.85rem; }
@media (max-width: 575px) { .hide-sm { display: none; } }
tr.highlight td { background: color-mix(in srgb, var(--pico-primary) 12%, transparent); }
.show-sm { display: none; }
@media (max-width: 575px) { .show-sm { display: inline; } }
.filters input[type="search"] { margin-bottom: 0; }

/* Calendario per molti alloggi: intestazione dei giorni fissa, righe compatte, menu sul giorno libero */
.cal { max-height: 75vh; overflow: auto; }
.cal-head { position: sticky; top: 0; z-index: 3; background: var(--pico-background-color); border-bottom: 1px solid var(--pico-muted-border-color); }
.cal-head .cal-name { z-index: 4; }
.cal-prop { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
a.cal-cell.picked { background: color-mix(in srgb, var(--pico-primary) 25%, transparent); }
.cal-bar-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0 1rem; }
.cal-bar-top .cal-summary { margin: 0 0 0.5rem; }
.cal-filter select { margin: 0 0 0.5rem; padding-block: 0.35rem; min-width: 12rem; }
.cal-empty { padding: 1rem; margin: 0; }
.cal-menu { position: fixed; z-index: 20; display: flex; flex-direction: column; gap: 0.4rem; padding: 0.75rem; min-width: 13rem; background: var(--pico-card-background-color); border: 1px solid var(--pico-muted-border-color); border-radius: var(--pico-border-radius); box-shadow: 0 6px 24px rgba(0,0,0,.15); }
.cal-menu[hidden] { display: none; }
.cal-menu strong { font-size: 0.85rem; }
.cal-menu a[role="button"] { padding: 0.4rem 0.75rem; font-size: 0.9rem; margin: 0; }
@media (max-width: 767px) { .cal { --name: 5.75rem; --cell: 1.9rem; max-height: 70vh; } .cal-name { font-size: 0.8rem; padding: 0.3rem 0.4rem; } }

/* Pulizie: piano della settimana e pagina dell'addetta */
.day-title { font-size: 1rem; margin: 1.25rem 0 0.4rem; padding-bottom: 0.25rem; border-bottom: 1px solid var(--pico-muted-border-color); }
.day-title.today { color: var(--pico-primary); }
.day-title.late { color: #b4541a; }
.day-empty { margin: 0 0 0.5rem; }
.clean-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.4rem 1rem; padding: 0.5rem 0.6rem; margin: 0 0 0.4rem; border: 1px solid var(--pico-muted-border-color); border-left: 4px solid var(--pico-muted-border-color); border-radius: var(--pico-border-radius); }
.clean-row.urgent { border-left-color: #b4541a; }
.clean-row.done { border-left-color: #2e8540; opacity: 0.8; }
.clean-what { flex: 1 1 14rem; line-height: 1.35; }
.clean-what .badge { margin-left: 0.25rem; }
.clean-how { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; flex: 2 1 22rem; justify-content: flex-end; }
.clean-how > * { margin: 0 !important; }
.clean-how select { width: auto; min-width: 9rem; padding-block: 0.3rem; }
.clean-how input.hours { width: 4.5rem; padding-block: 0.3rem; }
.clean-how input.note { flex: 1 1 9rem; padding-block: 0.3rem; }
.clean-how button { padding: 0.3rem 0.75rem; }
.clean-how .done-box { white-space: nowrap; }
.extra-delete { margin: -0.3rem 0 0.5rem; text-align: right; font-size: 0.8rem; }
.badge.ok { background: #2e8540; color: #fff; }
.badge.warn { background: #b4541a; color: #fff; }
.report { color: #b4541a; }
.week-nav { width: auto; margin-bottom: 0.5rem; }
.cleaner-page .job { padding: 1rem; }
.cleaner-page .job.urgent { border-left: 4px solid #b4541a; }
.cleaner-page .job header { margin-bottom: 0.5rem; padding-bottom: 0.5rem; display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; justify-content: space-between; }
.cleaner-page .job form button { width: 100%; }
.cleaner-page .note { background: var(--pico-code-background-color); padding: 0.5rem 0.75rem; border-radius: var(--pico-border-radius); }
@media (max-width: 575px) { .clean-how { justify-content: flex-start; } .clean-how select { flex: 1 1 8rem; } }

/* Primo avvio */
.setup { border-left: 4px solid var(--pico-primary); }
.setup ol { margin: 0.5rem 0 0; padding-left: 1.25rem; }
.setup li.done { color: var(--pico-muted-color); list-style: none; margin-left: -1.1rem; }
.setup-table input { margin: 0; padding-block: 0.35rem; min-width: 9rem; }
.setup-table td { vertical-align: middle; }
