@import url("style-mobile.php") screen and (max-width: 639px);
:root {
  --bg: #f6f4ef;
  --card: #fff;
  --text: #1c1b19;
  --muted: #5c5a56;
  --accent: #c45c26;
  --accent-dark: #9a4218;
  --border: #e2ddd4;
  --radius: 12px;
  --font: "Georgia", "Times New Roman", serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Loghi header: grandi su desktop, proporzionati su mobile */
  --logo-badge-size: clamp(4.75rem, 20vw, 8.5rem);
  --logo-badge-padding: 0.45rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body.site {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
}

@media (max-width: 639px) {
  .topbar-inner {
    padding: 0.75rem 0.85rem;
    justify-content: center;
  }
  /* Prima riga: i due loghi affiancati; sotto titolo e azioni */
  .logo-slot--left {
    order: 1;
  }
  .logo-slot--right {
    order: 2;
  }
  .topbar-main {
    order: 3;
    flex: 1 1 100%;
    width: 100%;
  }
}

.logo-slot {
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  min-height: calc(var(--logo-badge-size) + var(--logo-badge-padding) * 2);
  display: flex;
  align-items: center;
}

.logo-slot--left {
  justify-content: flex-start;
}

.logo-slot--right {
  justify-content: flex-end;
}

.topbar-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-width: 0;
}

@media (min-width: 640px) {
  .topbar-main {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }
}

.logo-badge {
  background: #fff;
  border-radius: 50%;
  padding: var(--logo-badge-padding);
  box-shadow: 0 2px 12px rgba(28, 27, 25, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--logo-badge-size);
  height: var(--logo-badge-size);
  flex-shrink: 0;
}

.logo-badge img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.brand {
  font-family: var(--font);
  font-size: clamp(1.2rem, 4vw, 1.45rem);
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.top-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: 0.95rem;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 639px) {
  .btn {
    min-height: 44px;
    padding: 0.55rem 1rem;
  }
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-dark);
}

.btn-primary:hover {
  background: var(--accent-dark);
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border-color: var(--border);
}

.btn-ghost:hover {
  border-color: var(--accent);
}

.otp-input {
  text-align: center;
  letter-spacing: 0.35em;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 1.35rem;
  padding: 0.75rem 0.9rem;
  max-width: 14rem;
  margin-left: auto;
  margin-right: auto;
}

.otp-actions {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.main {
  flex: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
  padding-bottom: max(2rem, env(safe-area-inset-bottom, 0));
  width: 100%;
}

@media (min-width: 640px) {
  .main {
    padding: 2rem 1.25rem;
  }
}

/* Più respiro su desktop (pagine pubbliche) */
@media (min-width: 900px) {
  .main {
    max-width: 980px;
  }
}

@media (min-width: 1200px) {
  .main {
    max-width: 1100px;
  }
}

h1 {
  font-family: var(--font);
  font-size: clamp(1.45rem, 5vw, 2rem);
  margin: 0 0 0.5rem;
  line-height: 1.2;
}

.newsletter-preview img {
  max-width: 100%;
  height: auto;
  display: block;
}

.lead {
  color: var(--muted);
  margin-top: 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin: 1.5rem 0;
}

.card.highlight {
  box-shadow: 0 8px 24px rgba(28, 27, 25, 0.08);
}

.meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.empty {
  color: var(--muted);
  font-style: italic;
}

.recent {
  margin-top: 2.5rem;
}

.news-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.news-list li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.news-list a {
  color: var(--accent-dark);
  font-weight: 600;
}

.footer {
  padding: 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Admin */
body.admin {
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--bg);
  margin: 0;
  min-height: 100vh;
}

.admin-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom, 0));
}

@media (min-width: 640px) {
  .admin-wrap {
    padding: 1.5rem;
  }
}

@media (min-width: 1100px) {
  .admin-wrap {
    max-width: 1400px;
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

.admin-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.admin-logos {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 1rem;
  gap: 0.75rem;
}

.admin-logos-side {
  flex: 1 1 0;
  min-width: 0;
}

.admin-logos .logo-badge {
  width: clamp(3.5rem, 14vw, 5.5rem);
  height: clamp(3.5rem, 14vw, 5.5rem);
  max-width: min(40vw, 5.75rem);
  max-height: min(40vw, 5.75rem);
  padding: var(--logo-badge-padding);
}

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.admin-nav a {
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 600;
}

.admin-nav a:hover {
  text-decoration: underline;
}

/* Dashboard: bottoni grandi touch-friendly */
.admin-dashboard-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.admin-dashboard-buttons + .admin-dashboard-buttons {
  margin-top: 1rem;
}

.card {
  width: 100%;
}

/* Mobile overrides moved to includes/style_mobile.php */
.admin-dashboard-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-height: 72px;
  padding: 1rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.admin-dashboard-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(28, 27, 25, 0.06);
}

.admin-dashboard-btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-dark);
}

.admin-dashboard-btn--primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  box-shadow: 0 4px 12px rgba(196, 92, 38, 0.25);
}

.admin-dashboard-btn--ghost {
  background: transparent;
}

.admin-dashboard-btn__label {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 0.2rem;
}

.admin-dashboard-btn--primary .admin-dashboard-btn__label {
  color: inherit;
}

.admin-dashboard-btn__desc {
  font-size: 0.85rem;
  color: var(--muted);
}

.admin-dashboard-btn--primary .admin-dashboard-btn__desc {
  color: rgba(255, 255, 255, 0.9);
}

/* Checkbox multipli (es. macro categorie) */
.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.checkbox-list label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  margin-bottom: 0;
  cursor: pointer;
}

.search-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  max-width: 480px;
}
.search-bar input[type="search"] {
  flex: 1;
  min-width: 200px;
}

/* Week picker (home) */
.week-card--center {
  text-align: center;
}
.week-picker {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 0.6rem;
  align-items: center;
  max-width: 420px;
  margin: 0 auto;
}
.week-date {
  max-width: 220px;
  justify-self: center;
  padding: 0.35rem 0.55rem !important;
  border-radius: 10px;
}
.week-arrow {
  width: 44px;
  height: 44px;
  padding: 0;
}
.week-toggle {
  display: none;
}

/* Newsletter title */
.newsletter-title {
  text-align: center;
  margin-top: 0;
}

/* Area pubblica: scelta anno (dashboard / block_enroll) */
.public-block-year-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  max-width: 22rem;
}
.public-block-year-form select {
  min-height: 44px;
}

.form-grid {
  display: grid;
  gap: 1rem;
  max-width: 420px;
}

.form-grid--split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  max-width: 560px;
}

@media (max-width: 639px) {
  .form-grid--split {
    grid-template-columns: 1fr;
  }
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="date"],
input[type="datetime-local"],
input[type="search"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}
input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(196, 92, 38, 0.2);
}

.input-with-prefix {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
}
.input-with-prefix .input-prefix {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.65rem;
  background: #faf8f4;
  color: var(--muted);
  font: inherit;
  border-right: 1px solid var(--border);
}
.input-with-prefix input {
  flex: 1;
  min-width: 0;
  border: none;
  border-radius: 0;
}
.input-with-prefix input:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--accent);
}

/* Data: testo gg/mm/aaaa + icona calendario */
.date-field {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
  position: relative;
}
.date-field__text {
  flex: 1;
  min-width: 0;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
.date-field__text:focus {
  box-shadow: inset 0 0 0 2px var(--accent) !important;
}
.date-field__picker-slot {
  position: relative;
  flex-shrink: 0;
  width: 2.85rem;
  min-height: 2.65rem;
  border-left: 1px solid var(--border);
  background: #faf8f4;
}
.date-field__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 2.65rem;
  color: var(--accent);
  pointer-events: none;
}
.date-field__icon {
  display: block;
}
.date-field__native {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
  font-size: 16px;
}
.date-field__picker-slot:hover {
  background: #f3ebe0;
}
.date-field__native:focus {
  outline: none;
}
.date-field__picker-slot:focus-within {
  box-shadow: inset 0 0 0 2px var(--accent);
}

textarea {
  min-height: 100px;
}

.msg-error {
  background: #fdecea;
  color: #8a1c0f;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.msg-ok {
  background: #e8f5e9;
  color: #1b5e20;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

/* «La mia squadra» (public/squadre.php): tinta = squadra reale, non .msg-ok (sempre verde) */
.squadra-tone {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-top: 0.35rem;
  margin-bottom: 0;
  font-weight: 650;
  border: 1px solid rgba(0, 0, 0, 0.08);
}
.squadra-tone.team-col-gialli {
  background: linear-gradient(180deg, #fffde7 0%, #fff9c4 40%, #fff8e1 100%);
  color: #4a3f00;
  border-color: rgba(249, 168, 37, 0.35);
}
.squadra-tone.team-col-verdi {
  background: linear-gradient(180deg, #f1f8e9 0%, #e8f5e9 45%, #e0f2f1 100%);
  color: #1b5e20;
  border-color: rgba(67, 160, 71, 0.35);
}
.squadra-tone.team-col-rossi {
  background: linear-gradient(180deg, #fff5f5 0%, #ffebee 40%, #fce4ec 100%);
  color: #b71c1c;
  border-color: rgba(229, 115, 115, 0.4);
}
.squadra-tone.team-col-blu {
  background: linear-gradient(180deg, #e3f2fd 0%, #e8f4fd 45%, #f5f9ff 100%);
  color: #0d47a1;
  border-color: rgba(66, 165, 245, 0.4);
}
.squadra-tone.team-col-parity-0 {
  background: linear-gradient(180deg, #faf5ff 0%, #f3e5f5 45%, #fce4ec 100%);
  color: #4a148c;
  border-color: rgba(171, 71, 188, 0.35);
}
.squadra-tone.team-col-parity-1 {
  background: linear-gradient(180deg, #e0f7fa 0%, #e8f5e9 45%, #f1f8e9 100%);
  color: #004d40;
  border-color: rgba(38, 166, 154, 0.35);
}
.squadra-tone.team-col-parity-2 {
  background: linear-gradient(180deg, #fff8e1 0%, #fff3e0 45%, #fafafa 100%);
  color: #e65100;
  border-color: rgba(251, 140, 0, 0.35);
}
.squadra-tone.team-col-parity-3 {
  background: linear-gradient(180deg, #fafafa 0%, #eceff1 45%, #ffffff 100%);
  color: #37474f;
  border-color: rgba(144, 164, 174, 0.45);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

table.data th,
table.data td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

table.data th {
  background: #faf8f4;
  font-size: 0.85rem;
}

input[type="checkbox"] {
  appearance: auto;
  -webkit-appearance: checkbox;
  accent-color: var(--accent);
}

/* Tabelle admin: scroll orizzontale su schermi stretti */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0.5rem 0 0;
}

/* Matrice iscrizioni: area un filo più larga; tabella dimensioni “naturali” (come prima), scroll se serve */
body.admin-matrix .admin-wrap {
  max-width: min(1800px, calc(100vw - 1.5rem));
  width: 100%;
}

body.admin-matrix .card--matrix {
  max-width: 100%;
}

.matrix-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  justify-content: space-between;
}

.matrix-toolbar-back {
  justify-content: flex-start;
  margin: 0;
}

.matrix-toolbar-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

/* Vista a schede: nascosta solo da tablet/desktop (il foglio mobile mostra/nasconde sotto 640px) */
@media (min-width: 640px) {
  body.admin-matrix .matrix-mobile-list {
    display: none;
  }
}

body.admin-matrix .table-scroll--matrix {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

body.admin-matrix .table-scroll--matrix table.data--matrix {
  width: max-content;
  min-width: 100%;
}

body.admin-matrix .table-scroll--matrix table.data--matrix th,
body.admin-matrix .table-scroll--matrix table.data--matrix td {
  padding: 0.65rem 0.75rem;
  vertical-align: top;
}

body.admin-matrix .matrix-th-nome {
  min-width: 240px;
}

body.admin-matrix .matrix-th-week {
  min-width: 210px;
}

body.admin-matrix .matrix-day-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 8px;
  align-items: stretch;
  width: 100%;
}

body.admin-matrix .matrix-day-card {
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  background: #fff;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
}

body.admin-matrix .matrix-day-label {
  font-weight: 700;
  font-size: 0.9rem;
}

body.admin-matrix .matrix-day-slot {
  font-weight: 800;
  font-size: 1rem;
  min-width: 22px;
  text-align: center;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  padding: 2px 9px;
  background: rgba(0, 0, 0, 0.02);
}

body.admin-matrix .matrix-week-notes {
  margin-top: 0.45rem;
  white-space: normal;
}

body.admin-matrix .matrix-week-actions {
  margin-top: 0.5rem;
}

/* Mobile overrides moved to includes/style_mobile.php */