:root {
  --bg: #000000;
  --card-bg: #0d0d0d;
  --subcard-bg: #141414;
  --input-bg: #161616;
  --border: #262626;
  --text: #ffffff;
  --text-muted: #8e8e93;
  --primary: #38bdf8;
  --primary-text: #000000;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --day-bg: #1a2736;
  --day-border: #0284c7;
  --invite-bg: #111c26;
  --log-bg: #0b1116;
  --log-border: #1e293b;
  --notes-bg: #161616;
  --notes-text: #e2e8f0;
  --radius: 12px;
}

[data-theme="light"] {
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --subcard-bg: #f8fafc;
  --input-bg: #ffffff;
  --border: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #0284c7;
  --primary-text: #ffffff;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --day-bg: #e0f2fe;
  --day-border: #38bdf8;
  --invite-bg: #f0f9ff;
  --log-bg: #f1f5f9;
  --log-border: #cbd5e1;
  --notes-bg: #fefce8;
  --notes-text: #334155;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }

body { background-color: var(--bg); color: var(--text); padding: 14px; min-height: 100vh; transition: background-color 0.2s, color 0.2s; }
.container { max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.hidden { display: none !important; }

header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 8px; border-bottom: 1px solid var(--border); gap: 8px; }
.header-brand { display: flex; align-items: center; gap: 10px; }
.site-logo { height: 38px; width: auto; max-width: 100px; object-fit: contain; border-radius: 6px; }
h1 { font-size: 1.1rem; font-weight: 700; color: var(--primary); }

.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.section-title { font-size: 0.95rem; font-weight: 700; margin-bottom: 10px; color: var(--primary); display: flex; justify-content: space-between; align-items: center; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 6px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
label { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; }
input, select, textarea { background: var(--input-bg); border: 1px solid var(--border); color: var(--text); padding: 10px; border-radius: 8px; font-size: 0.9rem; outline: none; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 70px; font-size: 0.85rem; line-height: 1.4; }

.btn { border: none; border-radius: 8px; padding: 12px 14px; font-weight: 700; font-size: 0.9rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; transition: opacity 0.2s; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-success { background: var(--success); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-sm { padding: 6px 10px; font-size: 0.78rem; width: auto; }

/* Switch Sole / Luna */
.theme-toggle-pill { display: inline-flex; background: var(--subcard-bg); border: 1px solid var(--border); border-radius: 99px; padding: 3px; gap: 4px; }
.theme-opt { border: none; background: transparent; color: var(--text-muted); padding: 6px 12px; border-radius: 99px; font-size: 0.82rem; font-weight: 700; cursor: pointer; display: flex; align-items: center; gap: 5px; }
.theme-opt.active { background: var(--primary); color: var(--primary-text); }

/* Auth Tabs */
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 14px; background: var(--subcard-bg); border: 1px solid var(--border); padding: 4px; border-radius: 8px; }
.auth-tab { padding: 8px; text-align: center; border-radius: 6px; font-size: 0.85rem; font-weight: 700; cursor: pointer; color: var(--text-muted); }
.auth-tab.active { background: var(--primary); color: var(--primary-text); }

/* Trainer Client List & Badges */
.invite-box { background: var(--invite-bg); border: 1px dashed var(--primary); border-radius: 8px; padding: 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.invite-code { font-family: monospace; font-size: 0.8rem; color: var(--primary); word-break: break-all; }
.client-card { background: var(--subcard-bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.client-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.status-badge { font-size: 0.72rem; font-weight: 700; padding: 3px 8px; border-radius: 99px; display: inline-block; margin-top: 4px; }
.status-active { background: rgba(34, 197, 94, 0.15); color: var(--success); border: 1px solid var(--success); }
.status-expiring { background: rgba(245, 158, 11, 0.15); color: var(--warning); border: 1px solid var(--warning); }
.status-expired { background: rgba(239, 68, 68, 0.15); color: var(--danger); border: 1px solid var(--danger); }
.status-none { background: rgba(142, 142, 147, 0.15); color: var(--text-muted); border: 1px solid var(--border); }

/* Builder & Preview */
.filter-row { display: flex; gap: 8px; margin-bottom: 8px; }
.filter-row select { max-width: 125px; }
.filter-row input { flex: 1; }
.preview-box { display: flex; gap: 14px; align-items: center; margin: 8px 0; background: var(--subcard-bg); border: 1px solid var(--border); padding: 8px; border-radius: 8px; }
.preview-photos { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }
.preview-photo-wrap { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.preview-thumb { width: 62px; height: 62px; border-radius: 6px; object-fit: cover; background: #fff; border: 1px solid var(--border); }
.photo-tag { font-size: 9px; color: var(--text-muted); text-transform: uppercase; font-weight: 700; }
.preview-info { font-size: 0.85rem; line-height: 1.3; }

.exercise-list { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.day-group { display: flex; flex-direction: column; gap: 8px; }
.day-badge { background: var(--day-bg); border: 1px solid var(--day-border); color: var(--primary); font-size: 0.8rem; font-weight: 700; padding: 6px 10px; border-radius: 6px; text-transform: uppercase; }
.exercise-item { background: var(--subcard-bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.exercise-top { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.item-photos { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }
.item-img { width: 44px; height: 44px; border-radius: 5px; object-fit: cover; border: 1px solid var(--border); background: #fff; }
.item-details { flex: 1; font-size: 0.85rem; margin-left: 4px; }
.item-details strong { font-size: 0.9rem; display: block; margin-bottom: 2px; }
.item-sub { color: var(--text-muted); font-size: 0.75rem; margin-top: 2px; }
.item-notes { color: var(--primary); font-size: 0.75rem; white-space: pre-wrap; margin-top: 4px; line-height: 1.35; }
.btn-del { background: transparent; border: none; color: var(--danger); font-size: 1.2rem; cursor: pointer; padding: 4px 6px; }

/* Griglia 2x2 perfettamente allineata per i pulsanti del Builder */
.builder-item-actions,
.item-actions {
  display: grid;
  grid-template-columns: repeat(2, 30px);
  gap: 4px;
  flex-shrink: 0;
}

.builder-btn-row {
  display: contents;
}

.btn-builder-act,
.btn-icon {
  width: 30px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  line-height: 1;
}

.btn-builder-act:hover:not(:disabled),
.btn-icon:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-builder-act:disabled,
.btn-icon:disabled {
  opacity: 0.3;
  cursor: default;
}

.btn-builder-act.del {
  color: var(--danger);
}

.btn-builder-act.del:hover {
  border-color: var(--danger);
}

/* Pannello modifica rapida inline nel Builder */
.builder-inline-edit {
  background: var(--card-bg);
  border: 1px solid var(--warning);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.builder-edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

@media (min-width: 520px) {
  .builder-edit-grid {
    grid-template-columns: 1.2fr 1.2fr 0.8fr 0.8fr;
  }
}

.builder-inline-edit input,
.builder-inline-edit select,
.builder-inline-edit textarea {
  padding: 7px 8px;
  font-size: 0.82rem;
}

.builder-inline-edit textarea {
  min-height: 56px;
}

/* Diario Carichi Atleta */
.log-box { background: var(--log-bg); border: 1px solid var(--log-border); border-radius: 6px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.log-box.editing-mode { border-color: var(--warning); box-shadow: 0 0 0 1px var(--warning); }
.log-row-top { display: grid; grid-template-columns: 1fr 1.3fr 1fr; gap: 6px; align-items: center; }
.log-row-bottom { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: stretch; }
.log-box input { padding: 7px 8px; font-size: 0.8rem; }
.log-box textarea { padding: 7px 8px; font-size: 0.8rem; min-height: 44px; resize: vertical; line-height: 1.35; }
.last-log-tag { font-size: 0.74rem; color: var(--success); font-weight: 600; }

/* Pulsanti azione su singolo log (Modifica / Elimina) */
.log-header-row { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.log-mini-actions { display: inline-flex; gap: 4px; flex-shrink: 0; }
.btn-icon-mini { background: transparent; border: 1px solid var(--border); color: var(--text-muted); border-radius: 5px; padding: 2px 6px; font-size: 0.72rem; cursor: pointer; line-height: 1.2; }
.btn-icon-mini:hover { border-color: var(--primary); color: var(--text); }
.btn-icon-mini.del:hover { border-color: var(--danger); color: var(--danger); }
.past-log-item-flex { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; }

/* Vista Progressi Trainer affiancata */
.progress-split { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 560px) {
  .progress-split { grid-template-columns: 1.15fr 0.85fr; align-items: start; }
}
.athlete-feedback-box { background: var(--log-bg); border: 1px solid var(--log-border); border-left: 3px solid var(--success); border-radius: 6px; padding: 8px 10px; font-size: 0.8rem; }
.athlete-feedback-box.empty { border-left-color: var(--border); color: var(--text-muted); }
.feedback-header { display: flex; justify-content: space-between; align-items: center; font-size: 0.72rem; color: var(--success); font-weight: 700; margin-bottom: 4px; }
.feedback-metrics { font-weight: 700; color: var(--text); font-size: 0.84rem; }
.feedback-note { color: var(--text-muted); font-size: 0.76rem; margin-top: 4px; font-style: italic; white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; line-height: 1.35; }
.past-logs-details { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--border); font-size: 0.74rem; color: var(--text-muted); }
.past-logs-details summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.past-log-line { padding: 4px 0; border-bottom: 1px solid var(--border); white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }

/* Campanella Notifiche & Banner Scadenze */
.notif-btn-wrap {
  position: relative;
  display: inline-flex;
}

.notif-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--danger);
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 800;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--bg);
}

.alert-item-card {
  background: var(--subcard-bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--warning);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.alert-item-card.urgent {
  border-left-color: var(--danger);
}

.athlete-expiry-banner {
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid var(--warning);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.82rem;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.athlete-expiry-banner.expired {
  background: rgba(239, 68, 68, 0.14);
  border-color: var(--danger);
}

/* Dashboard Analytics & Statistiche Trainer */
.stats-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

@media (min-width: 560px) {
  .stats-kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.kpi-box {
  position: relative;
  background: var(--subcard-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 10px 10px;
  text-align: center;
}

.kpi-box .btn-stat-info {
  position: absolute;
  top: 6px;
  right: 6px;
  margin-left: 0;
}

.kpi-value {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary);
  display: block;
}

.kpi-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
  margin-top: 2px;
  display: block;
}

.stats-card-block {
  background: var(--subcard-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

.stats-block-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.chart-canvas-wrap {
  position: relative;
  width: 100%;
  height: 210px;
}

/* Calendario attività (ultimi 28 giorni) */
.activity-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  margin-top: 6px;
}

.cal-day-cell {
  border-radius: 6px;
  padding: 6px 2px;
  text-align: center;
  font-size: 0.72rem;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-muted);
}

.cal-day-cell.trained {
  background: rgba(34, 197, 94, 0.22);
  border-color: var(--success);
  color: var(--text);
  font-weight: 800;
}

.rir-compare-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}

.rir-pill-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  text-align: center;
}

/* Pulsante Info (i) e riquadro spiegazione nelle Statistiche */
.btn-stat-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 1px solid var(--primary);
  background: transparent;
  color: var(--primary);
  font-size: 0.68rem;
  font-weight: 800;
  font-family: Georgia, serif;
  font-style: italic;
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
  vertical-align: middle;
  line-height: 1;
  flex-shrink: 0;
}

.btn-stat-info:hover {
  background: var(--primary);
  color: var(--primary-text);
}

.stat-info-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 6px;
  margin-bottom: 8px;
  text-align: left;
}

.stat-info-box strong {
  color: var(--text);
}

/* Evidenziazione Circuiti nell'App (Builder, Atleta, Storico Trainer) */
.circuit-group-box {
  border: 2px solid var(--primary);
  border-left-width: 5px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.05);
  padding: 8px;
  margin-bottom: 10px;
}

.circuit-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--primary);
  color: var(--primary-text);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  padding: 5px 10px;
  border-radius: 6px;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.circuit-group-footer {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary);
  text-align: right;
  padding-top: 4px;
}

.circuit-group-box .exercise-item {
  margin-bottom: 6px;
  border-color: rgba(56, 189, 248, 0.35);
}

.circuit-group-box .exercise-item:last-of-type {
  margin-bottom: 0;
}

/* Campo Password con icona SVG minimal */
.password-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-wrap input {
  padding-right: 42px;
}

.btn-toggle-pwd {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease;
}

.btn-toggle-pwd:hover {
  color: var(--text);
}

/* Note Atleta (Verde) vs Note Coach (Rosso) */
.note-athlete-box {
  background: rgba(16, 185, 129, 0.12);
  border-left: 3.5px solid #10b981;
  color: #059669;
  padding: 6px 9px;
  border-radius: 6px;
  font-size: 0.79rem;
  font-weight: 400;
  margin-top: 5px;
  white-space: pre-wrap;
}

body:not(.light-theme) .note-athlete-box {
  color: #34d399;
}

.note-coach-box {
  background: rgba(239, 68, 68, 0.12);
  border-left: 3.5px solid #ef4444;
  color: #dc2626;
  padding: 6px 9px;
  border-radius: 6px;
  font-size: 0.79rem;
  font-weight: 400;
  margin-top: 6px;
  white-space: pre-wrap;
}

body:not(.light-theme) .note-coach-box {
  color: #f87171;
}

.coach-reply-form {
  display: flex;
  gap: 6px;
  margin-top: 7px;
  align-items: center;
}

.coach-reply-form input {
  font-size: 0.78rem;
  padding: 6px 8px;
  border-color: rgba(239, 68, 68, 0.45);
}

/* Barra compatta inserimento carichi atleta */
.athlete-inputs-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  width: 100%;
}

.athlete-inputs-row input {
  margin: 0;
  padding: 6px 8px;
  font-size: 0.8rem;
}

.athlete-inputs-row .inp-kg {
  width: 68px;
  flex-shrink: 0;
}

.athlete-inputs-row .inp-reps {
  flex: 1;
  min-width: 85px;
}

.athlete-inputs-row .inp-rir {
  width: 58px;
  flex-shrink: 0;
}

.athlete-inputs-row .btn {
  width: auto;
  flex-shrink: 0;
  padding: 6px 12px;
}

/* Allinea Serie/Reps, Rest e RIR sulla stessa riga con stile uniforme */
.item-sub,
.item-sub strong {
  display: inline;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

.item-sub strong {
  color: var(--primary);
}

/* =========================================================
   PDF LAYOUT & FIX DEFINITIVO SAFARI iOS / DESKTOP
   ========================================================= */
#pdfPreviewWrapper {
  display: block !important;
  position: fixed !important;
  top: 0 !important;
  left: -10000px !important;
  width: 740px !important;
  height: auto !important;
  background: #ffffff !important;
  z-index: -1 !important;
  overflow: visible !important;
}

.pdf-sheet {
  background: #ffffff !important;
  color: #1e293b !important;
  padding: 16px 18px !important;
  width: 720px !important;
  max-width: 720px !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  font-size: 11px;
}

.pdf-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #111827; padding-bottom: 8px; margin-bottom: 10px; }
.pdf-header-left { display: flex; align-items: center; gap: 12px; }
.pdf-logo { height: 50px; width: auto; max-width: 120px; object-fit: contain; }
.pdf-header h2 { font-size: 18px; color: #111827; font-weight: 800; }
.pdf-coach-tag { font-size: 10.5px; font-weight: 800; color: #111827; text-transform: uppercase; }
.pdf-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: #f1f5f9; padding: 7px 10px; border-radius: 6px; margin-bottom: 8px; font-size: 10.5px; }
.pdf-general-notes { background: #fffbeb; border-left: 3px solid #f59e0b; padding: 8px 10px; font-size: 10.5px; color: #78350f; margin-bottom: 10px; border-radius: 4px; display: none; line-height: 1.4; }
.pdf-day-banner,
.pdf-day-title {
  background: #0f172a;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  padding: 6px 10px;
  border-radius: 4px;
  margin-top: 12px;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.pdf-table,
#pdfSheet table {
  width: 100% !important;
  table-layout: fixed !important;
  border-collapse: collapse !important;
  margin-bottom: 8px;
}

.pdf-table th { background: #e2e8f0; color: #334155; text-align: left; padding: 5px 6px; font-size: 9.5px; text-transform: uppercase; }
.pdf-table td { padding: 6px; border-bottom: 1px solid #cbd5e1; vertical-align: middle !important; word-wrap: break-word !important; overflow-wrap: break-word !important; }

#pdfSheet th:nth-child(1),
#pdfSheet td:nth-child(1) {
  width: 34px !important;
  min-width: 34px !important;
  padding-left: 3px !important;
  padding-right: 3px !important;
  text-align: center !important;
  white-space: nowrap !important;
}

#pdfSheet th:nth-child(2),
#pdfSheet td:nth-child(2) { width: 92px !important; max-width: 92px !important; text-align: center !important; }

#pdfSheet th:nth-child(3),
#pdfSheet td:nth-child(3) { width: 155px !important; }

#pdfSheet th:nth-child(4),
#pdfSheet td:nth-child(4) { width: 72px !important; }

#pdfSheet th:nth-child(5),
#pdfSheet td:nth-child(5) { width: 52px !important; }

#pdfSheet th:nth-child(6),
#pdfSheet td:nth-child(6) { width: 52px !important; }

#pdfSheet td:nth-child(2) img {
  width: 40px !important;
  max-width: 40px !important;
  height: 40px !important;
  max-height: 40px !important;
  object-fit: contain !important;
  display: inline-block !important;
  vertical-align: middle !important;
  margin: 1px !important;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
}

#pdfSheet td:nth-child(2) img:only-child {
  width: 78px !important;
  max-width: 78px !important;
  height: 44px !important;
  max-height: 44px !important;
}

/* Evidenziazione Circuiti nel PDF */
.pdf-circuit-banner {
  background: #e0f2fe;
  color: #0369a1;
  font-weight: 800;
  font-size: 10px;
  padding: 4px 8px;
  border-left: 4px solid #0284c7;
  text-transform: uppercase;
}

.pdf-circuit-row td {
  background-color: #f0f9ff !important;
  border-left: 3px solid #0284c7;
}

.pdf-circuit-end {
  background: #f0f9ff;
  color: #0369a1;
  font-weight: 700;
  font-size: 9px;
  text-align: right;
  padding: 3px 8px;
  border-left: 4px solid #0284c7;
  border-bottom: 1.5px solid #0284c7;
}

.pdf-footer { display: flex; justify-content: space-between; margin-top: 14px; padding-top: 8px; border-top: 1px solid #cbd5e1; font-size: 9.5px; color: #64748b; }

#pdfSheet tr,
.pdf-day-title,
.pdf-header,
.pdf-meta,
.pdf-general-notes {
  break-inside: avoid !important;
  page-break-inside: avoid !important;
}

.pdf-day-title {
  break-after: avoid !important;
  page-break-after: avoid !important;
}

/* Protezione extra anti-taglio righe nel PDF */
.pdf-day-section {
  display: block;
}

.pdf-table tr,
.pdf-table td,
.pdf-table th {
  break-inside: avoid !important;
  page-break-inside: avoid !important;
}

.pdf-day-title,
.pdf-general-notes,
.pdf-header {
  break-inside: avoid !important;
  page-break-inside: avoid !important;
  break-after: avoid !important;
  page-break-after: avoid !important;
}

/* Fix impaginazione Anamnesi su iPhone / iOS Safari */
#trainerAnamnesisView input,
#trainerAnamnesisView select,
#trainerAnamnesisView textarea {
  min-width: 0;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
}

/* Allinea sempre in basso i campi affiancati anche se le label vanno su 2 righe */
#trainerAnamnesisView .grid-2,
#trainerAnamnesisView .grid-3 {
  align-items: end;
}

#trainerAnamnesisView .grid-2 > .field,
#trainerAnamnesisView .grid-3 > .field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

/* Su schermi stretti (iPhone) impila i campi doppi dell'anamnesi a larghezza piena */
@media (max-width: 480px) {
  #trainerAnamnesisView .grid-2 {
    grid-template-columns: 1fr;
  }

  #trainerAnamnesisView input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
    min-height: 40px;
  }
}

@media (max-width: 640px) {
  .client-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    width: 100%;
    margin-top: 10px;
  }

  .client-actions .btn {
    width: 100%;
    justify-content: center;
    text-align: center;
  }
}

/* Fix allineamento form Check-in Settimanale su iOS Safari / iPhone */
#athleteCheckinCard .grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  align-items: end;
}

#athleteCheckinCard .field {
  min-width: 0;
  margin-bottom: 10px;
}

#athleteCheckinCard .field label {
  display: block;
  font-size: 0.72rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 5px;
}

#athleteCheckinCard input[type="date"],
#athleteCheckinCard input[type="number"],
#athleteCheckinCard select {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 42px;
  min-height: 42px;
  max-height: 42px;
  line-height: 20px;
  padding: 10px 10px;
  margin: 0;
  font-size: 0.85rem;
  box-sizing: border-box;
  border-radius: 8px;
}

/* Freccia custom pulita per le <select> su iOS dopo appearance: none */
#athleteCheckinCard select {
  padding-right: 26px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px 12px;
}
