/* ============================================================
   NeuroLens SaaS — Shared Stylesheet
   ============================================================ */

:root {
  /* Colors (tema chiaro — unico tema del progetto) */
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface2: #eceef5;
  --border: #d5d8e8;
  --accent: #7c6ff7;
  --accent-hover: #6458e0;
  --accent-light: rgba(124, 111, 247, 0.12);
  --text: #1a1d2e;
  --text-muted: #5c6080;
  --success: #34d399;
  --error: #f87171;
  --warning: #fbbf24;

  /* Shape */
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.1);
  --transition: 0.2s ease;

  /* Typography */
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  --text-xs: 0.72rem;
  --text-sm: 0.825rem;
  --text-base: 0.95rem;
  --text-md: 1rem;
  --text-lg: 1.15rem;
  --text-xl: 1.35rem;
  --text-2xl: 1.6rem;

  /* Spacing scale (4px grid) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* Layout */
  --sidebar-w: 240px;
  --content-max: 1200px;
  --touch-min: 44px;

  /* Breakpoints (consultabili da JS via getComputedStyle) */
  --bp-sm: 640px;
  --bp-md: 768px;
  --bp-lg: 1024px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[x-cloak] { display: none !important; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ── Buttons ──────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background var(--transition), opacity var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); text-decoration: none; }

.btn-danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--error);
  border: 1px solid rgba(248, 113, 113, 0.3);
}
.btn-danger:hover { background: rgba(248, 113, 113, 0.25); text-decoration: none; }

.btn-sm { padding: 6px 14px; font-size: 0.85rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-icon { padding: 6px 8px; line-height: 1; }
.btn-icon svg { display: block; }

/* ── Forms ────────────────────────────────────────────────── */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

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

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 10px 14px;
  width: 100%;
  transition: border-color var(--transition);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}

input::placeholder { color: var(--text-muted); }

.field-error {
  font-size: 0.8rem;
  color: var(--error);
}

/* ── Cards ────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

/* ── Alerts ───────────────────────────────────────────────── */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 16px;
}
.alert-error { background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.3); color: var(--error); }
.alert-success { background: rgba(52,211,153,0.1); border: 1px solid rgba(52,211,153,0.3); color: var(--success); }
.alert-warning { background: rgba(251,191,36,0.1); border: 1px solid rgba(251,191,36,0.3); color: var(--warning); }

/* ── Auth layout ──────────────────────────────────────────── */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 28px;
}

.auth-logo .accent { color: var(--accent); }

.auth-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ── Footer legale globale (GDPR doc links) ───────────────── */
.nl-legal-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: auto;
  padding: 18px 24px;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}
.nl-legal-footer a { color: var(--text-muted); text-decoration: none; }
.nl-legal-footer a:hover { color: var(--accent); text-decoration: underline; }
.nl-legal-footer .sep { color: var(--border); user-select: none; }
.nl-legal-footer--fixed {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  margin-top: 0;
  background: var(--surface);
  z-index: 10;
}

/* ── Consensi GDPR al signup ──────────────────────────────── */

.consent-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 20px 0 24px;
  padding: 16px;
  background: var(--surface-alt, rgba(0, 0, 0, 0.02));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 6px);
}

.consent-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--text);
  cursor: pointer;
}

.consent-row input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
  cursor: pointer;
}

.consent-row a {
  color: var(--accent);
  text-decoration: underline;
}

.consent-row.consent-optional {
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px dashed var(--border);
  padding-top: 10px;
  margin-top: 4px;
}

.consent-required {
  color: var(--danger, #dc2626);
  font-weight: 700;
}

.consent-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 4px 0 0;
}

/* ── Pagine legali (/privacy, /terms, /dpa, /subprocessors) ── */

.legal-page {
  max-width: 820px;
  margin: 0 auto;
  padding: 40px 24px 60px;
  line-height: 1.65;
}

.legal-page header.legal-header {
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.legal-page h1 {
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.legal-page .legal-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.legal-page h2 {
  font-size: 1.2rem;
  margin: 32px 0 12px;
  color: var(--accent);
}

.legal-page h3 {
  font-size: 1rem;
  margin: 20px 0 8px;
}

.legal-page p, .legal-page li { font-size: 0.92rem; }

.legal-page ul, .legal-page ol {
  padding-left: 22px;
  margin: 10px 0;
}

.legal-page .legal-draft {
  background: #fff7ed;
  border-left: 4px solid #f59e0b;
  padding: 12px 16px;
  border-radius: 4px;
  margin: 16px 0;
  font-size: 0.85rem;
  color: #78350f;
}

.legal-page .legal-nav {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  font-size: 0.85rem;
}

.legal-page .legal-nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.legal-page .legal-nav a.active,
.legal-page .legal-nav a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.legal-page table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.88rem;
}
.legal-page table th, .legal-page table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.legal-page table th {
  background: var(--surface-alt, rgba(0,0,0,0.03));
  font-weight: 600;
}

/* ── Dashboard layout ─────────────────────────────────────── */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 200;
  transition: transform var(--transition);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 700;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo .accent { color: var(--accent); }

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.nav-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 8px 20px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-radius: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--accent-light);
  color: var(--text);
  text-decoration: none;
}

.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  border-left: 3px solid var(--accent);
}

.nav-item .icon { font-size: 1.1rem; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-email {
  font-size: 0.8rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Main content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.page-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.content {
  flex: 1;
  padding: 32px;
  max-width: 1100px;
}

/* Mobile hamburger */
.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 150;
}

/* ── Hours progress bar ───────────────────────────────────── */

.hours-bar-wrap {
  background: var(--surface2);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
  margin-top: 6px;
}

.hours-bar {
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.4s ease;
}

.hours-bar.low { background: var(--warning); }
.hours-bar.critical { background: var(--error); }

/* ── Badges & Pills ───────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success { background: rgba(52,211,153,0.15); color: var(--success); }
.badge-error { background: rgba(248,113,113,0.15); color: var(--error); }
.badge-warning { background: rgba(251,191,36,0.15); color: var(--warning); }
.badge-muted { background: var(--surface2); color: var(--text-muted); }
.badge-accent { background: var(--accent-light); color: var(--accent); }

/* ── Table ────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }

/* ── Toast notifications ──────────────────────────────────── */

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.875rem;
  box-shadow: var(--shadow);
  animation: toastIn 0.2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

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

@keyframes toastIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Stats grid ───────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
}

.stat-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Section header ───────────────────────────────────────── */

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

.section-title {
  font-size: 1rem;
  font-weight: 700;
}

/* ── Spinner ──────────────────────────────────────────────── */

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(0,0,0,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ── Modal (globale, varianti dimensione) ─────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  overflow-y: auto;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-6);
  width: 100%;
  max-width: 560px;             /* default = md */
  box-shadow: var(--shadow);
  max-height: calc(100vh - var(--space-8));
  overflow-y: auto;
}

.modal-sm { max-width: 440px; }
.modal-md { max-width: 560px; }
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 920px; }

.modal-title {
  font-size: var(--text-lg);
  font-weight: 700;
  margin-bottom: var(--space-5);
}

/* ── Utility classes (riducono inline styles) ─────────────── */

/* Flex helpers */
.row          { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.row-tight    { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.row-between  { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.row-end      { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); flex-wrap: wrap; }
.row-baseline { display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap; }
.stack        { display: flex; flex-direction: column; gap: var(--space-3); }
.stack-tight  { display: flex; flex-direction: column; gap: var(--space-2); }
.flex-1       { flex: 1 1 0; min-width: 0; }
.no-shrink    { flex-shrink: 0; }

/* Text helpers */
.text-muted   { color: var(--text-muted); }
.text-xs      { font-size: var(--text-xs); }
.text-sm      { font-size: var(--text-sm); }
.text-lg      { font-size: var(--text-lg); }
.text-bold    { font-weight: 600; }
.text-center  { text-align: center; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

/* Spacing helpers */
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

/* Page section */
.section { margin-bottom: var(--space-6); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--text-muted);
}

/* Tabs (estratto dai pattern inline ripetuti) */
.tabs-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-4);
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tabs-bar .tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  transition: color var(--transition), border-color var(--transition);
}
.tabs-bar .tab-btn:hover { color: var(--text); }
.tabs-bar .tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tabs-bar .tab-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Search field globale ─────────────────────────────────── */

.search-field {
  position: relative;
  width: 100%;
  max-width: 480px;
}
.search-field input[type="search"]::-webkit-search-cancel-button { display: none; }
.search-field input[type="search"],
.search-field input[type="text"] {
  width: 100%;
  padding: 14px 40px 14px 44px;
  font-size: var(--text-base);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: var(--touch-min);
}
.search-field input[type="search"]:focus,
.search-field input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  outline: none;
}
.search-field::before {
  content: "🔍";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--text-base);
  color: var(--text-muted);
  pointer-events: none;
  opacity: 0.6;
}
.search-field .search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--text-sm);
  padding: var(--space-1) var(--space-2);
  line-height: 1;
  border-radius: 4px;
}
.search-field .search-clear:hover {
  color: var(--text);
  background: var(--surface2);
}
.search-field-full { max-width: 100%; }

/* Autocomplete dropdown (usato in patient picker / search) */
.dropdown-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}
.dropdown-input {
  width: 100%;
  padding-right: 28px;
}
.dropdown-clear {
  position: absolute;
  right: var(--space-2);
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--text-sm);
  padding: var(--space-1);
  line-height: 1;
}
.dropdown-clear:hover { color: var(--text); }
.dropdown-panel {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  z-index: 200;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.dropdown-item {
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  font-size: var(--text-sm);
  transition: background var(--transition);
}
.dropdown-item:hover { background: var(--surface2); }
.dropdown-item.selected {
  background: var(--accent-light);
  font-weight: 600;
}

/* Required asterisk per form labels */
.required-mark { color: var(--error); }

/* Spinner size variants */
.spinner-sm { width: 14px; height: 14px; }
.spinner-lg { width: 28px; height: 28px; }

/* Sticky upload banner (Service Worker driven) */
.tx-banner {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
  position: sticky;
  top: 57px;
  z-index: 90;
  flex-wrap: wrap;
}
.tx-banner-label { flex-shrink: 0; }
.tx-banner-track {
  flex: 1 1 200px;
  min-width: 120px;
  background: var(--border);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
}
.tx-banner-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  width: 0%;
  transition: width .3s ease;
}
.tx-banner-fill.tx-banner-indeterminate {
  width: 40%;
  animation: tx-banner-slide 1.4s ease-in-out infinite;
}
@keyframes tx-banner-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}
.tx-banner-pct {
  color: var(--text-muted);
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  min-width: 40px;
  text-align: right;
}

/* Synthesis dot badge (sulla riga lista trascrizioni) */
.synth-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 99px;
  cursor: help;
}
.synth-pending { background: var(--surface2); color: var(--text-muted); }
.synth-running {
  background: var(--accent-light);
  color: var(--accent);
  animation: synth-spin 1.5s linear infinite;
  transform-origin: center;
}
.synth-done    { background: var(--accent-light); color: var(--accent); }
.synth-error   { background: rgba(248,113,113,0.15); color: var(--error); }
.synth-missing { background: var(--surface2); color: var(--text-muted); opacity: 0.6; }
@keyframes synth-spin {
  to { transform: rotate(360deg); }
}

/* Mini progress bar (10 blocchetti: 5 verde trascrizione + 5 blu sintesi) */
.mini-progress {
  display: inline-flex;
  gap: 2px;
  align-items: center;
}
.mini-progress .block {
  width: 8px;
  height: 14px;
  background: var(--surface2);
  border-radius: 1px;
  transition: background var(--transition);
}

.mini-progress .block.filled-green { background: var(--success); }
.mini-progress .block.filled-blue  { background: var(--accent); }
.mini-progress .block.block-error  { background: var(--error); opacity: 0.6; }

.mini-progress .block.pulse-green {
  background: rgba(52, 211, 153, 0.25);
  animation: mini-pulse-green 1.2s ease-in-out infinite;
}
.mini-progress .block.pulse-blue {
  background: rgba(124, 111, 247, 0.25);
  animation: mini-pulse-blue 1.2s ease-in-out infinite;
}
@keyframes mini-pulse-green {
  0%, 100% { background: rgba(52, 211, 153, 0.25); }
  50%      { background: var(--success); }
}
@keyframes mini-pulse-blue {
  0%, 100% { background: rgba(124, 111, 247, 0.25); }
  50%      { background: var(--accent); }
}

.mini-progress-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-left: var(--space-2);
  font-variant-numeric: tabular-nums;
}

/* Cell text helpers (tabelle: titolo principale + sottotitolo) */
.cell-primary {
  font-weight: 600;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell-secondary {
  font-size: var(--text-xs);
  color: var(--text-muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Focus visibili (accessibilità) */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;       /* hanno già border-color: accent */
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .hamburger { display: block; }
  .main-content { margin-left: 0; }
  /* Guard anti-overflow orizzontale su mobile: niente scroll dx/sx di pagina.
     `clip` (non `hidden`) non crea uno scroll container verticale annidato e non
     disabilita lo scroll interno voluto di .stats-wrap (suo overflow-x:auto). */
  .content { padding: var(--space-5) var(--space-4); overflow-x: clip; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  /* Tipografia leggermente ridotta */
  body { font-size: 0.95rem; }

  /* Modale: occupa quasi tutto lo schermo */
  .modal-backdrop { padding: var(--space-2); align-items: flex-start; padding-top: var(--space-4); }
  .modal,
  .modal-sm, .modal-md, .modal-lg, .modal-xl {
    max-width: 100%;
    padding: var(--space-4);
  }

  /* Card padding ridotto */
  .card { padding: var(--space-4); }

  /* Stats: 1 colonna */
  .stats-grid { grid-template-columns: 1fr; }

  /* ── Tabelle mobile: card layout (niente scroll orizzontale) ── */
  .table-wrap { overflow-x: visible; }
  table { min-width: unset !important; width: 100%; border-collapse: separate; border-spacing: 0; }

  table thead { display: none; }

  table tbody tr {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-3);
    padding: var(--space-1) var(--space-3);
  }

  table tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    border: none;
    border-bottom: 1px solid var(--border);
  }
  table tbody td:last-child { border-bottom: none; }

  /* Prima cella = titolo card: colonna intera, no label */
  table tbody td:first-child {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding-bottom: var(--space-2);
    font-weight: 600;
  }

  /* Label automatica prima di ogni cella (tranne prima e ultima) */
  table tbody td[data-label]::before {
    content: attr(data-label);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .4px;
    flex-shrink: 0;
    min-width: 72px;
  }

  /* Ultima cella (azioni): bottoni affiancati a sinistra */
  table tbody td:last-child {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding-top: var(--space-2);
  }

  /* Bottoni: touch target minimo */
  .btn { min-height: var(--touch-min); padding: var(--space-3) var(--space-4); }
  .btn-sm { min-height: 36px; padding: var(--space-2) var(--space-3); }

  /* Form fields: touch friendly */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  select,
  textarea {
    min-height: var(--touch-min);
    font-size: 16px;   /* evita lo zoom iOS sui campi */
  }

  /* Topbar padding ridotto */
  .topbar { padding: var(--space-3) var(--space-4); }

  /* Page title più piccolo */
  .page-title { font-size: var(--text-lg); }

  /* Drop-zone */
  .drop-zone { padding: var(--space-5) var(--space-3); }

  /* Auth pages — padding ridotto */
  .auth-page { padding: var(--space-3); }
}

/* ── Upload Nav Guard — modal overlay ──────────────────────── */

.nl-guard-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.nl-guard-overlay.nl-guard-visible {
  opacity: 1;
}

.nl-guard-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-8) var(--space-8) var(--space-6);
  max-width: 420px;
  width: 100%;
  text-align: center;
  transform: scale(0.92) translateY(8px);
  transition: transform 0.22s cubic-bezier(0.34, 1.4, 0.64, 1), opacity 0.2s ease;
}
.nl-guard-overlay.nl-guard-visible .nl-guard-dialog {
  transform: scale(1) translateY(0);
}

.nl-guard-icon {
  font-size: 2.4rem;
  margin-bottom: var(--space-3);
  line-height: 1;
}

.nl-guard-title {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text);
  margin: 0 0 var(--space-3);
}

.nl-guard-body {
  font-size: var(--text-base);
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0 0 var(--space-6);
}
.nl-guard-body strong {
  color: var(--text);
}

.nl-guard-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
}
.nl-guard-actions .btn {
  flex: 1;
  min-width: 130px;
}
