/* Nakapartments App — shared styles. Refreshed 2026-08-11 for usability.
   Class names are unchanged from before so every page picks up the new look. */

:root {
    --color-bg: #f4f6f9;
    --color-surface: #ffffff;
    --color-surface-2: #f8fafc;
    --color-border: #e5e8ee;
    --color-border-strong: #d3d8e0;
    --color-text: #16202e;
    --color-text-muted: #64748b;

    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-primary-soft: #eaf1ff;
    --color-success: #15803d;
    --color-success-soft: #dcfce7;
    --color-warning: #b45309;
    --color-warning-soft: #fef3c7;
    --color-danger: #dc2626;
    --color-danger-soft: #fee2e2;

    --radius: 10px;
    --radius-sm: 7px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.04);
    --shadow: 0 4px 16px rgba(16, 24, 40, 0.08);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.12);

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.55;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}
body { display: flex; flex-direction: column; min-height: 100vh; }

h1 { font-size: 1.55rem; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 .35rem; }
h2 { font-size: 1.2rem; font-weight: 650; margin: 1.75rem 0 .85rem; letter-spacing: -0.01em; }
h3 { font-size: 1rem; font-weight: 650; margin: 0 0 .4rem; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header + nav ---------- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--color-border);
    padding: 0.55rem 1.25rem;
}
.app-header__inner {
    max-width: 1240px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.app-header__brand {
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--color-text);
    text-decoration: none;
    letter-spacing: -0.02em;
    white-space: nowrap;
}
.app-header__brand:hover { text-decoration: none; }
.app-header__nav {
    display: flex;
    gap: 0.15rem;
    flex-wrap: wrap;
    align-items: center;
}
.app-header__nav a {
    color: var(--color-text-muted);
    text-decoration: none;
    font-weight: 550;
    font-size: 0.9rem;
    padding: 0.4rem 0.7rem;
    border-radius: 8px;
    white-space: nowrap;
    transition: background 0.12s, color 0.12s;
}
.app-header__nav a:hover { background: var(--color-surface-2); color: var(--color-text); text-decoration: none; }
.app-header__nav a[aria-current="page"] { background: var(--color-primary-soft); color: var(--color-primary-hover); }
.app-header__user {
    margin-left: auto;
    display: inline-flex;
    gap: 0.6rem;
    align-items: center;
    font-size: 0.88rem;
    color: var(--color-text-muted);
}
.app-header__user a { color: var(--color-text-muted); font-weight: 550; }

/* Mobile menu toggle — hidden on desktop, becomes the ☰ button under 720px */
.nav-toggle {
    position: absolute;
    width: 1px; height: 1px;
    opacity: 0;
    pointer-events: none;
}
.nav-toggle__btn { display: none; }

.env-badge {
    font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
    padding: 0.2rem 0.5rem; border-radius: 999px; letter-spacing: 0.05em;
}
.env-badge--staging { background: var(--color-warning-soft); color: var(--color-warning); }
.env-badge--dev { background: #dbeafe; color: #1e40af; }

/* ---------- Layout ---------- */
.app-main {
    flex: 1;
    max-width: 1240px;
    width: 100%;
    margin: 0 auto;
    padding: 1.75rem 1.25rem 3rem;
}
.app-footer {
    padding: 1rem 1.25rem;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    text-align: center;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}

.hero h1 { font-size: 2rem; }
.hero__subtitle { color: var(--color-text-muted); margin: 0 0 2rem; }

/* ---------- Home tile launcher ---------- */
.home__title { font-size: 1.6rem; margin: 0 0 0.2rem; }
.home__subtitle { color: var(--color-text-muted); margin: 0 0 1.5rem; }

.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 0.9rem;
}

.tile {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-height: 118px;
    padding: 1rem 1.1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    color: var(--color-text);
    /* stop iOS from flashing a grey box on tap */
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.tile:hover {
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--color-border-strong);
}
.tile:active { transform: translateY(0); box-shadow: var(--shadow-sm); }
.tile:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--color-primary-soft); }

.tile__icon { font-size: 1.7rem; line-height: 1.2; margin-bottom: 0.35rem; }
.tile__label { font-weight: 650; font-size: 1rem; }
.tile__hint { color: var(--color-text-muted); font-size: 0.82rem; line-height: 1.35; }

.home__meta {
    margin: 2rem 0 0;
    color: var(--color-text-muted);
    font-size: 0.8rem;
}
.home__meta a { color: var(--color-text-muted); text-decoration: underline; }

/* ---------- Cards ---------- */
.status-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem 1.4rem;
    box-shadow: var(--shadow-sm);
}
.status-card h2 { margin: 0 0 0.9rem; font-size: 1.1rem; }
.status-card h3 { margin: 0 0 0.5rem; }
.status-card ul { list-style: none; padding: 0; margin: 0 0 1rem; }
.status-card li { padding: 0.25rem 0; font-size: 0.92rem; }
.status-card__note {
    margin: 1rem 0 0; padding-top: 1rem;
    border-top: 1px solid var(--color-border);
    color: var(--color-text-muted); font-size: 0.9rem;
}

/* ---------- Citofoni ---------- */
/* Apri is the first column, and stays put — on a phone the staff view must be
   usable without scrolling sideways. */
.doors-open { padding: 0.6rem 1.1rem; white-space: nowrap; }
/* (the mobile treatment lives in the Mobile block at the end of this file —
   it has to come AFTER the shared .sync-table rule to win) */

/* ---------- Add a door device (Porte) ---------- */
.door-add {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius); padding: 0.85rem 1.1rem; margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
}
.door-add > summary { cursor: pointer; font-weight: 650; color: var(--color-primary); }
.door-add__grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 0.85rem; margin: 1rem 0 0.75rem;
}
.door-add__grid label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.2rem; }
.door-add__grid input, .door-add__grid select {
    width: 100%; box-sizing: border-box; padding: 0.5rem;
    border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); font: inherit;
}
.door-add__grid .clean-meta { display: block; margin-top: 0.2rem; }
.door-add__actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* ---------- Guest House Info editor (apartment page) ---------- */
.guest-info {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius); padding: 0.85rem 1.1rem; margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}
.guest-info > summary { cursor: pointer; font-weight: 650; display: flex; gap: 0.5rem; align-items: center; }
.guest-info__preview {
    background: var(--color-primary-soft); border-radius: var(--radius-sm);
    padding: 0.7rem 0.9rem; margin-bottom: 1rem; font-size: 0.9rem;
}
.guest-info__preview ul { margin: 0.4rem 0 0; padding-left: 1.1rem; }
.guest-info__preview li { padding: 0.15rem 0; }
.guest-info__form { display: grid; gap: 0.85rem; max-width: 680px; }
.guest-info__row { display: flex; flex-direction: column; gap: 0.25rem; }
.guest-info__row textarea, .guest-info__row input[type="text"] {
    width: 100%; box-sizing: border-box; padding: 0.5rem;
    border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm);
    font: inherit;
}
.guest-info__flag { display: flex; gap: 0.5rem; align-items: center; cursor: pointer; }
.guest-info__flag input { width: 20px; height: 20px; }

/* ---------- Per-apartment appliance summary ---------- */
.apt-appliances {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius); padding: 0.85rem 1.1rem; margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}
.apt-appliances > summary { cursor: pointer; font-weight: 650; display: flex; gap: 0.5rem; align-items: center; }
.apt-appliances__list { list-style: none; padding: 0; margin: 0.75rem 0 0; }
.apt-appliances__list li { padding: 0.35rem 0; border-bottom: 1px solid var(--color-border); font-size: 0.92rem; }
.apt-appliances__list li:last-child { border-bottom: 0; }

/* ---------- Multi-select action bar (Manutenzione) ---------- */
.bulk-bar {
    position: sticky; bottom: 0; z-index: 20;
    display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap;
    margin-top: 0.75rem; padding: 0.75rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}
.bulk-bar[hidden] { display: none; }
.bulk-bar__count { font-size: 0.9rem; color: var(--color-text-muted); white-space: nowrap; }
.bulk-bar select {
    padding: 0.45rem 0.5rem; border-radius: var(--radius-sm);
    border: 1px solid var(--color-border-strong); background: var(--color-surface);
    font-size: 0.88rem; max-width: 100%;
}
/* big enough to hit with a thumb */
.bulk-pick, #bulk-all { width: 20px; height: 20px; cursor: pointer; }

@media (max-width: 720px) {
    .bulk-bar { flex-direction: column; align-items: stretch; }
    .bulk-bar select, .bulk-bar .btn { width: 100%; }
}

/* ---------- Sort switcher (Istruzioni check-in) ---------- */
.sort-tabs { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; margin: 0.6rem 0 1.25rem; }
.sort-tabs a {
    padding: 0.45rem 0.85rem; border-radius: 999px;
    border: 1px solid var(--color-border-strong); background: var(--color-surface);
    color: var(--color-text-muted); font-size: 0.85rem; font-weight: 600; white-space: nowrap;
}
.sort-tabs a:hover { text-decoration: none; color: var(--color-text); }
.sort-tabs a.is-active {
    background: var(--color-primary); border-color: var(--color-primary); color: #fff;
}
.sort-group {
    margin: 0.9rem 0 0; font-size: 0.95rem; color: var(--color-text-muted);
    text-transform: uppercase; letter-spacing: 0.05em;
}

/* ---------- Staff screen + permission matrix ---------- */
.staff-add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 0.75rem; }
.staff-add-grid label { display: block; font-weight: 600; margin-bottom: 0.2rem; font-size: 0.9rem; }
.staff-add-grid input, .staff-add-grid select { width: 100%; padding: 0.5rem; box-sizing: border-box; }

.staff-card { margin-bottom: 1.25rem; }
.staff-card__head {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 1rem; flex-wrap: wrap;
    padding-bottom: 0.9rem; margin-bottom: 0.9rem;
    border-bottom: 1px solid var(--color-border);
}
.staff-card__actions { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.staff-card__actions select, .staff-card__actions input { padding: 0.35rem; }
.staff-card__save { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; margin-top: 1rem; }
.staff-admin-note {
    margin: 0; padding: 0.7rem 0.9rem; border-radius: var(--radius-sm);
    background: var(--color-primary-soft); color: var(--color-text); font-size: 0.9rem;
}

.perm-grid { display: flex; flex-direction: column; gap: 0.35rem; }
.perm-row {
    display: flex; justify-content: space-between; align-items: center;
    gap: 1rem; flex-wrap: wrap;
    padding: 0.55rem 0.7rem; border-radius: var(--radius-sm); background: var(--color-surface-2);
}
.perm-row__name { display: flex; flex-direction: column; min-width: 190px; }
.perm-row__choices { display: flex; gap: 0.3rem; flex-wrap: wrap; }

/* Three-way switch: the radio itself is hidden, the label is the button */
.perm-opt { position: relative; cursor: pointer; }
.perm-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.perm-opt span {
    display: inline-block; padding: 0.4rem 0.7rem; min-height: 20px;
    border: 1px solid var(--color-border-strong); border-radius: 999px;
    background: var(--color-surface); color: var(--color-text-muted);
    font-size: 0.82rem; font-weight: 600; white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}
.perm-opt input:checked + span { background: var(--color-text-muted); border-color: var(--color-text-muted); color: #fff; }
.perm-opt--view input:checked + span { background: var(--color-warning); border-color: var(--color-warning); color: #fff; }
.perm-opt--edit input:checked + span { background: var(--color-success); border-color: var(--color-success); color: #fff; }
.perm-opt input:focus-visible + span { box-shadow: 0 0 0 3px var(--color-primary-soft); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.95rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.2;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, box-shadow 0.12s, transform 0.02s;
    font-family: inherit;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--color-primary-soft); }
.btn--primary { background: var(--color-primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--color-primary-hover); }
.btn--ghost { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border-strong); }
.btn--ghost:hover { background: var(--color-surface-2); border-color: var(--color-text-muted); }

/* ---------- Form controls (global — tidies the many inline-styled forms) ---------- */
input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="email"], input[type="search"], input[type="tel"], input[type="url"],
select, textarea {
    font-family: inherit;
    font-size: 0.92rem;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.65rem;
    line-height: 1.4;
}
textarea { width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-soft);
}
input::placeholder, textarea::placeholder { color: #9aa4b2; }
label { font-size: 0.9rem; }
input[type="file"] { font-size: 0.85rem; color: var(--color-text-muted); }

/* ---------- Page header ---------- */
.sync-page__header { margin-bottom: 1.5rem; }
.sync-page__header h1 { margin: 0 0 0.3rem; }
.page-subtitle { color: var(--color-text-muted); margin: 0; font-size: 0.92rem; }
.sync-page__refreshed { color: var(--color-text-muted); font-size: 0.85rem; margin: 0 0 0.5rem; }
.sync-page__refreshed code { font-size: 0.8rem; }

/* ---------- Tables ---------- */
.sync-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.sync-table th, .sync-table td {
    text-align: left;
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.9rem;
    vertical-align: middle;
}
.sync-table th {
    background: var(--color-surface-2);
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.7rem;
}
.sync-table tbody tr { transition: background 0.1s; }
.sync-table tbody tr:hover { background: var(--color-surface-2); }
.sync-table tr:last-child td { border-bottom: none; }
.sync-table code { font-size: 0.78rem; color: var(--color-text-muted); }

.sync-row td:first-child { position: relative; padding-left: 1.7rem; }
.sync-row td:first-child::before {
    content: "●"; position: absolute; left: 0.7rem; font-size: 1rem; line-height: 1; top: 0.7rem;
}
.sync-row--ok      td:first-child::before { color: var(--color-success); }
.sync-row--warn    td:first-child::before { color: var(--color-warning); }
.sync-row--fail    td:first-child::before { color: var(--color-danger); }
.sync-row--running td:first-child::before { color: var(--color-primary); }
.sync-row--fail { background: var(--color-danger-soft); }
.sync-row--warn { background: var(--color-warning-soft); }

.sync-error {
    display: inline-block; font-family: ui-monospace, monospace; font-size: 0.78rem;
    color: var(--color-danger); max-width: 320px; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom;
}
.sync-empty {
    background: var(--color-surface); border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius); padding: 2rem 1.5rem; color: var(--color-text-muted); text-align: center;
}

.sync-page__legend {
    margin-top: 1.5rem; background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius); padding: 0.75rem 1rem; font-size: 0.9rem;
}
.sync-page__legend summary { cursor: pointer; color: var(--color-text-muted); }
.sync-page__legend ul { list-style: none; padding: 0; margin: 0.75rem 0 0; }
.sync-page__legend li { padding: 0.2rem 0; }

.sync-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 0.4rem; vertical-align: baseline; }
.sync-dot--ok { background: var(--color-success); }
.sync-dot--warn { background: var(--color-warning); }
.sync-dot--fail { background: var(--color-danger); }
.sync-dot--running { background: var(--color-primary); }

/* ---------- Stat tiles ---------- */
.clean-summary { display: flex; flex-wrap: wrap; gap: 0.85rem; margin: 0 0 1.5rem; }
.clean-tile {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius); padding: 0.9rem 1.2rem; min-width: 130px; box-shadow: var(--shadow-sm);
}
.clean-tile__num { font-size: 1.7rem; font-weight: 750; letter-spacing: -0.02em; }
.clean-tile__label { color: var(--color-text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.clean-tile--urgent .clean-tile__num { color: var(--color-danger); }
.clean-tile--info .clean-tile__num { color: var(--color-primary); }

/* ---------- Badges ---------- */
.clean-badge {
    display: inline-block; font-size: 0.7rem; font-weight: 700;
    padding: 0.22rem 0.6rem; border-radius: 999px; white-space: nowrap;
    text-transform: uppercase; letter-spacing: 0.03em; vertical-align: middle;
}
.clean-badge--urgent { background: var(--color-danger-soft); color: var(--color-danger); }
.clean-badge--info   { background: #e0edff; color: var(--color-primary-hover); }
.clean-badge--ok     { background: var(--color-success-soft); color: var(--color-success); }
.clean-badge--muted  { background: #eef1f5; color: var(--color-text-muted); }

.clean-meta { color: var(--color-text-muted); font-size: 0.83rem; }
.clean-count { display: inline-block; margin-right: 0.5rem; font-size: 0.85rem; }

/* ---------- Media viewer ---------- */
.clean-session {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; box-shadow: var(--shadow-sm);
}
.clean-session__head { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.clean-session__head h3 { margin: 0; font-size: 1rem; }
.phase-label { margin: 0.9rem 0 0.4rem; color: var(--color-text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.6rem; }
.media-item { border: 1px solid var(--color-border); border-radius: var(--radius-sm); overflow: hidden; background: #000; }
.media-item img, .media-item video { display: block; width: 100%; height: 150px; object-fit: cover; }
.media-empty { color: var(--color-text-muted); font-size: 0.85rem; margin: 0.2rem 0 0; }

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
    .app-main { padding: 1.25rem 0.9rem 2.5rem; }
    .app-header { padding: 0.5rem 0.9rem; }

    /* One tidy row: brand … badge · user · ☰ ; the menu drops below when opened */
    .app-header__inner { gap: 0.5rem; }
    .app-header__brand { order: 1; font-size: 1rem; }
    .env-badge { order: 2; }
    .app-header__user { order: 3; }
    .nav-toggle__btn {
        order: 4;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 42px;
        min-height: 38px;
        border: 1px solid var(--color-border-strong);
        border-radius: 8px;
        background: var(--color-surface);
        font-size: 1.05rem;
        line-height: 1;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .nav-toggle__btn::before { content: "\2630"; }            /* ☰ */
    .nav-toggle:checked ~ .nav-toggle__btn::before { content: "\2715"; }  /* ✕ */
    .nav-toggle:checked ~ .nav-toggle__btn { background: var(--color-primary-soft); border-color: var(--color-primary); }
    .nav-toggle:focus-visible ~ .nav-toggle__btn { box-shadow: 0 0 0 3px var(--color-primary-soft); }

    .app-header__nav {
        order: 5;
        flex-basis: 100%;
        display: none;
        flex-direction: column;
        align-items: stretch;   /* override the desktop centring */
        gap: 0.1rem;
        margin-top: 0.4rem;
        padding-top: 0.5rem;
        border-top: 1px solid var(--color-border);
    }
    .nav-toggle:checked ~ .app-header__nav { display: flex; }
    /* full-width rows, comfortable to tap */
    .app-header__nav a { padding: 0.75rem 0.6rem; font-size: 0.95rem; text-align: left; }
    h1 { font-size: 1.35rem; }
    /* let wide tables scroll instead of overflowing the page */
    .sync-table { display: block; overflow-x: auto; white-space: nowrap; }

    /* ...except the citofoni list: staff must reach Apri with a thumb, never
       by scrolling sideways. Must come after the .sync-table rule above. */
    .doors-table { display: table; width: 100%; overflow-x: visible; white-space: normal; }
    .doors-table th, .doors-table td { padding: 0.5rem 0.4rem; vertical-align: middle; }
    .doors-open { width: 100%; padding: 0.7rem 0.5rem; }
    .doors-table .fire-result { display: block; margin-top: 0.25rem; }

    /* home tiles: always 2 per row on a phone, big enough to tap */
    .tile-grid { grid-template-columns: 1fr 1fr; gap: 0.7rem; }
    .tile { min-height: 108px; padding: 0.85rem 0.9rem; }
    .tile__icon { font-size: 1.5rem; }
    .tile__label { font-size: 0.95rem; }
    .tile__hint { font-size: 0.75rem; }

    /* staff: stack each permission row so the three buttons stay tappable */
    .staff-add-grid { grid-template-columns: 1fr; }
    .perm-row { flex-direction: column; align-items: stretch; gap: 0.5rem; }
    .perm-row__choices { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.3rem; }
    .perm-opt span { display: block; text-align: center; padding: 0.65rem 0.2rem; font-size: 0.78rem; }
}

/* Apartment heading row when the Manutenzione board is grouped by apartment */
.issues-group td {
    background: var(--color-surface-2);
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    padding: 0.45rem 0.75rem;
}

/* ---------- Scheda appartamento (rifatta 2026-08-22: era troppo lunga) ---------- */
.apt-toolbar { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.25rem; }

.apt-card {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    padding: .9rem 1.1rem; margin-bottom: .9rem; max-width: 900px;
}
.apt-card > summary {
    cursor: pointer; font-weight: 650; display: flex; gap: .5rem; align-items: center;
}
.apt-card label { display: block; font-weight: 600; font-size: .82rem; margin-bottom: .25rem; }

.apt-todo {
    background: #fffbeb; border: 1px solid var(--color-warning);
    border-radius: var(--radius); padding: .8rem 1.1rem; margin-bottom: .9rem; max-width: 900px;
}
.apt-todo ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.apt-todo li { padding: .1rem 0; font-size: .9rem; }

/* le tre impostazioni una accanto all'altra invece che impilate */
.apt-setup { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .9rem; }
.apt-setup__row { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.apt-setup select, .apt-setup input[type="date"] {
    padding: .4rem; border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm); font: inherit; min-width: 0; flex: 1;
}
.apt-setup__link { grid-column: 1 / -1; border-top: 1px solid var(--color-border); padding-top: .7rem; }
.apt-setup__link code { font-size: .8rem; word-break: break-all; flex: 1; }

.apt-guest__list { list-style: none; padding: 0; margin: .7rem 0 0; }
.apt-guest__list li { padding: .3rem 0; border-bottom: 1px solid var(--color-border); font-size: .9rem; }
.apt-guest__list li:last-child { border-bottom: 0; }

.apt-fields__title { margin: 1.75rem 0 .5rem; }
.apt-section > summary { font-size: .95rem; }
/* due colonne: dimezza la lunghezza della pagina */
.apt-fields {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: .75rem 1rem; margin-top: .9rem;
}
.apt-field--wide { grid-column: 1 / -1; }
.apt-field input[type="text"], .apt-field input[type="date"],
.apt-field textarea, .apt-field select {
    width: 100%; box-sizing: border-box; padding: .45rem;
    border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); font: inherit;
}
.apt-field__check { font-weight: 400 !important; display: flex; gap: .4rem; align-items: center; }
.apt-field__check input { width: 18px; height: 18px; }
.apt-field__img { max-width: 140px; border-radius: 6px; display: block; margin-bottom: 6px; }

/* il salvataggio resta a portata di mano anche a fondo pagina */
.apt-save {
    position: sticky; bottom: 0; z-index: 10; max-width: 900px;
    padding: .75rem 0; background: linear-gradient(transparent, var(--color-bg) 40%);
}

@media (max-width: 720px) {
    .apt-setup, .apt-fields { grid-template-columns: 1fr; }
}

/* Info casa: gli argomenti standard in due colonne, per vedere in una schermata
   tutto quello che l'ospite legge invece di scorrere un modulo lunghissimo. */
.house-fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: .9rem;
    max-width: 1100px;
    align-items: start;
}
.house-field {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: .8rem .9rem;
}
.house-field--flag { flex-direction: row; align-items: center; gap: .6rem; }
.house-field input[type="text"], .house-field input:not([type]), .house-field textarea {
    padding: .5rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font: inherit;
    width: 100%;
}
.house-fields__save { grid-column: 1 / -1; }

/* Foto/video attaccati a un argomento delle info casa (quadro elettrico,
   contatore): miniature piccole dentro il riquadro del campo. */
.house-field__media { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: .5rem; }
.house-field__shot { position: relative; display: inline-block; }
.house-field__shot img, .house-field__shot video {
    width: 76px; height: 76px; object-fit: cover;
    border-radius: 6px; border: 1px solid #e2e8f0; display: block; background: #f8fafc;
}
.house-field__x {
    position: absolute; top: -6px; right: -6px;
    width: 20px; height: 20px; line-height: 18px; padding: 0;
    border-radius: 50%; border: 1px solid #e2e8f0; background: #fff;
    color: #dc2626; cursor: pointer; font-size: 12px;
}
.house-field__add { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.house-field__add input[type="file"] { max-width: 190px; font-size: 12px; }

/* Chiedi all'app — la domanda in evidenza, la risposta grande e leggibile. */
.wiki-form { display: flex; gap: .5rem; max-width: 780px; margin-bottom: 1rem; }
.wiki-form input {
    flex: 1; padding: .8rem 1rem; font-size: 1rem;
    border: 1px solid #cbd5e1; border-radius: 10px;
}
.wiki-esempi { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: 1.5rem; }
.wiki-esempio {
    background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 999px;
    padding: .35rem .8rem; font: inherit; font-size: .85rem; color: #334155; cursor: pointer;
}
.wiki-esempio:hover { background: #e2e8f0; }
.wiki-risposta {
    background: #fff; border: 1px solid #e2e8f0; border-left: 4px solid var(--color-primary, #2563eb);
    border-radius: 10px; padding: 1.1rem 1.3rem; max-width: 780px; margin-bottom: .6rem;
}
.wiki-risposta p { margin: 0; font-size: 1.05rem; line-height: 1.55; }
.wiki-grezzo { max-width: 900px; line-height: 1.6; }

/* Chiedi all'app — le foto legate alla risposta (contatore, caldaia, ingresso). */
.wiki-foto { display: flex; flex-wrap: wrap; gap: .8rem; margin: .8rem 0 1rem; }
.wiki-foto figure { margin: 0; max-width: 190px; }
.wiki-foto img, .wiki-foto video {
    /* "contain" e non "cover": queste immagini si guardano per capire dov'è
       una cosa, e il QR del WiFi va inquadrato — ritagliarli li rende inutili. */
    width: 190px; height: 170px; object-fit: contain; display: block;
    border-radius: 8px; border: 1px solid #e2e8f0; background: #fff; padding: 4px;
}
.wiki-foto figcaption { font-size: .78rem; color: #64748b; margin-top: .3rem; line-height: 1.3; }
