/* ==============================================================
   Fitness Time Club — Design System (stile "luxury club")
   Nero assoluto + bianco, tipografia grotesca bold in maiuscolo,
   angoli netti, bottoni bianchi pieni / contorno, niente gradienti.
   Nessun colore d'accento: il contrasto fa tutto il lavoro.
   ===================================================================== */

[hidden] { display: none !important; }

:root {
  --bg: #000000;
  --bg-deep: #000000;
  --surface: #0b0b0b;
  --surface-2: #141414;
  --surface-3: #1f1f1f;
  --border: #2b2b2b;
  --border-soft: rgba(255, 255, 255, 0.08);

  /* I vecchi nomi "ember/gold/aqua" restano come alias per non toccare
     tutto il resto del CSS: ora sono tutti bianco / grigi. */
  --ember: #ffffff;
  --ember-dark: #8a8a8a;
  --ember-soft: rgba(255, 255, 255, 0.10);
  --ember-glow: rgba(255, 255, 255, 0.18);

  --gold: #9c9c9c;
  --gold-soft: rgba(255, 255, 255, 0.08);
  --gold-dark: #4a4a4a;

  --aqua: #d6d6d6;
  --aqua-soft: rgba(255, 255, 255, 0.08);
  --aqua-dark: #5a5a5a;

  --text: #ffffff;
  --text-muted: #a8a8a8;
  --text-faint: #6b6b6b;

  --success: #3ddc84;
  --success-soft: rgba(61, 220, 132, 0.14);
  --warning: #ffffff;

  --font-display: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-body: 'Inter', 'Helvetica Neue', Helvetica, Arial, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --radius-sm: 0px;
  --radius-md: 0px;
  --radius-lg: 0px;
  --tap-min: 52px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --shadow-card: none;
  --shadow-pop: 0 24px 60px -20px rgba(0, 0, 0, 0.9);

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
}

/* Grana sottile fissa: rompe la piattezza del nero puro senza costare
   in leggibilità. Puramente decorativa, sotto ogni contenuto reale. */
.grain {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 180px 180px;
}

button, input, select {
  font-family: inherit;
  color: inherit;
}

h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }
p { margin: 0 0 8px; }
.muted { color: var(--text-muted); font-size: 14px; }

.icon {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.15em;
  flex-shrink: 0;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  position: relative;
  z-index: 1;
}

/* ---------------------------- TOP BAR ---------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: #000;
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 36px; height: 36px; border-radius: 0; box-shadow: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-text strong {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.5px;
  font-weight: 400;
  line-height: 1;
}
.brand-text span { font-size: 10px; color: var(--gold); text-transform: uppercase; letter-spacing: 1.4px; font-weight: 700; margin-top: 3px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.icon-btn {
  width: var(--tap-min);
  height: var(--tap-min);
  min-width: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  color: var(--text-muted);
}
.icon-btn .icon { width: 19px; height: 19px; }
.icon-btn:active { background: var(--surface-2); color: var(--text); }

.badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 5px 10px;
  border-radius: 0;
}
.badge-offline { background: var(--gold); color: #000000; }

/* ---------------------------- LAYOUT / VIEWS ---------------------------- */
main#view-app {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px calc(96px + var(--safe-bottom));
}

.view { animation: fade-in 0.18s ease-out; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-title {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 400;
  letter-spacing: 0.3px;
  margin: 2px 0 16px;
}

.stack { display: flex; flex-direction: column; gap: 12px; }

/* ---------------------------- CARDS ---------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-card);
}

.card-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 1.1px;
  margin-bottom: 10px;
}

/* ---------------------------- AUTH ---------------------------- */
.view-auth {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-top) + 24px) 20px calc(var(--safe-bottom) + 24px);
  background:
    var(--bg-deep);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.auth-logo {
  width: min(240px, 72%);
  height: auto;
  border-radius: 0;
  margin-bottom: 18px;
  box-shadow: none;
}
.auth-card h1 {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 400;
  letter-spacing: 0.4px;
}

.auth-form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; text-align: left; }

.signup-fields { display: flex; flex-direction: column; gap: 14px; }

/* Modale "Aggiungi esercizio": stessa spaziatura tra tutti i campi, anche dentro i gruppi Catalogo/Personalizzato */
#aex-catalogo-fields:not([hidden]),
#aex-custom-fields:not([hidden]) { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }

.field input,
.field select,
.field textarea,
.pr-lookup input {
  min-height: var(--tap-min);
  padding: 0 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
}

.field textarea { padding: 12px 14px; font-family: inherit; resize: vertical; }
.field input:focus, .pr-lookup input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--ember);
  box-shadow: none;
}

.form-error {
  background: var(--ember-soft);
  color: #ffffff;
  border: 1px solid var(--ember-dark);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
}

/* ---------------------------- BUTTONS ---------------------------- */
.btn {
  min-height: var(--tap-min);
  padding: 0 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.15s ease, opacity 0.15s ease;
  touch-action: manipulation;
}
.btn .icon { width: 17px; height: 17px; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-block { width: 100%; }

.btn-primary {
  background: #fff;
  color: #000000;
  box-shadow: none;
}
.btn-primary:active { background: #d9d9d9; }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:active { background: var(--surface-3); }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:active { color: var(--text); }

.btn-round {
  width: var(--tap-min);
  height: var(--tap-min);
  border-radius: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 700;
  padding: 0;
}

.btn-sm { min-height: 40px; padding: 0 14px; font-size: 13px; }

/* ---------------------------- TAB BAR ---------------------------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  background: var(--bg-deep);
  border-top: 1px solid var(--border);
  padding: 6px 6px calc(6px + var(--safe-bottom));
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 0 6px;
  background: transparent;
  border: none;
  border-top: 2px solid transparent;
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  min-height: var(--tap-min);
  transition: color 0.15s ease;
}

.tab-icon { width: 21px; height: 21px; display: inline-flex; }
.tab-icon .icon { width: 100%; height: 100%; }

.tab-btn.is-active { color: var(--ember); border-top-color: var(--ember); }

/* ---------------------------- SESSION / EXERCISE CARDS ---------------------------- */
.session-card {
  position: relative;
  border-radius: 0;
  overflow: hidden;
}
.session-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: #fff;
}
.session-card .card-title { color: var(--text); font-size: 18px; text-transform: none; letter-spacing: 0; font-weight: 800; }

.exercise-item {
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 0;
  margin-bottom: 10px;
  overflow: hidden;
}
.exercise-item:last-child { margin-bottom: 0; }

.exercise-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.exercise-head .exercise-name { flex: 1; min-width: 0; }
.exercise-name { font-weight: 800; font-size: 16px; }
.exercise-target { font-size: 11px; color: var(--gold); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 700; }

.exercise-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 4px 10px;
  border-radius: 0;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.chip .icon { width: 12px; height: 12px; margin-right: 4px; }
.chip-red { background: var(--ember-soft); color: #ffffff; border-color: var(--ember-dark); }

.set-log-row {
  display: grid;
  grid-template-columns: 44px 1fr 1fr 1fr auto;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}
.set-log-row span.set-num {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--text-muted);
  text-align: center;
}
.set-log-row input {
  min-height: 44px;
  min-width: 0;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  padding: 0 4px;
}
.set-log-row input:focus { outline: none; border-color: var(--ember); }
.set-log-row .btn-round { width: 44px; height: 44px; }
.set-log-row .btn-round .icon { width: 18px; height: 18px; }
.set-log-row.is-done .btn-round { background: var(--success); color: #000000; border-color: var(--success); }

.set-log-legend {
  display: grid;
  grid-template-columns: 44px 1fr 1fr 1fr auto;
  gap: 6px;
  font-size: 10.5px;
  color: var(--text-faint);
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}

/* ---------------------------- STAT / STORICO ---------------------------- */
.stat-row { display: flex; gap: 16px; }
.stat { flex: 1; text-align: center; }
.stat-value {
  display: block;
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 400;
  line-height: 1;
  color: var(--ember);
  font-variant-numeric: tabular-nums;
}
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 700; margin-top: 4px; display: inline-block; }

.pr-lookup { display: flex; gap: 8px; margin-bottom: 10px; }
.pr-lookup input { flex: 1; }
.pr-result { margin: 0; }
.pr-result.has-value { color: var(--text); font-weight: 800; font-size: 16px; }

.log-day-group { margin-bottom: 4px; }
.log-day-header {
  font-size: 12px;
  font-weight: 800;
  color: var(--gold);
  margin: 4px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.log-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 14px;
}
.log-row .log-exercise { font-weight: 700; }
.log-row .log-detail { color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ---------------------------- INFO PALESTRA ---------------------------- */
.info-hours-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.info-hours-table td { padding: 9px 0; border-bottom: 1px solid var(--border-soft); font-weight: 600; }
.info-hours-table td:last-child { text-align: right; color: var(--text-muted); font-weight: 700; font-variant-numeric: tabular-nums; }

.course-grid { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------------------------- TIMER OVERLAY ---------------------------- */
.timer-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(4px);
}

.timer-card { width: 100%; max-width: 340px; text-align: center; }
.timer-label {
  display: block;
  font-size: 13px;
  font-weight: 800;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}
.timer-display {
  font-family: var(--font-display);
  font-size: 104px;
  font-weight: 400;
  color: var(--ember);
  font-variant-numeric: tabular-nums;
  margin-bottom: 24px;
  letter-spacing: 2px;
}
.timer-display.is-warning { color: var(--gold); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.timer-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 18px;
}
.timer-controls .btn-primary { width: 92px; height: 92px; border-radius: 0; font-size: 15px; }

/* ---------------------------- MODAL (+ AGGIUNGI ESERCIZIO) ---------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(0, 0, 0, 0.86);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  backdrop-filter: blur(4px);
}

.modal-card {
  width: 100%;
  max-width: 480px;
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 22px 20px calc(20px + var(--safe-bottom));
  box-shadow: var(--shadow-pop);
}

@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal-card { border-radius: var(--radius-lg); border-bottom: 1px solid var(--border); }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal-head .card-title { margin-bottom: 0; font-size: 16px; color: var(--text); text-transform: none; letter-spacing: 0; }
.modal-head .icon-btn { width: 36px; height: 36px; min-width: 36px; min-height: 36px; }
.modal-head .icon-btn .icon { width: 15px; height: 15px; }

/* ---- Modal "+ Esercizio": toggle catalogo / personalizzato (segmented) ---- */
.aex-mode-toggle {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
}
.chip-toggle {
  flex: 1;
  min-height: 42px;
  padding: 0 8px;
  border-radius: 0;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}
.chip-toggle .icon { width: 14px; height: 14px; }
.chip-toggle.is-active { background: var(--ember-soft); color: #ffffff; }

/* ---------------------------- ICONE PERICOLO (elimina/rimuovi) ---------------------------- */
.icon-btn-danger {
  color: #ffffff;
  border-color: var(--ember-dark);
  background: var(--ember-soft);
}
.icon-btn-sm {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
}
.icon-btn-sm .icon { display: block; vertical-align: baseline; margin: 0; }
.icon-btn-danger { border-color: var(--ember-dark); }

/* Titolo con icona (BIA): icona fissa, testo su blocco separato allineato alla "C" */
.card-title-icon {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  line-height: 1.3;
}
.card-title-icon > .icon { width: 20px; height: 20px; margin-top: -2px; vertical-align: baseline; color: var(--gold); }
.card-title-icon > span { min-width: 0; }
.bia-sub { white-space: nowrap; }
.icon-btn-sm .icon { width: 13px; height: 13px; }

.scheda-head-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.scheda-head-actions .chip {
  height: 28px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
}

.exercise-row-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
}
.exercise-row-line:not(:last-child) { border-bottom: 1px solid var(--border-soft); }

.exercise-row-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.exercise-row-name {
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
  overflow-wrap: break-word;
}
.exercise-row-meta {
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}
.exercise-row-meta .icon { width: 11px; height: 11px; margin: 0 1px 0 3px; }
.exercise-row-note {
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.3;
  display: inline-flex;
  align-items: flex-start;
  gap: 4px;
}
.exercise-row-note .icon { width: 12px; height: 12px; margin-top: 2px; color: var(--gold); flex-shrink: 0; }

.icon-btn-remove {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-faint);
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
  touch-action: manipulation;
}
.icon-btn-remove .icon { width: 13px; height: 13px; }
.icon-btn-remove:hover,
.icon-btn-remove:active {
  color: #ffffff;
  background: var(--ember-soft);
}

.btn-pill-add {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 0;
  padding: 5px 11px;
  border-radius: 0;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  touch-action: manipulation;
}
.btn-pill-add:hover,
.btn-pill-add:active {
  background: var(--ember-soft);
  border-color: var(--ember-dark);
  color: #ffffff;
}

/* ---------------------------- DASHBOARD ISTRUTTORE ---------------------------- */
main#view-dashboard, main#view-athlete-detail, main#view-athlete-home {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px calc(24px + var(--safe-bottom));
}

.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.dash-header .view-title { margin: 0; }

.search-input {
  width: 100%;
  min-height: var(--tap-min);
  padding: 0 14px;
  margin-bottom: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}
.search-input::placeholder { color: var(--text-faint); font-weight: 500; }
.search-input:focus { outline: none; border-color: var(--ember); box-shadow: none; }

.select-input {
  min-height: var(--tap-min);
  padding: 0 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
}

/* Filtri dashboard: tab con sottolineatura invece della classica pillola
   colorata da "dashboard SaaS generica" — piu' simile a una vera barra
   di navigazione di sezione. */
.filter-pills {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
}
.filter-pills::-webkit-scrollbar { display: none; }

.pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 0;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-faint);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  margin-bottom: -1px;
}
.pill .icon { width: 14px; height: 14px; }
.pill.is-active { color: var(--text); border-bottom-color: var(--ember); }
.pill-count {
  background: var(--surface-2);
  color: var(--text-faint);
  border-radius: 0;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
}
.pill.is-active .pill-count { background: var(--ember-soft); color: #ffffff; }

.athlete-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.15s ease;
}
.athlete-card:active { transform: scale(0.985); border-color: var(--border); }
.athlete-avatar {
  width: 44px;
  height: 44px;
  border-radius: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.5px;
  color: var(--gold);
  flex-shrink: 0;
}
.athlete-info { flex: 1; min-width: 0; }
.athlete-name { font-weight: 800; font-size: 16px; }
.athlete-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 7px; align-items: center; }

.badge-categoria {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 800;
  padding: 4px 9px 4px 7px;
  border-radius: 0;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.badge-categoria .icon { width: 11px; height: 11px; margin-right: 4px; }
.badge-categoria.cat-sala_pesi { background: var(--ember-soft); color: #ffffff; border: 1px solid var(--ember-dark); }
.badge-categoria.cat-personal { background: var(--gold-soft); color: var(--gold); border: 1px solid var(--gold-dark); }
.badge-categoria.cat-nuoto { background: var(--aqua-soft); color: var(--aqua); border: 1px solid var(--aqua-dark); }

.scheda-status { font-size: 12px; color: var(--text-muted); font-weight: 600; display: inline-flex; align-items: flex-start; gap: 5px; line-height: 1.3; }
.scheda-status .icon { width: 13px; height: 13px; flex-shrink: 0; margin-top: 1px; }
.scheda-status-text { min-width: 0; }
.scheda-status.has-scheda { color: var(--success); font-weight: 700; }

/* ---------------------------- SIMULATE BANNER ---------------------------- */
.simulate-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--gold-soft);
  border: 1px solid var(--gold-dark);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
}
.simulate-banner .icon { width: 14px; height: 14px; margin-right: 2px; }

/* ---------------------------- TOAST ---------------------------- */
.toast-container {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(80px + var(--safe-bottom));
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--ember);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--shadow-pop);
  animation: toast-in 0.2s ease-out;
}
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: #ef4444; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------------------------- BIA / COMPOSIZIONE CORPOREA ---------------------------- */
.bia-metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.bia-metric {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}
.bia-metric-value {
  display: block;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 400;
  color: var(--ember);
  font-variant-numeric: tabular-nums;
}
.bia-metric-value small { font-size: 12px; font-weight: 700; font-family: var(--font-body); margin-left: 2px; color: var(--text-muted); }
.bia-metric-label {
  display: block;
  font-size: 10.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  margin-top: 2px;
}
.bia-delta {
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 0;
}
.bia-delta-good { background: var(--success-soft); color: #7ed079; }
.bia-delta-bad { background: var(--ember-soft); color: #ffffff; }
.bia-delta-flat { background: rgba(255, 255, 255, 0.07); color: var(--text-muted); }

.bia-history-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 4px; }
.bia-history-table th {
  text-align: left;
  font-size: 10.5px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 800;
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
}
.bia-history-table td { padding: 8px 4px; border-bottom: 1px solid var(--border-soft); color: var(--text); font-variant-numeric: tabular-nums; }
.bia-history-table tr:last-child td { border-bottom: none; }

/* ---------------------------- MISC ---------------------------- */
.empty-state { text-align: center; padding: 36px 16px; color: var(--text-muted); }
.empty-state-icon {
  width: 42px;
  height: 42px;
  margin: 0 auto 12px;
  display: block;
  color: var(--text-faint);
}
.empty-state-icon .icon { width: 100%; height: 100%; }

@media (min-width: 640px) {
  main#view-app, main#view-dashboard, main#view-athlete-detail, main#view-athlete-home { padding-left: 24px; padding-right: 24px; max-width: 640px; margin: 0 auto; width: 100%; }
  .topbar, .tabbar { padding-left: max(16px, calc(50% - 320px + 16px)); padding-right: max(16px, calc(50% - 320px + 16px)); }
}

/* ---------------------------- SCHEDA: PDF / INVIA / ADDOME-CARDIO ---------------------------- */
.scheda-actions { display: flex; gap: 8px; margin: 0 0 12px; }
.scheda-actions .btn { flex: 1; }
.session-extra { font-size: 13px; color: var(--text-muted); margin: 8px 0 0; line-height: 1.4; }
.session-extra strong { color: var(--text); font-size: 11px; letter-spacing: 0.5px; margin-right: 4px; }
.exercise-row-tecnica { font-size: 12px; color: #ffffff; font-weight: 700; }

/* ---------------------------- BIA COMPLETA ---------------------------- */
.bia-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bia-form-grid .field span { font-size: 11px; }
.bia-more { margin: 4px 0 10px; }
.bia-more > summary { cursor: pointer; font-size: 13px; font-weight: 700; color: var(--text-muted); padding: 8px 0; }
.bia-more[open] > summary { color: var(--text); }
.bia-calcoli { font-size: 13px; margin: 0; }
.bia-detail-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 4px; }
.bia-detail-table th { text-align: left; color: var(--text-muted); font-weight: 700; padding: 6px 4px; width: 20%; }
.bia-detail-table td { padding: 6px 4px; color: var(--text); font-variant-numeric: tabular-nums; width: 30%; }
.bia-detail-table tr { border-bottom: 1px solid var(--border-soft); }
.bia-detail-table tr:last-child { border-bottom: none; }
.bia-form-grid > * { min-width: 0; }
.bia-form-grid input { width: 100%; min-width: 0; box-sizing: border-box; }
#delete-athlete-btn { color: #ffffff; }

/* Schede comprimibili (vista coach) */
.scheda-toggle { cursor: pointer; -webkit-tap-highlight-color: transparent; user-select: none; }
.scheda-toggle .exercise-name { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.scheda-chevron { display: inline-flex; flex-shrink: 0; color: var(--gold); transition: transform .2s ease; }
.scheda-chevron .icon { width: 18px; height: 18px; }
.scheda-collassabile.is-collapsed .scheda-chevron { transform: rotate(-90deg); }
.scheda-collassabile.is-collapsed .scheda-body { display: none; }
.scheda-collassabile.is-collapsed .scheda-toggle { margin-bottom: 0; }

/* ==============================================================
   Pubblicazione scheda/BIA + vista utente (sola lettura)
   ===================================================================== */
.logout-btn { font-size: 13px; padding: 6px 12px; }
.chip-live { background: var(--aqua-soft); color: var(--aqua); border-color: var(--aqua-dark); display: inline-flex; align-items: center; gap: 4px; }
.chip-live .icon { width: 13px; height: 13px; }
.btn-publish { background: var(--aqua-soft); color: var(--aqua); border: 1px solid var(--aqua-dark); }
.scheda-actions { flex-wrap: wrap; }
.scheda-actions .btn { min-width: 96px; }

.bia-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 0;
  padding: 3px 8px; font-size: 11px; font-weight: 700; cursor: pointer;
}
.bia-toggle .icon { width: 12px; height: 12px; }
.bia-toggle.is-on { color: var(--aqua); border-color: var(--aqua-dark); background: var(--aqua-soft); }
.bia-origin { display: block; font-size: 10px; color: var(--gold); font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; }
.circ-history-row { font-size: 13px; color: var(--text-muted); margin: 8px 0; line-height: 1.5; }
.circ-history-row strong { color: var(--text); display: block; }

.field-check { flex-direction: row; align-items: center; gap: 10px; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--text); }
.field-check input { width: 20px; height: 20px; accent-color: var(--ember); }
.home-tabs { margin-bottom: 14px; }

/* Assegna nuova scheda: giorni a spunta in verticale */
.nsc-days { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.nsc-days legend { padding: 0; margin-bottom: 8px; font-size: 12px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.nsc-day { display: flex; flex-direction: row; align-items: center; gap: 12px; min-height: var(--tap-min); padding: 0 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; }
.nsc-day input { width: 22px; height: 22px; flex: none; accent-color: var(--ember); }
.nsc-day:has(input:checked) { border-color: var(--ember); }

/* Vista utente: contenuto non selezionabile/copiabile (i campi dei form restano utilizzabili) */
body.is-athlete #view-athlete-home { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.is-athlete #view-athlete-home input { -webkit-user-select: text; user-select: text; }
@media print { body.is-athlete #app, body.is-athlete .modal-overlay { display: none !important; } body.is-athlete::before { content: "Contenuto non stampabile"; display: block; padding: 24px; } }

/* Frecce spostamento esercizi */
.exercise-row-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.move-btns { display: flex; flex-direction: column; gap: 4px; }
.icon-btn-move {
  width: 32px; height: 22px; min-height: 22px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2, rgba(255,255,255,.06)); color: var(--text-muted);
  border: 1px solid var(--border-soft); border-radius: 0; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn-move .icon { width: 14px; height: 14px; }
.icon-btn-move-down .icon { transform: rotate(180deg); }
.icon-btn-move:hover:not(:disabled) { color: var(--gold); border-color: var(--gold); }
.icon-btn-move:disabled { opacity: .3; cursor: default; }

/* Misure antropometriche */
.antrop-group { margin: 14px 0 6px; font-size: 11px; font-weight: 800; letter-spacing: .08em; color: var(--text-muted); }
.antrop-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border-soft); border-radius: 0; }
.antrop-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.antrop-table th, .antrop-table td { padding: 8px 10px; text-align: center; white-space: nowrap; border-bottom: 1px solid var(--border-soft); }
.antrop-table thead th { background: #000; color: #fff; font-size: 11px; font-weight: 700; }
.antrop-table tbody th { text-align: left; position: sticky; left: 0; background: var(--surface, #1c1816); color: var(--text); font-weight: 700; }
.antrop-table tbody tr:last-child th, .antrop-table tbody tr:last-child td { border-bottom: none; }
#antrop-campi .antrop-group:first-child { margin-top: 4px; }

/* Tabella storico BIA: scorre in orizzontale invece di sbordare dalla card (colonna Online/Nascosta) */
.bia-history-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.bia-toggle { white-space: nowrap; }

/* ---- Registrazione / privacy ---- */
.link-inline { color: var(--ember); text-decoration: underline; }
.privacy-text { font-size: 14px; line-height: 1.5; color: var(--text); max-height: 52vh; overflow-y: auto; margin: 4px 0 14px; }
.privacy-text p { margin: 0 0 10px; }
.badge-nuovo { display: inline-block; padding: 2px 8px; border-radius: 0; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; background: var(--gold-soft); color: var(--gold); border: 1px solid var(--gold-dark); margin-right: 6px; }

/* Pulsanti azioni atleta: stessa altezza, spaziatura e allineamento */
.athlete-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.athlete-actions .btn { width: 100%; min-height: 48px; white-space: nowrap; }

/* ---------------------------- SCHEDE CARICATE COME PDF ---------------------------- */
#upload-scheda-btn { margin-top: 10px; min-height: 48px; }
.icon-flip { transform: rotate(180deg); }
.pdf-scheda-info {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; margin-bottom: 4px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 0;
  font-size: 13px;
}
.pdf-scheda-info .icon { width: 20px; height: 20px; flex: none; color: var(--ember); }
.pdf-scheda-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }

/* ---------------------------- DIETA PDF ---------------------------- */
.dieta-section .dieta-item { padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.dieta-section .dieta-file { font-size: 12px; margin: 2px 0 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dieta-section #upload-dieta-btn { min-height: 48px; }


/* ==============================================================
   TEMA "LUXURY CLUB" — tipografia, bottoni, componenti
   (regole finali: hanno la precedenza sulle precedenti)
   ===================================================================== */
.grain { display: none; }

body { font-weight: 400; letter-spacing: 0.005em; -webkit-font-smoothing: antialiased; }

/* Wordmark largo e spaziato nella top bar */
.topbar { padding-top: calc(var(--safe-top) + 14px); padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.brand { gap: 12px; }
.brand-text strong {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.34em;
  text-transform: uppercase;
}
.brand-text span { color: var(--text-muted); font-size: 9px; letter-spacing: 0.3em; font-weight: 500; margin-top: 5px; }

/* Titoli: grandi, pesanti, maiuscolo */
.view-title, .auth-card h1 {
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  line-height: 1.02;
}
.view-title { font-size: 34px; margin: 4px 0 20px; }
.auth-card h1 { font-size: 38px; margin-bottom: 10px; }
.auth-card .muted { font-size: 15px; }

.card-title {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.22em;
}
.session-card .card-title { color: #fff; font-size: 20px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.01em; }
.modal-head .card-title { font-size: 15px; text-transform: uppercase; letter-spacing: 0.12em; font-weight: 700; }

/* Card piatte con filetto sottile */
.card { border: 1px solid var(--border); background: var(--surface); }
.session-card::before { height: 2px; }
.exercise-item, .log-row, .bia-metric, .pdf-scheda-info { background: var(--surface-2); border-color: var(--border-soft); }
.exercise-name, .athlete-name { font-weight: 700; letter-spacing: 0.01em; }
.exercise-target { color: var(--text-muted); letter-spacing: 0.14em; font-weight: 600; }

/* Bottoni: pieno bianco / contorno, maiuscolo spaziato */
.btn {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  min-height: 54px;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.06s ease;
}
.btn-primary { background: #fff; color: #000; border: 1px solid #fff; }
.btn-primary:hover { background: #ececec; }
.btn-secondary { background: #000; color: #fff; border: 1px solid #fff; }
.btn-secondary:active, .btn-secondary:hover { background: #fff; color: #000; }
.btn-ghost { color: var(--text-muted); letter-spacing: 0.14em; }
.btn-sm { min-height: 40px; font-size: 11px; letter-spacing: 0.14em; }
.btn-publish { background: #000; color: #fff; border: 1px solid #fff; }
.btn:focus-visible, .tab-btn:focus-visible, .icon-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.icon-btn { background: #000; border: 1px solid var(--border); color: #fff; }
.icon-btn:active { background: #fff; color: #000; }
.btn-round { background: #000; border: 1px solid #fff; }

/* Campi: rettangoli neri con bordo, label piccole e spaziate */
.field { font-size: 10.5px; letter-spacing: 0.2em; font-weight: 600; }
.field input, .field select, .field textarea, .pr-lookup input, .search-input, .select-input {
  background: #000;
  border: 1px solid #4a4a4a;
  font-weight: 500;
}
.field input:focus, .pr-lookup input:focus, .field select:focus, .field textarea:focus, .search-input:focus {
  border-color: #fff;
}
.set-log-row input { background: #000; border-color: #4a4a4a; }
.set-log-row input:focus { border-color: #fff; }
.set-log-row.is-done .btn-round { background: #fff; color: #000; border-color: #fff; }
.set-log-row span.set-num, .athlete-avatar { font-family: var(--font-display); font-weight: 700; }
.athlete-avatar { color: #fff; }

/* Numeri grandi, pesanti */
.stat-value, .bia-metric-value, .timer-display { font-family: var(--font-display); font-weight: 800; letter-spacing: -0.02em; }
.stat-value { font-size: 44px; color: #fff; }
.bia-metric-value { font-size: 28px; color: #fff; }
.timer-display { font-size: 108px; color: #fff; }
.timer-display.is-warning { color: #fff; }
.timer-controls .btn-primary { width: 96px; height: 96px; }

/* Tab bar: nera, voce attiva bianca con filetto sopra */
.tabbar { background: #000; border-top: 1px solid var(--border); }
.tab-btn { font-size: 10px; letter-spacing: 0.16em; font-weight: 600; }
.tab-btn.is-active { color: #fff; border-top-color: #fff; }

/* Filtri / pill: solo testo con sottolineatura bianca */
.pill { letter-spacing: 0.12em; text-transform: uppercase; font-size: 11.5px; font-weight: 600; }
.pill.is-active { color: #fff; border-bottom-color: #fff; }
.pill.is-active .pill-count { background: #fff; color: #000; }

/* Chip / badge: rettangoli con filetto */
.chip, .badge-categoria { letter-spacing: 0.08em; }
.chip-red, .badge-categoria.cat-sala_pesi, .badge-categoria.cat-personal, .badge-categoria.cat-nuoto, .chip-live {
  background: transparent; color: #fff; border: 1px solid #fff;
}
.badge-offline { background: #fff; color: #000; letter-spacing: 0.14em; }
.chip-toggle.is-active { background: #fff; color: #000; }
.btn-pill-add { letter-spacing: 0.1em; text-transform: uppercase; font-size: 10.5px; }
.btn-pill-add:hover, .btn-pill-add:active { background: #fff; border-color: #fff; color: #000; }

/* Messaggi */
.form-error { background: transparent; border: 1px solid #fff; color: #fff; }
.toast { background: #fff; color: #000; border: none; border-left: 4px solid #000; letter-spacing: 0.02em; }
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: #e5484d; }
.simulate-banner { background: transparent; border: 1px solid var(--border); color: #fff; letter-spacing: 0.04em; }

/* Modali e overlay */
.modal-overlay, .timer-overlay { background: rgba(0, 0, 0, 0.92); backdrop-filter: none; }
.modal-card { background: #000; border: 1px solid var(--border); }

/* Tabelle */
.antrop-table thead th { background: #fff; color: #000; letter-spacing: 0.1em; text-transform: uppercase; }
.antrop-table tbody th { background: #000; }
.bia-history-table th, .bia-detail-table th { letter-spacing: 0.16em; }
.log-day-header { color: var(--text-muted); letter-spacing: 0.2em; }

.link-inline { color: #fff; }
.field-check input { accent-color: #fff; }
.badge-nuovo { background: #fff; color: #000; border-color: #fff; }
.scheda-chevron { color: #fff; }
.card-title-icon > .icon { color: #fff; }
.exercise-row-note .icon { color: var(--text-muted); }
.exercise-row-tecnica { color: #fff; letter-spacing: 0.06em; }
.pdf-scheda-info .icon { color: #fff; }
.icon-btn-danger { background: #000; border-color: #fff; color: #fff; }

/* Firma */
.credit { margin: 28px 0 8px; text-align: center; font-size: 10px; font-weight: 500; letter-spacing: 0.24em; text-transform: uppercase; color: var(--text-faint); }
.credit strong { color: var(--text-muted); font-weight: 600; }

/* Login: gerarchia più pulita */
.auth-card h1 { margin-bottom: 6px; }
.auth-card .muted#auth-intro { font-size: 13px; letter-spacing: 0.02em; margin-bottom: 0; }
.auth-form { margin-top: 22px; gap: 12px; }
#auth-toggle-mode { margin-top: 4px; font-size: 11.5px; letter-spacing: 0.1em; white-space: nowrap; }
#auth-forgot { min-height: 40px; font-size: 10.5px; margin-top: -2px; }
.credit {
  margin: 36px 0 4px;
  font-size: clamp(9px, 2.8vw, 11px);
  letter-spacing: 0.14em;
  white-space: nowrap;
  color: var(--text-muted);
}
.credit strong { color: #fff; font-weight: 700; }


/* ==============================================================
   COMFORT VISIVO (2026-10-14) — regole finali
   Meno contrasto "bianco su nero" che affatica la vista: grigi
   morbidi, bianco sporco, scritte dei pulsanti normali (non tutte
   maiuscole e spaziate), azione principale in rosso del logo,
   angoli appena arrotondati, più respiro tra i riquadri.
   ===================================================================== */
:root {
  --bg: #0f0f10;
  --bg-deep: #0f0f10;
  --surface: #171718;
  --surface-2: #1e1e20;
  --surface-3: #28282b;
  --border: #38383c;
  --border-soft: rgba(255, 255, 255, 0.07);
  --text: #ececea;
  --text-muted: #a3a3a8;
  --text-faint: #72727a;
  --brand-red: #c4122f;
  --brand-red-press: #a50f27;
}
html, body { background: var(--bg-deep); color: var(--text); }
.stack { gap: 16px; }
.card { padding: 18px; }

/* Angoli appena arrotondati */
.btn, .icon-btn, .icon-btn-sm, .btn-pill-add, .btn-round { border-radius: 8px; }
.card, .modal-card { border-radius: 12px; }
.session-card { overflow: hidden; }
.field input, .field select, .field textarea, .search-input, .select-input, .pr-lookup input, .set-log-row input { border-radius: 8px; }
.exercise-item, .pdf-scheda-info, .bia-metric, .log-row, .form-error, .simulate-banner { border-radius: 8px; }
.chip, .badge-categoria, .chip-toggle, .bia-toggle, .badge-nuovo { border-radius: 6px; }

/* Pulsanti: scritte normali, un po' più grandi, niente spaziatura esagerata */
.btn { font-size: 15px; font-weight: 600; letter-spacing: 0.01em; text-transform: none; white-space: nowrap; }
.btn-sm { font-size: 13.5px; letter-spacing: 0.01em; }
.btn-ghost { letter-spacing: 0.02em; }

/* Principale = rosso del logo; secondario = grigio con filetto morbido */
.btn-primary { background: var(--brand-red); color: #fff; border: 1px solid var(--brand-red); }
.btn-primary:hover { background: var(--brand-red); }
.btn-primary:active { background: var(--brand-red-press); }
.btn-secondary, .btn-publish { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-3); color: var(--text); }
.btn-secondary:active { background: var(--surface-3); color: var(--text); }
.btn:focus-visible, .tab-btn:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--text-muted); }
.icon-btn, .icon-btn-danger, .btn-round { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.icon-btn:active { background: var(--surface-3); color: var(--text); }
.icon-btn-danger { color: #e08a92; }
.set-log-row.is-done .btn-round { background: var(--brand-red); color: #fff; border-color: var(--brand-red); }

/* Titoli di sezione e etichette: meno spaziati, più leggibili */
.card-title { letter-spacing: 0.14em; font-size: 11.5px; }
.field { font-size: 11.5px; letter-spacing: 0.08em; }
.tab-btn { font-size: 10.5px; letter-spacing: 0.06em; }
.tab-btn.is-active { color: var(--text); border-top-color: var(--brand-red); }
.pill { letter-spacing: 0.06em; }
.pill.is-active { color: var(--text); border-bottom-color: var(--brand-red); }
.pill.is-active .pill-count { background: var(--brand-red); color: #fff; }
.exercise-target, .bia-origin { letter-spacing: 0.08em; }

/* Campi */
.field input, .field select, .field textarea, .pr-lookup input, .search-input, .select-input, .set-log-row input {
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.field input:focus, .pr-lookup input:focus, .field select:focus, .field textarea:focus, .search-input:focus, .set-log-row input:focus {
  border-color: var(--text-muted);
}

/* Chip e badge: filetto grigio, non bianco */
.chip-red, .badge-categoria.cat-sala_pesi, .badge-categoria.cat-personal, .badge-categoria.cat-nuoto {
  background: transparent; color: var(--text); border: 1px solid var(--border);
}
.chip-live { background: var(--success-soft); color: var(--success); border: 1px solid rgba(61, 220, 132, 0.4); }
.chip-toggle.is-active { background: var(--surface-3); color: var(--text); box-shadow: inset 0 -2px 0 var(--brand-red); }
.badge-offline, .badge-nuovo { background: var(--surface-3); color: var(--text); border-color: var(--border); }
.btn-pill-add:hover, .btn-pill-add:active { background: var(--surface-3); border-color: var(--border); color: var(--text); }
.bia-toggle.is-on { color: var(--success); border-color: rgba(61, 220, 132, 0.4); background: var(--success-soft); }

/* Superfici */
.tabbar, .modal-card { background: var(--bg-deep); }
.modal-overlay, .timer-overlay { background: rgba(10, 10, 11, 0.9); }
.antrop-table thead th { background: var(--surface-3); color: var(--text); letter-spacing: 0.06em; }
.antrop-table tbody th { background: var(--surface); }
.toast { background: var(--surface-3); color: var(--text); border-left: 4px solid var(--text-muted); }
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: #e5484d; }
.session-card::before { background: var(--brand-red); }

/* ---- Allineamenti ---- */
/* + Nuova BIA / + Nuove misure: stessa dimensione, una riga, allineati a destra e al centro del titolo */
.exercise-head:has(> #new-bia-btn), .exercise-head:has(> #new-antrop-btn) { align-items: center; margin-bottom: 10px; }
#new-bia-btn, #new-antrop-btn {
  flex: 0 0 auto;
  width: 124px;
  min-height: 36px;
  padding: 0 10px;
  font-size: 13px;
  white-space: nowrap;
}
/* Apri / Invia / Pubblica: tre pulsanti uguali, icona e scritta centrate su una riga */
.scheda-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.scheda-actions .btn { min-width: 0; width: 100%; padding: 0 6px; gap: 6px; line-height: 1; white-space: nowrap; }
.scheda-actions .btn .icon { flex: none; margin: 0; }
#auth-toggle-mode { letter-spacing: 0.02em; font-size: 13px; }
#auth-forgot { letter-spacing: 0.02em; font-size: 12.5px; }
.credit { letter-spacing: 0.1em; }

/* Dashboard: titolo libero, "Nuovo atleta" a tutta larghezza sotto */
.dash-header { margin-bottom: 16px; }
.dash-new-btn { margin-bottom: 12px; }

/* Testata scheda: titolo su una riga a sinistra, azioni allineate a destra */
.scheda-toggle { flex-wrap: nowrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.scheda-toggle .scheda-title {
  flex: 1;
  min-width: 0;
  display: block;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.scheda-head-actions { gap: 8px; align-items: center; }
.scheda-head-actions .chip { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; padding: 0 10px; white-space: nowrap; }
.scheda-chevron { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; flex-shrink: 0; color: var(--text-muted); }
.scheda-chevron .icon { width: 16px; height: 16px; }
.scheda-collassabile.is-collapsed .scheda-chevron { transform: rotate(-90deg); }
.scheda-actions .btn { min-width: 0; padding: 0 8px; white-space: nowrap; }
.scheda-actions .btn .icon { flex-shrink: 0; }

/* ---------------------------- FOTO PALESTRA ---------------------------- */
/* Login: foto della sala pesi a tutto schermo, scurita per tenere leggibile il form */
.view-auth {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.45) 0%, rgba(0, 0, 0, 0.6) 45%, rgba(0, 0, 0, 0.88) 100%),
    url('images/gym-hero.jpg') center 30% / cover no-repeat,
    #000;
}

/* Info: foto grande con titolo sopra */
.gym-hero { position: relative; overflow: hidden; border: 1px solid var(--border); background: #000; }
.gym-hero img { display: block; width: 100%; height: 190px; object-fit: cover; object-position: center 35%; }
.gym-hero::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 35%, rgba(0,0,0,0.85) 100%); }
.gym-hero-text { position: absolute; left: 16px; right: 16px; bottom: 14px; z-index: 1; display: flex; flex-direction: column; gap: 4px; }
.gym-hero-text strong { font-size: 20px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; line-height: 1.1; }
.gym-hero-text span { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }

/* Galleria a scorrimento orizzontale */
.gym-gallery {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-left: 16px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: 0 -16px;
  padding: 0 16px;
}
.gym-gallery::-webkit-scrollbar { display: none; }
.gym-gallery figure { flex: 0 0 78%; max-width: 320px; margin: 0; position: relative; scroll-snap-align: start; border: 1px solid var(--border); background: #000; overflow: hidden; }
.gym-gallery img { display: block; width: 100%; height: 190px; object-fit: cover; }
.gym-gallery figcaption { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 12px 10px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; background: linear-gradient(180deg, transparent, rgba(0,0,0,0.85)); }
.view-auth .auth-card h1, .view-auth #auth-intro { text-shadow: 0 1px 12px rgba(0,0,0,0.9); } .view-auth #auth-intro { color: #d8d8d8; }

/* Banner con foto della palestra in cima a dashboard e home atleta */
.page-hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: 150px;
  padding: 16px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  background: #000 center / cover no-repeat;
  overflow: hidden;
}
.page-hero::before { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0.88) 100%); }
.page-hero .view-title { position: relative; margin: 0; text-shadow: 0 2px 14px rgba(0,0,0,0.8); }
.page-hero--dash { background-image: url('images/gym-hex.jpg'); background-position: center 30%; }
.page-hero--home { background-image: url('images/gym-start.jpg'); background-position: center 60%; }

/* Dashboard istruttore: banner con foto della sala */
#view-dashboard .dash-header {
  position: relative;
  min-height: 150px;
  padding: 16px;
  align-items: flex-end;
  border: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.15) 0%, rgba(0, 0, 0, 0.85) 100%),
    url('images/gym-hex.jpg') center 35% / cover no-repeat,
    #000;
}
#view-dashboard .dash-header .view-title { text-shadow: 0 2px 14px rgba(0, 0, 0, 0.9); }

/* ---------------------------- LOGIN: pannello leggibile, identico su telefono e PC ---------------------------- */
.view-auth {
  align-items: stretch;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.55) 50%, rgba(0, 0, 0, 0.8) 100%),
    url('images/gym-hero.jpg') center 35% / cover no-repeat,
    #000;
}
.view-auth .auth-card {
  margin: auto;
  width: 100%;
  max-width: 420px;
  padding: 24px 22px 18px;
  background: rgba(8, 8, 9, 0.72);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
/* Il nome del club è già nel logo: il titolo resta solo per accessibilità */
.view-auth .auth-card h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; }
.view-auth .auth-logo { width: min(210px, 62%); margin: 0 auto 14px; display: block; }
.view-auth #auth-intro { font-size: 14px; line-height: 1.4; color: #e6e6e6; margin: 0; text-shadow: none; }
.view-auth .auth-form { margin-top: 18px; gap: 12px; }
.view-auth .field { font-size: 11.5px; color: #d6d6d6; letter-spacing: 0.16em; }
.view-auth .credit { margin: 22px 0 2px; color: #bdbdbd; }
.view-auth .credit strong { color: #fff; }

/* Schermi bassi (PC con finestra bassa, telefoni piccoli): tutto deve entrare senza scorrere */
@media (max-height: 760px) {
  .view-auth { padding-top: 14px; padding-bottom: 14px; }
  .view-auth .auth-card { padding: 16px 20px 12px; }
  .view-auth .auth-logo { width: min(150px, 46%); margin-bottom: 10px; }
  .view-auth #auth-intro { font-size: 13px; }
  .view-auth .auth-form { margin-top: 12px; gap: 9px; }
  .view-auth .field input { min-height: 46px; }
  .view-auth .btn { min-height: 48px; }
  .view-auth #auth-forgot { min-height: 34px; }
  .view-auth .credit { margin-top: 12px; }
}
@media (max-height: 640px) {
  .view-auth .auth-logo { width: 110px; }
  .view-auth .field input { min-height: 42px; }
  .view-auth .btn { min-height: 44px; }
}
/* Telefono in verticale: il taglio mostra luci a esagono e scaffale, non solo il lato sinistro */
@media (orientation: portrait) {
  .view-auth {
    background:
      linear-gradient(180deg, rgba(0, 0, 0, 0.45) 0%, rgba(0, 0, 0, 0.5) 50%, rgba(0, 0, 0, 0.78) 100%),
      url('images/gym-hero.jpg') 72% 30% / cover no-repeat,
      #000;
  }
}

/* ---------------------------- LOGIN v3: niente barra doppia, foto come fascia su telefono ---------------------------- */
/* Nel login il logo è già nel form: la barra in alto sparisce */
#app:has(#view-auth:not([hidden])) .topbar { display: none; }

@media (max-width: 600px) {
  /* Telefono: fascia con la foto in alto, form su fondo scuro sotto */
  .view-auth {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 0 0 calc(var(--safe-bottom) + 14px);
    background: #000;
  }
  .view-auth::before {
    content: '';
    display: block;
    flex: none;
    height: clamp(120px, 26dvh, 210px);
    background:
      linear-gradient(180deg, rgba(0, 0, 0, 0.35) 0%, rgba(0, 0, 0, 0) 40%, #000 100%),
      url('images/gym-hero.jpg') 68% 40% / cover no-repeat;
  }
  .view-auth .auth-card {
    margin: 0;
    max-width: none;
    padding: 0 22px 8px;
    background: transparent;
    border: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .view-auth .auth-logo { width: min(170px, 48%); margin: calc(-1 * clamp(40px, 8dvh, 64px)) auto 12px; position: relative; box-shadow: 0 8px 26px rgba(0, 0, 0, 0.6); }
}
@media (max-width: 600px) and (max-height: 700px) {
  .view-auth .auth-logo { width: 120px; margin-bottom: 8px; }
  .view-auth .auth-form { margin-top: 10px; gap: 8px; }
  .view-auth .credit { margin-top: 10px; }
}

/* Login telefono: la fascia foto occupa lo spazio libero (niente nero vuoto), logo con angoli morbidi */
@media (max-width: 600px) {
  .view-auth { min-height: 100dvh; }
  .view-auth::before {
    flex: 1 1 auto;
    height: auto;
    min-height: clamp(120px, 26dvh, 210px);
    max-height: 360px;
  }
  .view-auth .auth-logo { border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.14); }
}

/* Login: anche la zona sotto (area sicura dell'iPhone) è nera, niente striscia grigia */
html:has(#view-auth:not([hidden])),
body:has(#view-auth:not([hidden])),
#app:has(#view-auth:not([hidden])) { background: #000; }
.view-auth { min-height: 100vh; min-height: 100dvh; padding-bottom: calc(var(--safe-bottom) + 14px); }
@supports (-webkit-touch-callout: none) { .view-auth { min-height: -webkit-fill-available; } }

/* Home atleta: saluto elegante, banner più alto sulla pista START, schede su una riga */
.page-hero--home { min-height: 190px; background-position: center 82%; }
.page-hero--home .view-title { display: flex; flex-direction: column; gap: 2px; text-transform: none; letter-spacing: 0; }
.page-hero--home .hero-hello { font-size: 12px; font-weight: 600; letter-spacing: 0.28em; text-transform: uppercase; color: #d8d8d8; }
.page-hero--home .hero-name { font-size: 30px; font-weight: 800; line-height: 1.05; letter-spacing: -0.01em; text-transform: none; overflow-wrap: anywhere; }
.home-tabs .chip-toggle { white-space: nowrap; letter-spacing: 0.04em; padding: 0 6px; }
.empty-state p { max-width: 280px; margin: 0 auto; line-height: 1.5; }

/* Home atleta v2: foto pulita (START visibile), saluto sotto, schede leggibili, stato vuoto curato */
.page-hero--home { min-height: 180px; margin-bottom: 0; background-position: center 78%; }
.page-hero--home::before { background: linear-gradient(180deg, rgba(0,0,0,0) 55%, rgba(0,0,0,0.5) 100%); }
.home-greeting { display: flex; flex-direction: column; gap: 3px; margin: 16px 2px 16px; }
.home-greeting .hero-hello { font-size: 12px; font-weight: 600; letter-spacing: 0.28em; text-transform: uppercase; color: var(--text-muted); }
.home-greeting .hero-name { font-size: 30px; font-weight: 800; line-height: 1.05; letter-spacing: -0.01em; overflow-wrap: anywhere; }

.home-tabs .chip-toggle { min-height: 50px; font-size: 13px; font-weight: 700; color: #c8c8c8; gap: 7px; }
.home-tabs .chip-toggle .icon { width: 17px; height: 17px; }
.home-tabs .chip-toggle.is-active { color: #fff; background: var(--surface-3); box-shadow: inset 0 -2px 0 #c8102e; }

#athlete-home-content .empty-state {
  margin-top: 6px;
  padding: 44px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: #d4d4d4;
}
#athlete-home-content .empty-state-icon { width: 60px; height: 60px; margin-bottom: 16px; color: #8a8a8a; }
#athlete-home-content .empty-state p { font-size: 15px; max-width: 270px; }

.logout-btn { color: #dcdcdc; font-size: 13px; font-weight: 600; min-height: 36px; padding: 6px 14px; border: 1px solid var(--border); background: transparent; }


/* ==== Ritocchi grafici 2026-10-15 ==== */
/* Simula Allenamento: spazi uguali sopra e sotto (tolto il margine extra sul tasto Elimina) */
.athlete-actions { gap: 12px; }
.athlete-actions #delete-athlete-btn { margin-top: 0; }

/* Etichette di sezione e tasti sotto i contenuti (dieta e scheda: stessa struttura) */
.athlete-section-label { display: flex; align-items: center; gap: 8px; margin: 18px 0 10px; font-size: 13px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); }
.athlete-section-label .icon { width: 16px; height: 16px; }
.athlete-upload-actions { display: flex; flex-direction: column; gap: 10px; margin: 4px 0 14px; }

/* Titolo scheda/dieta: si legge per intero (va a capo), niente "..." */
.scheda-toggle { align-items: flex-start; }
.scheda-toggle .scheda-title { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; padding-top: 4px; }

/* ONLINE, cestino e freccetta: stesse colonne in tutte le card */
.scheda-head-actions { align-items: center; }
.scheda-head-actions .chip { min-width: 0; padding: 0 8px; font-size: 10px; letter-spacing: 0.06em; gap: 3px; justify-content: center; }
.scheda-head-actions .icon-btn-sm { width: 28px; height: 28px; }
.scheda-chevron { width: 28px; height: 28px; }
.dieta-card .dieta-file { font-size: 12px; margin: 2px 0 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Banner dashboard: foto piu' visibile, titolo piccolo in basso a sinistra */
.page-hero--dash { min-height: 190px; background-position: center 38%; }
.page-hero--dash::before { background: linear-gradient(180deg, rgba(0,0,0,0) 55%, rgba(0,0,0,0.75) 100%); }
.page-hero--dash .view-title { font-size: 16px; letter-spacing: 0.22em; font-weight: 800; }

/* Header giorno scheda: titolo su una riga, bottoni sotto affiancati a meta' */
.exercise-head.day-head { flex-direction: column; align-items: stretch; gap: 10px; }
.exercise-head.day-head .exercise-name { flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-head-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
.day-head-actions .btn-pill-add { justify-content: center; width: 100%; padding: 8px 6px; white-space: nowrap; }

a.btn { text-decoration: none; }
