/* ============================================
   Statify — Stylesheet globale
   ============================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface2: #f2f2f0;
  --border: #e8e8e4;
  --border2: #d4d4ce;
  --text-primary: #1a1a18;
  --text-secondary: #6b6b65;
  --text-tertiary: #9e9e96;
  --accent: #1db954;
  --accent-light: #e8f8ee;
  --accent-text: #0f7a34;
  --blue: #2563eb;
  --blue-light: #eff6ff;
  --blue-text: #1d4ed8;
  --red: #dc2626;
  --red-light: #fef2f2;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
}

html, body { height: 100%; max-width: 100%; overflow-x: hidden; }
body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text-primary); font-size: 14px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
img, video { max-width: 100%; height: auto; }

/* ============================================
   LAYOUT — sidebar + main
   ============================================ */
.app { display: grid; grid-template-columns: 230px 1fr; height: 100vh; }

/* SIDEBAR */
.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; height: 100vh; height: 100dvh; position: sticky; top: 0; }
.sb-logo { padding: 22px 20px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.sb-logo-icon { width: 32px; height: 32px; background: #1db954; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sb-logo-icon svg { width: 18px; height: 18px; fill: white; }
.sb-logo-text { font-size: 14px; font-weight: 600; color: var(--text-primary); letter-spacing: -0.01em; }
.sb-logo-sub { font-size: 11px; color: var(--text-tertiary); margin-top: 1px; }
.sb-nav { padding: 12px 10px; flex: 1 1 auto; overflow-y: auto; min-height: 0; -webkit-overflow-scrolling: touch; }
.sb-section-label { font-size: 10px; font-weight: 600; color: var(--text-tertiary); letter-spacing: 0.08em; text-transform: uppercase; padding: 10px 10px 6px; }
.sb-link { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: var(--radius-sm); font-size: 13px; color: var(--text-secondary); font-weight: 400; margin-bottom: 1px; transition: background 0.1s, color 0.1s; text-decoration: none; }
.sb-link:hover { background: var(--bg); color: var(--text-primary); }
.sb-link.active { background: var(--accent-light); color: var(--accent-text); font-weight: 500; }
.sb-link svg { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.7; }
.sb-link.active svg { opacity: 1; }
.sb-badge { margin-left: auto; background: #ea580c; color: #fff; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 999px; min-width: 18px; text-align: center; line-height: 1.3; }
.sb-link.active .sb-badge { background: #c2410c; }
.sb-footer { padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; flex-shrink: 0; background: var(--surface); }
.sb-av { width: 32px; height: 32px; border-radius: 50%; background: #e0f2fe; color: #0369a1; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; flex-shrink: 0; }
.sb-uname { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.sb-urole { font-size: 11px; color: var(--text-tertiary); }

/* MAIN */
.main { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* TOPBAR */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 28px; height: 56px; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.topbar-left { display: flex; flex-direction: column; }
.topbar-page { font-size: 14px; font-weight: 600; color: var(--text-primary); letter-spacing: -0.01em; }
.topbar-bread { font-size: 11px; color: var(--text-tertiary); margin-top: 1px; }
.topbar-right { display: flex; align-items: center; gap: 6px; }

/* DATE BUTTONS */
.date-btn { font-size: 12px; padding: 5px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; color: var(--text-secondary); background: var(--surface); font-family: 'DM Sans', sans-serif; text-decoration: none; transition: all 0.1s; display: inline-flex; align-items: center; }
.date-btn:hover { border-color: var(--border2); color: var(--text-primary); }
.date-btn.active { background: var(--accent-light); border-color: #a7e8c0; color: var(--accent-text); font-weight: 500; }
.date-sep { color: var(--border2); font-size: 12px; padding: 0 4px; }
.date-range { font-size: 12px; padding: 5px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-secondary); background: var(--surface); display: flex; align-items: center; gap: 6px; }
.date-range svg { width: 12px; height: 12px; opacity: 0.5; }

/* CONTENT */
.content { flex: 1; overflow-y: auto; padding: 24px 28px; }

/* METRICS */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.mc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.mc-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.mc-icon svg { width: 16px; height: 16px; }
.mc-icon.green { background: var(--accent-light); } .mc-icon.green svg { stroke: var(--accent-text); }
.mc-icon.blue  { background: var(--blue-light); }  .mc-icon.blue svg  { stroke: var(--blue-text); }
.mc-icon.orange { background: #fff7ed; }            .mc-icon.orange svg { stroke: #c2410c; }
.mc-icon.purple { background: #f5f3ff; }            .mc-icon.purple svg { stroke: #6d28d9; }
.mc-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.mc-val { font-size: 26px; font-weight: 600; color: var(--text-primary); letter-spacing: -0.02em; line-height: 1.1; }
.mc-sub { font-size: 11px; color: var(--text-tertiary); margin-top: 4px; }
.mc-trend { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 500; margin-top: 6px; padding: 2px 6px; border-radius: 20px; }
.mc-trend.up   { background: var(--accent-light); color: var(--accent-text); }
.mc-trend.down { background: #fef2f2; color: #b91c1c; }

/* PANELS */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); margin-bottom: 18px; overflow: hidden; }
.panel-header { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.panel-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.panel-title-sub { font-size: 11px; color: var(--text-tertiary); margin-top: 1px; }
.panel-action { font-size: 12px; color: var(--blue); display: flex; align-items: center; gap: 4px; padding: 5px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-weight: 500; transition: background 0.1s; text-decoration: none; }
.panel-action:hover { background: var(--blue-light); }
.panel-action svg { width: 12px; height: 12px; }

/* TABLE */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { padding: 10px 20px; text-align: left; font-size: 11px; font-weight: 600; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.06em; background: #fafaf8; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 13px 20px; border-bottom: 1px solid var(--border); color: var(--text-primary); font-size: 13px; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: #fafaf8; }
.tbl a { color: inherit; text-decoration: none; }
.tbl a:hover { color: var(--accent-text); }

/* AVATAR */
.user-cell { display: flex; align-items: center; gap: 10px; }
.av { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.av-b { background: #dbeafe; color: #1d4ed8; }
.av-t { background: #d1fae5; color: #065f46; }
.av-c { background: #fee2e2; color: #991b1b; }
.av-p { background: #ede9fe; color: #5b21b6; }
.av-g { background: #dcfce7; color: #166534; }
.av-o { background: #ffedd5; color: #9a3412; }
.user-name { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.user-email { font-size: 11px; color: var(--text-tertiary); margin-top: 1px; }

/* GENRE CHIPS */
.genre-wrap { display: flex; gap: 4px; flex-wrap: wrap; }
.gc { font-size: 11px; padding: 3px 8px; border-radius: 20px; background: var(--surface2); color: var(--text-secondary); border: 1px solid var(--border); white-space: nowrap; }

/* BAR */
.bar-wrap { display: flex; align-items: center; gap: 10px; }
.bar-bg { flex: 1; height: 5px; background: var(--surface2); border-radius: 3px; min-width: 80px; }
.bar-fill { height: 5px; background: #1db954; border-radius: 3px; }
.mins-val { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; font-family: 'DM Mono', monospace; min-width: 52px; text-align: right; }

/* BADGE */
.badge { font-size: 11px; padding: 3px 9px; border-radius: 20px; font-weight: 500; white-space: nowrap; }
.badge-blue  { background: var(--blue-light); color: var(--blue-text); }
.badge-green { background: var(--accent-light); color: var(--accent-text); }
.badge-gray  { background: var(--surface2); color: var(--text-secondary); border: 1px solid var(--border); }
.badge-red   { background: var(--red-light); color: var(--red); }
.badge-orange { background: #fff7ed; color: #c2410c; }

/* TWO COL */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* PLAYLIST ROWS */
.pl-item { display: flex; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--border); gap: 12px; }
.pl-item:last-child { border-bottom: none; }
.pl-rank { font-size: 12px; font-weight: 600; color: var(--text-tertiary); font-family: 'DM Mono', monospace; width: 18px; flex-shrink: 0; }
.pl-dot { width: 8px; height: 8px; border-radius: 50%; background: #1db954; flex-shrink: 0; }
.pl-info { flex: 1; min-width: 0; }
.pl-name { font-size: 13px; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-users { font-size: 11px; color: var(--text-tertiary); margin-top: 1px; }
.pl-mins { font-size: 13px; font-weight: 600; color: var(--text-primary); font-family: 'DM Mono', monospace; white-space: nowrap; }
.pl-mins-label { font-size: 10px; color: var(--text-tertiary); text-align: right; margin-top: 1px; }

/* GENRE ROWS */
.genre-item { display: flex; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--border); gap: 12px; }
.genre-item:last-child { border-bottom: none; }
.genre-color { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.genre-info { flex: 1; }
.genre-name { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.genre-users { font-size: 11px; color: var(--text-tertiary); margin-top: 1px; }
.genre-bar-wrap { width: 80px; }
.genre-bar-bg { height: 4px; background: var(--surface2); border-radius: 2px; }
.genre-bar-fill { height: 4px; border-radius: 2px; }
.genre-mins { font-size: 13px; font-weight: 600; font-family: 'DM Mono', monospace; color: var(--text-primary); white-space: nowrap; min-width: 52px; text-align: right; }

/* ============================================
   BUTTONS & FORMS
   ============================================ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 18px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; font-family: 'DM Sans', sans-serif; cursor: pointer; border: none; text-decoration: none; transition: all 0.15s; white-space: nowrap; }
.btn-primary   { background: var(--accent); color: white; }
.btn-primary:hover { background: #17a349; }
.btn-secondary { background: var(--surface); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface2); }
.btn-danger    { background: var(--red-light); color: var(--red); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm  { padding: 5px 12px; font-size: 12px; }
.btn-full { width: 100%; }
.btn svg { width: 14px; height: 14px; }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-input { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; font-family: 'DM Sans', sans-serif; color: var(--text-primary); background: var(--surface); transition: border-color 0.15s; outline: none; }
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(29,185,84,0.1); }
.form-input.error { border-color: var(--red); }
.form-hint { font-size: 11px; color: var(--text-tertiary); margin-top: 4px; }
select.form-input { cursor: pointer; }

/* ALERTS */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; }
.alert-error   { background: var(--red-light); color: var(--red); border: 1px solid #fecaca; }
.alert-success { background: var(--accent-light); color: var(--accent-text); border: 1px solid #a7e8c0; }
.alert-info    { background: var(--blue-light); color: var(--blue-text); border: 1px solid #bfdbfe; }

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 36px 40px; width: 100%; max-width: 380px; }
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.login-logo-icon { width: 36px; height: 36px; background: #1db954; border-radius: 9px; display: flex; align-items: center; justify-content: center; }
.login-logo-icon svg { width: 20px; height: 20px; fill: white; }
.login-logo-title { font-size: 15px; font-weight: 600; }
.login-logo-sub { font-size: 11px; color: var(--text-tertiary); margin-top: 1px; }
.login-heading { font-size: 20px; font-weight: 600; margin-bottom: 6px; letter-spacing: -0.02em; }
.login-sub { font-size: 13px; color: var(--text-secondary); margin-bottom: 24px; }
.login-footer { text-align: center; margin-top: 20px; font-size: 12px; color: var(--text-tertiary); }
.login-footer a { color: var(--blue); text-decoration: none; }

/* ============================================
   USER CARDS (utenti.php)
   ============================================ */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.user-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm); text-decoration: none; color: inherit; transition: box-shadow 0.15s, border-color 0.15s; display: block; }
.user-card:hover { box-shadow: var(--shadow-md); border-color: var(--border2); }
.user-card-bannato { opacity: 0.55; }
.user-card-bannato:hover { opacity: 0.85; }
.user-card-top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.user-card-av { width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; flex-shrink: 0; }
.user-card-name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.user-card-email { font-size: 11px; color: var(--text-tertiary); margin-top: 1px; }
.user-card-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; border-top: 1px solid var(--border); padding-top: 14px; }
.ucs { text-align: center; }
.ucs-val { font-size: 18px; font-weight: 600; color: var(--text-primary); font-family: 'DM Mono', monospace; letter-spacing: -0.02em; }
.ucs-label { font-size: 10px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 2px; }

/* ============================================
   BACK LINK & DETAIL HEADER
   ============================================ */
.back-link { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-secondary); text-decoration: none; margin-bottom: 20px; }
.back-link:hover { color: var(--text-primary); }
.back-link svg { width: 13px; height: 13px; }
.detail-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.detail-header-left { display: flex; align-items: center; gap: 16px; }
.detail-av { width: 54px; height: 54px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 600; flex-shrink: 0; }
.detail-name { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.detail-meta { font-size: 12px; color: var(--text-tertiary); margin-top: 4px; }

/* ============================================
   ACCOUNT SPOTIFY CARD (user side)
   ============================================ */
.account-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.account-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; transition: box-shadow 0.15s, border-color 0.15s; }
.account-card:hover { box-shadow: var(--shadow-md); border-color: var(--accent); }
.account-card-icon { width: 44px; height: 44px; background: #1db954; border-radius: 11px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.account-card-icon svg { width: 22px; height: 22px; fill: white; }
.account-card-name { font-size: 14px; font-weight: 600; }
.account-card-sub { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }
.account-card-arrow { margin-left: auto; color: var(--text-tertiary); }
.account-card-arrow svg { width: 16px; height: 16px; }

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state svg { width: 40px; height: 40px; margin: 0 auto 12px; opacity: 0.25; display: block; stroke: var(--text-secondary); }
.empty-state h3 { font-size: 15px; font-weight: 500; color: var(--text-primary); margin-bottom: 6px; }
.empty-state p { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }

/* ============================================
   USER SIMPLE LAYOUT (pagine utente)
   ============================================ */
.user-app { min-height: 100vh; display: flex; flex-direction: column; }
.user-header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 32px; height: 56px; display: flex; align-items: center; justify-content: space-between; }
.user-header-logo { display: flex; align-items: center; gap: 9px; }
.user-header-logo-icon { width: 28px; height: 28px; background: #1db954; border-radius: 7px; display: flex; align-items: center; justify-content: center; }
.user-header-logo-icon svg { width: 15px; height: 15px; fill: white; }
.user-header-title { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.user-header-right { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-secondary); }
.user-content { flex: 1; padding: 32px; max-width: 900px; width: 100%; margin: 0 auto; }
.user-page-title { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 6px; }
.user-page-sub { font-size: 13px; color: var(--text-secondary); margin-bottom: 24px; }

/* ============================================
   SYNC STATUS
   ============================================ */
.sync-row { display: flex; align-items: center; padding: 13px 20px; border-bottom: 1px solid var(--border); gap: 12px; }
.sync-row:last-child { border-bottom: none; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.sync-dot.completata { background: var(--accent); }
.sync-dot.errore     { background: var(--red); }
.sync-dot.in_corso   { background: #f59e0b; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 10px; }

/* ============================================
   IMPOSTAZIONI — grid responsive
   ============================================ */
.imp-grid { display: grid; gap: 18px; align-items: start; }
.imp-grid-1 { grid-template-columns: 1fr; }
.imp-grid-2 { grid-template-columns: 1fr 1fr; }
.imp-info-grid { padding: 20px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 768px) {
  .imp-grid-2 { grid-template-columns: 1fr; }
  .imp-info-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 16px; }
}
@media (max-width: 480px) {
  .imp-info-grid { grid-template-columns: 1fr; gap: 14px; }
}

/* ============================================
   HAMBURGER & SIDEBAR MOBILE (default: hidden)
   ============================================ */
.sb-burger {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  margin-right: 8px;
  cursor: pointer;
  color: var(--text-primary);
  border-radius: var(--radius-sm);
}
.sb-burger:hover { background: var(--surface2); }
.sb-burger svg { width: 22px; height: 22px; display: block; }
.sb-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 90;
  opacity: 0;
  transition: opacity .2s;
}
.sb-overlay.open { display: block; opacity: 1; }

/* ============================================
   RESPONSIVE — Tablet (≤ 1024px)
   ============================================ */
@media (max-width: 1024px) {
  /* Metriche curatore: 4 → 2 colonne */
  .metrics { grid-template-columns: repeat(2, 1fr); gap: 12px; }

  /* Two-col → 1 col */
  .two-col { grid-template-columns: 1fr; }

  /* Sidebar più stretta */
  .app { grid-template-columns: 200px 1fr; }

  /* Content padding ridotto */
  .content { padding: 20px 22px; }
  .topbar { padding: 0 22px; }
}

/* ============================================
   RESPONSIVE — Mobile (≤ 768px)
   ============================================ */
@media (max-width: 768px) {
  body { font-size: 13px; }

  /* ── PANNELLO CURATORE: sidebar a scomparsa ── */
  .app { grid-template-columns: 1fr; height: auto; min-height: 100vh; width: 100%; max-width: 100%; overflow-x: hidden; }
  .main, .content, .user-content { max-width: 100%; min-width: 0; }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 270px;
    max-width: 85vw;
    height: 100vh;
    height: 100dvh;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    overscroll-behavior: contain;
  }
  .sidebar.open { transform: translateX(0); }
  /* Notch / Dynamic Island in alto, home indicator in basso */
  .sb-logo { padding-top: max(22px, calc(env(safe-area-inset-top) + 14px)); }
  .sb-footer { padding-bottom: max(14px, calc(env(safe-area-inset-bottom) + 12px)); }

  .sb-burger { display: inline-flex; align-items: center; justify-content: center; }

  .main { height: auto; overflow: visible; }

  /* Topbar mobile — 2 righe (titolo sopra, filtri sotto se necessari) */
  .topbar {
    flex-wrap: wrap;
    padding: 8px 14px;
    height: auto;
    min-height: 52px;
    gap: 8px;
  }
  .topbar-left { min-width: 0; flex: 1; }
  .topbar-page { font-size: 13px; }
  .topbar-bread { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-right { flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
  .topbar-right .btn-sm { padding: 5px 9px; font-size: 11px; }

  /* Filtri data nella topbar — collassa */
  .topbar-right form { flex-wrap: wrap; gap: 4px !important; width: 100%; justify-content: flex-end; }
  .topbar-right input[type="date"] { flex: 1 1 0; min-width: 0; width: auto !important; max-width: 160px; font-size: 12px !important; padding: 6px 8px !important; }

  /* Filtri data anche fuori dalla topbar (es. pagine utente) */
  form input[type="date"] { width: auto !important; max-width: 160px; min-width: 0; flex: 1 1 0; }

  /* Content */
  .content { padding: 16px 14px; }

  /* Metriche 2 colonne ma più compatte (override anche stili inline) */
  .metrics { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; margin-bottom: 18px; }
  .mc { padding: 14px 14px; }
  .mc-val { font-size: 21px; }

  /* Panel header su mobile: stack invece di space-between */
  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 14px;
  }
  .panel-header > * { width: 100%; }
  .panel-action { width: auto; align-self: flex-start; }

  /* ── TABELLE → CARD STACK su mobile (niente scroll orizzontale) ── */
  .panel > .tbl,
  .panel > table {
    display: block;
    width: 100%;
    overflow: visible;
    white-space: normal;
    background: transparent;
    padding: 10px;
  }
  .tbl thead { display: none; }
  .tbl tbody { display: block; width: 100%; }
  .tbl tr {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
  }
  .tbl tr:last-child { margin-bottom: 0; }
  .tbl tr:hover td { background: transparent; }
  .tbl td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 0;
    border-bottom: none;
    font-size: 13px;
    white-space: normal !important;
    word-break: break-word;
    min-width: 0;
    max-width: 100% !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }
  .tbl td:first-child {
    padding: 0 0 10px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
    display: block;
  }
  .tbl td > div[style*="white-space:nowrap"],
  .tbl td > div[style*="white-space: nowrap"] {
    white-space: normal !important;
    max-width: 100% !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }
  /* Label opzionale tramite data-label */
  .tbl td[data-label]::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
  }
  .tbl td:first-child[data-label]::before { display: none; }
  /* La cella utente/avatar resta full-width sopra */
  .tbl .user-cell { width: 100%; }
  /* Bar wrap: in card stack, allinea a destra ma non sforare */
  .tbl .bar-wrap { flex: 1; min-width: 0; max-width: 65%; }
  .tbl .bar-bg { min-width: 0; }
  /* Generi: chip in wrap senza sforare */
  .tbl .genre-wrap { justify-content: flex-end; max-width: 70%; }

  /* Detail header */
  .detail-header { flex-direction: column; align-items: flex-start; gap: 14px; }
  .detail-header-left { gap: 12px; }
  .detail-av { width: 46px; height: 46px; font-size: 16px; }
  .detail-name { font-size: 17px; }

  /* Card grid utenti — 1 colonna su mobile */
  .card-grid { grid-template-columns: 1fr; gap: 12px; }
  .user-card { padding: 16px; }

  /* Account grid utente */
  .account-grid { grid-template-columns: 1fr; gap: 10px; }
  .account-card { padding: 14px 16px; gap: 12px; }
  .account-card-name { font-size: 13px; }
  .account-card-sub { font-size: 10px; }

  /* User layout (pagine utente) */
  .user-header { padding: 0 14px; height: 52px; gap: 8px; }
  .user-header-title { font-size: 13px; }
  .user-header-right { gap: 6px; }
  .user-header-right .btn-sm { padding: 5px 9px; font-size: 11px; }
  /* Nasconde il nickname testuale nell'header per fare spazio ai bottoni */
  .user-header-right > span:first-child { display: none; }

  .user-content { padding: 18px 14px; }
  .user-page-title { font-size: 17px; }
  .user-page-sub { font-size: 12px; margin-bottom: 16px; }

  /* Bottoni */
  .btn { padding: 9px 14px; font-size: 12px; }
  .btn-sm { padding: 6px 10px; font-size: 11px; }

  /* Empty state */
  .empty-state { padding: 40px 16px; }
  .empty-state svg { width: 34px; height: 34px; }

  /* Sync row */
  .sync-row { padding: 12px 14px; gap: 10px; }

  /* Playlist item — mobile compact */
  .pl-item { padding: 12px 14px; gap: 10px; }
  .pl-name { font-size: 12px; }
  .pl-mins { font-size: 12px; }

  /* Genre item */
  .genre-item { padding: 12px 14px; }
  .genre-bar-wrap { width: 50px; }

  /* Date buttons compatti */
  .date-btn { padding: 5px 9px; font-size: 11px; }
  .date-sep { display: none; }
}

/* ============================================
   RESPONSIVE — Telefoni piccoli (≤ 480px)
   ============================================ */
@media (max-width: 480px) {
  /* Metriche: 1 colonna invece di 2 (override anche stili inline) */
  .metrics { grid-template-columns: 1fr !important; }
  .mc { padding: 14px 16px; }
  .mc-val { font-size: 22px; }

  /* User card stats più compatte */
  .user-card-stats { gap: 4px; }
  .ucs-val { font-size: 16px; }
  .ucs-label { font-size: 9px; }

  /* Form input più grande per touch (16px evita zoom su iOS) */
  .form-input { padding: 11px 13px; font-size: 16px; }
  input, select, textarea { font-size: 16px; }

  /* Sidebar a piena larghezza su telefoni piccoli */
  .sidebar { width: 85%; max-width: 280px; }

  /* User header: bottone "Impostazioni" diventa solo icona */
  .user-header-right .btn-sm { padding: 5px 8px; }

  /* Modal/dialog inline si adattano a schermi piccoli */
  [style*="min-width:280px"], [style*="min-width: 280px"] { min-width: 0 !important; }

  /* Topbar input date piccoli ma usabili */
  .topbar-right input[type="date"] { font-size: 13px !important; padding: 8px !important; }
}

/* ============================================
   TOUCH-FRIENDLY (input min height 44px su touch)
   ============================================ */
@media (hover: none) and (pointer: coarse) {
  .btn, .sb-link, .panel-action, .date-btn {
    min-height: 38px;
  }
  .form-input { min-height: 40px; }
}
