/* ============================================================
   APP — Fitness Coaching Platform
   style.css — Design system v2 — Premium redesign
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* ============================================================
   0. GLOBAL OVERFLOW LOCK — prevents horizontal scroll
   ============================================================ */
html {
  overflow-x: hidden !important;
}
body {
  overflow-x: hidden !important;
  max-width: 100vw !important;
}
.analytics-breakdown-wrap {
  overflow-x: auto !important;
  position: relative !important;
}
*, *::before, *::after {
  box-sizing: border-box;
}

/* ============================================================
   1. CSS VARIABLES — TEMA UNICO (dark)
   L'app e' dark-only. La classe .dark resta su <html> come alias
   per non invalidare le regole `.dark .x` gia' scritte nei file.
   ============================================================ */
:root {
  --bg-base:          #0a0c0b;
  --bg-surface:       #131614;
  --card-bg:          #161a18;
  --card-inner:       #1e2320;
  --accent:           #5ce577;
  --accent-hover:     #47d163;
  --on-accent:        #0a0c0b;
  --accent-light:     rgba(92, 229, 119, 0.12);
  --accent-shadow:    rgba(92, 229, 119, 0.28);
  --accent-shadow-lg: rgba(92, 229, 119, 0.38);
  --text-primary:     #f2f5f3;
  --text-secondary:   #9aa5a0;
  --text-muted:       #6b7671;
  --border:           #262b28;
  --border-strong:    #333a36;
  --border-focus:     #5ce577;
  --danger:           #f87171;
  --danger-light:     rgba(248, 113, 113, 0.12);
  --success:          #5ce577;
  --success-light:    rgba(92, 229, 119, 0.12);
  --warning:          #fbbf24;
  --warning-light:    rgba(251, 191, 36, 0.12);
  --info:             #60a5fa;
  --info-light:       rgba(96, 165, 250, 0.12);

  /* Alias storici usati in giro nei file: restano validi */
  --accent-text:      #0a0c0b;
  --accent-text-muted:rgba(0,0,0,0.55);
  --accent-bg-soft:   rgba(92, 229, 119, 0.08);
  --shadow-accent-sm: 0 2px 8px rgba(92, 229, 119, 0.28);
  --surface:          #131614;

  --font-display:     'Oswald', 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-body:        'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;

  --sidebar-width:    260px;
  --topbar-height:    68px;
  --bottom-nav-h:     64px;
  --radius-card:      20px;
  --radius-btn:       14px;
  --radius-sm:        12px;
  --radius-xs:        8px;

  /* Su fondo nero le ombre grigie non si leggono: bordo + alone accent */
  --shadow-card:      0 1px 2px rgba(0,0,0,0.40);
  --shadow-card-hover:0 6px 22px rgba(0,0,0,0.55);
  --shadow-sm:        0 1px 4px rgba(0,0,0,0.35);
  --shadow-md:        0 4px 16px rgba(0,0,0,0.45);
  --shadow-lg:        0 8px 32px rgba(0,0,0,0.55);
  --shadow-accent:    0 6px 18px rgba(92, 229, 119, 0.28);
  --shadow-accent-lg: 0 10px 30px rgba(92, 229, 119, 0.34);

  --transition:       all 0.2s ease;
  --transition-slow:  all 0.35s ease;
}

/* Alias: le regole `.dark .x` sparse nei file continuano a valere. */
.dark { color-scheme: dark; }

/* ============================================================
   3. RESET E BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, video { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select { font-family: inherit; }
ul, ol { list-style: none; }

/* ============================================================
   4. ANIMAZIONI
   ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInFast {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes dropdownOpen {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes slideInLeft {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

/* ============================================================
   5. SEZIONI — VISIBILITÀ (pattern .view e .cv)
   ============================================================ */
.view {
  display: none;
}

.view.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

/* ============================================================
   6. TIPOGRAFIA
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.005em;
  line-height: 1.12;
  color: var(--text-primary);
}

h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); font-weight: 700; }
h2 { font-size: clamp(1.375rem, 3vw, 1.875rem); font-weight: 700; }
h3 { font-size: clamp(1.125rem, 2.5vw, 1.375rem); }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }

/* Testo display riusabile: titoli, numeri KPI, label, bottoni, badge */
.u-display {
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Escape: rimette il font di corpo dove il maiuscolo non ha senso */
.u-body-font {
  font-family: var(--font-body);
  text-transform: none;
  letter-spacing: normal;
  font-weight: 600;
}

.text-muted     { color: var(--text-secondary); }
.fw-700         { font-weight: 700; }

/* ============================================================
   7. LAYOUT — SIDEBAR + TOPBAR + CONTENUTO
   ============================================================ */
/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  box-shadow: none;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.3s ease;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Logo area */
.sidebar-logo {
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* Logo mark — 40×40 accent square */
.logo-mark,
.sidebar-logo-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: var(--accent-text);
  font-size: 1.25rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: -0.03em;
}

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-logo .logo-title,
.sidebar-app-name {
  font-family: var(--font-display);
  font-size: 1.1875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  color: var(--text-primary);
  line-height: 1.15;
}

.sidebar-logo .logo-sub,
.sidebar-app-sub {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Nav area */
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-group {
  margin-top: 24px;
}

.sidebar-group:first-child {
  margin-top: 0;
}

.sidebar-group-label {
  font-family: var(--font-display);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  padding: 0 8px;
  margin-bottom: 8px;
}

/* Profile card at bottom of sidebar */
.sidebar-profile {
  padding: 12px 12px 16px;
  border-top: 1px solid var(--border);
}

.sidebar-profile-card {
  background: var(--card-inner);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-profile .profile-info {
  flex: 1;
  min-width: 0;
}

.sidebar-profile .profile-name {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-profile .profile-role {
  font-family: var(--font-display);
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Profile actions button in sidebar */
.sidebar-profile-actions {
  margin-left: auto;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.sidebar-profile-actions:hover {
  background: var(--accent-light);
  color: var(--text-primary);
}

/* ── Sidebar profile dropdown ──────────────────────────── */
.sidebar-profile-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  min-width: 172px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.13);
  overflow: hidden;
  display: none;
  z-index: 200;
}
.sidebar-profile-dropdown.open { display: block; }
.sidebar-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background 0.15s;
}
.sidebar-dropdown-item:hover { background: var(--bg-base); }
.sidebar-dropdown-item.danger { color: #ef4444; }
.sidebar-dropdown-item + .sidebar-dropdown-item { border-top: 1px solid var(--border); }

/* Backdrop overlay sidebar mobile */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  animation: fadeInFast 0.2s ease;
}

.sidebar-backdrop.active {
  display: block;
}

/* Main content area */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: rgba(10, 12, 11, 0.82);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 28px;
}

/* Contenuto pagina */
.page-content {
  padding: 28px 28px 48px;
  flex: 1;
}

/* ============================================================
   8. NAV ITEMS
   ============================================================ */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  user-select: none;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--card-inner);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  box-shadow: var(--shadow-accent);
}

.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 0.625rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

.nav-item.active .nav-badge {
  background: rgba(0,0,0,0.2);
  color: var(--accent-text);
}

/* Bottom navigation — cliente mobile */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-h);
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding: 0 8px;
  align-items: center;
  justify-content: space-around;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  flex: 1;
  max-width: 80px;
}

.bottom-nav-item svg {
  width: 22px;
  height: 22px;
  stroke-width: 2;
}

.bottom-nav-item.active {
  color: var(--accent);
}

.bottom-nav-item.active svg {
  stroke: var(--accent);
}

/* ============================================================
   9. CARD — premium (no border, only shadow)
   ============================================================ */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-card-hover);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-primary);
  letter-spacing: 0.03em;
}

.card-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ============================================================
   10. KPI CARDS — con più carattere
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 22px 24px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-card-hover);
}

.kpi-label {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 0.005em;
  color: var(--text-primary);
  line-height: 1;
}

.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  padding: 4px 10px;
  border-radius: 20px;
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Nei design il delta e' testo colorato nudo, senza pillola */
.kpi-delta.up {
  background: transparent;
  color: var(--success);
  padding-left: 0;
}

.kpi-delta.down {
  background: transparent;
  color: var(--danger);
  padding-left: 0;
}

.kpi-delta.neutral {
  background: transparent;
  color: var(--text-muted);
  padding-left: 0;
}

/* Icona KPI: solo il glifo accent in alto a destra, niente cerchio */
.kpi-icon {
  position: absolute;
  top: 22px;
  right: 22px;
  width: 22px;
  height: 22px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}
.kpi-icon svg { width: 20px; height: 20px; }

/* ============================================================
   11. HERO CARD
   ============================================================ */
/* ============================================================
   12. BOTTONI — con più personalità
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius-btn);
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  outline: none;
  white-space: nowrap;
  line-height: 1;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-sm {
  padding: 9px 16px;
  font-size: 0.8125rem;
  border-radius: 11px;
}

.btn-lg {
  padding: 16px 30px;
  font-size: 1.0625rem;
  border-radius: 16px;
}

/* Primary — accent pieno, testo scuro, alone verde */
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-accent-lg);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(92, 229, 119, 0.22);
}

/* Ghost */
.btn-ghost {
  background: var(--card-inner);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

/* Danger */
.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.btn-danger:hover {
  background: var(--danger-light);
  border-color: var(--danger);
}

/* Success */
.btn-success {
  background: transparent;
  color: var(--success);
  border: 1px solid rgba(92, 229, 119, 0.35);
}

.btn-success:hover {
  background: var(--success-light);
  border-color: var(--success);
}

/* Loading spinner */
.btn-loading {
  pointer-events: none;
}

.btn-loading::after {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0,0,0,0.25);
  border-top-color: var(--accent-text);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ============================================================
   13. INPUT E FORM — premium
   ============================================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-label {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.10em;
  display: block;
  margin-bottom: 8px;
}

.form-input,
.search-input {
  width: 100%;
  padding: 15px 18px;
  background: var(--card-inner);
  border: 1px solid var(--border);
  border-radius: 14px;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
  transition: all 0.2s ease;
  outline: none;
}

.form-input::placeholder,
.search-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.form-input:focus,
.search-input:focus {
  background: var(--bg-surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* Hide native select appearance — replaced by .custom-select */
select.form-input {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  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='%235ce577' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 42px;
}

/* Input icon wrapper */
.input-wrapper {
  position: relative;
}

.input-wrapper .input-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.input-wrapper .input-icon-right {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.input-wrapper .input-icon-right:hover {
  color: var(--text-primary);
}

.input-wrapper .form-input.has-icon-left  { padding-left: 46px; }
.input-wrapper .form-input.has-icon-right { padding-right: 46px; }

.search-input {
  background: var(--card-inner);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px 12px 42px;
  font-size: 0.875rem;
}

.search-input:focus {
  background: var(--bg-surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  padding-left: 42px;
}

/* Slider */
.slider-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(92, 229, 119, 0.40);
  transition: var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 4px 16px rgba(92, 229, 119, 0.55);
}

/* Toggle */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.toggle {
  width: 44px;
  height: 24px;
  background: var(--border);
  border-radius: 12px;
  position: relative;
  transition: var(--transition);
  flex-shrink: 0;
}

.toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: var(--transition);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.toggle.on {
  background: var(--accent);
}

.toggle.on::after {
  transform: translateX(20px);
}

.toggle-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ============================================================
   14. CUSTOM SELECT — componente premium
   Sostituisce tutti i <select> nativi
   ============================================================ */
.custom-select {
  position: relative;
  width: 100%;
  user-select: none;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--card-inner);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  gap: 10px;
}

.custom-select.open .custom-select-trigger {
  background: var(--bg-surface);
  border-color: var(--accent);
  border-width: 2px;
  box-shadow: 0 0 0 4px rgba(92, 229, 119, 0.12);
}

.custom-select-trigger:hover:not(.open) {
  border-color: var(--border-strong);
  background: var(--bg-surface);
}

.custom-select-value {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.custom-select-value.placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.custom-select-arrow {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--accent);
  transition: transform 0.2s ease;
}

.custom-select.open .custom-select-arrow {
  transform: rotate(180deg);
}

/* Dropdown panel */
.custom-select-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.50);
  z-index: 200;
  overflow: hidden;
  border: 1px solid var(--border);
}

.custom-select.open .custom-select-dropdown {
  display: block;
  animation: dropdownOpen 0.15s ease;
}

.custom-select-option {
  padding: 12px 18px;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.12s ease;
}

.custom-select-option:hover {
  background: var(--card-inner);
}

.custom-select-option.selected {
  background: rgba(92, 229, 119, 0.12);
  color: var(--text-primary);
  font-weight: 700;
}

/* Size variants */
.custom-select.select-sm .custom-select-trigger {
  padding: 8px 12px;
  border-radius: 10px;
}

.custom-select.select-sm .custom-select-value {
  font-size: 0.8rem;
}

.custom-select.select-sm .custom-select-option {
  padding: 9px 14px;
  font-size: 0.8rem;
}

/* ============================================================
   15. PILL / BADGE
   ============================================================ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 20px;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.pill-green {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid rgba(92, 229, 119, 0.30);
}

.pill-red {
  background: var(--danger-light);
  color: var(--danger);
}

.pill-amber {
  background: var(--warning-light);
  color: var(--warning);
}

.pill-blue {
  background: var(--info-light);
  color: var(--info);
}

.pill-neutral {
  background: var(--card-inner);
  color: var(--text-secondary);
}



.pill-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.pill-purple {
  background: rgba(124,58,237,0.18);
  color: #c084fc;
}

.pill-orange {
  background: rgba(234,88,12,0.18);
  color: #fb923c;
}

.pill-sm {
  padding: 3px 10px;
  font-size: 0.69rem;
  letter-spacing: 0.03em;
}

/* ── Modal body / footer ────────────────────────────── */
.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-footer {
  display: flex;
  gap: 8px;
  padding: 0 20px 20px;
}
.modal-footer .btn { flex: 1; }

/* Blocca scroll del body quando un modal è aperto */
body:has(.modal-overlay.open) { overflow: hidden; }

/* ── Payments table in profilo ───────────────────────── */
.payments-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
.payments-table th {
  text-align: left; padding: 8px 12px;
  font-family: var(--font-display);
  font-size: 0.72rem; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.payments-table td {
  padding: 10px 12px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.payments-table tbody tr:last-child td { border-bottom: none; }
.payments-table .amount-cell { font-weight: 700; color: var(--text-primary); }

/* ============================================================
   16. AVATAR
   ============================================================ */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--on-accent);
  flex-shrink: 0;
  overflow: hidden;
  user-select: none;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-sm { width: 32px; height: 32px; font-size: 0.75rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.125rem; }

/* ============================================================
   17. CHAT BUBBLES
   ============================================================ */
.chat-window-messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.bubble {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.9375rem;
  line-height: 1.5;
  position: relative;
}

.chat-window-input {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--card-bg);
}

/* ============================================================
   17b. CHAT LAYOUT — container / window / svh
   ============================================================ */
.chat-container {
  display: flex;
  height: calc(100vh - var(--topbar-height));
  overflow: hidden;
}

.chat-window {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

@media (max-width: 768px) {
  .chat-container {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    height: auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 50;
    transform: translateY(0);
    will-change: transform;
  }
  .chat-sidebar {
    display: flex !important;
    flex-direction: column;
    width: 100%;
    height: 100%;
  }
  .chat-window {
    display: none;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow: hidden;
  }
  .chat-window.mobile-open {
    display: flex !important;
  }
  .chat-back-btn {
    display: flex !important;
  }
  .chat-window-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .chat-window-input {
    flex-shrink: 0;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}

@media (min-width: 769px) {
  .chat-back-btn { display: none !important; }
  .chat-sidebar { display: flex; }
  .chat-window { display: flex !important; }
}

/* ============================================================
   18. CHART BOX
   ============================================================ */
.chart-box {
  position: relative;
  height: 280px;
  width: 100%;
}

/* ============================================================
   21. TABELLA — premium rows
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  background: var(--card-bg);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
}

thead th {
  padding: 14px 20px;
  text-align: left;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--bg-surface);
}

tbody td {
  padding: 16px 20px;
  font-size: 0.875rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background 0.15s ease;
  cursor: pointer;
}

tbody tr:hover {
  background: var(--card-inner);
}

/* ============================================================
   22. TOAST NOTIFICATION
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  animation: slideInLeft 0.3s ease;
  pointer-events: all;
  min-width: 280px;
  max-width: 380px;
}

.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-info    { border-left: 3px solid var(--info); }

/* ============================================================
   24. STEPPER
   ============================================================ */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 32px;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.step-label {
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.step.active .step-label { color: var(--text-primary); font-weight: 700; }

.step-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 8px;
}

.step-line.done { background: var(--accent); }

/* ============================================================
   25. CARD NUTRIZIONE / PASTO
   ============================================================ */
.meal-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 24px;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  border-left: 4px solid transparent;
}

.meal-card.current {
  border-left-color: var(--accent);
}

.meal-card.completed {
  background: rgba(92, 229, 119, 0.06);
  border-color: rgba(92, 229, 119, 0.22);
  border-left-color: var(--success);
}

.meal-icon-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

.meal-name {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  flex: 1;
}

.meal-card.completed .meal-name {
  text-decoration: line-through;
  opacity: 0.5;
}

.meal-kcal {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.meal-ingredients {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ingredient-pill {
  background: var(--card-inner);
  border-radius: 8px;
  padding: 4px 12px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}



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

/* ============================================================
   26. UTILS GENERALI
   ============================================================ */
.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

.divider-text {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.divider-text::before,
.divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.hidden     { display: none !important; }

.flex            { display: flex; }

/* ============================================================
   27. GLOBAL COMPONENT UPGRADES
   ============================================================ */

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 16px;
  background: var(--card-inner);
  transition: border-color 0.2s, background 0.2s;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(92, 229, 119, 0.08);
}

.drop-zone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  gap: 6px;
}

.drop-zone-icon  { color: var(--text-muted); margin-bottom: 6px; }
.drop-zone-title { font-family: var(--font-display); font-size: 0.9375rem; font-weight: 600; text-transform: uppercase; color: var(--text-primary); }
.drop-zone-sub   { font-size: 0.78rem; color: var(--text-muted); }

/* Onboarding goal cards */
.onb-goal-card {
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  background: var(--bg-base);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.onb-goal-card:hover {
  border-color: var(--accent);
  background: rgba(92, 229, 119, 0.08);
  box-shadow: 0 4px 16px rgba(92, 229, 119, 0.18);
}

.onb-goal-card.selected {
  border-color: var(--accent);
  background: rgba(92, 229, 119, 0.12);
  box-shadow: 0 4px 16px rgba(92, 229, 119, 0.18);
}

/* Scheda / video card — elevated hover */
.scheda-card,
.video-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.scheda-card:hover,
.video-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
}

/* Stepper nav buttons */
.analytics-source-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ============================================================
   28. RESPONSIVE — 1024px (laptop)
   ============================================================ */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
    animation: slideInLeft 0.3s ease;
  }

  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    padding: 16px !important;
    padding-top: 80px !important;
    padding-bottom: calc(var(--bottom-nav-h) + 24px) !important;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  :root {
    --topbar-height: 64px;
  }

  .topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 90;
    padding: 0 16px;
    height: 64px !important;
    min-height: 64px !important;
    max-height: 64px !important;
    overflow: hidden !important;
    align-items: center !important;
  }

  .page-content {
    padding: 20px 16px 32px;
  }

  .topbar-search {
    display: none;
  }
}

/* ============================================================
   29. RESPONSIVE — 768px (tablet)
   ============================================================ */
@media (max-width: 768px) {
  /* Card oggi — stack verticale su mobile */
  .oggi-grid,
  .oggi-bottom {
    display: flex !important;
    flex-direction: column !important;
    overflow-x: visible !important;
    gap: 12px !important;
  }
  .oggi-grid > *,
  .oggi-bottom > * {
    width: 100% !important;
    min-width: unset !important;
    flex-shrink: unset !important;
  }

  /* Bottom nav — distribuita su tutta la larghezza */
  .bottom-nav-inner {
    display: flex !important;
    justify-content: space-around !important;
    width: 100% !important;
    padding: 0 !important;
  }
  .bottom-nav-item {
    flex: 1 !important;
    text-align: center !important;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .kpi-value {
    font-size: 1.75rem;
  }

  .card {
    padding: 18px;
  }

  /* Chat sidebar full-width on mobile */
  .chat-sidebar {
    padding: 0 !important;
    width: 100% !important;
  }
  .chat-conv-list {
    width: 100% !important;
  }
  .chat-conv-item {
    padding: 16px !important;
    width: 100% !important;
  }

  /* ===== MOBILE RESPONSIVE FIX GLOBALE ===== */

  .table-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    max-width: 100% !important;
  }
  .table-wrap table {
    min-width: 600px;
  }

  /* Chat: svh height + sticky input above iOS keyboard */
  .chat-window-messages {
    -webkit-overflow-scrolling: touch !important;
  }
  .chat-window-input {
    flex-shrink: 0 !important;
  }

  .charts-grid {
    grid-template-columns: 1fr !important;
  }

  .kpi-card {
    min-height: auto !important;
    overflow: hidden !important;
  }
}

/* ============================================================
   30. RESPONSIVE — 480px (mobile)
   ============================================================ */
@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .kpi-card {
    padding: 16px;
  }

  .kpi-value {
    font-size: 1.625rem;
  }

  .card {
    padding: 16px;
    border-radius: 16px;
  }

  .topbar {
    height: 60px;
  }

  .page-content {
    padding: 16px 12px 80px;
  }

  .bottom-nav {
    display: flex;
  }

  .topbar-date,
  .topbar-greeting {
    display: none;
  }

  .bubble {
    max-width: 85%;
  }

  .toast-container {
    bottom: 80px;
    right: 12px;
    left: 12px;
  }

  .toast {
    min-width: auto;
    max-width: 100%;
  }

  /* All table wrappers scroll internally */
  .table-wrap,
  .costs-table-wrap,
  .analytics-table-wrap,
  .summary-table-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    max-width: 100% !important;
  }
  .table-wrap table,
  .costs-table-wrap table,
  .analytics-table-wrap table,
  .summary-table-wrap table {
    min-width: 600px;
  }

  table {
    min-width: 540px;
  }

  /* Charts shorter on small screens */
  .chart-box {
    height: 200px;
  }

  /* Hide topbar section label on mobile (title already visible in page) */
  .topbar-section-label {
    display: none !important;
  }

  /* Profile header actions: stack vertically on mobile */
  .profile-header-actions {
    flex-direction: column;
    width: 100%;
    gap: 8px;
  }
  .profile-header-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* Workout form selectors: stack vertically on mobile */
  .nf-selectors-grid {
    grid-template-columns: 1fr !important;
  }

  /* Template toggle row: stack on mobile */
  .template-toggle-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  /* Chat: sticky input (480px inherits from 768px block above) */

  /* Charts grids: single column on mobile */
  .costi-charts-grid,
  .dash-charts-row,
  .analytics-charts-row {
    grid-template-columns: 1fr !important;
  }

  /* Nutrition macro avg: 2x2 on mobile */
  .macro-inputs-grid,
  .nf-weekly-avg-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Onboarding form: see full rules below (Fix 7) */

  /* Workout / schede cards: single column on mobile */
  .schede-grid {
    grid-template-columns: 1fr !important;
  }
  .scheda-card {
    max-width: 100% !important;
    width: 100% !important;
  }

  /* KPI cards: no min-height issues on mobile */
  .kpi-card {
    min-height: auto !important;
    padding: 16px !important;
  }

  /* Fix 1 — prevent iOS zoom on input focus */
  .chat-window-input input,
  .chat-window-input textarea,
  input[type="text"],
  input[type="email"],
  input[type="number"],
  textarea,
  select {
    font-size: 16px !important;
  }

  /* Fix 3 — nutrition/workout day tabs: horizontal scroll only */
  .workout-day-tabs {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    white-space: nowrap !important;
    touch-action: pan-x !important;
  }
  .workout-day-panel {
    touch-action: pan-y !important;
  }

  /* Fix 4 — nutrition macro grid: 2x2 layout */
  .nf-macro-row {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }
  .nf-macro-row > div {
    display: flex !important;
    flex-direction: column !important;
  }
  .nf-macro-label {
    font-size: 11px !important;
    white-space: nowrap !important;
  }

  /* Fix 5 — analytics breakdown scrollable, provenienza compact */
  .analytics-breakdown-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .analytics-breakdown-wrap table {
    min-width: 550px !important;
  }
  .analytics-source-wrap {
    overflow-x: hidden !important;
    width: 100% !important;
  }
  .analytics-source-wrap .source-row {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    padding: 12px 0 !important;
    border-bottom: 1px solid var(--border) !important;
  }
  .analytics-source-wrap .source-bar-wrap {
    width: 100% !important;
    height: 8px !important;
    border-radius: 4px !important;
    background: var(--border) !important;
  }
  .analytics-source-wrap .source-bar {
    height: 100% !important;
    border-radius: 4px !important;
  }

  /* Fix 6 — costi/summary table: padding first column */
  .costs-table-wrap td:first-child,
  .costs-table-wrap th:first-child,
  .summary-table-wrap td:first-child,
  .summary-table-wrap th:first-child {
    padding-left: 12px !important;
  }

  /* Fix 7 — onboarding form: single column + date input iOS fix */
  input[type="date"] {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding: 16px 20px !important;
    padding-inline-start: 20px !important;
    font-size: 16px !important;
    font-family: 'Plus Jakarta Sans', sans-serif !important;
    display: block !important;
    box-sizing: border-box !important;
    -webkit-appearance: none !important;
    appearance: none !important;
  }
  .onboarding-form-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
  }
  .onboarding-form-grid > * {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  /* Fix 2 — workout day tabs: visible chips, exercise fields stacked */
  .workout-day-tabs {
    display: flex !important;
    gap: 8px !important;
    overflow-x: auto !important;
    padding-bottom: 4px !important;
    margin-bottom: 16px !important;
    border-bottom: none !important;
  }
  .workout-day-tab {
    flex-shrink: 0 !important;
    padding: 10px 20px !important;
    border-radius: 10px !important;
    background: var(--bg-surface) !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    border: 2px solid transparent !important;
    border-bottom: 2px solid transparent !important;
    white-space: nowrap !important;
    margin-bottom: 0 !important;
  }
  .workout-day-tab.active {
    background: var(--accent) !important;
    color: var(--accent-text) !important;
    border-color: var(--accent-hover) !important;
  }
  .exercise-form-row {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    padding: 16px !important;
    margin-bottom: 12px !important;
  }
  .exercise-form-fields {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px !important;
  }
  .exercise-form-row .form-input {
    width: 100% !important;
    min-height: 44px !important;
  }
  .exercise-drag-card {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
    padding: 12px !important;
  }
  .exercise-drag-card .exercise-form-fields {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    width: 100% !important;
    flex: none !important;
  }
  .exercise-drag-card .exercise-form-fields .wf-ex-nome {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    min-width: 0 !important;
  }
  .exercise-drag-card .exercise-form-fields .wf-ex-desc {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    min-width: 0 !important;
  }
  .exercise-drag-card .exercise-form-fields .wf-ex-serie,
  .exercise-drag-card .exercise-form-fields .wf-ex-reps {
    width: 100% !important;
    min-width: 0 !important;
  }
  .exercise-drag-card .exercise-form-fields .wf-ex-carico {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    min-width: 0 !important;
  }
  .exercise-drag-card .exercise-form-fields .exercise-form-remove {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    justify-content: center !important;
  }

  /* Fix 3 — provenienza clienti: label + pct in header row, bar below */
  .source-row {
    flex-direction: column !important;
    gap: 6px !important;
    padding: 12px 0 !important;
    border-bottom: 1px solid var(--border) !important;
  }
  .source-bar-wrap {
    width: 100% !important;
    height: 8px !important;
    border-radius: 4px !important;
  }
}

/* ============================================================
   EMPTY STATE — .empty-state-cta (usato da renderEmptyState)
   ============================================================ */
.empty-state-cta {
  padding: 10px 20px;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.empty-state-cta:hover {
  opacity: 0.85;
}

/* ============================================================
   CHAT — bolla upload media (pending/progress/errore) — chat-upload.js
   ============================================================ */
.chat-upload-bubble { align-self: flex-end; max-width: 78%; margin: 2px 0; }
.chat-upload-inner {
  background: var(--accent);
  color: var(--accent-text, #0a0a0a);
  border-radius: 16px;
  border-bottom-right-radius: 5px;
  padding: 12px 14px;
  min-width: 190px;
  box-shadow: var(--shadow-accent, 0 4px 14px rgba(0,0,0,0.08));
}
.chat-upload-head { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; font-weight: 700; margin-bottom: 9px; }
.chat-upload-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.chat-upload-bar { height: 6px; background: rgba(0,0,0,0.16); border-radius: 3px; overflow: hidden; }
.chat-upload-fill { height: 100%; width: 0; background: rgba(255,255,255,0.92); border-radius: 3px; transition: width 0.2s ease; }
.chat-upload-meta { margin-top: 7px; font-size: 0.7rem; font-weight: 700; opacity: 0.92; }
.chat-upload-error .chat-upload-inner { background: #ef4444; color: #fff; }
.chat-upload-retry {
  margin-top: 9px; background: #fff; color: #b91c1c;
  border: none; border-radius: 9px; padding: 6px 14px;
  font-size: 0.72rem; font-weight: 800; cursor: pointer; font-family: inherit;
}
.chat-upload-retry:hover { background: #fef2f2; }
