*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button, a, [onclick] { touch-action: manipulation; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; background: #0d0d0d; min-height: 100%; min-height: 100dvh; }

:root {
  --blue: #2f8fef;
  --blue-light: #57b4ff;
  --blue-dark: #1565c0;
  --blue-bg: #e0f2fe;
  --green: #16a34a;
  --green-light: #22c55e;
  --green-dark: #15803d;
  --green-bg: #dcfce7;
  --brand-gradient: linear-gradient(135deg, var(--blue) 0%, var(--blue) 65%, var(--green-light) 100%);
  --black: #0d0d0d;
  --white: #ffffff;
  --gray-50: #f7f7f6;
  --gray-100: #ececea;
  --gray-200: #d4d4d0;
  --gray-400: #9a9a96;
  --gray-600: #5a5a58;
  --gray-800: #2a2a28;
  --red: #c0392b;
  --red-bg: #fdecea;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

body {
  font-family: 'Inter', sans-serif;
  /* Sfondo scuro come <html>: evita bande chiare nelle safe area (notch,
     home indicator) su iPhone se il body diventa visibile prima che il
     contenuto della pagina attiva venga dipinto sopra. */
  background: var(--black);
  color: var(--black);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.6;
}

/* ── PAGES ── */
.page { display: none; min-height: 100vh; min-height: 100dvh; }
.page.active { display: flex; flex-direction: column; }

/* ── LANDING ── */
#page-landing {
  background: var(--black);
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}
.landing-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 70% 70% at 75% 25%, rgba(47,143,239,0.38) 0%, transparent 70%),
    radial-gradient(ellipse 35% 40% at 10% 85%, rgba(22,163,74,0.15) 0%, transparent 60%);
}
.landing-grid {
  position: absolute; inset: 0; opacity: 0.04;
  background-image: linear-gradient(rgba(255,255,255,0.5) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,0.5) 1px, transparent 1px);
  background-size: 40px 40px;
}
.landing-content {
  position: relative; z-index: 1;
  text-align: center; padding: 2rem;
  max-width: 700px;
}
.landing-badge {
  display: inline-block;
  background: rgba(47,143,239,0.28);
  border: 1px solid rgba(87,180,255,0.45);
  color: #9cd4ff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 6px 16px;
  border-radius: 20px;
  margin-bottom: 0.75rem;
}
.landing-logo {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: clamp(3rem, 8vw, 5.5rem);
  font-weight: 900;
  color: var(--white);
  line-height: 0.95;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}
.landing-logo span { color: var(--blue-light); }
.landing-sub {
  font-size: 1rem;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 300;
  margin-bottom: 1rem;
}
.landing-tagline {
  font-size: 1.1rem;
  color: rgba(255,255,255,0.75);
  margin-bottom: 1.25rem;
  font-weight: 300;
}
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--brand-gradient);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  padding: 16px 36px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  letter-spacing: 0.02em;
}
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(47,143,239,0.35); }
.btn-primary:active { transform: translateY(0); }
#landing-guest, #landing-user { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }
@media (min-width: 769px) {
  #landing-user .btn-primary { width: 290px; }
}
.landing-contacts {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem 1.5rem;
  margin-top: 1.25rem; padding-top: 1rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.landing-contact-item {
  display: flex; align-items: center; gap: 6px;
  color: rgba(255,255,255,0.45); font-size: 0.8rem;
  text-decoration: none; transition: color 0.2s;
}
.landing-contact-item:hover { color: rgba(255,255,255,0.8); }
.landing-fields {
  display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap;
  margin-bottom: 2.5rem;
}
.field-pill {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 12px 20px;
  text-align: center;
}
.field-pill .label { font-size: 10px; color: rgba(255,255,255,0.4); text-transform: uppercase; letter-spacing: 0.1em; }
.field-pill .value { font-family: 'Barlow Condensed', sans-serif; font-size: 1.6rem; font-weight: 700; color: var(--blue-light); }
.field-pill .field-price { font-size: 0.82rem; color: rgba(255,255,255,0.75); margin-top: 4px; font-weight: 600; }
.field-pill .field-price-unit { font-size: 0.7rem; color: rgba(255,255,255,0.45); font-weight: 400; }
.field-pill .field-price-total { font-size: 0.7rem; color: rgba(255,255,255,0.4); margin-top: 2px; }


/* ── FOOTER COPYRIGHT ── */
.page-footer {
  text-align: center;
  font-size: 0.72rem;
  color: var(--gray-400);
  padding: 1.25rem 1rem;
  border-top: 1px solid var(--gray-100);
  margin-top: auto;
}

/* ── AUTH PAGE ── */
#page-auth { background: var(--gray-50); }
.auth-layout {
  min-height: calc(100vh - 64px);
  min-height: calc(100dvh - 64px);
  display: flex; align-items: center; justify-content: center;
  padding: 2rem 1rem;
}
.auth-card {
  background: var(--white); border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 2.5rem; width: 100%; max-width: 420px;
}
.auth-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.8rem; font-weight: 900; color: var(--black);
  margin-bottom: 0.4rem;
}
.auth-sub { font-size: 0.88rem; color: var(--gray-600); margin-bottom: 1.75rem; line-height: 1.5; }
.auth-new-label {
  font-size: 0.8rem; color: var(--gray-600);
  background: #f0fdf4; border: 1px solid #bbf7d0;
  border-radius: 8px; padding: 0.65rem 0.9rem;
  margin-bottom: 1rem;
}
.auth-dev-banner {
  background: #fef3c7; border: 1px solid #fcd34d;
  border-radius: 8px; padding: 0.65rem 0.9rem;
  font-size: 0.82rem; font-weight: 600; color: #92400e;
  margin-bottom: 1rem;
}
.auth-error { color: var(--red); font-size: 0.82rem; min-height: 1.2rem; margin-bottom: 0.5rem; }
.field-error { color: var(--red); font-size: 0.78rem; margin-top: 0.25rem; min-height: 1rem; }
input.input-error { border-color: var(--red) !important; }
.auth-back-btn {
  display: block; width: 100%; background: transparent; border: none;
  color: var(--gray-600); font-size: 0.85rem; cursor: pointer;
  text-align: center; padding: 0.75rem; margin-top: 0.5rem;
  font-family: inherit; transition: color 0.2s;
}
.auth-back-btn:hover { color: var(--black); }


/* ── LE MIE PRENOTAZIONI ── */
#page-myBookings { background: var(--gray-50); }
.myb-empty {
  text-align: center; padding: 3rem 1rem;
  color: var(--gray-600); font-size: 0.95rem;
}
.myb-card {
  background: var(--white); border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg); padding: 1.25rem 1.5rem;
  margin-bottom: 1rem; box-shadow: var(--shadow);
  transition: opacity 0.2s;
}
.myb-card.annullata { opacity: 0.55; }
.myb-card-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.5rem; }
.myb-field {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.5rem; font-weight: 900; color: var(--blue);
}
.myb-dt { font-size: 0.88rem; color: var(--gray-600); margin-top: 2px; }
.myb-id { font-size: 0.75rem; color: var(--gray-400); margin-bottom: 0.75rem; }
.myb-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ── TOPBAR ── */
.topbar {
  background: var(--black);
  padding: env(safe-area-inset-top, 0px) 2rem 0;
  min-height: calc(64px + env(safe-area-inset-top, 0px));
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
}
.topbar-logo {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.5rem; font-weight: 900;
  color: var(--white); letter-spacing: 0.02em;
  display: flex; align-items: center; gap: 8px;
  order: 2;
}
.topbar-nav { order: 1; }
.topbar-logo span { color: var(--blue-light); }
.topbar-favicon {
  width: 30px; height: 30px;
  border-radius: 8px;
  flex-shrink: 0;
}

.topbar-nav { display: flex; gap: 8px; align-items: center; }
.nav-btn {
  background: transparent; border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.7); padding: 8px 16px;
  border-radius: 8px; cursor: pointer; font-size: 0.85rem; font-weight: 500;
  transition: all 0.2s; font-family: inherit;
}
.nav-btn:hover { border-color: rgba(255,255,255,0.4); color: #fff; }
.nav-btn.active, .nav-btn.green { background: var(--brand-gradient); border-color: transparent; color: #fff; }

/* ── BOOKING PAGE ── */
#page-booking { background: var(--gray-50); }
.booking-layout {
  width: 100%; max-width: 780px; margin: 0 auto; padding: 2.5rem 1.5rem;
  flex: 1;
}
.page-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 2.2rem; font-weight: 900;
  color: var(--black); letter-spacing: -0.01em;
  margin-bottom: 0.25rem;
}

.card {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.card-title {
  font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--gray-400); margin-bottom: 1.25rem;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.form-row.one { grid-template-columns: 1fr; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }
@media(max-width: 600px) { .form-row, .form-row.three { grid-template-columns: 1fr; } }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.8rem; font-weight: 600; color: var(--gray-800); }
.form-group input, .form-group select {
  width: 100%; min-width: 0;
  height: 44px; padding: 0 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 0.95rem; font-family: inherit;
  color: var(--black);
  background: var(--white);
  transition: border-color 0.2s;
  outline: none;
}
.form-group input:focus, .form-group select:focus { border-color: var(--blue); }
.form-group input.error, .form-group select.error { border-color: var(--red); }
.field-hint { font-size: 0.75rem; color: var(--gray-400); }
.field-error { font-size: 0.75rem; color: var(--red); }

/* Tipo campo selector */
.field-type-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.field-type-btn {
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 8px;
  text-align: center; cursor: pointer;
  transition: all 0.2s; background: var(--white);
}
.field-type-btn:hover { border-color: var(--blue); background: var(--blue-bg); }
.field-type-btn.selected { border-color: var(--blue); background: var(--blue-bg); }
.field-type-btn .type-code {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.8rem; font-weight: 900;
  color: var(--blue-dark); line-height: 1;
}
.field-type-btn .type-desc { font-size: 0.7rem; color: var(--gray-600); margin-top: 2px; }

/* Slots */
.slots-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px,1fr)); gap: 8px; margin-top: 0.75rem; }
.slot-btn {
  border: 1.5px solid var(--gray-200);
  border-radius: 8px; padding: 10px 4px;
  text-align: center; cursor: pointer;
  font-size: 0.85rem; font-weight: 500;
  color: var(--black); background: var(--white);
  transition: all 0.2s;
}
.slot-btn:hover:not(.booked) { border-color: var(--blue); background: var(--blue-bg); color: var(--blue-dark); }
.slot-btn.selected { border-color: transparent; background: var(--brand-gradient); color: #fff; }
.slot-btn.booked {
  background: var(--gray-100); color: var(--gray-400);
  border-color: var(--gray-100); cursor: not-allowed;
  text-decoration: line-through;
}
.no-date-msg { font-size: 0.85rem; color: var(--gray-400); padding: 1rem 0; text-align: center; }


/* Phone verify */
.phone-wrap { display: flex; gap: 8px; }
.phone-wrap input { flex: 1; }
.verify-btn {
  height: 44px; padding: 0 16px;
  background: var(--brand-gradient); color: #fff;
  border: none; border-radius: var(--radius);
  font-size: 0.85rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  font-family: inherit; transition: filter 0.2s;
}
.verify-btn:hover { filter: brightness(1.08); }
.verify-btn:disabled { background: var(--gray-200); color: var(--gray-400); cursor: not-allowed; }
.verified-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: #dcfce7; color: #15803d;
  font-size: 0.75rem; font-weight: 600;
  padding: 4px 10px; border-radius: 20px;
}
.otp-wrap { display: flex; gap: 8px; margin-top: 8px; }
.otp-wrap input { width: 120px; letter-spacing: 0.3em; text-align: center; font-weight: 700; }

/* Submit btn */
.submit-btn {
  width: 100%; height: 52px;
  background: var(--brand-gradient); color: #fff;
  border: none; border-radius: var(--radius);
  font-size: 1rem; font-weight: 700;
  cursor: pointer; font-family: inherit;
  transition: all 0.2s; letter-spacing: 0.02em;
}
.submit-btn:hover { filter: brightness(1.08); }
.submit-btn:disabled { background: var(--gray-200); color: var(--gray-400); cursor: not-allowed; }

/* ── CONFIRM ── */
#page-confirm { background: var(--gray-50); }
.confirm-center {
  flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem;
}
.confirm-box {
  background: var(--white); border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg); padding: 3rem 2.5rem;
  max-width: 520px; width: 100%; text-align: center;
  box-shadow: var(--shadow-lg);
}
.confirm-icon {
  width: 72px; height: 72px;
  background: #dcfce7; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1.5rem;
  font-size: 2rem;
}
.confirm-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 2rem; font-weight: 900;
  color: var(--black); margin-bottom: 0.5rem;
}
.confirm-sub { color: var(--gray-600); font-size: 0.9rem; margin-bottom: 2rem; }
.confirm-detail {
  background: var(--gray-50);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: left;
  margin-bottom: 1.5rem;
}
.confirm-row {
  display: flex; justify-content: space-between;
  padding: 6px 0; font-size: 0.9rem;
}
.confirm-row:not(:last-child) { border-bottom: 1px solid var(--gray-100); }
.confirm-row .label { color: var(--gray-600); }
.confirm-row .value { font-weight: 600; }

/* ── ADMIN ── */
#page-admin { background: var(--gray-50); }
.admin-layout { display: flex; flex: 1; min-height: 0; }
.admin-sidebar {
  width: 220px; background: var(--black); flex-shrink: 0;
  padding: 1.5rem 1rem; display: flex; flex-direction: column;
  position: sticky; top: 64px; height: calc(100vh - 64px); height: calc(100dvh - 64px); overflow-y: auto;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  color: rgba(255,255,255,0.6); cursor: pointer;
  font-size: 0.85rem; font-weight: 500;
  transition: all 0.2s; border: none; background: transparent;
  font-family: inherit; text-align: left;
}
.sidebar-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-link.active { background: var(--brand-gradient); color: #fff; }
.sidebar-link svg { width: 16px; height: 16px; flex-shrink: 0; }

.admin-main { flex: 1; overflow-y: auto; padding: 2rem; }
.admin-section { display: none; }
.admin-section.active { display: block; }
.admin-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.5rem;
}
.admin-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.8rem; font-weight: 900; color: var(--black);
}

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card {
  background: var(--white); border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg); padding: 1.25rem;
}
.stat-card .sc-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--gray-400); font-weight: 700; }
.stat-card .sc-value { font-family: 'Barlow Condensed', sans-serif; font-size: 2.2rem; font-weight: 900; color: var(--black); line-height: 1; margin-top: 4px; }
.stat-card .sc-sub { font-size: 0.75rem; color: var(--gray-600); margin-top: 4px; }

/* Table */
.table-wrap { background: var(--white); border: 1px solid var(--gray-100); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); }
.table-filter { padding: 1rem 1.25rem; border-bottom: 1px solid var(--gray-100); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filter-input {
  height: 36px; padding: 0 12px; border: 1.5px solid var(--gray-200);
  border-radius: 8px; font-size: 0.85rem; font-family: inherit;
  flex: 1; min-width: 160px; outline: none;
}
.filter-input:focus { border-color: var(--blue); }
.filter-select {
  height: 36px; padding: 0 10px; border: 1.5px solid var(--gray-200);
  border-radius: 8px; font-size: 0.85rem; font-family: inherit;
  background: var(--white); cursor: pointer; outline: none;
}

/* ── Calendario prenotazioni (admin) ── */
.book-calendar {
  background: var(--white); border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg); padding: 1rem;
  margin-bottom: 1.25rem; box-shadow: var(--shadow);
  max-width: 340px;
}
.book-cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; gap: 0.5rem; }
.book-cal-nav { display: flex; gap: 6px; flex-shrink: 0; }
.book-cal-nav button, .book-cal-today {
  height: 32px; border-radius: 8px; border: 1px solid var(--gray-200);
  background: var(--white); cursor: pointer; font-family: inherit;
  transition: all 0.2s; color: var(--gray-800); flex-shrink: 0;
}
.book-cal-nav button { width: 32px; font-size: 1.1rem; line-height: 1; }
.book-cal-today { padding: 0 10px; font-size: 0.78rem; font-weight: 600; }
.book-cal-nav button:hover, .book-cal-today:hover { background: var(--gray-50); border-color: var(--gray-400); }
.book-cal-title {
  font-family: 'Barlow Condensed', sans-serif; font-size: 1.3rem;
  font-weight: 900; text-transform: capitalize; text-align: center;
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.book-cal-dow {
  display: grid; grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}
.book-cal-dow span {
  text-align: center; font-size: 0.7rem; font-weight: 700;
  color: var(--gray-400); text-transform: uppercase;
}
.book-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.book-cal-day {
  position: relative; aspect-ratio: 1; display: flex; align-items: center;
  justify-content: center; border-radius: 8px; cursor: pointer;
  font-size: 0.85rem; font-weight: 600; color: var(--black);
  border: 1.5px solid transparent; transition: all 0.15s;
}
.book-cal-day:hover { background: var(--gray-50); }
.book-cal-day.empty { visibility: hidden; cursor: default; }
.book-cal-day.today { border-color: var(--blue); }
.book-cal-day.has-bookings::after {
  content: ''; position: absolute; bottom: 5px; width: 5px; height: 5px;
  border-radius: 50%; background: var(--blue);
}
.book-cal-day.selected { background: var(--brand-gradient); color: #fff; border-color: transparent; }
.book-cal-day.selected::after { background: #fff; }
.book-cal-filter-active {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 1rem; padding-top: 0.9rem; border-top: 1px solid var(--gray-100);
  font-size: 0.85rem; color: var(--gray-600);
}

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
thead th {
  text-align: left; padding: 12px 16px;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--gray-400); font-weight: 700;
  border-bottom: 1px solid var(--gray-100);
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--gray-50); color: var(--gray-800); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--gray-50); }

.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
}
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-owner  { background: #3b0000; color: #fca5a5; }
.badge-admin  { background: #fee2e2; color: #b91c1c; }
.badge-red    { background: var(--red-bg); color: var(--red); }
.badge-amber  { background: var(--amber-bg); color: var(--amber); }
.badge-gray   { background: var(--gray-100); color: var(--gray-600); }

.action-btn {
  background: transparent; border: 1px solid var(--gray-200);
  border-radius: 6px; padding: 5px 10px;
  font-size: 0.78rem; cursor: pointer; font-family: inherit;
  color: var(--gray-800); transition: all 0.2s;
}
.action-btn:hover { border-color: var(--gray-400); }
.action-icon { padding: 5px 9px; font-size: 0.85rem; }
.action-btn.danger:hover { border-color: var(--red); color: var(--red); }
.action-btn.success:hover { border-color: var(--green); color: var(--green); }
.action-btns { display: flex; gap: 6px; }

/* Admin add btn */
.add-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--brand-gradient); color: #fff;
  border: none; border-radius: var(--radius); padding: 10px 20px;
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: filter 0.2s;
}
.add-btn:hover { filter: brightness(1.08); }

/* Modal */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 1000;
  align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white); border-radius: var(--radius-lg);
  padding: 2rem; max-width: 500px; width: 100%;
  box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto;
}
#modal-add-booking .modal,
#modal-edit-booking .modal { max-width: 640px; }
.modal-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.5rem; font-weight: 900;
  margin-bottom: 1.25rem;
}
.modal-btns { display: flex; gap: 10px; margin-top: 1.5rem; justify-content: flex-end; }
.modal-btn-cancel {
  padding: 10px 20px; background: var(--gray-100);
  border: none; border-radius: var(--radius);
  font-family: inherit; font-size: 0.9rem; cursor: pointer; font-weight: 500;
}
.modal-btn-submit {
  padding: 10px 24px; background: var(--brand-gradient); color: #fff;
  border: none; border-radius: var(--radius);
  font-family: inherit; font-size: 0.9rem; cursor: pointer; font-weight: 600;
  transition: filter 0.2s;
}
.modal-btn-submit:hover { filter: brightness(1.08); }

/* Modal — header / footer / close (usati nel modal cliente) */
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem;
}
.modal-header .modal-title { margin-bottom: 0; }
.modal-close {
  background: none; border: none; font-size: 1.5rem; line-height: 1;
  cursor: pointer; color: var(--gray-400); padding: 0 4px;
}
.modal-close:hover { color: var(--black); }
.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end; margin-top: 1.5rem;
}
.btn-cancel {
  padding: 10px 20px; background: var(--gray-100); border: none;
  border-radius: var(--radius); font-family: inherit; font-size: 0.9rem;
  cursor: pointer; font-weight: 500;
}
.btn-save {
  padding: 10px 24px; background: var(--brand-gradient); color: #fff; border: none;
  border-radius: var(--radius); font-family: inherit; font-size: 0.9rem;
  cursor: pointer; font-weight: 600; transition: filter 0.2s;
}
.btn-save:hover { filter: brightness(1.08); }

/* Toggle switch — conf. password */
.pw-toggle { display:inline-flex; align-items:center; cursor:pointer; user-select:none; }
.pw-toggle input { display:none; }
.pw-toggle-track {
  width:40px; height:22px; background:var(--gray-200); border-radius:11px;
  position:relative; transition:background 0.2s;
}
.pw-toggle-track::after {
  content:''; position:absolute; top:3px; left:3px;
  width:16px; height:16px; border-radius:50%;
  background:#fff; box-shadow:0 1px 3px rgba(0,0,0,.2);
  transition:transform 0.2s;
}
.pw-toggle input:checked + .pw-toggle-track { background:var(--blue); }
.pw-toggle input:checked + .pw-toggle-track::after { transform:translateX(18px); }

/* Admin login */
.admin-login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; min-height: 100dvh; background: var(--black);
}
.admin-login-box {
  background: #1a1a1a; border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-lg); padding: 2.5rem; width: 360px;
  text-align: center;
}
.admin-login-logo {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 2rem; font-weight: 900; color: var(--white);
  margin-bottom: 0.25rem;
}
.admin-login-logo span { color: var(--blue-light); }
.admin-login-sub { font-size: 0.8rem; color: rgba(255,255,255,0.4); margin-bottom: 2rem; }
.admin-login-input {
  width: 100%; height: 46px; padding: 0 14px;
  background: rgba(255,255,255,0.06); border: 1.5px solid rgba(255,255,255,0.1);
  border-radius: var(--radius); color: #fff; font-size: 0.95rem; font-family: inherit;
  margin-bottom: 12px; outline: none;
}
.admin-login-input:focus { border-color: var(--blue); }
.admin-login-input::placeholder { color: rgba(255,255,255,0.3); }
.admin-login-btn {
  width: 100%; height: 46px; background: var(--brand-gradient);
  color: #fff; border: none; border-radius: var(--radius);
  font-size: 0.95rem; font-weight: 700; cursor: pointer;
  font-family: inherit; transition: filter 0.2s;
}
.admin-login-btn:hover { filter: brightness(1.08); }
.login-error { color: #f87171; font-size: 0.8rem; margin-top: 8px; }

/* Alert */
.alert {
  padding: 12px 16px; border-radius: var(--radius); font-size: 0.88rem;
  margin-bottom: 1rem;
}
.alert-danger { background: var(--red-bg); color: var(--red); border: 1px solid rgba(192,57,43,0.2); }
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid rgba(21,128,61,0.2); }

/* Toast */
.toast {
  position: fixed; bottom: 2rem; right: 2rem; z-index: 9999;
  background: var(--black); color: #fff;
  padding: 14px 20px; border-radius: var(--radius);
  font-size: 0.88rem; font-weight: 500;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px); opacity: 0;
  transition: all 0.3s; pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.green { background: var(--green); }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--gray-400); font-size: 0.9rem; }

/* ── Logs ──────────────────────────────────────────────── */
.log-filters { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ── Imposta Orari ─────────────────────────────────────── */
.orari-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  padding: 1.25rem;
}
.orari-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
}
.orari-card-head {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.orari-field-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-600);
}
.orari-add-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.orari-add-form input[type="time"] {
  padding: 6px 10px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--gray-800);
  background: var(--gray-50);
  width: 100px;
}
.orari-arrow { color: var(--gray-400); font-size: 1rem; }
.orari-slots {
  padding: 1rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 56px;
}
.slot-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--blue-bg);
  color: var(--blue-dark);
  border-radius: 20px;
  padding: 4px 10px 4px 12px;
  font-size: 0.78rem;
  font-weight: 600;
}
.slot-tag-del {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--blue-dark);
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.slot-tag-del:hover { opacity: 1; }
.no-slots-msg {
  font-size: 0.82rem;
  color: var(--gray-400);
  align-self: center;
}

/* ── Link di rimando (login admin) ────────────────────────── */
.admin-back-link {
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,0.4); font-size: 0.8rem;
  margin-top: 0.75rem; display: block; width: 100%;
  text-align: center;
}
.admin-back-link:hover { color: rgba(255,255,255,0.7); }

/* ═══════════════════════════════════════════
   MOBILE — Admin panel (max 768px)
   Desktop layout invariato
   ═══════════════════════════════════════════ */
/* ═══════════════════════════════════════════
   TABLET (769px – 1024px)
   ═══════════════════════════════════════════ */
@media (min-width: 769px) and (max-width: 1024px) {
  .admin-sidebar { width: 180px; padding: 1rem 0.75rem; }
  .sidebar-link  { padding: 9px 10px; font-size: 0.82rem; gap: 8px; }
  .admin-main    { padding: 1.5rem; }
  .booking-layout { padding: 1.75rem 1.25rem; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  #modal-add-booking .modal,
  #modal-edit-booking .modal { max-width: 560px; }
}

/* ═══════════════════════════════════════════
   MOBILE — tutto (max 768px)
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {

  /* Niente overflow orizzontale */
  img, video, iframe { max-width: 100%; height: auto; }
  input, select, textarea { max-width: 100%; min-width: 0; }

  /* Topbar: solo favicon a destra, bottoni (emoji-only) a sinistra */
  .topbar { padding: 0 1rem; min-height: 56px; flex-shrink: 0; }
  .topbar-logo { font-size: 0; gap: 0; } /* nasconde testo IKONIC SPORT */
  .topbar-favicon { width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0; }
  .topbar-nav { gap: 6px; align-items: center; }
  .nav-label { display: none; } /* bottoni topbar: solo emoji su mobile */
  .nav-btn {
    padding: 8px 12px; font-size: 1rem;
    border-radius: 8px; white-space: nowrap;
    border-color: rgba(255,255,255,0.2);
    line-height: 1;
  }
  /* Prenota il campo: solo 2 bottoni, c'è spazio per il testo */
  #booking-topbar-nav .nav-label { display: inline; }
  #booking-topbar-nav .nav-btn { font-size: 0.78rem; }

  /* Le mie prenotazioni: stessa dimensione di "Prenota il campo" */
  #myb-topbar-nav .nav-label { display: inline; }
  #myb-topbar-nav .nav-btn { font-size: 0.78rem; }

  /* ── LANDING — riempie tutta la pagina, distribuita elegantemente ── */
  .landing-content {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-evenly;
    padding: 2.75rem 1.25rem 2rem;
    gap: 0.5rem;
  }
  .landing-badge,
  .landing-logo,
  .landing-sub,
  .landing-tagline { margin-bottom: 0; }
  .landing-fields {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    width: 100%;
    margin-bottom: 0;
  }
  .field-pill { padding: 10px 8px; min-width: 0; }
  .field-pill .field-price-unit { display: none; }
  .field-pill .value,
  .field-pill .field-price,
  .field-pill .field-price-total { overflow-wrap: break-word; }
  #landing-guest, #landing-user { width: 100%; }
  .btn-primary { width: 100%; justify-content: center; }
  .landing-contacts { width: 100%; margin-top: 0; gap: 0.3rem 1rem; }
  .landing-contact-item { font-size: 0.72rem; }

  /* ── PAGINE PUBBLICHE ── */

  /* Auth */
  .auth-layout { padding: 1.25rem 1rem; flex: 1; min-height: 0; align-items: center; justify-content: center; }
  .auth-card { padding: 1.75rem 1.25rem; width: 100%; max-width: 100%; border-radius: 16px; }
  .auth-title { font-size: 1.6rem; margin-bottom: 0.25rem; }
  .auth-sub { font-size: 0.85rem; margin-bottom: 1.5rem; }
  #auth-phone-prefix { width: 100px !important; flex-shrink: 0; font-size: 0.85rem !important; }

  /* Booking */
  .booking-layout { padding: 1.25rem 1rem; max-width: 100%; }
  .page-title { font-size: 1.7rem; margin-bottom: 0.75rem; }
  .card { padding: 1.1rem; margin-bottom: 1rem; border-radius: 12px; }
  .card-title { font-size: 0.78rem; margin-bottom: 0.75rem; }
  .field-type-grid { gap: 8px; }
  .field-type-btn { padding: 14px 6px; border-radius: 10px; }
  .field-type-btn .type-code { font-size: 1.5rem; }
  .field-type-btn .type-desc { font-size: 0.68rem; margin-top: 3px; }
  .slots-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .slot-btn { font-size: 0.8rem; padding: 10px 4px; border-radius: 8px; }
  .submit-btn { height: 52px; font-size: 1rem; border-radius: 12px; margin-top: 0.5rem; }

  /* My Bookings */
  .myb-card { padding: 1rem 1.1rem; border-radius: 12px; margin-bottom: 0.85rem; }
  .myb-card-head { flex-direction: column; gap: 0.3rem; align-items: flex-start; }
  .myb-field { font-size: 1.2rem; }
  .myb-date { font-size: 0.82rem; }
  .myb-status { font-size: 0.72rem; padding: 3px 8px; }
  .myb-actions { gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
  .myb-actions .nav-btn { font-size: 0.8rem; padding: 8px 12px; }

  /* Confirm */
  .confirm-center { padding: 1.25rem 1rem; align-items: center; justify-content: center; }
  .confirm-box { padding: 2rem 1.25rem; border-radius: 16px; width: 100%; }
  .confirm-title { font-size: 1.6rem; }
  .confirm-sub { font-size: 0.87rem; }
  .confirm-detail { margin: 1.25rem 0; }
  .confirm-row { font-size: 0.87rem; padding: 6px 0; }
  .confirm-icon { width: 60px; height: 60px; font-size: 1.6rem; margin-bottom: 1.25rem; }

  /* ── ADMIN ── */
  .admin-layout { flex-direction: column; }
  .admin-sidebar {
    width: 100%; height: auto; position: static;
    padding: 0.4rem 0.75rem; flex-direction: column; gap: 0;
  }
  .sidebar-nav {
    flex-direction: row; overflow-x: auto; gap: 4px;
    padding-bottom: 4px; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .sidebar-nav::-webkit-scrollbar { display: none; }
  .sidebar-link { flex-shrink: 0; padding: 7px 11px; font-size: 0.77rem; white-space: nowrap; }
  .sidebar-link svg { display: none; }
  .admin-sidebar > div:not(.sidebar-nav) { display: none; }
  .admin-main { padding: 0.9rem; overflow-y: visible; }
  .admin-header { flex-direction: column; align-items: flex-start; gap: 0.6rem; margin-bottom: 0.9rem; }
  .admin-header > div:last-child { width: 100%; display: flex; flex-wrap: wrap; gap: 0.5rem; }
  .admin-header .add-btn,
  .admin-header #maintenance-btn { flex: 1; text-align: center; justify-content: center; }
  .admin-title { font-size: 1.3rem; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; margin-bottom: 1.25rem; }
  .stat-card { padding: 0.9rem; }
  .stat-card .sc-value { font-size: 1.8rem; }

  /* Calendario prenotazioni: su mobile riempie la larghezza disponibile
     invece di restare stretto con spazio vuoto a destra */
  .book-calendar { padding: 0.9rem; margin-bottom: 1rem; max-width: 100%; }
  .book-cal-header { gap: 0.35rem; }
  .book-cal-title { font-size: 0.95rem; }
  .book-cal-nav button { width: 28px; height: 28px; font-size: 1rem; }
  .book-cal-today { height: 28px; padding: 0 8px; font-size: 0.72rem; }
  .book-cal-day { font-size: 0.78rem; }
  .book-cal-dow span { font-size: 0.62rem; }
  .book-cal-filter-active { font-size: 0.8rem; }

  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap table { min-width: 520px; }
  .table-filter { flex-direction: column; padding: 0.75rem; }
  .filter-input { width: 100%; min-width: 0; }
  .filter-select { width: 100%; }
  .log-filters { flex-direction: column; width: 100%; }
  .action-btn { padding: 5px 8px; font-size: 0.74rem; }
  tbody td { padding: 9px 10px; font-size: 0.83rem; }
  thead th { padding: 9px 10px; }

  /* Admin login */
  .admin-login-wrap { padding: 2rem 1rem; align-items: center; }
  .admin-login-box { width: 100%; max-width: 380px; padding: 1.75rem 1.25rem; }

  /* Modali */
  .modal { width: 100% !important; max-width: 100% !important; padding: 1.25rem 1rem;
           border-radius: 16px 16px 0 0; margin: 0; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .form-row { grid-template-columns: 1fr !important; }
  .modal-btns { flex-direction: column-reverse; gap: 8px; }
  .modal-btn-cancel, .modal-btn-submit { width: 100%; text-align: center; padding: 13px; font-size: 0.95rem; }
  .modal-footer { flex-direction: column-reverse; gap: 8px; }
  .btn-cancel, .btn-save { width: 100%; text-align: center; padding: 13px; font-size: 0.95rem; }

  /* Orari e scuole */
  .orari-grid { grid-template-columns: 1fr; padding: 0.75rem; }
  .orari-add-form input[type="time"] { width: 80px; }
  #table-schools { min-width: 700px; }
  #table-schools td > div { flex-wrap: wrap; gap: 4px; }
  #admin-scuole > div:nth-child(2) { font-size: 0.8rem; }
  #table-ipblocks { min-width: 650px; }

  /* Pagamenti */
  #admin-payments .admin-header .add-btn { width: 100%; text-align: center; }

  /* Credits footer */
  #admin-mobile-credits {
    display: block; padding: 1rem; text-align: center;
    font-size: 0.7rem; color: var(--gray-400);
    border-top: 1px solid var(--gray-100); line-height: 1.8; margin-top: 0.75rem;
  }

  /* Toast */
  .toast { left: 0.75rem; right: 0.75rem; bottom: 1.25rem; text-align: center; }

  /* Form rows generali */
  .form-row, .form-row.three { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════
   PICCOLI TELEFONI (max 390px)
   ═══════════════════════════════════════════ */
@media (max-width: 390px) {
  /* Nascondi testo bottoni topbar: solo emoji */
  .nav-label { display: none; }
  .topbar { padding: 0 0.75rem; min-height: 52px; }
  .topbar-favicon { width: 30px; height: 30px; }
  .nav-btn { padding: 6px 9px; font-size: 0.75rem; }

  /* Landing — schermi piccoli */
  .landing-content { padding: 1.5rem 1rem; }
  .landing-logo { font-size: 2.6rem; }

  /* Auth */
  .auth-card { padding: 1.5rem 1rem; }
  #auth-phone-prefix { width: 88px !important; }

  /* Booking */
  .booking-layout { padding: 1rem 0.75rem; }
  .page-title { font-size: 1.5rem; }
  .slots-grid { grid-template-columns: repeat(2, 1fr); }

  /* Admin */
  .sidebar-link { padding: 6px 8px; font-size: 0.73rem; }
}

/* ═══════════════════════════════════════════
   iOS SAFE AREA (viewport-fit=cover)
   ═══════════════════════════════════════════ */

/* Impedisce il rubber-band overscroll (sia verticale che orizzontale) che
   su iOS Safari fa "molleggiare" la pagina quando si trascina col dito,
   anche in presenza di un minimo overflow — e espone il canvas bianco
   sotto (html e body hanno già lo sfondo scuro impostato in cima al file) */
html, body { overscroll-behavior: none; }

/* Footer pubblico: padding extra per il tasto home iPhone */
.page-footer {
  padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
}

/* Pagina conferma: spazio per il tasto home */
.confirm-center {
  padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
}

/* Admin sidebar sticky: offset per topbar safe-area-aware */
.admin-sidebar {
  top: calc(64px + env(safe-area-inset-top, 0px));
  height: calc(100dvh - 64px - env(safe-area-inset-top, 0px));
}

/* Admin credits */
#admin-mobile-credits {
  padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
}

/* Mobile: sidebar non sticky (topbar già gestita nel blocco mobile principale) */
@media (max-width: 768px) {
  .topbar { padding-top: env(safe-area-inset-top, 0px); }
  .admin-sidebar { top: 0; height: auto; }
}

/* Padding bottom globale su tutte le pagine per home indicator */
.page { padding-bottom: env(safe-area-inset-bottom, 0px); }

@keyframes _spin { to { transform: rotate(360deg); } }
.btn-spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: _spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
