/* Palette APEX · Digital Personal Training: blu notte, blu elettrico (accent) e arancio (accent-2, dettagli) */
:root {
  --bg-color: #0b1220;
  --card-bg: #151f33;
  --input-bg: #1c2942;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-2: #f97316;
  --on-accent: #ffffff;
  --text-main: #ffffff;
  --text-muted: #9fb0c8;
  --green: #4caf50;
  --red: #f44336;
  --border: #2a3a58;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: dark; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  margin: 0 auto;
  max-width: 600px;
  padding: calc(70px + env(safe-area-inset-top)) 16px 24px;
  -webkit-tap-highlight-color: transparent;
}
body.detail { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

button { font-family: inherit; }
h1 { font-size: 1.4rem; text-align: center; margin: 0 0 16px; color: var(--accent); }
/* Marchio APEX (schermate di accesso): "APE" blu + "X" arancio, sottotitolo in maiuscoletto */
h1.brand { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-bottom: 18px; }
.brand-apex { font-size: 2.3rem; font-weight: 900; letter-spacing: 0.1em; line-height: 1; color: var(--accent); }
.brand-apex .x { color: var(--accent-2); }
.brand-sub { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.28em; text-transform: uppercase; color: var(--text-muted); }
.muted { color: var(--text-muted); }
.small { font-size: 0.8rem; }
.center { text-align: center; }
.empty { text-align: center; color: var(--text-muted); padding: 24px 0; }

/* ---------- Barra timer di riposo (fissa in alto) ---------- */
/* Barra in alto: nella pagina di allenamento (vista "day") il timer di riposo, ovunque altrove logo e nome dell'app */
#brand-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  background: var(--card-bg); border-bottom: 2px solid var(--accent);
  padding: 6px 12px; padding-top: calc(6px + env(safe-area-inset-top)); box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}
#brand-bar > div { max-width: 600px; margin: 0 auto; display: flex; align-items: center; justify-content: center; gap: 10px; }
body.wide #brand-bar > div { max-width: 960px; }
#brand-bar img { width: 36px; height: 36px; border-radius: 50%; }
#brand-bar .brand-apex { font-size: 1.3rem; }
#brand-bar .brand-sub { font-size: 0.55rem; letter-spacing: 0.22em; }
body:not(.detail) #timer-bar, body.detail #brand-bar, body.auth #brand-bar { display: none; }
.brand-logo { width: 96px; height: 96px; border-radius: 50%; margin-bottom: 8px; }
#timer-bar {
  position: fixed; top: 0; left: 0; right: 0;
  background: var(--card-bg);
  border-bottom: 2px solid var(--accent);
  padding: 8px 12px;
  padding-top: calc(8px + env(safe-area-inset-top));
  z-index: 1000;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}
#timer-bar > div {
  max-width: 600px; margin: 0 auto;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
#timer-bar.idle .timer-running, #timer-bar:not(.idle) .timer-idle { display: none; }
#timer-bar .timer-done-label { display: none; color: var(--green); font-weight: bold; font-size: 0.9rem; }
#timer-bar.finished .timer-done-label { display: inline; }
#timer-bar.finished .timer-track { display: none; }
.timer-label { font-size: 0.85rem; color: var(--text-muted); margin-right: 4px; }
.chip {
  background: var(--input-bg); color: var(--accent);
  border: 1px solid var(--accent); border-radius: 999px;
  padding: 6px 12px; font-size: 0.85rem; font-weight: bold; cursor: pointer;
}
.chip:active { background: var(--accent); color: var(--on-accent); }
#timer-display {
  font-size: 1.5rem; font-weight: bold; color: var(--accent);
  font-variant-numeric: tabular-nums; min-width: 4.5ch; text-align: center;
}
.timer-track { flex: 1; max-width: 180px; height: 6px; background: #3a3a3a; border-radius: 3px; overflow: hidden; }
#timer-fill { height: 100%; width: 100%; background: var(--accent); transition: width 0.25s linear; }
#timer-bar.finished { animation: flash 1s ease-in-out 3; }
@keyframes flash { 0%, 100% { background: #232323; } 50% { background: #2e5a30; } }
.btn-timer-stop {
  background: var(--red); color: #fff; border: none;
  padding: 6px 12px; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 0.85rem;
}
#timer-bar .timer-running { cursor: pointer; }   /* un tocco sul tempo riapre il timer a tutto schermo */

/* ---------- Timer di riposo a tutto schermo ---------- */
/* Copre tutta la pagina (sopra barre e menu, sotto le finestre di dialogo): anello che si svuota in senso orario e
   cifre grandi. --tf-color: blu mentre scorre, arancio negli ultimi 10 secondi (.last), verde a riposo finito. */
#timer-full {
  --tf-color: var(--accent);
  --tf-size: min(80vw, 50vh, 420px);
  position: fixed; inset: 0; z-index: 1500;
  background: radial-gradient(circle at 50% 40%, #17263f 0%, var(--bg-color) 65%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: calc(20px + env(safe-area-inset-top)) 20px calc(20px + env(safe-area-inset-bottom));
  overflow-y: auto; overscroll-behavior: contain; text-align: center;
}
#timer-full.last { --tf-color: var(--accent-2); }
#timer-full.finished { --tf-color: var(--green); }
body.timer-open { overflow: hidden; }
.tf-top { display: flex; flex-direction: column; gap: 6px; }
.tf-kicker { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.28em; text-transform: uppercase; color: var(--text-muted); }
#tf-title { font-size: 1.3rem; font-weight: 700; min-height: 1.3em; overflow-wrap: anywhere; }
/* Tempo della serie appena chiusa (js/pace.js): verde nei tempi, arancio troppo lunga, giallo troppo breve */
#tf-pace { font-size: 0.95rem; font-weight: 600; white-space: pre-line; max-width: 30em; margin: 0 auto; overflow-wrap: anywhere; }
#tf-pace[hidden] { display: none; }
.pace { margin: 6px 0 2px; }
.pace-ok { color: var(--green); }
.pace-long { color: var(--accent-2); }
.pace-short { color: #facc15; }
.tf-ring { position: relative; width: var(--tf-size); height: var(--tf-size); flex-shrink: 0; }
.tf-ring svg { width: 100%; height: 100%; display: block; overflow: visible; }
.tf-ring circle { fill: none; }
.tf-track { stroke: var(--input-bg); stroke-width: 10; }
.tf-ticks { stroke: var(--border); stroke-width: 5; stroke-dasharray: 1.2 6.968; }   /* 60 tacche, una al secondo */
#tf-arc {
  stroke: var(--tf-color); stroke-width: 10; stroke-linecap: round;
  stroke-dasharray: 565.49; stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.25s linear, stroke 0.3s;
  filter: drop-shadow(0 0 5px var(--tf-color));
}
.tf-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
#tf-time {
  font-size: calc(var(--tf-size) * 0.22); font-weight: 800; line-height: 1; color: var(--tf-color);
  font-variant-numeric: tabular-nums; transition: color 0.3s;
}
#tf-sub { font-size: 0.9rem; color: var(--text-muted); }
#timer-full.last #tf-time { animation: tf-pulse 1s ease-in-out infinite; }
#timer-full.finished .tf-ring { animation: tf-pulse 0.8s ease-in-out 3; }
@keyframes tf-pulse { 50% { transform: scale(1.06); } }
#tf-next { font-size: 1rem; color: var(--text-muted); min-height: 1.3em; max-width: 30em; overflow-wrap: anywhere; }
.tf-buttons { display: flex; gap: 10px; width: 100%; max-width: 420px; }
.tf-buttons .btn { margin: 0; flex: 1; }
/* A riposo finito un tocco qualsiasi chiude: al posto dei pulsanti resta solo l'invito */
#timer-full.finished .tf-buttons { position: relative; }
#timer-full.finished .tf-buttons .btn { visibility: hidden; }
#timer-full.finished .tf-buttons::before {
  content: 'Tocca per continuare'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 0.95rem;
}
@media (prefers-reduced-motion: reduce) {
  #timer-full.last #tf-time, #timer-full.finished .tf-ring { animation: none; }
}

/* ---------- Video di fine esercizio ---------- */
/* Sopra al timer di riposo: riquadro verticale 9:16 al centro, il più grande possibile; il video orizzontale
   riempie il riquadro tagliando i lati (object-fit: cover). Un tocco o ✕ chiude. */
#ex-video {
  position: fixed; inset: 0; z-index: 1600; background: rgba(0, 0, 0, 0.94);
  display: flex; align-items: center; justify-content: center;
}
#ex-video video {
  width: min(100vw, calc(100vh * 9 / 16));
  width: min(100vw, calc(100dvh * 9 / 16));
  aspect-ratio: 9 / 16; object-fit: cover; background: #000; display: block;
}
.ex-video-close {
  position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px;
  width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 1.3rem; line-height: 44px;
}

/* ---------- Card ---------- */
.card {
  background-color: var(--card-bg);
  border-radius: 12px; padding: 14px; margin-bottom: 14px;
  border: 1px solid var(--border);
}
.day-card {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  cursor: pointer; transition: background 0.2s ease;
}
.day-card:hover { background-color: #1c2942; }
.day-info { min-width: 0; }
.day-info strong { font-size: 1.05rem; display: block; }
.day-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.chev { color: var(--accent); font-size: 1.2rem; margin-left: 4px; }

.btn-icon {
  background: transparent; border: 1px solid var(--border); color: var(--text-main);
  border-radius: 8px; min-width: 36px; height: 36px; font-size: 0.95rem; cursor: pointer;
  transition: all 0.2s ease;
}
.btn-icon:hover { background: var(--accent); color: var(--on-accent); }
.btn-icon.danger { border-color: var(--red); }
.btn-icon.danger:hover { background: var(--red); color: #fff; }

.detail-header { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 14px; }
.detail-header h1 { margin: 0; }

.summary-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.summary .big { font-size: 1.5rem; font-weight: bold; color: var(--accent); line-height: 1.2; }
.summary .right { text-align: right; }
.progress-track { height: 5px; background: var(--input-bg); border-radius: 3px; overflow: hidden; margin: 10px 0 6px; }
.progress-fill { height: 100%; background: var(--green); transition: width 0.2s; }

.card-header {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  margin-bottom: 10px; border-bottom: 1px solid var(--border); padding-bottom: 8px;
}
.exercise-title { font-size: 1.05rem; font-weight: bold; min-width: 0; overflow-wrap: anywhere; }
.header-actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn-action-sm {
  background: transparent; border: 1px solid var(--border); color: var(--text-main);
  border-radius: 8px; padding: 6px 10px; font-size: 0.9rem; cursor: pointer; font-weight: bold;
  min-height: 34px; transition: all 0.2s ease;
}
.btn-action-sm:hover { background: var(--accent); color: var(--on-accent); }
.btn-image { border-color: var(--accent); color: var(--accent); }

/* ---------- Tabella serie ---------- */
table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 0.85rem; }
col.c-num { width: 22px; }
col.c-prev { width: 50px; }
col.c-done { width: 36px; }
col.c-del { width: 28px; }
th { color: var(--text-muted); text-align: center; padding: 0 0 6px; font-weight: 500; font-size: 0.75rem; }
td { padding: 4px 2px; text-align: center; vertical-align: middle; }
tr.done td { background: rgba(76, 175, 80, 0.08); }
tr.done td:first-child { border-radius: 6px 0 0 6px; }
tr.done td:last-child { border-radius: 0 6px 6px 0; }
.set-num { color: var(--text-muted); font-size: 0.8rem; }
.prev-data { color: var(--text-muted); font-size: 0.75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

input[type="text"] {
  width: 100%;
  background: var(--input-bg); border: 1px solid var(--border); color: var(--text-main);
  padding: 8px 2px; border-radius: 6px; text-align: center;
  font-size: 16px; /* 16px evita lo zoom automatico su iOS */
  font-family: inherit;
}
input:focus { outline: none; border-color: var(--accent); }
tr.done input { color: var(--text-muted); }

.btn-done {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--border); background: transparent; color: var(--text-muted);
  cursor: pointer; font-size: 1rem; font-weight: bold; transition: all 0.15s ease;
}
.btn-done.is-done { background: var(--green); border-color: var(--green); color: #fff; }
.btn-delete-row { background: transparent; color: var(--red); border: none; font-size: 1rem; cursor: pointer; padding: 6px 2px; }

.set-controls { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.set-controls .notes { flex: 1; text-align: left; padding: 8px 10px; }
.btn-add-set {
  background: var(--input-bg); color: var(--text-main); border: 1px solid var(--border);
  padding: 9px 12px; border-radius: 6px; cursor: pointer; font-size: 0.85rem; font-weight: bold; white-space: nowrap;
}

.stats {
  margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--border);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 10px; font-size: 0.85rem;
}
.badge-pos { color: var(--green); font-weight: bold; }
.badge-neg { color: var(--red); font-weight: bold; }
/* Suggerimento carico per la prossima sessione */
.suggest {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px;
  background: rgba(59, 130, 246, 0.1); border: 1px solid rgba(59, 130, 246, 0.5); border-radius: 10px; padding: 8px 12px; font-size: 0.88rem;
}
.suggest.muted { background: transparent; border-style: dashed; border-color: var(--border); font-size: 0.8rem; }
.suggest .txt { min-width: 0; }
.suggest .btn-action-sm { flex-shrink: 0; }

details.log { margin-top: 8px; }
details.log summary { cursor: pointer; color: var(--accent); font-size: 0.85rem; padding: 4px 0; }
.log-table { margin-top: 6px; font-size: 0.78rem; table-layout: auto; }
.log-table th, .log-table td { text-align: left; padding: 4px; }
.log-table .num { text-align: right; white-space: nowrap; }
.log-table tbody tr { border-top: 1px solid var(--border); }
.log-sets { color: var(--text-muted); }

/* ---------- Pulsanti ---------- */
.btn {
  background-color: var(--accent); color: var(--on-accent); border: none;
  padding: 12px 16px; border-radius: 8px; font-weight: bold; cursor: pointer;
  width: 100%; margin-top: 8px; font-size: 0.95rem;
}
.btn:hover { background-color: var(--accent-hover); }
.btn-secondary { background-color: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-secondary:hover { background-color: rgba(59, 130, 246, 0.12); }
.btn-danger { background-color: var(--red); color: #fff; }
.btn-danger:hover { background-color: #d32f2f; }
.btn-io {
  background-color: var(--input-bg); color: var(--text-main); border: 1px solid var(--border);
  padding: 8px 12px; border-radius: 6px; font-size: 0.8rem; cursor: pointer; font-weight: bold;
}
.btn-link { background: none; border: none; color: var(--text-muted); font-size: 0.85rem; cursor: pointer; padding: 8px; text-decoration: underline; }
.btn-link.danger { color: var(--red); }
.back-btn { background: none; border: none; color: var(--accent); font-size: 1rem; cursor: pointer; margin-bottom: 12px; padding: 4px 0; }
.backup-container {
  margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
}
.day-footer { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 16px; }

/* ---------- Barra azioni fissa in basso (vista scheda) ---------- */
#bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: #1a1a1a; border-top: 1px solid var(--border);
  padding: 10px 16px; padding-bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 900;
}
#bottom-bar .bar-inner { max-width: 600px; margin: 0 auto; display: flex; gap: 10px; }
#bottom-bar .btn { margin: 0; }
#bottom-bar .btn-secondary { flex: 0 0 auto; width: auto; padding-inline: 14px; }

/* ---------- Finestre di dialogo ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 2000;
  background-color: rgba(0, 0, 0, 0.78);
  display: flex; align-items: flex-end; justify-content: center; padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
@media (min-width: 600px) { .overlay { align-items: center; } }
.sheet {
  background-color: var(--card-bg); border: 1px solid var(--border); border-radius: 14px;
  width: 100%; max-width: 480px; padding: 16px; position: relative;
  box-shadow: 0 8px 24px rgba(0,0,0,0.8);
}
.sheet h3 { margin: 0 0 8px; color: var(--accent); font-size: 1.05rem; padding-right: 24px; }
.sheet p { margin: 0 0 12px; font-size: 0.9rem; }
.sheet input { text-align: left; padding: 10px 12px; margin-bottom: 12px; }
.sheet-action {
  display: block; width: 100%; background: var(--input-bg); color: var(--text-main);
  border: 1px solid var(--border); border-radius: 8px; padding: 12px; font-size: 0.95rem;
  text-align: left; cursor: pointer; margin-bottom: 8px;
}
.sheet-action.danger { color: var(--red); border-color: rgba(244, 67, 54, 0.4); }
.sheet-action:disabled { opacity: 0.4; cursor: default; }
.sheet-buttons { display: flex; gap: 10px; margin-top: 4px; }
.sheet-buttons .btn { margin: 0; }
.sheet-buttons a.btn { text-decoration: none; text-align: center; display: block; }
.image-sheet { text-align: center; }
.image-sheet img { max-width: 100%; max-height: 60vh; border-radius: 8px; margin: 10px 0; border: 1px solid var(--border); }
.modal-close { position: absolute; top: 6px; right: 10px; background: none; border: none; color: var(--text-muted); font-size: 1.6rem; cursor: pointer; }
.modal-close:hover { color: var(--text-main); }

/* ---------- Statistiche ---------- */
.tag {
  display: inline-block; font-size: 0.7rem; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; margin-top: 4px; cursor: pointer;
}
.tag:hover { border-color: var(--accent); color: var(--accent); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip.active { background: var(--accent); color: var(--on-accent); }
select {
  background: var(--input-bg); color: var(--text-main); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 14px; font-family: inherit; max-width: 100%;
}
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
@media (min-width: 700px) { body.wide .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.tile .label { font-size: 0.75rem; color: var(--text-muted); }
.tile .value { font-size: 1.45rem; font-weight: 600; margin: 2px 0; }
.tile .delta { font-size: 0.78rem; color: var(--text-muted); }
.chart-title { font-weight: bold; font-size: 1rem; }
.chart { margin-top: 10px; }
.chart-card select { width: 100%; margin-top: 10px; }
.chart-card .chips { margin-top: 8px; }
.ex-kpis { font-size: 0.85rem; margin-top: 8px; display: flex; flex-direction: column; gap: 3px; }
.stat-table { font-size: 0.8rem; table-layout: auto; margin-top: 8px; }
.stat-table th, .stat-table td { text-align: left; padding: 4px; }
.stat-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stat-table tbody tr { border-top: 1px solid var(--border); }

.chart-svg { display: block; max-width: 100%; overflow: visible; font-family: inherit; }
.chart-svg .grid { stroke: #2c2c2c; stroke-width: 1; }
.chart-svg .axis { fill: var(--text-muted); font-size: 10.5px; }
.chart-svg .lbl { fill: var(--text-main); font-size: 11px; }
.chart-svg .vlabel { fill: var(--text-main); font-size: 10.5px; font-weight: 600; }
.chart-svg .mark { fill: var(--accent); }
.chart-svg .mark.dim { fill: #5a5a5a; }
.chart-svg .mark.hot, .chart-svg .dot.hot { fill: #dcc8ff; }
.chart-svg .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .wash { fill: var(--accent); opacity: 0.1; }
.chart-svg .dot { fill: var(--accent); stroke: var(--card-bg); stroke-width: 2; }
.chart-svg .band { fill: rgba(255, 255, 255, 0.06); }
.chart-svg .crosshair { stroke: #555; stroke-width: 1; visibility: hidden; }
.chart-svg .hit { fill: transparent; pointer-events: all; cursor: pointer; outline: none; }
.chart-svg .hit:focus-visible { stroke: var(--accent); stroke-width: 1; }
#chart-tip {
  position: fixed; z-index: 3500; background: #2b2b2b; border: 1px solid #444; border-radius: 8px;
  padding: 6px 10px; pointer-events: none; font-size: 0.8rem; max-width: 240px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.6);
}
#chart-tip .tv { font-weight: 700; font-size: 0.95rem; }
#chart-tip .tl { color: var(--text-muted); }

/* ---------- Account, login, profilo, backoffice ---------- */
body.auth { padding-top: calc(24px + env(safe-area-inset-top)); }
body.auth #timer-bar { display: none; }
body.wide { max-width: 960px; }
.account-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 14px; font-size: 0.85rem;
}
.account-row .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-row .acts { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; } /* va a capo: 🚪 Esci sempre visibile */
.banner {
  background: rgba(255, 152, 0, 0.12); border: 1px solid #ff9800; color: #ffcc80;
  border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: 0.85rem;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.banner strong { color: #fff; }
.banner button { background: var(--accent-2); color: #000; border: none; border-radius: 6px; padding: 6px 10px; font-weight: bold; cursor: pointer; font-size: 0.8rem; white-space: nowrap; }
.banner .acts { display: flex; gap: 6px; flex-shrink: 0; }
.banner.msg { background: rgba(59, 130, 246, 0.12); border-color: var(--accent); color: #dbeafe; }
.banner.msg button { background: var(--accent); }
.banner.msg .quote { display: block; margin-top: 3px; font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.banner .txt { min-width: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tab {
  flex: 1; background: none; border: none; color: var(--text-muted); padding: 10px;
  font-size: 0.95rem; font-weight: bold; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.field, input.field[type="text"] {
  width: 100%; display: block;
  background: var(--input-bg); border: 1px solid var(--border); color: var(--text-main);
  padding: 11px 12px; border-radius: 8px; text-align: left; font-size: 16px; font-family: inherit; margin-bottom: 10px;
}
.field:focus { outline: none; border-color: var(--accent); }
label.lbl { display: block; font-size: 0.8rem; color: var(--text-muted); margin: 6px 0 4px; }
label.check { display: flex; align-items: flex-start; gap: 10px; font-size: 0.9rem; margin: 6px 0 10px; cursor: pointer; line-height: 1.35; }
label.check input { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; accent-color: var(--accent); }
label.check a { color: var(--accent); }
.auth-error { color: var(--red); font-size: 0.85rem; margin: 10px 0 0; min-height: 1.2em; text-align: center; }
.auth-error:empty { display: none; }
.auth-notice { color: var(--green); font-size: 0.85rem; margin: 10px 0 0; text-align: center; }
.auth-notice:empty { display: none; }
/* Riquadro della persona in cima all'elenco schede (workout.js → personCardHtml) */
.person-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px 22px;
  grid-template-areas: "photo data" "chart chart" "checks checks" "cal cal"; align-items: start;
}
/* Atleta: "I miei dati e progressi" e "Il mio calendario" come sezioni da aprire, sotto le schede (workout.js) */
details.fold { margin-top: 12px; padding: 0; }
details.fold > summary { list-style: none; cursor: pointer; padding: 14px 16px; font-weight: bold; display: flex; align-items: center; gap: 8px; min-height: 48px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: '▾'; margin-left: auto; color: var(--text-muted); transition: transform 0.2s; }
details.fold[open] > summary::after { transform: rotate(180deg); }
details.fold > .person-card { border: 0; background: none; margin: 0; padding: 0 16px 16px; box-shadow: none; }
details.fold > .pc-cal { padding: 12px 16px 16px; }
/* Calendario del solo atleta in fondo al riquadro (calendar.js → athleteCalendarHtml): celle più basse, non cliccabili */
.pc-cal { grid-area: cal; min-width: 0; border-top: 1px solid var(--border); padding-top: 12px; }
.pc-cal .acal-cell { min-height: 56px; cursor: default; }
.pc-cal .acal-cell:hover { border-color: var(--border); }
.pc-cal .acal-cell.today { border-color: var(--accent-2); }
.pc-photo { grid-area: photo; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.pc-data { grid-area: data; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 22px; min-width: 0; }
.pc-col .chart-title { margin-bottom: 4px; }
.pc-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.pc-row > span:last-child { text-align: right; min-width: 0; }
.pc-email { overflow-wrap: anywhere; }
.pc-edit { grid-column: 1 / -1; margin-top: 8px; }
.pc-chart { grid-area: chart; min-width: 0; border-top: 1px solid var(--border); padding-top: 12px; }
@media (max-width: 560px) {
  .person-card { grid-template-columns: minmax(0, 1fr); grid-template-areas: "photo" "data" "chart" "checks" "cal"; }
  .pc-data { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .ck-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Costanza (mappa a quadratini) e anello della settimana, sotto la crescita settimanale */
.pc-extra { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.pc-heat { flex: 1; min-width: 0; }
.heat { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px; }
.heat-col { display: flex; flex-direction: column; gap: 4px; flex: none; }
.heat-cell { display: inline-block; width: 18px; height: 18px; border-radius: 4px; background: var(--input-bg); }
@media (min-width: 900px) { .heat-cell { width: 22px; height: 22px; } .heat { gap: 5px; } .heat-col { gap: 5px; } }
.heat-cell.l1 { background: rgba(59, 130, 246, 0.35); }
.heat-cell.l2 { background: rgba(59, 130, 246, 0.6); }
.heat-cell.l3 { background: rgba(59, 130, 246, 0.85); }
.heat-cell.l4 { background: var(--accent-2); box-shadow: 0 0 8px rgba(249, 115, 22, 0.55); }
.heat-cell.lf { background: transparent; border: 1px dashed var(--border); }
.heat-legend { display: flex; align-items: center; gap: 4px; margin-top: 6px; }
.heat-legend .heat-cell { width: 12px; min-width: 12px; height: 12px; }
.streak { color: var(--accent-2); }
.pc-ring { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.ring-bg { fill: none; stroke: var(--input-bg); stroke-width: 9; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 9; stroke-linecap: round; transition: stroke-dasharray 0.6s ease; }
.ring-fg.full { stroke: var(--green); }
.ring-num { fill: var(--text-main); font-size: 19px; font-weight: 800; }
.ring-lbl { fill: var(--text-muted); font-size: 8.5px; letter-spacing: 0.04em; text-transform: uppercase; }
/* Check periodici (checks.js) */
.pc-checks { grid-area: checks; min-width: 0; border-top: 1px solid var(--border); padding-top: 12px; }
.ck-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.ck-tile { background: var(--input-bg); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.ck-tile strong { display: block; font-size: 1.15rem; margin: 2px 0; }
.ck-change { margin-top: 2px; }
.ck-bar { display: grid; grid-template-columns: 96px minmax(0, 1fr) 76px; align-items: center; gap: 8px; margin: 5px 0; font-size: 0.85rem; }
.ck-bar-lbl { color: var(--text-muted); }
.ck-bar-val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.ck-bar-track { position: relative; height: 12px; border-radius: 6px; background: var(--input-bg); }
.ck-bar-track::before { content: ''; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: var(--border); }
.ck-bar-fill { position: absolute; top: 0; bottom: 0; border-radius: 6px; }
.ck-bar-fill.neg { right: 50%; background: linear-gradient(270deg, var(--accent), #60a5fa); }
.ck-bar-fill.pos { left: 50%; background: linear-gradient(90deg, var(--accent-2), #fdba74); }
.ck-table td.acts { text-align: right; white-space: nowrap; }
.ck-table td.acts .btn-icon { margin-left: 4px; }
.ck-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 10px; }
.ck-form .lbl { display: grid; gap: 2px; }
.ck-photos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 6px 0 10px; }
.ck-slot { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ck-thumb { width: 100%; aspect-ratio: 3 / 4; border-radius: 8px; border: 1px dashed var(--border); background: var(--input-bg); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ck-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ck-pick { cursor: pointer; text-align: center; width: 100%; }
.ck-cmp-sel { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ck-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ck-pair figure { margin: 0; border-radius: 8px; overflow: hidden; background: var(--input-bg); aspect-ratio: 3 / 4; display: flex; flex-direction: column; justify-content: center; }
.ck-pair img { width: 100%; height: 100%; object-fit: cover; flex: 1; min-height: 0; }
.ck-pair figcaption { font-size: 0.75rem; color: var(--text-muted); text-align: center; padding: 3px 0; }
.ck-pair .empty-ph { align-items: center; }
.tpl-users { margin-top: 8px; font-size: 0.9rem; display: flex; flex-wrap: wrap; gap: 2px 6px; align-items: center; }
.tpl-users .tpl-user { padding: 2px 8px; border: 1px solid var(--border); border-radius: 999px; text-decoration: none; font-size: 0.85rem; }
.tpl-users .tpl-user:hover { border-color: var(--accent); }
/* Modifica di un modello: niente sessioni, storico, suggerimenti o spunte (sono valori di partenza) */
body.tplmode #session-summary, body.tplmode .exercise .stats, body.tplmode .exercise details.log, body.tplmode .exercise .suggest,
body.tplmode .btn-done, body.tplmode .c-prev, body.tplmode .prev-data, body.tplmode .exercise th:nth-child(2),
body.tplmode #bottom-bar [data-action="save-session"], body.tplmode [data-action="undo-session"], body.tplmode [data-action="template-save-day"] { display: none !important; }
.code-row .quota { flex-basis: 100%; text-align: center; font-size: 0.8rem; color: var(--text-muted); }
.code-row .quota.full { color: #ffcc80; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: 0.8rem; margin: 14px 0 6px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.inline-form { display: flex; gap: 8px; align-items: flex-start; }
.inline-form .field { margin-bottom: 0; }
.inline-form .btn { width: auto; margin: 0; padding: 11px 14px; flex-shrink: 0; }
.code-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.6rem; letter-spacing: 0.25em;
  color: var(--accent); background: var(--input-bg); border: 1px dashed var(--accent); border-radius: 10px;
  padding: 12px; text-align: center; margin: 10px 0;
}
.setup-card ol { padding-left: 20px; font-size: 0.9rem; line-height: 1.5; }

/* ---------- Backoffice istruttore: elenco atleti (tabella su PC, card su telefono) ---------- */
.code-row { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; font-size: 0.85rem; }
.code-row .code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.15rem; letter-spacing: 0.2em; color: var(--accent); }
.ath-table { table-layout: auto; width: 100%; font-size: 0.88rem; margin-bottom: 8px; }
.ath-table th { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.ath-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
.ath-table tr.ath { cursor: pointer; }
.ath-table tr.ath:hover td { background: #1c2942; }
.ath-table tr.is-blocked .who { opacity: 0.6; }
.ath-table .who strong { display: block; font-size: 1rem; }
.ath-table .who .muted { font-size: 0.78rem; }
.ath-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ath-table .pct { font-size: 1.05rem; font-weight: bold; }
.ath-table td.acts { text-align: right; white-space: nowrap; }
.ath-table td.acts .btn-icon { margin-left: 4px; }
.pill {
  display: inline-block; font-size: 0.7rem; font-weight: bold; border-radius: 999px; padding: 2px 8px; margin-left: 6px; vertical-align: middle;
}
.pill.blocked { background: rgba(244, 67, 54, 0.18); color: #ff8a80; border: 1px solid rgba(244, 67, 54, 0.5); }
.pill.warn { background: rgba(255, 152, 0, 0.18); color: #ffcc80; border: 1px solid rgba(255, 152, 0, 0.5); }
.pill.ok { background: rgba(76, 175, 80, 0.18); color: #a5d6a7; border: 1px solid rgba(76, 175, 80, 0.5); }
.table-wrap { overflow-x: auto; }
.ath-table tr.ath:not([data-action]) { cursor: default; }
.ath-table tr.ath:not([data-action]):hover td { background: transparent; }
.recall { border-color: #ff9800; }
.recall-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); }
/* Foto / avatar degli utenti (avatar.js) */
.avatar {
  flex: none; display: inline-flex; align-items: center; justify-content: center; overflow: hidden;
  border-radius: 50%; border: 2px solid var(--border); color: #fff; font-weight: bold; padding: 0;
  vertical-align: middle; line-height: 1; user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.av-sm { width: 32px; height: 32px; font-size: 0.8rem; }
.av-md { width: 44px; height: 44px; font-size: 1rem; }
.av-lg { width: 96px; height: 96px; font-size: 2.2rem; }
.av-xl { width: 120px; height: 120px; font-size: 2.8rem; }
.av-xl .av-emoji { font-size: 4rem; }
.av-sm .av-emoji { font-size: 1.05rem; }
.av-md .av-emoji { font-size: 1.45rem; }
.av-lg .av-emoji { font-size: 3.2rem; }
.av-initials { text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); }
button.avatar.av-edit { cursor: pointer; font-family: inherit; }
button.avatar.av-edit:hover { border-color: var(--accent); }
.who-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who-text { min-width: 0; flex: 1; display: flex; flex-direction: column; align-items: flex-start; }
.ath-table .who .pill { white-space: nowrap; }
h1 .avatar { margin-right: 4px; }
.av-preview { display: flex; justify-content: center; margin: 4px 0 12px; }
.av-file { cursor: pointer; text-align: center; }
.av-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; margin: 8px 0; }
.av-opt {
  aspect-ratio: 1; border-radius: 50%; border: 2px solid var(--border); background: var(--input-bg);
  font-size: 1.2rem; padding: 0; cursor: pointer; color: inherit;
}
.av-opt.sel { border-color: var(--accent-2); box-shadow: 0 0 0 2px var(--accent-2); }
.pill.new {
  background: var(--accent); color: var(--on-accent); font-size: 0.78rem; padding: 3px 10px;
  box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7); animation: blink-new 1.1s ease-in-out infinite;
}
.btn-icon .dot, .btn-io .pill.new { animation: blink-new 1.1s ease-in-out infinite; }
/* Lampeggio per i messaggi non letti: visibile anche con la coda dell'occhio */
@keyframes blink-new {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7); }
  50% { opacity: 0.35; box-shadow: 0 0 0 6px rgba(59, 130, 246, 0); }
}
@media (prefers-reduced-motion: reduce) { .pill.new, .btn-icon .dot { animation: none; } }
.btn-icon.warn { border-color: #ff9800; }
.btn-icon.warn:hover { background: var(--accent-2); color: #000; }
.btn-icon .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); margin-left: 3px; vertical-align: super; }
.btn-icon.has-new { border-color: var(--accent); }
/* Supervisione: intestazione del blocco di ogni istruttore */
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.admin-head strong { font-size: 1.05rem; }
.admin-head .btn-io { white-space: nowrap; }
/* Supervisione a pagine: Palestre → istruttori → atleti (briciole + righe cliccabili) */
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin: -4px 0 12px; font-size: 0.95rem; }
.crumbs .crumb { padding: 2px 4px; }
.nav-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.nav-row:last-child { border-bottom: none; }
.nav-row:hover { background: rgba(255, 255, 255, 0.03); }
.nav-row strong { font-size: 1.05rem; }
.nav-row.is-off, .nav-row.is-blocked { opacity: 0.7; }
.nav-row .chev { color: var(--accent); font-size: 1.1rem; padding: 0 4px; }
.gym-head { background: rgba(59, 130, 246, 0.08); }
.card.is-blocked > .admin-head { opacity: 0.7; }
.codes-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 14px; border-bottom: 1px solid var(--border); }
.code-chip {
  display: inline-flex; align-items: center; gap: 2px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--accent); background: var(--input); border: 1px dashed var(--accent); border-radius: 8px; padding: 2px 4px 2px 10px; letter-spacing: 0.1em;
}
.code-chip .btn-link { padding: 4px 6px; text-decoration: none; letter-spacing: 0; }
@media (max-width: 640px) {
  .ath-table thead { display: none; }
  .ath-table, .ath-table tbody, .ath-table tr, .ath-table td { display: block; width: 100%; }
  .ath-table tr { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
  .ath-table tr.ath:hover td { background: transparent; }
  .ath-table td, .ath-table td.num { padding: 2px 0; border: none; text-align: left; white-space: normal; }  .ath-table td.who { padding-bottom: 6px; }
  .ath-table td[data-label]::before { content: attr(data-label) ": "; color: var(--text-muted); font-size: 0.8rem; }
  .ath-table td.acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
  .ath-table td.acts .btn-icon { margin: 0; flex: 1; }
  .ath-table .pct { font-size: 1rem; }
  .card .ath-table { padding: 10px 10px 0; }
  .card .ath-table tr { background: var(--input); }
}

/* ---------- Calendario dell'istruttore: allenamenti salvati/previsti per atleta (un colore ciascuno) e appuntamenti ---------- */
.cal-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal-title { flex: 1; min-width: 0; font-weight: bold; font-size: 1.05rem; }
.cal-title .cal-month { text-transform: capitalize; }
.cal-nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.cal-nav .btn-icon { font-size: 1.2rem; line-height: 1; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 8px; }
.cal-chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--input-bg); border: 1px solid var(--border); color: var(--text-main);
  border-radius: 999px; padding: 4px 10px 4px 8px; font-size: 0.8rem; cursor: pointer; font-family: inherit; max-width: 100%;
}
.cal-chip:hover { border-color: var(--c); }
.cal-chip .sw { width: 12px; height: 12px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.cal-chip .days { color: var(--text-muted); font-size: 0.72rem; white-space: nowrap; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.cal-dow { text-align: center; font-size: 0.72rem; color: var(--text-muted); padding: 2px 0 4px; text-transform: uppercase; }
.cal-cell {
  min-height: 78px; min-width: 0; background: var(--input-bg); border: 1px solid var(--border); border-radius: 8px; padding: 4px;
  display: flex; flex-direction: column; gap: 2px; text-align: left; font-family: inherit; color: var(--text-main); cursor: pointer;
}
.cal-cell:hover { border-color: var(--accent); }
.cal-cell.other { opacity: 0.45; }
.cal-cell.today { border-color: var(--accent-2); }
.cal-cell.today .cal-num { color: var(--accent-2); font-weight: bold; }
.cal-cell.selected { background: rgba(59, 130, 246, 0.16); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-num { font-size: 0.78rem; color: var(--text-muted); line-height: 1; }
.cal-mark, .cal-appt {
  display: block; font-size: 0.7rem; line-height: 1.25; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--c);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.cal-mark.done { background: var(--c); color: #0b1220; font-weight: 600; }
.cal-mark.plan { color: var(--c); border-style: dashed; background: transparent; }
.cal-appt { background: rgba(255, 255, 255, 0.07); color: var(--text-main); border-left-width: 4px; }
.cal-more { font-size: 0.68rem; color: var(--text-muted); }
.cal-hint { margin: 8px 0 0; }
.cal-detail { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
.cal-detail-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.cal-detail-head strong { text-transform: capitalize; font-size: 0.95rem; }
.appt-row { display: flex; align-items: center; gap: 8px; padding: 6px 0 6px 10px; border-left: 4px solid var(--c); margin: 6px 0; font-size: 0.9rem; }
.appt-row .when { font-variant-numeric: tabular-nums; font-weight: bold; white-space: nowrap; min-width: 3.2em; }
.cal-who { display: inline-flex; align-items: center; gap: 5px; margin: 3px 10px 3px 0; }
.cal-who .sw { width: 11px; height: 11px; border-radius: 50%; background: var(--c); border: 2px solid var(--c); flex-shrink: 0; }
.cal-who.plan .sw { background: transparent; }
/* Dialogo "giorni di allenamento e colore" */
.cal-days { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.cal-days label { display: inline-flex; align-items: center; gap: 5px; background: var(--input-bg); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 0.9rem; }
.cal-days input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.cal-swatches { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 10px; }
.cal-swatch { position: relative; width: 28px; height: 28px; cursor: pointer; }
.cal-swatch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.cal-swatch span { display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--c); border: 3px solid transparent; }
.cal-swatch input:checked + span { border-color: #fff; box-shadow: 0 0 0 2px var(--c); }
@media (max-width: 640px) {
  .cal-title { flex-basis: 100%; }
  .cal-nav { width: 100%; justify-content: space-between; }
  .cal-cell { min-height: 48px; padding: 3px; flex-direction: row; flex-wrap: wrap; align-content: flex-start; gap: 3px; }
  .cal-cell .cal-num { width: 100%; margin-bottom: 1px; }
  /* Sul telefono niente testo: pallino pieno = salvato, anello = previsto, quadratino = appuntamento */
  .cal-mark, .cal-appt { width: 9px; height: 9px; padding: 0; border-radius: 50%; font-size: 0; border-width: 2px; flex-shrink: 0; }
  .cal-appt { border-radius: 2px; background: var(--c); border-color: var(--c); }
  .cal-more { font-size: 0.6rem; line-height: 9px; }
}

/* ---------- Menu laterale tipo Outlook (istruttore / ApexMaster): voci a sinistra, contenuto a destra ----------
   body.side = menu attivo. Da 900 px in su è fisso a sinistra; sotto è un pannello a scomparsa (☰ nella barra in alto,
   body.side-open = aperto) e nella barra resta sempre 🚪 Esci. */
.side-btn { display: none; background: none; border: 1px solid var(--border); color: var(--text-main); border-radius: 8px; width: 36px; height: 36px; font-size: 1.1rem; line-height: 1; cursor: pointer; flex-shrink: 0; padding: 0; }
.side-btn:hover { border-color: var(--accent); }
#brand-bar .side-btn { position: absolute; top: 50%; transform: translateY(-50%); }
#brand-bar .side-btn:first-child { left: 10px; }
#brand-bar .side-exit { right: 10px; }
#brand-bar > div { position: relative; }
#timer-bar .timer-menu { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); }
#sidebar {
  position: fixed; top: calc(50px + env(safe-area-inset-top)); bottom: 0; left: 0; width: 250px; z-index: 950;
  background: var(--card-bg); border-right: 1px solid var(--border); overflow-y: auto;
  padding: 10px 10px calc(12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 1px;
}
/* In alto: foto/avatar + nome + email */
.side-user { display: flex; align-items: center; gap: 10px; padding: 6px 8px 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; min-width: 0; }
.side-user .avatar { border-width: 1px; }
.side-user-txt { min-width: 0; display: flex; flex-direction: column; }
.side-user-txt strong { color: var(--text-main); font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-txt span { color: var(--text-muted); font-size: 0.74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Titoli di sezione (Gestione, Allenamento, …) e intestazione del modello in modifica */
.side-sec { font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-muted); opacity: 0.8; padding: 14px 12px 4px; }
.side-head { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); padding: 10px 10px 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-item {
  position: relative; display: flex; align-items: center; gap: 11px; width: 100%; background: none; border: none;
  color: var(--text-muted); font: inherit; font-size: 0.9rem; font-weight: 500; text-align: left; padding: 8px 12px;
  border-radius: 8px; cursor: pointer; transition: background 0.15s, color 0.15s;
}
.side-item .ico { flex: none; opacity: 0.85; }
.side-item:hover { background: var(--input-bg); color: var(--text-main); }
.side-item:hover .ico { opacity: 1; }
/* Voce attiva: fondo tenue e barra blu a sinistra */
.side-item.active { background: rgba(59, 130, 246, 0.14); color: var(--text-main); font-weight: 600; }
.side-item.active .ico { color: var(--accent); opacity: 1; }
.side-item.active::before { content: ''; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.side-item .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item .cnt { font-size: 0.7rem; color: var(--text-muted); font-weight: 600; white-space: nowrap; background: var(--input-bg); border-radius: 999px; padding: 1px 8px; }
.side-item.active .cnt { color: var(--accent); background: rgba(59, 130, 246, 0.16); }
.side-item .cnt.new { background: var(--accent); color: var(--on-accent); }
.side-item .tag { font-size: 0.66rem; font-weight: 600; color: #ffcc80; background: rgba(255, 152, 0, 0.15); border-radius: 4px; padding: 0 5px; margin-left: 4px; }
/* Sotto-voci (le schede, i giorni del modello): rientrate, più piccole, con un pallino al posto dell'icona */
.side-item.sub { padding-left: 50px; font-size: 0.84rem; padding-top: 6px; padding-bottom: 6px; }
.side-item.sub:not(:has(.ico))::after { content: ''; position: absolute; left: 31px; top: 50%; width: 5px; height: 5px; margin-top: -2.5px; border-radius: 50%; background: var(--border); }
.side-item.sub.active:not(:has(.ico))::after { background: var(--accent); }
.side-item.sub:has(.ico) { padding-left: 24px; }
.side-item.sub .ico { width: 15px; height: 15px; margin-left: 2px; }
.side-item.add { color: var(--accent); }
.side-item.sub2 { padding-left: 46px; font-size: 0.84rem; }
.side-item.sub3 { padding-left: 64px; font-size: 0.84rem; }
.side-item.back { color: var(--accent-2); font-weight: 600; }
.side-item.danger:hover { color: #ff8a80; }
.side-spacer { flex: 1; min-height: 12px; }
.side-item.exit { border-top: 1px solid var(--border); border-radius: 0 0 8px 8px; margin-top: 4px; padding-top: 12px; }
#side-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 940; }
@media (min-width: 900px) {
  body.side { max-width: none; margin: 0; padding-left: calc(250px + 24px); padding-right: 24px; }
  body.side #app-container { max-width: 960px; margin: 0 auto; }
  body.side.wide #app-container { max-width: 1040px; }
  body.side .account-row { display: none; }        /* la navigazione è nel menu */
  body.side #bottom-bar { left: 250px; }
  body.side #side-backdrop { display: none !important; }
}
@media (max-width: 899px) {
  body.side .side-btn { display: inline-flex; align-items: center; justify-content: center; }
  body.side #brand-bar > div, body.side #timer-bar > div { padding: 0 44px; }
  #sidebar { width: min(300px, 85vw); transform: translateX(-105%); transition: transform 0.2s ease; box-shadow: 0 0 24px rgba(0, 0, 0, 0.6); }
  body.side-open #sidebar { transform: none; }
}

/* ---------- Chat istruttore ↔ atleta ---------- */
/* La vista occupa tutta l'altezza: i messaggi si accumulano dal basso e la barra di scrittura resta in fondo */
body.chatv #app-container { display: flex; flex-direction: column; min-height: calc(100vh - 94px - env(safe-area-inset-top)); }
.chat-log { display: flex; flex-direction: column; justify-content: flex-end; gap: 10px; padding: 4px 0 12px; flex: 1; }
.msg { display: flex; flex-direction: column; max-width: 82%; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.them { align-self: flex-start; align-items: flex-start; }
.bubble {
  padding: 10px 14px; border-radius: 16px; font-size: 0.95rem; line-height: 1.35;
  white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--border); background: var(--card-bg);
}
.msg.me .bubble { background: var(--accent); color: var(--on-accent); border-color: var(--accent); border-bottom-right-radius: 4px; }
.msg.them .bubble { border-bottom-left-radius: 4px; }
.msg .meta { font-size: 0.72rem; color: var(--text-muted); margin: 3px 6px 0; }
/* Chiave di licenza inviata in chat dall'amministrazione (l'istruttore la attiva con un tocco) */
.msg .bubble.key { margin-top: 4px; padding: 6px 10px; background: var(--input-bg); color: var(--text-muted); border-style: dashed; }
.msg .bubble.key code { font-size: 0.68rem; word-break: break-all; }
.chat-compose {
  position: sticky; bottom: 0; display: flex; gap: 8px; align-items: flex-end;
  padding: 10px 0 calc(8px + env(safe-area-inset-bottom)); background: var(--bg-color); border-top: 1px solid var(--border);
}
.chat-compose .field { margin: 0; }
.chat-compose .btn { width: auto; margin: 0; padding: 11px 16px; flex-shrink: 0; }
.blocked-card { text-align: center; border-color: rgba(244, 67, 54, 0.5); }
.blocked-card .big-icon { font-size: 2.6rem; margin-bottom: 6px; }
.dialog-form label.lbl { margin-top: 2px; }
.dialog-form .field { margin-bottom: 10px; }
.pick-list { max-height: 40vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 4px 10px; margin-bottom: 10px; }
.pick-list label.check { margin: 8px 0; }
.setup-card code { background: var(--input-bg); padding: 1px 5px; border-radius: 4px; font-size: 0.85em; }
.spinner { text-align: center; color: var(--text-muted); padding: 40px 0; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  background: var(--input-bg); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 0.9rem;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
  z-index: 3000; max-width: 90vw; text-align: center; box-shadow: 0 4px 12px rgba(0,0,0,0.6);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
body.detail #toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
