:root {
  --blue: #1565C0;
  --blue-light: #1E88E5;
  --blue-pale: #E3F0FF;
  --orange: #E65100;
  --orange-light: #FF8F00;
  --red: #C62828;
  --green: #2E7D32;
  --yellow: #F9A825;
  --gray-50: #F8F9FA;
  --gray-100: #F1F3F4;
  --gray-200: #E8EAED;
  --gray-300: #DADCE0;
  --gray-400: #BDC1C6;
  --gray-500: #9AA0A6;
  --gray-600: #80868B;
  --gray-700: #5F6368;
  --gray-800: #3C4043;
  --gray-900: #202124;
  --white: #FFFFFF;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
  --radius: 8px;
  --radius-lg: 12px;
  --font: 'DM Sans', system-ui, sans-serif;
  --mono: 'DM Mono', monospace;
}

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

/* ── DOCUMENTI · stato scheda + badge settimane ──────────── */
.doc-stato {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.doc-stato-iniziale {
  background: #E8F5E9;
  color: #1B5E20;
  border: 1px solid #A5D6A7;
}
.doc-stato-modificata {
  background: #FFF3E0;
  color: #E65100;
  border: 1px solid #FFB74D;
}
.doc-sett-badge {
  display: inline-block;
  padding: 2px 6px;
  margin: 0 1px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--mono);
}
.doc-sett-badge.sett1 { background: #FFEBEE; color: #B71C1C; }
.doc-sett-badge.sett2 { background: #FFF3E0; color: #E65100; }
.doc-sett-badge.sett3 { background: #FFFDE7; color: #827717; }


body {
  font-family: var(--font);
  font-size: 15px;
  color: var(--gray-900);
  background: var(--gray-50);
  min-height: 100vh;
}

/* ── LOGIN SCREEN ────────────────────────────────── */
#login-screen {
  display: none;
  position: fixed; inset: 0; z-index: 999;
  background: linear-gradient(135deg, #0D47A1 0%, #1565C0 50%, #0D47A1 100%);
  align-items: center; justify-content: center;
}
#login-screen.visible { display: flex; }
.login-card {
  background: white;
  border-radius: 16px;
  padding: 40px 40px 32px;
  width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: loginIn .3s ease;
}
@keyframes loginIn { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:none} }
.login-logo {
  width: 220px;
  max-width: 100%;
  margin: 0 auto 20px;
}
.login-logo img {
  display: block;
  width: 100%;
  max-height: 72px;
  height: auto;
  object-fit: contain;
}
.login-title { text-align: center; font-size: 20px; font-weight: 600; color: var(--gray-900); margin-bottom: 4px; }
.login-sub { text-align: center; font-size: 13px; color: var(--gray-500); margin-bottom: 28px; }
.login-field { margin-bottom: 14px; }
.login-field label { display: block; font-size: 11px; font-weight: 700; color: var(--gray-600); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 6px; }
.login-field input {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--gray-300); border-radius: var(--radius);
  font-family: var(--font); font-size: 14px; color: var(--gray-900);
  transition: border-color .15s, box-shadow .15s;
  background: white;
}
.login-field input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(21,101,192,.15); }
.login-field input.error { border-color: var(--red); box-shadow: 0 0 0 3px rgba(198,40,40,.12); }
.login-error {
  background: #FFEBEE; border: 1px solid #EF9A9A;
  border-radius: var(--radius); padding: 10px 14px;
  font-size: 12px; color: var(--red); margin-bottom: 14px;
  display: none; align-items: center; gap: 8px;
}
.login-error.visible { display: flex; }
.login-btn {
  width: 100%; padding: 12px;
  background: var(--blue); color: white; border: none;
  border-radius: var(--radius); font-family: var(--font);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .15s, transform .1s;
  margin-top: 6px;
}
.login-btn:hover { background: var(--blue-light); }
.login-btn:active { transform: scale(.98); }
.login-btn:disabled { background: var(--gray-400); cursor: not-allowed; }
.login-footer { text-align: center; margin-top: 20px; font-size: 11px; color: var(--gray-400); }

/* ── APP wrapper — nascosto finché non si fa login ── */
#app-wrapper { display: none; }
#app-wrapper.visible { display: block; }

/* ── RIEPILOGO POST-ISCRIZIONE ──────────────────── */
#pannello-riepilogo {
  display: none;
  position: fixed; inset: 0; z-index: 150;
  background: rgba(0,0,0,.45);
  align-items: center; justify-content: center;
  padding: 20px;
}
#pannello-riepilogo.visible { display: flex; }
.riepilogo-card {
  background: white;
  border-radius: var(--radius-lg);
  width: 100%; max-width: 620px;
  max-height: 92vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: loginIn .25s ease;
}
.riepilogo-header {
  background: var(--green);
  color: white;
  padding: 20px 24px 16px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex; align-items: center; gap: 14px;
}
.riepilogo-header .icon-ok {
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.riepilogo-header h3 { font-size: 18px; font-weight: 600; margin-bottom: 2px; }
.riepilogo-header p  { font-size: 13px; opacity: .85; }
.riepilogo-body { padding: 22px 24px; }
.riepilogo-row {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.riepilogo-field {
  flex: 1; min-width: 120px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 10px 14px;
}
.riepilogo-field .lbl {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--gray-500); margin-bottom: 3px;
}
.riepilogo-field .val {
  font-size: 14px; font-weight: 600; color: var(--gray-900);
}
.riepilogo-field .val.mono { font-family: var(--mono); color: var(--blue); }
.attiv-riepilogo {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 8px; margin-bottom: 16px;
}
.attiv-col {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--gray-200);
}
.attiv-col-header {
  padding: 6px 10px;
  font-size: 11px; font-weight: 700;
  color: white; text-align: center;
}
.attiv-col-header.s1 { background: #C62828; }
.attiv-col-header.s2 { background: #E65100; }
.attiv-col-header.s3 { background: #F9A825; color: #333; }
.attiv-col-body { background: white; padding: 8px 10px; }
.attiv-item {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 0; font-size: 12px;
}
.attiv-item .dot {
  width: 16px; height: 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0;
}
.attiv-item .dot.si { background: #E8F5E9; color: var(--green); }
.attiv-item .dot.no { background: var(--gray-100); color: var(--gray-400); }
.totale-riepilogo {
  background: var(--blue-pale);
  border: 1.5px solid #90CAF9;
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 16px;
}
.riepilogo-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 16px 24px;
  border-top: 1px solid var(--gray-100);
}

/* ── LOGOUT btn in header ───────────────────────── */
/* ── STATISTICHE MIGLIORATE ─────────────────────── */
.stat-block {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.stat-block-header {
  display: flex; align-items: center; gap: 0;
  border-bottom: 1px solid var(--gray-100);
}
.stat-block-title {
  padding: 12px 18px;
  font-size: 13px; font-weight: 700;
  color: white;
  min-width: 180px;
}
.stat-block-title.s1 { background: #C62828; }
.stat-block-title.s2 { background: #E65100; }
.stat-block-title.s3 { background: #F57F17; color: #1a1a1a; }
.stat-block-meta {
  display: flex; gap: 20px; padding: 10px 20px;
  align-items: center; background: var(--gray-50);
  flex: 1;
}
.stat-block-meta .meta-item { text-align: center; }
.stat-block-meta .meta-label { font-size: 10px; color: var(--gray-500); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.stat-block-meta .meta-value { font-size: 18px; font-weight: 700; color: var(--gray-900); font-family: var(--mono); }
.stat-block-meta .meta-value.blue { color: var(--blue); }
.stat-block-meta .meta-value.green { color: var(--green); }
.stat-block-meta .divider-v { width: 1px; height: 32px; background: var(--gray-200); }
.stat-block-body {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
}
.stat-row {
  padding: 14px 18px;
  border-right: 1px solid var(--gray-100);
  display: flex; flex-direction: column; gap: 8px;
}
.stat-row:last-child { border-right: none; }
.stat-row-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 600; color: var(--gray-700);
}
.stat-row-label .pill {
  font-size: 11px; font-weight: 700; font-family: var(--mono);
  padding: 2px 8px; border-radius: 10px;
}
.stat-row-bar { height: 10px; background: var(--gray-100); border-radius: 5px; overflow: hidden; }
.stat-row-bar .fill { height: 100%; border-radius: 5px; transition: width .4s ease; }
.stat-row-detail {
  display: flex; gap: 12px; font-size: 11px; color: var(--gray-500);
}
.stat-row-detail span { display: flex; align-items: center; gap: 4px; }
.stats-totale-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 0; text-align: center;
}
.stats-totale-cell {
  padding: 16px 12px;
  border-right: 1px solid var(--gray-100);
}
.stats-totale-cell:last-child { border-right: none; }
.stats-totale-cell .lbl { font-size: 11px; color: var(--gray-500); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.stats-totale-cell .val { font-size: 22px; font-weight: 700; font-family: var(--mono); color: var(--gray-900); }
.stats-totale-cell .val.blue { color: var(--blue); }
.stats-totale-cell .val.green { color: var(--green); }

body:not(.mobile-standalone)[data-section="statistiche"] main {
  max-width: 1680px;
  padding-left: 18px;
  padding-right: 18px;
}

body:not(.mobile-standalone) #s-statistiche .stats-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

body:not(.mobile-standalone) #s-statistiche .stat-card {
  min-height: 148px;
  padding: 24px 26px 22px;
}

body:not(.mobile-standalone) #s-statistiche .stat-value {
  font-size: 42px;
  line-height: 1.05;
}

body:not(.mobile-standalone) #s-statistiche .stat-block {
  margin-bottom: 16px;
}

body:not(.mobile-standalone) #s-statistiche .stat-block-title {
  min-width: 220px;
  padding: 16px 24px;
  font-size: 15px;
}

body:not(.mobile-standalone) #s-statistiche .stat-block-meta {
  gap: 28px;
  padding: 12px 28px;
}

body:not(.mobile-standalone) #s-statistiche .stat-block-body {
  grid-template-columns: 1fr 1fr 1.08fr;
}

body:not(.mobile-standalone) #s-statistiche .stat-row {
  padding: 18px 24px;
  gap: 10px;
}

body:not(.mobile-standalone) #s-statistiche .stat-row-label {
  font-size: 13px;
}

body:not(.mobile-standalone) #s-statistiche .stat-row-detail {
  font-size: 12px;
}

body:not(.mobile-standalone) #s-statistiche .stat-row-bar {
  height: 12px;
  border-radius: 999px;
}

body:not(.mobile-standalone) #s-statistiche .stat-row-bar .fill {
  border-radius: 999px;
}

@media (min-width: 769px) and (max-width: 1180px) {
  body:not(.mobile-standalone) #s-statistiche .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body:not(.mobile-standalone) #s-statistiche .stat-block-body {
    grid-template-columns: 1fr;
  }

  body:not(.mobile-standalone) #s-statistiche .stat-row {
    border-right: none;
    border-bottom: 1px solid var(--gray-100);
  }

  body:not(.mobile-standalone) #s-statistiche .stat-row:last-child {
    border-bottom: none;
  }
}

/* ── ALERT CAPACITÀ ──────────────────────────────── */
.cap-alert {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; margin-bottom: 16px;
  border: 1.5px solid;
}
.cap-alert.warning {
  background: #FFFDE7; border-color: #F9A825; color: #E65100;
}
.cap-alert.danger {
  background: #FFEBEE; border-color: #EF9A9A; color: var(--red);
}
.cap-alert.ok {
  background: #E8F5E9; border-color: #A5D6A7; color: var(--green);
}
.cap-badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700;
  font-family: var(--mono);
}
.cap-badge.full { background: #FFEBEE; color: var(--red); }
.cap-badge.warn { background: #FFFDE7; color: #E65100; }
.cap-badge.ok   { background: #E8F5E9; color: var(--green); }

.logout-btn {
  background: rgba(255,255,255,.15); color: white; border: 1px solid rgba(255,255,255,.3);
  padding: 6px 12px; border-radius: var(--radius); font-family: var(--font);
  font-size: 12px; font-weight: 500; cursor: pointer; margin-left: 12px;
  transition: background .15s;
}
.logout-btn:hover { background: rgba(255,255,255,.25); }
.user-chip {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: rgba(255,255,255,.85);
}

/* ── HEADER ─────────────────────────────────────── */
header {
  background: var(--blue);
  color: white;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}
.logo-badge {
  width: 92px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.logo-badge img {
  display: block;
  width: 100%;
  max-height: 100%;
  height: auto;
  object-fit: contain;
}
header h1 { font-size: 17px; font-weight: 600; letter-spacing: -0.3px; }
header h1 span { opacity: 0.7; font-weight: 400; }
.api-status {
  margin-left: auto;
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; opacity: 0.9;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #A5D6A7;
  animation: pulse 2s infinite;
}
.status-dot.offline { background: #EF9A9A; animation: none; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ── NAV ─────────────────────────────────────────── */
nav {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  display: flex;
  gap: 0;
  overflow-x: auto;
}
.nav-btn {
  padding: 15px 20px;
  background: none; border: none; cursor: pointer;
  font-family: var(--font); font-size: 14px; font-weight: 500;
  color: var(--gray-600);
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: all .15s;
}
.nav-btn:hover { color: var(--blue); }
.nav-btn.active { color: var(--blue); border-bottom-color: var(--blue); }
.nav-btn .badge {
  display: inline-block; margin-left: 6px;
  background: var(--blue-pale); color: var(--blue);
  font-size: 11px; font-weight: 600; padding: 1px 6px;
  border-radius: 10px; font-family: var(--mono);
}

/* ── MAIN ─────────────────────────────────────────── */
/* Larghezza estesa a 1560px per sfruttare meglio gli schermi
   dei portatili moderni (1366-1920px) e ridurre lo spazio bianco. */
main { padding: 24px 28px; max-width: 1560px; margin: 0 auto; }
.section { display: none; }
.section.active { display: block; }

/* ── CARDS ─────────────────────────────────────────── */
.card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s;
}
.card-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1.5px solid var(--gray-100);
}
.card-header h2 { font-size: 17px; font-weight: 700; color: var(--gray-900); letter-spacing: -.2px; }
.card-header .subtitle { font-size: 13px; color: var(--gray-500); margin-left: auto; }

/* ── FORM GRID ─────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.form-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 12px; font-weight: 700; color: var(--gray-600); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 2px; }
.form-group input, .form-group select {
  padding: 11px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-family: var(--font); font-size: 14px;
  color: var(--gray-900);
  background: var(--gray-50);
  transition: all .15s;
}
.form-group input:focus, .form-group select:focus {
  outline: none; border-color: var(--blue); background: white;
  box-shadow: 0 0 0 3px rgba(21,101,192,.12);
}
.form-group input:hover, .form-group select:hover { border-color: var(--gray-400); }
.form-group select { cursor: pointer; }

/* ── BUTTONS ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border: none; border-radius: var(--radius);
  font-family: var(--font); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all .15s; text-decoration: none;
  letter-spacing: .1px;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: var(--blue); color: white; box-shadow: 0 1px 3px rgba(21,101,192,.3); }
.btn-primary:hover { background: #1976D2; box-shadow: 0 3px 8px rgba(21,101,192,.35); }
.btn-success { background: var(--green); color: white; box-shadow: 0 1px 3px rgba(46,125,50,.3); }
.btn-success:hover { background: #388E3C; box-shadow: 0 3px 8px rgba(46,125,50,.35); }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #D32F2F; }
.btn-outline {
  background: white; color: var(--gray-700);
  border: 1.5px solid var(--gray-200);
}
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); color: var(--gray-900); }
.btn-orange { background: var(--orange); color: white; }
.btn-orange:hover { background: var(--orange-light); }
.btn-sm { padding: 7px 13px; font-size: 13px; }
.btn-icon { padding: 7px; border-radius: var(--radius); }

/* ── SEARCH BAR ─────────────────────────────────────── */
.search-bar {
  display: flex; gap: 10px; align-items: center;
  margin-bottom: 16px;
}
.search-bar input {
  flex: 1; padding: 11px 16px;
  border: 1.5px solid var(--gray-200); border-radius: var(--radius);
  font-family: var(--font); font-size: 14px;
  background: var(--gray-50);
  transition: all .15s;
}
.search-bar input:focus { outline: none; border-color: var(--blue); background: white; box-shadow: 0 0 0 3px rgba(21,101,192,.12); }
.search-bar input::placeholder { color: var(--gray-400); }

/* ── TABLE ─────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--gray-200); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead { background: #1A237E; color: white; }
thead th {
  padding: 13px 16px; text-align: left;
  font-weight: 700; font-size: 11px; letter-spacing: .8px;
  white-space: nowrap; text-transform: uppercase;
}
thead th.center { text-align: center; }
tbody tr { border-bottom: 1px solid var(--gray-100); transition: background .15s; }
tbody tr:hover { background: #F0F7FF; }
tbody tr:last-child { border-bottom: none; }
td { padding: 13px 16px; color: var(--gray-800); vertical-align: middle; font-size: 14px; }
td.center { text-align: center; }
td.mono { font-family: var(--mono); font-size: 13px; color: var(--blue); font-weight: 600; }

body:not(.mobile-standalone)[data-section="iscritti"] main {
  max-width: 1680px;
  padding-left: 16px;
  padding-right: 16px;
}

#s-iscritti .card {
  padding: 18px;
}

#s-iscritti table {
  font-size: 13px;
}

#s-iscritti thead th,
#s-iscritti td {
  padding: 8px 9px;
}

#s-iscritti tbody td:nth-child(n+6):nth-child(-n+14) {
  width: 34px;
  min-width: 34px;
  padding-left: 5px;
  padding-right: 5px;
}

#s-iscritti thead th:last-child,
#s-iscritti tbody td:last-child {
  position: sticky;
  right: 0;
  width: 260px;
  min-width: 260px;
  box-shadow: -10px 0 16px rgba(255,255,255,.92), -1px 0 0 var(--gray-200);
}

#s-iscritti thead th:last-child {
  z-index: 4;
  background: #1A237E;
}

#s-iscritti tbody td:last-child {
  z-index: 3;
  background: white;
}

#s-iscritti tbody tr:hover td:last-child {
  background: #F0F7FF;
}

#s-iscritti tbody td:last-child .btn {
  padding-left: 9px;
  padding-right: 9px;
}

.mobile-list { display: none; }
.mobile-iscritto-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}
.mobile-iscritto-card + .mobile-iscritto-card { margin-top: 10px; }
.mobile-iscritto-top {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}
.mobile-iscritto-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
}
.mobile-iscritto-meta {
  font-size: 12px;
  color: var(--gray-600);
  margin-top: 6px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.mobile-iscritto-total {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--blue);
  white-space: nowrap;
}
.mobile-iscritto-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.mobile-iscritto-field {
  background: var(--gray-50);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.mobile-iscritto-field .lbl {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gray-500);
  margin-bottom: 4px;
}
.mobile-iscritto-field .val {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-900);
}
.mobile-iscritto-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.mobile-iscritto-actions .btn:first-child {
  grid-column: 1 / -1;
  justify-content: center;
}
.mobile-tesserato-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}
.mobile-tesserato-card + .mobile-tesserato-card { margin-top: 10px; }
.mobile-tesserato-top {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}
.mobile-tesserato-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
}
.mobile-tesserato-meta {
  font-size: 12px;
  color: var(--gray-600);
  margin-top: 6px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.mobile-tesserato-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.mobile-tesserato-field {
  background: var(--gray-50);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.mobile-tesserato-field .lbl {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gray-500);
  margin-bottom: 4px;
}
.mobile-tesserato-field .val {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-900);
}
.mobile-tesserato-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.mobile-tesserato-actions .btn {
  justify-content: center;
}

.mobile-gita-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}
.mobile-gita-card + .mobile-gita-card { margin-top: 10px; }
.mobile-gita-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}
.mobile-gita-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
}
.mobile-gita-meta {
  font-size: 12px;
  color: var(--gray-600);
  margin-top: 6px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.mobile-gita-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.mobile-gita-field {
  background: var(--gray-50);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.mobile-gita-field .lbl {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gray-500);
  margin-bottom: 4px;
}
.mobile-gita-field .val {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-900);
}

/* ── BADGES ─────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700;
  letter-spacing: .2px;
}
.badge-blue { background: #E3F0FF; color: #1565C0; }
.badge-red { background: #FFEBEE; color: #C62828; }
.badge-green { background: #E8F5E9; color: #2E7D32; }
.badge-yellow { background: #FFFDE7; color: #F57F17; }
.badge-orange { background: #FFF3E0; color: #E65100; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* ── SETTIMANE colors ───────────────────────────────── */
.sett1 { background: #FFEBEE; color: #B71C1C; }
.sett2 { background: #FFF3E0; color: #E65100; }
.sett3 { background: #FFFDE7; color: #F57F17; }

/* ── CHECK ICON ─────────────────────────────────────── */
.check { color: var(--green); font-size: 16px; }
.cross { color: var(--gray-400); font-size: 16px; }

/* ── CHECKBOX GRID (iscrizione) ─────────────────────── */
.attivita-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.sett-col {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
}
.sett-header {
  padding: 8px 12px;
  font-size: 11px; font-weight: 700; letter-spacing: .5px;
  color: white; text-align: center;
}
.sett-header.s1 { background: #C62828; }
.sett-header.s2 { background: #E65100; }
.sett-header.s3 { background: #F9A825; color: var(--gray-900); }
.sett-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; background: white; }
.check-item { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 4px 2px; border-radius: 6px; transition: background .1s; }
.check-item:hover { background: var(--gray-50); }
.check-item input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--blue); flex-shrink:0; }
.check-item span { font-size: 13px; font-weight: 500; }
.check-copy { display:flex; flex-direction:column; gap:3px; min-width:0; }
.cap-counter { display:inline-flex; align-items:center; width:max-content; font-size:11px !important; font-weight:700 !important; padding:2px 8px; border-radius:999px; background:var(--gray-100); color:var(--gray-600); }
.cap-counter.warn { background:#FFF3E0; color:#E65100; }
.cap-counter.full { background:#FFEBEE; color:var(--red); }
.check-item .price { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--blue); font-family: var(--mono); background: var(--blue-pale); padding: 2px 7px; border-radius: 8px; }

/* ── STATS CARDS ─────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card {
  background: white; border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg); padding: 20px 22px;
  border-left: 4px solid var(--blue);
  transition: box-shadow .15s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card.orange { border-left-color: var(--orange); }
.stat-card.green { border-left-color: var(--green); }
.stat-card.red { border-left-color: var(--red); }
.stat-label { font-size: 11px; color: var(--gray-500); font-weight: 700; text-transform: uppercase; letter-spacing: .7px; margin-bottom: 8px; }
.stat-value { font-size: 36px; font-weight: 700; color: var(--gray-900); font-family: var(--mono); line-height: 1; margin-bottom: 6px; }
.stat-sub { font-size: 12px; color: var(--gray-500); }

/* ── DASHBOARD NUOVA ─────────────────────────────── */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.dash-kpi {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 22px 22px 18px;
  display: flex; flex-direction: column;
  position: relative; overflow: hidden;
  transition: box-shadow .15s;
}
.dash-kpi:hover { box-shadow: var(--shadow-md); }
.dash-kpi-accent {
  position: absolute; top: 0; left: 0; right: 0; height: 4px;
}
.dash-kpi-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; margin-bottom: 14px;
}
.dash-kpi-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .7px; color: var(--gray-500); margin-bottom: 6px;
}
.dash-kpi-value {
  font-size: 40px; font-weight: 700; font-family: var(--mono);
  line-height: 1; color: var(--gray-900); margin-bottom: 8px;
}
.dash-kpi-sub {
  font-size: 12px; color: var(--gray-500);
  margin-top: auto; padding-top: 10px;
  border-top: 1px solid var(--gray-100);
}
.dash-kpi-delta {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; padding: 2px 8px;
  border-radius: 10px; margin-top: 6px;
}
.dashboard-mini-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--gray-400);
  padding: 10px 0 4px;
}
.dashboard-mini-title-gap { padding-top: 12px; }

/* ── OCCUPAZIONE BARS ────────────────────────────── */
.occ-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
}
.occ-item:last-child { border-bottom: none; }
.occ-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
}
.occ-label { font-size: 13px; font-weight: 600; color: var(--gray-800); flex: 1; }
.occ-count {
  font-family: var(--mono); font-size: 13px; font-weight: 700;
}
.occ-liberi { font-size: 11px; color: var(--gray-400); }
.occ-bar-wrap { height: 12px; background: var(--gray-100); border-radius: 6px; overflow: hidden; }
.occ-bar-fill { height: 100%; border-radius: 6px; transition: width .5s ease; }
.occ-tipo-badge {
  display: inline-block; font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 4px; text-transform: uppercase;
  letter-spacing: .4px; margin-right: 6px;
}
.dash-pay-row { margin-bottom: 14px; }
.dash-pay-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.dash-pay-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
}
.dash-pay-count {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
}
.dash-pay-count span {
  font-size: 11px;
  color: var(--gray-400);
  font-weight: 400;
}
.dash-pay-total {
  padding-top: 10px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--gray-500);
}
.dash-pay-total span:last-child {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--blue);
  font-size: 14px;
}

/* ── ULTIMI ISCRITTI ─────────────────────────────── */
.last-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--gray-100);
  transition: background .1s; cursor: pointer;
}
.last-item:last-child { border-bottom: none; }
.last-main { min-width: 0; }
.last-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--blue-pale);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--blue);
  flex-shrink: 0;
}
.last-name { font-weight: 600; font-size: 14px; color: var(--gray-900); }
.last-meta { font-size: 11px; color: var(--gray-500); margin-top: 2px; }
.last-side { text-align: right; margin-left: auto; }
.last-total {
  margin-left: auto; font-family: var(--mono);
  font-size: 15px; font-weight: 700; color: var(--blue);
}
.last-status { font-size: 11px; }
.last-pay-badge {
  font-size: 10px; padding: 2px 7px; border-radius: 8px;
  font-weight: 600; margin-left: 8px;
}

/* ── PROGRESS BAR ─────────────────────────────────────── */
.progress-bar { height: 8px; background: var(--gray-200); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width .3s; }

/* ── MODAL ─────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 200;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: white; border-radius: var(--radius-lg);
  width: 100%; max-width: 680px; max-height: 90vh;
  overflow-y: auto; box-shadow: var(--shadow-md);
  animation: modalIn .2s ease;
}
@keyframes modalIn { from{opacity:0;transform:translateY(-12px)} to{opacity:1;transform:none} }
.modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; gap: 12px;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--gray-200);
  display: flex; gap: 10px; justify-content: flex-end;
}
.modal-save-status {
  align-items: center;
  min-height: 32px;
  margin-right: auto;
  padding: 7px 11px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 700;
}
.modal-save-status.success { background: #E8F5E9; color: var(--green); }
.modal-save-status.pending { background: var(--blue-pale); color: var(--blue); }
.modal-save-status.muted { background: var(--gray-100); color: var(--gray-600); }
.modal-save-status.error { background: #FFEBEE; color: var(--red); }

.capacity-override-overlay {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(32,33,36,.46);
}
.capacity-override-overlay.open { display: flex; }
.capacity-override-card {
  width: min(520px, 100%);
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 70px rgba(0,0,0,.28);
  padding: 24px;
  text-align: center;
  border-top: 5px solid var(--red);
}
.capacity-override-icon {
  width: 46px;
  height: 46px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: #FFEBEE;
  color: var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 800;
  font-family: var(--mono);
}
.capacity-override-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: 8px;
}
.capacity-override-text {
  font-size: 14px;
  line-height: 1.45;
  color: var(--gray-700);
  margin-bottom: 14px;
}
.capacity-override-list {
  background: #FFF3E0;
  border: 1px solid #FFCC80;
  border-radius: var(--radius);
  color: #B74A00;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  padding: 10px 12px;
  margin-bottom: 18px;
}
.capacity-override-list div + div { margin-top: 6px; }
.capacity-override-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.edit-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 270;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(32,33,36,.5);
}
.edit-confirm-overlay.open { display: flex; }
.edit-confirm-card {
  width: min(560px, 100%);
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 70px rgba(0,0,0,.28);
  padding: 24px;
  text-align: center;
  border-top: 5px solid var(--blue);
}
.edit-confirm-icon {
  width: 46px;
  height: 46px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--blue-pale);
  color: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 800;
  font-family: var(--mono);
}
.edit-confirm-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: 8px;
}
.edit-confirm-text {
  font-size: 14px;
  line-height: 1.45;
  color: var(--gray-700);
  margin-bottom: 14px;
}
.edit-confirm-list {
  max-height: 220px;
  overflow-y: auto;
  background: #F6F9FD;
  border: 1px solid #D7E7FB;
  border-radius: var(--radius);
  color: var(--gray-800);
  font-size: 13px;
  text-align: left;
  padding: 10px 12px;
  margin-bottom: 18px;
}
.edit-confirm-list div + div { margin-top: 6px; }
.edit-confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Variante "warning" (arancio) per conferme di campi vuoti / non compilati */
.edit-confirm-card.warning { border-top-color: #FB8C00; }
.edit-confirm-card.warning .edit-confirm-icon {
  background: #FFF3E0;
  color: #E65100;
  font-family: var(--font);
  font-size: 22px;
}
.edit-confirm-card.warning .edit-confirm-list {
  background: #FFF8E1;
  border-color: #FFE0B2;
  color: #B74A00;
  font-weight: 600;
}

/* ── API CONFIG ─────────────────────────────────────── */
.config-section {
  background: var(--blue-pale);
  border: 1.5px solid #90CAF9;
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 20px;
}
.config-section h3 { font-size: 14px; font-weight: 700; color: var(--blue); margin-bottom: 6px; }

/* ── TOAST ─────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--gray-900); color: white;
  padding: 10px 16px; border-radius: var(--radius);
  font-size: 13px; z-index: 300; display: none;
  box-shadow: var(--shadow-md);
  animation: slideUp .2s ease;
}
#toast.success { background: var(--green); }
#toast.error { background: var(--red); }
@keyframes slideUp { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:none} }

/* ── EMPTY STATE ─────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 56px 20px; color: var(--gray-400);
}
.empty-state .icon { font-size: 48px; margin-bottom: 14px; opacity: .6; }
.empty-state p { font-size: 14px; color: var(--gray-500); font-weight: 500; }

/* ── FILTER ROW ─────────────────────────────────────── */
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filter-row select, .filter-row input {
  padding: 8px 12px; border: 1.5px solid var(--gray-200);
  border-radius: var(--radius); font-family: var(--font); font-size: 13px;
  background: var(--gray-50); cursor: pointer; transition: all .15s;
}
.filter-row select:focus, .filter-row input:focus {
  outline: none; border-color: var(--blue); background: white;
  box-shadow: 0 0 0 3px rgba(21,101,192,.10);
}
.filter-row select:hover, .filter-row input:hover { border-color: var(--gray-400); }

/* ── DIVIDER ─────────────────────────────────────────── */
.divider { height: 1px; background: var(--gray-200); margin: 16px 0; }

/* ── MODAL MODIFICA ISCRIZIONE ──────────────────── */
/* ── PANNELLO STORICO ISCRITTO ──────────────────── */
#pannello-storico {
  display: none;
  position: fixed; inset: 0; z-index: 160;
  background: rgba(0,0,0,.5);
  align-items: center; justify-content: center;
  padding: 20px;
}
#pannello-storico.visible { display: flex; }
.storico-card {
  background: white;
  border-radius: var(--radius-lg);
  width: 100%; max-width: 680px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: loginIn .2s ease;
}
.storico-card-header {
  background: #1A237E;
  color: white;
  padding: 18px 22px 14px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  flex-shrink: 0;
}
.storico-card-header h3 { font-size: 17px; font-weight: 700; margin-bottom: 3px; }
.storico-card-header p  { font-size: 12px; opacity: .8; }
.storico-card-body {
  flex: 1; overflow-y: auto;
  padding: 16px 20px;
}
.storico-card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--gray-100);
  display: flex; justify-content: flex-end; gap: 8px;
  flex-shrink: 0;
}
.mov-item {
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  border: 1px solid;
  display: flex; align-items: flex-start; gap: 12px;
}
.mov-item.addebito { background: #E3F0FF; border-color: #90CAF9; }
.mov-item.rimborso { background: #E8F5E9; border-color: #A5D6A7; }
.mov-icon { font-size: 22px; flex-shrink: 0; margin-top: 1px; }
.mov-body { flex: 1; }
.mov-importo { font-size: 18px; font-weight: 700; font-family: var(--mono); }
.mov-importo.addebito { color: var(--blue); }
.mov-importo.rimborso { color: var(--green); }
.mov-desc { font-size: 13px; font-weight: 600; color: var(--gray-900); margin: 2px 0; }
.mov-meta { font-size: 11px; color: var(--gray-500); }
.mov-note { font-size: 12px; color: var(--gray-600); background: white; border-radius: 4px; padding: 5px 8px; margin-top: 6px; border-left: 2px solid var(--gray-300); }
.mov-del { background: none; border: none; color: var(--gray-400); cursor: pointer; padding: 4px; border-radius: 4px; font-size: 14px; flex-shrink: 0; }
.mov-del:hover { background: #FFEBEE; color: var(--red); }
.diff-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--radius);
  margin-bottom: 6px; font-size: 13px;
}
.diff-item.aggiunta { background: #E3F0FF; border-left: 3px solid var(--blue); }
.diff-item.rimozione { background: #FFEBEE; border-left: 3px solid var(--red); }
.diff-item.neutro { background: var(--gray-50); border-left: 3px solid var(--gray-300); }
.diff-importo { margin-left: auto; font-family: var(--mono); font-weight: 700; font-size: 14px; }
.diff-importo.pos { color: var(--blue); }
.diff-importo.neg { color: var(--red); }

.storico-loading {.storico-loading {
  text-align: center; padding: 32px; color: var(--gray-400);
  font-size: 13px;
}
.nome-cliccabile {
  cursor: pointer;
  font-weight: 600;
  color: var(--gray-900);
  text-decoration: none;
  transition: color .15s;
}
.nome-cliccabile:hover {
  color: var(--blue);
  text-decoration: underline;
}

.storico-item {
  padding: 10px 14px;
  border-left: 3px solid var(--gray-200);
  margin-bottom: 8px;
  background: var(--gray-50);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 12px;
}
.storico-item.modifica { border-left-color: var(--blue); }
.storico-item.creazione { border-left-color: var(--green); }
.storico-item .st-time {
  font-size: 10px; font-weight: 700; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: .4px; margin-bottom: 4px;
}
.storico-item .st-campo {
  display: inline-block; background: var(--blue-pale); color: var(--blue);
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px;
  margin-right: 4px; font-family: var(--mono);
}
.storico-item .st-val {
  font-size: 11px; color: var(--gray-700);
}
.storico-item .st-arrow { color: var(--gray-400); margin: 0 4px; }
.storico-item .st-new { font-weight: 700; color: var(--gray-900); }
.tab-btn {
  padding: 8px 16px; background: none; border: none; cursor: pointer;
  font-family: var(--font); font-size: 13px; font-weight: 500;
  color: var(--gray-600); border-bottom: 2px solid transparent;
  transition: all .15s;
}
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab-btn:hover:not(.active) { color: var(--gray-900); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── PANNELLO CREA TESSERATO INLINE ─────────────── */
#inline-nuovo-tesserato {
  display: none;
  background: #FFFDE7;
  border: 1.5px solid #F9A825;
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
  animation: loginIn .2s ease;
}
#inline-nuovo-tesserato.visible { display: block; }
.inline-tess-header {
  background: #F57F17;
  color: white;
  padding: 12px 18px;
  display: flex; align-items: center; gap: 10px;
}
.inline-tess-header h4 { font-size: 14px; font-weight: 700; }
.inline-tess-header p  { font-size: 12px; opacity: .85; margin-top: 1px; }
.inline-tess-body { padding: 18px 18px 14px; }
.inline-tess-footer { padding: 12px 18px; border-top: 1px solid #FFE082; display: flex; gap: 10px; justify-content: flex-end; background: rgba(255,255,255,.5); }

/* ── SEZIONE TITOLO FORM ────────────────────────── */
.form-section-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .7px; color: var(--gray-400);
  margin: 16px 0 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--gray-100);
}

.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.gap-10 { gap: 10px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.ml-auto { margin-left: auto; }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 12px; }
.font-mono { font-family: var(--mono); }

/* ════════════════════════════════════════════════════════
   RESPONSIVE MOBILE — Grest Gazzera 2026
   Breakpoint principale: 768px (tablet/mobile)
   Breakpoint piccolo:    480px (smartphone)
   ════════════════════════════════════════════════════════ */

@media (max-width: 768px) {

  /* ── HEADER ─────────────────────────────────────────── */
  header {
    position: sticky;
    top: 0;
    z-index: 120;
    padding: 10px 12px;
    min-height: 58px;
    height: auto;
    gap: 10px;
    align-items: center;
    background: linear-gradient(135deg, #1565C0 0%, #0D47A1 100%);
    box-shadow: 0 8px 24px rgba(13,71,161,.22);
  }
  header h1 {
    font-size: 13px;
    line-height: 1.15;
    min-width: 0;
    flex: 1;
  }
  header h1 span { display: none; } /* nasconde il sottotitolo */
  .user-chip { display: none; }
  .logout-btn {
    margin-left: 0;
    padding: 7px 10px;
    font-size: 11px;
    border-radius: 999px;
    background: rgba(255,255,255,.16);
    border: 1px solid rgba(255,255,255,.18);
    color: white;
    flex-shrink: 0;
  }
  .api-status { display: none; } /* nasconde stato connessione */
  .logo-badge {
    width: 84px;
    height: 24px;
    border-radius: 10px;
    flex-shrink: 0;
    background: rgba(255,255,255,.12);
    border-color: rgba(255,255,255,.18);
  }

  /* ── NAV ─────────────────────────────────────────────── */
  nav {
    padding: 0 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  nav::-webkit-scrollbar { display: none; }
  .nav-btn {
    padding: 12px 10px;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .nav-btn .badge { display: none; } /* nasconde badge contatori */

  /* ── MAIN ────────────────────────────────────────────── */
  main {
    padding: 10px 10px 92px !important;
    background:
      radial-gradient(circle at top right, rgba(21,101,192,.08), transparent 34%),
      linear-gradient(180deg, #F6F9FD 0%, #EEF3F9 100%);
    min-height: calc(100vh - 58px);
  }
  .section { animation: none; }

  /* ── CARD ────────────────────────────────────────────── */
  .card {
    padding: 14px;
    border-radius: 18px;
    box-shadow: 0 10px 24px rgba(15,23,42,.06);
  }
  .card-header { margin-bottom: 12px; padding-bottom: 10px; flex-wrap: wrap; gap: 8px; }
  .card-header h2 { font-size: 14px; }

  /* ── DASHBOARD KPI ───────────────────────────────────── */
  .dash-grid {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(240px, 82vw);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    gap: 12px;
    margin: 0 -2px 16px;
    padding: 2px 2px 6px;
    scrollbar-width: none;
  }
  .dash-grid::-webkit-scrollbar { display: none; }
  #dashKpiGrid { grid-template-columns: none !important; }
  .dash-kpi {
    padding: 16px 16px 14px;
    min-height: 0;
    scroll-snap-align: start;
  }
  .dash-kpi-value { font-size: 34px; }
  .dash-kpi-icon { width: 36px; height: 36px; font-size: 16px; margin-bottom: 12px; }
  .dash-kpi-sub {
    line-height: 1.4;
    font-size: 12px;
  }

  /* ── DASHBOARD CORPO ─────────────────────────────────── */
  .dashboard-main {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }
  .dashboard-side { gap: 12px !important; }
  #subtitleSettimane {
    width: 100%;
    margin-left: 0 !important;
    font-size: 11px;
  }
  .dashboard-link-btn {
    width: 100%;
    margin-left: 0 !important;
    justify-content: center;
    min-height: 42px;
  }
  .dashboard-mini-title {
    font-size: 11px;
    letter-spacing: .8px;
    padding: 12px 0 6px;
  }
  .occ-item {
    padding: 13px 0;
  }
  .occ-header {
    flex-wrap: wrap;
    align-items: center;
    row-gap: 5px;
  }
  .occ-label {
    width: 100%;
    font-size: 13px;
    line-height: 1.25;
  }
  .occ-count { font-size: 15px; }
  .occ-liberi { font-size: 12px; }
  .occ-bar-wrap { height: 13px; }
  .dash-pay-top {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .dash-pay-label {
    width: 100%;
    font-size: 13px;
  }
  .dash-pay-count {
    width: 100%;
    font-size: 15px;
  }
  .dash-pay-total {
    padding-top: 12px;
    margin-top: 4px;
  }
  .last-item {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 0;
  }
  .last-main { flex: 1; }
  .last-side {
    width: 100%;
    margin-left: 0;
    text-align: left;
    padding-left: 46px;
  }
  .last-name {
    font-size: 14px;
    line-height: 1.25;
  }
  .last-meta {
    margin-top: 4px;
    line-height: 1.35;
  }
  .last-status {
    margin-top: 4px;
    font-size: 12px;
  }

  /* ── TABELLE: scroll orizzontale ─────────────────────── */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
  }
  table { min-width: 600px; font-size: 12px; }
  thead th { padding: 9px 10px; }
  td { padding: 9px 10px; }
  #s-gite .card-header { flex-wrap: wrap; }
  #s-gite .card-header > div:last-child {
    width: 100%;
    margin-left: 0 !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px !important;
  }
  #s-gite .card-header select {
    grid-column: 1 / -1;
    width: 100%;
  }
  #s-tesserati .table-wrap { display: none; }
  #s-tesserati .mobile-list { display: block; }
  #s-iscritti .table-wrap { display: none; }
  #s-iscritti .mobile-list { display: block; }
  #s-gite .table-wrap { display: none; }
  #s-gite .mobile-list { display: block; }

  /* ── SEARCH BAR ──────────────────────────────────────── */
  .search-bar { flex-wrap: wrap; }
  .search-bar input { min-width: 0; }
  .filter-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 12px;
  }
  .filter-row select { font-size: 13px; padding: 10px 12px; }
  .filter-row .ml-auto { margin-left: 0; grid-column: 1 / -1; }

  /* ── FORM ISCRIZIONE ─────────────────────────────────── */
  .form-grid { grid-template-columns: 1fr !important; }
  .form-grid.two { grid-template-columns: 1fr !important; }
  .form-grid.three { grid-template-columns: 1fr !important; }
  .attivita-grid { grid-template-columns: 1fr !important; }

  /* ── GITE CARDS ──────────────────────────────────────── */
  #s-gite > div:first-child {
    grid-template-columns: 1fr !important;
  }

  /* ── STATISTICHE ─────────────────────────────────────── */
  .stat-block-body {
    grid-template-columns: 1fr !important;
  }
  .stat-block-header {
    flex-wrap: wrap;
    flex-direction: column;
    align-items: stretch;
  }
  .stat-block-title {
    width: 100%;
    min-width: 0;
    padding: 12px 14px;
  }
  .stat-block-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 12px 14px;
    align-items: stretch;
  }
  .stat-block-meta .meta-item {
    text-align: left;
    background: white;
    border: 1px solid var(--gray-100);
    border-radius: var(--radius);
    padding: 10px 12px;
  }
  .stat-block-meta .meta-item[style*="margin-left:auto"] {
    grid-column: 1 / -1;
  }
  .stat-block-meta .divider-v { display: none; }
  .stat-row {
    border-right: none;
    border-top: 1px solid var(--gray-100);
    padding: 14px;
  }
  .stat-row:first-child { border-top: none; }
  .stat-row-detail {
    flex-wrap: wrap;
    gap: 6px 12px;
  }
  .stat-row-detail span:last-child {
    width: 100%;
    margin-left: 0 !important;
    justify-content: flex-start;
  }
  .stats-grid { grid-template-columns: 1fr !important; }
  .stats-totale-grid { grid-template-columns: 1fr 1fr !important; }

  /* ── ELENCHI FILTRI ──────────────────────────────────── */
  #s-elenchi .card > div[style*="grid-template-columns"] {
    display: flex !important;
    flex-direction: column !important;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
  }
  #s-elenchi .card > div[style*="grid-template-columns"] > div {
    border-right: none !important;
    border-bottom: 1px solid var(--gray-100);
  }

  /* ── RIEPILOGO POST-ISCRIZIONE ───────────────────────── */
  .attiv-riepilogo { grid-template-columns: 1fr !important; }
  .riepilogo-row { flex-wrap: wrap; }
  .riepilogo-field { min-width: calc(50% - 4px); }
  .riepilogo-footer { flex-wrap: wrap; gap: 8px; }
  .riepilogo-footer .btn { flex: 1; justify-content: center; font-size: 12px; }

  /* ── PANNELLO INLINE NUOVO TESSERATO ─────────────────── */
  .inline-tess-header { flex-wrap: wrap; }

  /* ── MODAL ───────────────────────────────────────────── */
  .modal {
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: 100vh;
    min-height: 92vh;
    display: flex;
    flex-direction: column;
  }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-header,
  .modal-tabbar,
  .modal-footer {
    position: sticky;
    z-index: 3;
  }
  .modal-header { top: 0; }
  .modal-tabbar { top: 68px; }
  .modal-body { padding: 14px; }
  .modal-scroll,
  .modal-body { flex: 1; }
  .modal-footer {
    bottom: 0;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
    background: white;
    flex-wrap: wrap;
  }
  .modal-footer .btn { flex: 1 1 calc(50% - 8px); justify-content: center; }
  #modal-modifica-iscrizione .modal-footer .btn-primary,
  #modal-modifica-tesserato .modal-footer .btn-primary,
  #modal-nuovo-tesserato .modal-footer .btn-success {
    flex-basis: 100%;
    order: 10;
  }
  .tab-btn { padding: 12px 14px; font-size: 14px; }
  #modal-modifica-iscrizione .modal-header,
  #modal-modifica-tesserato .modal-header,
  #modal-nuovo-tesserato .modal-header {
    padding: 14px 16px !important;
  }
  #modal-modifica-iscrizione .modal-tabbar { padding: 0 12px !important; }
  #modal-modifica-iscrizione .modal-scroll > .tab-panel,
  #modal-modifica-tesserato .modal-body,
  #modal-nuovo-tesserato .modal-body {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  /* ── PANNELLO LOGIN ──────────────────────────────────── */
  .login-card { padding: 28px 20px 24px; border-radius: 12px; }
  .login-title { font-size: 18px; }

  /* ── CASSA ───────────────────────────────────────────── */
  #s-cassa > div:nth-child(3) {
    grid-template-columns: 1fr !important;
  }
  #cassaKpi {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .stats-totale-cell { padding: 12px 8px; }
  .stats-totale-cell .val { font-size: 18px; }

  /* ── BOTTONI ─────────────────────────────────────────── */
  .btn { padding: 10px 12px; font-size: 13px; }
  .btn-sm { padding: 8px 10px; font-size: 12px; }

  /* ── ULTIMI ISCRITTI DASHBOARD ───────────────────────── */
  .last-avatar { width: 34px; height: 34px; font-size: 11px; }
  .last-name { font-size: 13px; }
  .last-total { font-size: 13px; }

  /* ── OCC BARS DASHBOARD ──────────────────────────────── */
  .occ-label { font-size: 12px; }
}

/* ════════════════════════════════════════════════════════
   SMARTPHONE PICCOLO (<480px)
   ════════════════════════════════════════════════════════ */
@media (max-width: 480px) {

  header {
    padding: 10px 10px;
    min-height: 56px;
  }
  header h1 { font-size: 12px; }
  .logo-badge { width: 74px; height: 22px; }
  .logout-btn {
    padding: 6px 9px;
    font-size: 10px;
  }
  main { padding: 8px 8px 92px !important; }
  .card { padding: 12px; border-radius: 16px; }

  /* KPI: carousel più largo su schermi piccoli */
  .dash-grid {
    grid-auto-columns: minmax(252px, 88vw);
    gap: 10px;
  }
  #dashKpiGrid { grid-template-columns: none !important; }
  .dash-kpi-value { font-size: 30px; }
  .dash-kpi { padding: 15px 14px 13px; }
  .dashboard-mini-title { padding-top: 8px; }
  .dash-pay-total {
    flex-direction: column;
    align-items: flex-start;
  }
  .last-side { padding-left: 0; }
  .occ-label { font-size: 12px; }
  .occ-count { font-size: 14px; }

  /* Nav ancora più compatta */
  .nav-btn { padding: 10px 8px; font-size: 11px; }

  /* Tabella: font ancora più piccolo */
  table { font-size: 11px; }
  td, thead th { padding: 7px 8px; }

  /* Riepilogo: tutto su una colonna */
  .riepilogo-field { min-width: 100%; }
  .totale-riepilogo { flex-wrap: wrap; gap: 8px; }
  .totale-riepilogo .val.big { font-size: 22px; }
  .mobile-iscritto-grid,
  .mobile-iscritto-actions,
  .mobile-tesserato-grid,
  .mobile-tesserato-actions,
  .mobile-gita-grid { grid-template-columns: 1fr; }
  .mobile-iscritto-total { font-size: 18px; }

  /* Statistiche totale: 1 colonna */
  .stats-totale-grid { grid-template-columns: 1fr !important; }
  .stats-totale-cell .val { font-size: 16px; }

  /* Cassa kpi */
  #cassaKpi { grid-template-columns: 1fr !important; }
  .dash-kpi-label { font-size: 10px; }
}

/* ════════════════════════════════════════════════════════
   TOUCH — Migliora l'esperienza tocco
   ════════════════════════════════════════════════════════ */
@media (hover: none) and (pointer: coarse) {
  /* Target più grandi per touch */
  .btn { min-height: 40px; }
  .check-item { min-height: 36px; padding: 6px 4px; }
  .nav-btn { min-height: 44px; }
  .form-group input,
  .form-group select,
  .search-bar input,
  .filter-row select { min-height: 42px; font-size: 16px; } /* 16px evita lo zoom automatico su iOS */

  /* Hover effects disabilitati su touch */
  tbody tr:hover { background: transparent; }
  .last-item:hover { background: transparent; }
}

/* ── BOTTOM NAV MOBILE ───────────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(16px);
  border-top: 1px solid rgba(148,163,184,.22);
  padding: 8px 0 env(safe-area-inset-bottom, 8px);
  z-index: 90;
  box-shadow: 0 -8px 24px rgba(15,23,42,.08);
}
.bottom-nav-items {
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 2px;
  padding: 0 4px;
}
.bottom-nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: none; cursor: pointer;
  padding: 8px 8px; border-radius: 14px;
  font-family: var(--font); color: var(--gray-500);
  transition: all .15s; min-width: 58px;
}
.bottom-nav-btn.active {
  color: var(--blue);
  background: rgba(21,101,192,.08);
}
.bottom-nav-btn .bn-icon { font-size: 20px; line-height: 1; }
.bottom-nav-btn .bn-label { font-size: 10px; font-weight: 700; letter-spacing: .2px; }
@media (max-width: 768px) {
  .bottom-nav { display: block; }
  /* Aggiunge padding al main per non essere coperto dalla bottom nav */
  main { padding-bottom: 92px !important; }
  /* Nasconde la nav superiore su mobile */
  nav { display: none; }
}

/* ─────────────────────────────────────────────────────────────
   ► INFO MEDICHE (uso interno staff — non in stampa)
   Redesign V10: textarea libere, stesso pattern dei contatti.
   Lascia vuoto = nulla da segnalare. Su salvataggio si chiede
   conferma se i 3 campi risultano tutti vuoti.
   ───────────────────────────────────────────────────────────── */

/* Titolo della sezione: leggermente accentato in arancio */
.form-section-title.med-section-title {
  color: #BF360C;
  border-bottom-color: #FFE0B2;
  margin-top: 18px;
}
.form-section-title.med-section-title::before {
  content: "";
}

/* Griglia dei 3 campi: una colonna sola, gap leggermente maggiore */
.med-fields-grid {
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 4px;
}

/* Singolo campo medico: usa lo stesso look dei form-group standard */
.med-field-group {
  background: #FFFBF2;
  border: 1px solid #FFE0B2;
  border-left: 3px solid #FB8C00;
  border-radius: var(--radius);
  padding: 10px 12px 12px;
  transition: border-color .2s, background .2s;
}
.med-field-group:focus-within {
  background: white;
  border-left-color: #C62828;
  border-color: #FFCDD2;
  box-shadow: 0 2px 8px rgba(229, 57, 53, .06);
}
.med-field-group label {
  font-size: 14.5px;
  font-weight: 800;
  color: #4E342E;
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: 8px;
  display: block;
  line-height: 1.3;
}

/* Textarea del campo: stessa estetica degli input, più ariosa */
.med-field {
  width: 100%;
  min-height: 88px;
  padding: 12px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  /* Stesso font del resto del programma (DM Sans) */
  font-family: 'DM Sans', system-ui, sans-serif !important;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.55;
  color: var(--gray-900);
  background: white;
  resize: vertical;
  transition: all .15s;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.med-field:hover { border-color: var(--gray-400); }
.med-field:focus {
  outline: none;
  border-color: #C62828;
  box-shadow: 0 0 0 3px rgba(198, 40, 40, .12);
}
.med-field::placeholder {
  color: var(--gray-500);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-style: italic;
}

/* Quando "Sì" è selezionato, accento rosso più forte */
.med-field-group:has(.med-yesno input[value="si"]:checked) {
  background: #FFF5F5;
  border-color: #FFCDD2;
  border-left-color: #C62828;
}

/* Hint sotto il campo (default per il resto del programma) */
.form-hint {
  font-size: 11px;
  color: var(--gray-600);
  line-height: 1.45;
  margin-top: 6px;
}
.form-hint em {
  font-style: normal;
  color: #2E7D32;
  font-weight: 600;
}

/* Hint specifico dei campi medici: italic, più piccolo e grigio chiaro */
.med-field-group .form-hint {
  font-size: 10.5px;
  font-style: italic;
  color: var(--gray-500);
  line-height: 1.4;
  margin-top: 4px;
}
.med-field-group .form-hint em {
  font-style: italic;
  color: var(--gray-500);
  font-weight: 400;
}

/* Radio Sì/No per ogni campo medico (iniettati da initMedToggles) */
.med-yesno {
  display: inline-flex;
  gap: 8px;
  margin-bottom: 10px;
  background: white;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 4px;
}
.med-yesno-opt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--gray-700);
  transition: background .15s, color .15s;
  user-select: none;
  margin: 0;
}
.med-yesno-opt input[type="radio"] {
  accent-color: #C62828;
  margin: 0;
  width: 14px;
  height: 14px;
  cursor: pointer;
}
.med-yesno-opt:hover {
  background: #FFF3E0;
}
.med-yesno-opt:has(input[type="radio"]:checked) {
  background: #FFEBEE;
  color: #C62828;
}
.med-yesno-opt:has(input[value="no"]:checked) {
  background: #E8F5E9;
  color: #2E7D32;
}

/* Mobile */
@media (max-width: 480px) {
  .med-field-group { padding: 10px 12px; }
  .med-field-group label { font-size: 13.5px; }
  .med-field { font-size: 14px; min-height: 80px; padding: 11px 12px; }
  .form-hint { font-size: 11px; }
  .med-yesno-opt { padding: 6px 12px; font-size: 13px; }
}
