:root {
  --bg: #f3f6f5;
  --surface: #ffffff;
  --ink: #163238;
  --muted: #667b80;
  --primary: #135d66;
  --primary-dark: #0d454c;
  --accent: #e7a44a;
  --line: #dce6e5;
  --danger: #a53a3a;
  --success: #227248;
  --shadow: 0 12px 30px rgba(20, 56, 62, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(145deg, #e7f1ef, #f7f4ec); }
.login-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 34px; box-shadow: var(--shadow); }
.brand-mark { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--primary); color: white; font-size: 24px; font-weight: 800; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(24px, 3vw, 36px); margin-bottom: 8px; }
h2 { font-size: clamp(22px, 2.5vw, 30px); margin-bottom: 0; }
h3 { margin-bottom: 0; }
.eyebrow { color: var(--primary); font-weight: 800; text-transform: uppercase; letter-spacing: .11em; font-size: 12px; margin: 14px 0 6px; }
.muted { color: var(--muted); }
label { display: flex; flex-direction: column; gap: 7px; color: #314f55; font-size: 14px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #c8d7d6; background: white; border-radius: 11px; padding: 11px 12px; color: var(--ink); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(19, 93, 102, .12); }
.login-card label { margin-top: 16px; }
button { border: 0; border-radius: 11px; padding: 11px 16px; font-weight: 800; }
.primary { background: var(--primary); color: white; }
.primary:hover { background: var(--primary-dark); }
.secondary { background: #e5eeee; color: var(--primary-dark); }
.ghost { background: transparent; color: var(--primary-dark); border: 1px solid var(--line); }
.full { width: 100%; margin-top: 20px; }
.form-error { min-height: 20px; color: var(--danger); margin: 12px 0 0; }
.topbar { display: flex; justify-content: space-between; gap: 20px; align-items: center; padding: 20px 4vw; background: white; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar h1 { font-size: 24px; }
.topbar .eyebrow { margin-top: 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.cloud-state, .user-badge { font-size: 13px; font-weight: 800; padding: 8px 10px; border-radius: 999px; background: #edf5f1; }
.cloud-state.online { color: var(--success); }
.cloud-state.offline { color: var(--danger); background: #fff0f0; }
.tabs { display: flex; gap: 8px; padding: 14px 4vw; overflow-x: auto; background: white; border-bottom: 1px solid var(--line); }
.tabs button { white-space: nowrap; background: transparent; color: var(--muted); }
.tabs button.active { background: var(--primary); color: white; }
main { padding: 28px 4vw 60px; max-width: 1500px; margin: auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 20px; }
.inline-actions { display: flex; gap: 8px; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px; box-shadow: var(--shadow); }
.compact { padding: 14px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stats-grid article { background: white; border: 1px solid var(--line); padding: 18px; border-radius: 16px; box-shadow: var(--shadow); }
.stats-grid strong { display: block; font-size: 30px; color: var(--primary); }
.stats-grid span { color: var(--muted); font-weight: 700; }
.filters { display: grid; grid-template-columns: minmax(180px, .7fr) minmax(260px, 1.3fr); gap: 14px; margin-bottom: 18px; align-items: end; }
.archive-filters { grid-template-columns: repeat(4, minmax(150px, 1fr)) auto auto; }
.guest-list { display: grid; gap: 16px; }
.seasonal-group { background: white; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); }
.seasonal-group-head { padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; gap: 14px; background: #f8fbfa; border-bottom: 1px solid var(--line); }
.seasonal-group-head h3 { margin: 0; }
.count-pill { background: var(--primary); color: white; border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 800; }
.guest-row { display: grid; grid-template-columns: minmax(190px, 1.2fr) minmax(160px, .9fr) minmax(170px, .9fr) auto; gap: 16px; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.guest-row:last-child { border-bottom: 0; }
.guest-name { font-weight: 900; }
.guest-meta { font-size: 13px; color: var(--muted); margin-top: 4px; line-height: 1.45; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.badge { border-radius: 999px; padding: 4px 8px; font-size: 12px; font-weight: 800; background: #edf2f2; }
.badge.overnight { background: #fff0d8; color: #805114; }
.badge.daily { background: #e7f3ff; color: #245d8a; }
.badge.left { background: #f0eded; color: #6b5a5a; }
.row-actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: end; }
.row-actions button { padding: 8px 10px; font-size: 13px; }
.empty-state { background: white; border: 1px dashed #bccdca; border-radius: 18px; padding: 40px 22px; text-align: center; color: var(--muted); }
.form-card { padding: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.span-2 { grid-column: span 2; }
.toggle-row { flex-direction: row; align-items: center; gap: 9px; }
.toggle-row input { width: auto; transform: scale(1.15); }
.people-header { display: flex; justify-content: space-between; align-items: end; margin: 28px 0 14px; }
.person-card { border: 1px solid var(--line); background: #fbfcfc; border-radius: 16px; padding: 18px; margin-bottom: 14px; }
.person-title { display: flex; justify-content: space-between; margin-bottom: 15px; }
.danger-link { background: transparent; color: var(--danger); padding: 0; }
.form-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; margin-bottom: 18px; }
.seasonals-list { display: grid; gap: 10px; }
.seasonal-item { background: white; border: 1px solid var(--line); border-radius: 14px; padding: 13px 15px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.seasonal-item.inactive { opacity: .58; }
.seasonal-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.danger-button { background: #fff0f0; color: var(--danger); border: 1px solid #efcaca; }
.danger-button:hover:not(:disabled) { background: #f9dddd; }
.danger-button:disabled { opacity: .45; cursor: not-allowed; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 100; max-width: 380px; background: #173c42; color: white; padding: 13px 16px; border-radius: 12px; box-shadow: var(--shadow); transform: translateY(140%); opacity: 0; transition: .25s ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: #8d3434; }
dialog { border: 0; border-radius: 20px; padding: 0; width: min(720px, calc(100% - 30px)); box-shadow: 0 25px 80px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(8, 28, 32, .56); }
.dialog-card { padding: 22px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.icon-btn { width: 38px; height: 38px; padding: 0; font-size: 25px; background: #edf2f2; }
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .archive-filters { grid-template-columns: repeat(2, 1fr); }
  .guest-row { grid-template-columns: 1fr 1fr; }
  .row-actions { justify-content: start; }
}
@media (max-width: 620px) {
  .topbar { position: static; align-items: flex-start; }
  .topbar-actions { justify-content: flex-start; }
  .cloud-state { display: none; }
  .section-head, .topbar { flex-direction: column; align-items: stretch; }
  .inline-actions { width: 100%; }
  .inline-actions input { flex: 1; }
  .stats-grid, .filters, .archive-filters, .form-grid, .inline-form { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .guest-row { grid-template-columns: 1fr; }
  .people-header { align-items: stretch; flex-direction: column; gap: 12px; }
  .seasonal-item { align-items: stretch; flex-direction: column; }
  .seasonal-actions { justify-content: stretch; }
  .seasonal-actions button { flex: 1; }
  .form-footer { flex-direction: column-reverse; }
  .form-footer button { width: 100%; }
}

/* Rubrica e scheda stagionale */
.directory-tools { display: grid; grid-template-columns: minmax(220px, 420px) 1fr; gap: 18px; align-items: end; margin-bottom: 18px; }
.alphabet-nav { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.alphabet-button { width: 34px; height: 34px; padding: 0; border-radius: 10px; background: #edf3f2; color: var(--primary-dark); }
.alphabet-button:hover { background: var(--primary); color: white; }
.seasonals-directory { display: grid; gap: 18px; }
.directory-letter-group { display: grid; grid-template-columns: 58px 1fr; gap: 14px; scroll-margin-top: 130px; }
.directory-letter { min-height: 58px; border-radius: 16px; display: grid; place-items: center; align-self: start; position: sticky; top: 130px; background: var(--primary); color: white; font-size: 28px; font-weight: 900; box-shadow: var(--shadow); }
.directory-entries { display: grid; gap: 9px; }
.seasonal-name-button { flex: 1; min-width: 220px; text-align: left; background: transparent; color: var(--ink); padding: 4px 0; }
.seasonal-name-button strong { display: block; font-size: 17px; }
.seasonal-name-button span { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; font-weight: 700; }

.wide-dialog { width: min(1180px, calc(100% - 24px)); max-width: none; max-height: calc(100vh - 24px); }
.seasonal-card-shell { padding: 0 24px 28px; max-height: calc(100vh - 24px); overflow-y: auto; }
.sticky-dialog-head { position: sticky; top: 0; z-index: 4; background: white; padding: 20px 0 16px; border-bottom: 1px solid var(--line); }
.dialog-head-actions { display: flex; align-items: center; gap: 12px; }
.year-control { min-width: 110px; }
.profile-section { padding: 25px 0; border-bottom: 1px solid var(--line); }
.profile-section:last-child { border-bottom: 0; }
.profile-section-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.profile-section h4 { margin: 20px 0 10px; color: var(--primary-dark); }
.profile-members-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.profile-member { border: 1px solid var(--line); background: #fbfcfc; border-radius: 15px; padding: 15px; display: grid; grid-template-columns: 1.2fr .8fr; gap: 12px; }
.profile-member-title { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; }
.profile-member .extra-age { grid-column: 1 / -1; }
.extras-head { margin-top: 22px; }
.empty-inline { border: 1px dashed #bdcdcb; border-radius: 13px; padding: 18px; color: var(--muted); text-align: center; grid-column: 1 / -1; }

.financial-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.financial-summary article { background: #f7faf9; border: 1px solid var(--line); border-radius: 14px; padding: 14px; min-height: 92px; }
.financial-summary span, .financial-summary small { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.financial-summary strong { display: block; margin-top: 7px; font-size: 19px; color: var(--primary-dark); }
.financial-summary small { margin-top: 5px; line-height: 1.35; }
.financial-summary .summary-total { background: #e8f1f0; border-color: #bad2cf; }
.financial-summary .summary-paid { background: #e9f6ee; border-color: #b8dbc6; }
.financial-summary .summary-due { background: #fff4e5; border-color: #ead0aa; }
.pricing-form, .payment-form { margin-bottom: 14px; box-shadow: none; }
.compact-footer { margin-top: 14px; }
.payment-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.payments-list { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.payment-table-head, .payment-row { display: grid; grid-template-columns: 120px 140px 1fr auto; gap: 14px; align-items: center; padding: 12px 14px; }
.payment-table-head { background: #eef4f3; color: var(--muted); font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .04em; }
.payment-row { background: white; border-top: 1px solid var(--line); }
.payment-row small { display: block; color: var(--muted); margin-top: 4px; }
.services-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.service-card { border: 1px solid var(--line); border-radius: 16px; padding: 18px; background: #fafcfc; }
.service-check { flex-direction: row; align-items: center; font-size: 17px; color: var(--ink); }
.service-check input { width: auto; transform: scale(1.25); }
.service-card p { min-height: 42px; margin: 13px 0; line-height: 1.45; }

@media (max-width: 950px) {
  .financial-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .payment-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .directory-tools { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .directory-letter-group { grid-template-columns: 42px 1fr; gap: 8px; }
  .directory-letter { min-height: 42px; font-size: 20px; position: static; }
  .profile-members-grid, .services-grid, .financial-summary, .payment-grid { grid-template-columns: 1fr; }
  .profile-member { grid-template-columns: 1fr; }
  .profile-member-title, .profile-member .extra-age { grid-column: 1; }
  .profile-section-head, .dialog-head-actions { align-items: stretch; flex-direction: column; }
  .payment-table-head { display: none; }
  .payment-row { grid-template-columns: 1fr 1fr; }
  .payment-row span:nth-child(3) { grid-column: 1 / -1; }
  .seasonal-card-shell { padding: 0 14px 20px; }
}
