/* ============================================================
 * ORE ELETTRA — Tema Dark Elegante con Ciano + Toggle Tema
 * ============================================================ */

:root {
  --bg: #0f1420;
  --bg-alt: #141a28;
  --surface: #1a1f2e;
  --surface-2: #212838;
  --surface-3: #2a3040;

  --border: #2a3040;
  --border-strong: #3a4155;

  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;

  --accent: #06b6d4;
  --accent-light: #22d3ee;
  --accent-dark: #0891b2;
  --accent-glow: rgba(6, 182, 212, .15);

  --success: #10b981;
  --success-glow: rgba(16, 185, 129, .15);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, .15);
  --warning: #f59e0b;
  --warning-glow: rgba(245, 158, 11, .15);
  --purple: #a855f7;
  --purple-glow: rgba(168, 85, 247, .15);

  --shadow-xs: 0 1px 2px rgba(0,0,0,.3);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
  --shadow: 0 4px 12px rgba(0,0,0,.35);
  --shadow-md: 0 8px 24px rgba(0,0,0,.4);
  --shadow-lg: 0 16px 40px rgba(0,0,0,.5);
  --shadow-xl: 0 24px 60px rgba(0,0,0,.6);

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 20px;

  --t-fast: .15s cubic-bezier(.4,0,.2,1);
  --t: .22s cubic-bezier(.4,0,.2,1);
}

body.light-theme {
  --bg: #f1f5f9;
  --bg-alt: #e2e8f0;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #e2e8f0;

  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --text: #0f172a;
  --text-muted: #475569;
  --text-subtle: #94a3b8;

  --accent: #0891b2;
  --accent-light: #06b6d4;
  --accent-dark: #0e7490;
  --accent-glow: rgba(8, 145, 178, .12);

  --success: #059669;
  --success-glow: rgba(5, 150, 105, .12);
  --danger: #dc2626;
  --danger-glow: rgba(220, 38, 38, .1);
  --warning: #d97706;
  --warning-glow: rgba(217, 119, 6, .12);
  --purple: #7c3aed;
  --purple-glow: rgba(124, 58, 237, .12);

  --shadow-xs: 0 1px 2px rgba(15,23,42,.04);
  --shadow-sm: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow: 0 4px 6px -1px rgba(15,23,42,.06), 0 2px 4px -1px rgba(15,23,42,.04);
  --shadow-md: 0 10px 15px -3px rgba(15,23,42,.08), 0 4px 6px -2px rgba(15,23,42,.05);
  --shadow-lg: 0 20px 25px -5px rgba(15,23,42,.1), 0 8px 10px -6px rgba(15,23,42,.06);
  --shadow-xl: 0 25px 50px -12px rgba(15,23,42,.25);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  padding-bottom: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color .25s, color .25s;
}

/* ============================================================
 * LOGIN
 * ============================================================ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at top left, rgba(6, 182, 212, .18), transparent 55%),
    radial-gradient(ellipse at bottom right, rgba(168, 85, 247, .12), transparent 55%),
    linear-gradient(135deg, #050810 0%, #0a0e1a 50%, #0f1420 100%);
  position: relative;
  overflow: hidden;
  transition: background .3s;
}
body.light-theme .login-screen {
  background:
    radial-gradient(ellipse at top left, rgba(8, 145, 178, .12), transparent 55%),
    radial-gradient(ellipse at bottom right, rgba(124, 58, 237, .08), transparent 55%),
    linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 50%, #f8fafc 100%);
}
.login-box {
  background: rgba(26, 31, 46, .85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(6, 182, 212, .2);
  border-radius: var(--r-xl);
  padding: 40px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow:
    0 0 0 1px rgba(6, 182, 212, .1),
    0 30px 60px -12px rgba(0, 0, 0, .7);
  position: relative;
  z-index: 1;
  animation: loginFadeIn .5s cubic-bezier(.16,1,.3,1);
}
body.light-theme .login-box {
  background: rgba(255, 255, 255, .95);
  border-color: rgba(8, 145, 178, .15);
  box-shadow: 0 20px 50px -12px rgba(15,23,42,.15), 0 0 0 1px rgba(8, 145, 178, .08);
}
@keyframes loginFadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.login-logo {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  overflow: hidden;
  background: transparent;
}
.login-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.login-box h1 {
  margin: 0 0 8px;
  font-size: 1.6rem;
  font-weight: 800;
  text-align: center;
  color: var(--text);
  letter-spacing: -.03em;
}
.login-sub {
  margin: 0 0 32px;
  font-size: .9rem;
  text-align: center;
  color: var(--text-muted);
}
.login-hint {
  margin: 24px 0 0;
  font-size: .78rem;
  text-align: center;
  color: var(--text-subtle);
  line-height: 1.5;
}
.login-error {
  background: var(--danger-glow);
  color: var(--danger);
  padding: 12px 16px;
  border-radius: var(--r-sm);
  font-size: .85rem;
  font-weight: 500;
  margin-bottom: 16px;
  border-left: 3px solid var(--danger);
  animation: shake .4s;
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ============================================================
 * HEADER
 * ============================================================ */
header {
  background: linear-gradient(135deg, #050810 0%, #0a0e1a 100%);
  color: white;
  padding: 16px 24px;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid rgba(6, 182, 212, .15);
  transition: background .25s, border-color .25s;
}
body.light-theme header {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(15,23,42,.06);
}
.header-content {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.brand-text { min-width: 0; }
.brand-text h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
body:not(.light-theme) .brand-text h1 { color: #e2e8f0; }
.brand-text p {
  margin: 0;
  font-size: .72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body:not(.light-theme) .brand-text p { color: #94a3b8; }
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.badge-foglio {
  background: rgba(6, 182, 212, .12);
  border: 1px solid rgba(6, 182, 212, .3);
  color: #67e8f9;
  padding: 6px 14px;
  border-radius: 100px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}
body.light-theme .badge-foglio {
  background: rgba(8, 145, 178, .1);
  border-color: rgba(8, 145, 178, .3);
  color: #0e7490;
}
.btn-logout {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
}
body:not(.light-theme) .btn-logout { color: #e2e8f0; }
body.light-theme .btn-logout {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #64748b;
}
.btn-logout:hover {
  background: rgba(239, 68, 68, .2);
  border-color: rgba(239, 68, 68, .4);
  color: #fca5a5;
}
.btn-theme {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  color: #94a3b8;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
  flex-shrink: 0;
}
body.light-theme .btn-theme {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #64748b;
}
.btn-theme:hover {
  background: rgba(6, 182, 212, .15);
  border-color: rgba(6, 182, 212, .4);
  color: #22d3ee;
  transform: rotate(15deg);
}
body.light-theme .btn-theme:hover {
  background: rgba(8, 145, 178, .1);
  border-color: rgba(8, 145, 178, .3);
  color: #0891b2;
}
.btn-install {
  background: linear-gradient(135deg, #0891b2 0%, #22d3ee 100%);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  display: none;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  box-shadow: 0 4px 16px -3px rgba(6, 182, 212, .5);
  transition: all var(--t-fast);
  white-space: nowrap;
}
.btn-install:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px -3px rgba(6, 182, 212, .7);
}
.btn-install:active { transform: scale(.97); }

/* ============================================================
 * TOOLBAR
 * ============================================================ */
.toolbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  position: sticky;
  top: 72px;
  z-index: 20;
  box-shadow: var(--shadow-xs);
  transition: background .25s, border-color .25s;
}
.toolbar-content {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toolbar select {
  flex: 1;
  min-width: 0;
  padding: 10px 16px;
  font-size: .88rem;
  font-weight: 600;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: all var(--t-fast);
  font-family: inherit;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
.toolbar select:hover { border-color: var(--border-strong); }
.toolbar select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.toolbar select#filtroPeriodo { flex: 0 0 auto; min-width: 170px; }
.toolbar select option { background: var(--surface-2); color: var(--text); }

.btn-icon {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 13px;
  cursor: pointer;
  line-height: 1;
  color: var(--text);
  transition: all var(--t-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}
.btn-icon:hover {
  background: var(--surface-3);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.btn-icon.primary {
  background: linear-gradient(135deg, #0891b2 0%, #22d3ee 100%);
  color: white;
  border-color: transparent;
  padding: 10px 18px;
  font-weight: 700;
  box-shadow: 0 4px 16px -3px rgba(6, 182, 212, .5);
}
.btn-icon.primary:hover {
  box-shadow: 0 6px 20px -3px rgba(6, 182, 212, .7);
  transform: translateY(-1px);
}
.admin-only { display: none; }
body.is-admin .admin-only { display: inline-flex; }

/* ============================================================
 * FILTRI EXTRA
 * ============================================================ */
.filtri-extra {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  position: sticky;
  top: 128px;
  z-index: 19;
  box-shadow: var(--shadow-xs);
  animation: slideDown .2s ease-out;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.filtri-extra-inner { max-width: 1440px; margin: 0 auto; }

/* ============================================================
 * CONTAINER
 * ============================================================ */
.container {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 24px 0 24px;
  box-sizing: border-box;
}
.container > *:last-child {
  margin-bottom: 0 !important;
}

/* ============================================================
 * KPI
 * ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
  width: 100%;
}
.kpi {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  transition: all var(--t), background .25s, border-color .25s;
}
.kpi::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
  box-shadow: 0 0 12px var(--accent);
}
.kpi .label {
  font-size: .68rem;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: .08em;
  display: block;
  margin-bottom: 8px;
}
.kpi .value {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.kpi .value small {
  font-size: .6em;
  font-weight: 600;
  opacity: .55;
  margin-left: 3px;
}
.kpi.green::after { background: var(--success); box-shadow: 0 0 12px var(--success); }
.kpi.green .value { color: var(--success); }
.kpi.orange::after { background: var(--warning); box-shadow: 0 0 12px var(--warning); }
.kpi.orange .value { color: var(--warning); }
.kpi.purple::after { background: var(--purple); box-shadow: 0 0 12px var(--purple); }
.kpi.purple .value { color: var(--purple); }
.kpi.red::after { background: var(--danger); box-shadow: 0 0 12px var(--danger); }
.kpi.red .value { color: var(--danger); }
.kpi.slate::after { background: var(--text-muted); box-shadow: 0 0 12px var(--text-muted); }
.kpi.slate .value { color: var(--text-muted); }

/* ============================================================
 * SEGMENTED
 * ============================================================ */
.segmented {
  display: inline-flex;
  background: var(--surface);
  padding: 5px;
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  gap: 3px;
  overflow-x: auto;
  max-width: 100%;
}
.segment {
  padding: 9px 18px;
  border-radius: var(--r-sm);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  border: none;
  background: transparent;
  white-space: nowrap;
  transition: all var(--t-fast);
  font-family: inherit;
  display: inline-flex;
  align-items: center;
}
.segment:hover { color: var(--text); background: var(--surface-2); }
.segment.active {
  background: linear-gradient(135deg, #0891b2 0%, #22d3ee 100%);
  color: white;
  box-shadow: 0 4px 16px -3px rgba(6, 182, 212, .5);
}

/* ============================================================
 * CARD
 * ============================================================ */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  overflow: hidden;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 280px);
  transition: box-shadow var(--t), background .25s, border-color .25s;
}
.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  flex-shrink: 0;
}
.card-header h3 {
  margin: 0;
  font-size: .9rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-header .count {
  font-size: .72rem;
  font-weight: 700;
  background: var(--accent-glow);
  color: var(--accent-light);
  border: 1px solid rgba(6, 182, 212, .3);
  padding: 4px 12px;
  border-radius: 100px;
}
body.light-theme .card-header .count {
  background: rgba(8, 145, 178, .1);
  color: #0e7490;
  border-color: rgba(8, 145, 178, .3);
}
.card-body {
  padding: 0;
  max-width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

/* ============================================================
 * TABELLA VOCI
 * ============================================================ */
.tabella-wrap {
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  max-width: 100%;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) var(--surface-3);
}
.tabella-wrap::-webkit-scrollbar { height: 10px; width: 10px; }
.tabella-wrap::-webkit-scrollbar-track { background: var(--surface-3); border-radius: 5px; }
.tabella-wrap::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 5px; min-width: 60px; }
.tabella-wrap::-webkit-scrollbar-thumb:hover { background: var(--accent-light); }
.tabella-wrap::-webkit-scrollbar-button { display: none; }

table.tabella {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: .78rem;
  min-width: 1200px;
  table-layout: auto;
}
table.tabella thead th {
  padding: 11px 10px;
  font-size: .67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 2px solid var(--border);
  border-right: 1px solid var(--border);
  white-space: normal;
  text-align: center;
  vertical-align: middle;
  line-height: 1.25;
  position: sticky;
  top: 0;
  z-index: 2;
  min-width: 70px;
  max-width: 110px;
}
table.tabella thead th:last-child { border-right: none; }
table.tabella tbody td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid rgba(42, 48, 64, .5);
  white-space: nowrap;
  text-align: center;
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
  transition: background var(--t-fast);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
table.tabella tbody td:last-child { border-right: none; }
table.tabella tbody tr:hover td { background: var(--surface-2); }
table.tabella tbody tr:last-child td { border-bottom: none; }
table.tabella tfoot td {
  padding: 14px 10px;
  font-weight: 800;
  font-size: .8rem;
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface-3) 100%);
  border-top: 2px solid var(--accent);
  color: var(--accent-light);
  border-right: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
table.tabella tfoot td:last-child { border-right: none; }
table.tabella .num { text-align: center; }

table.tabella thead th:nth-child(14),
table.tabella tbody td:nth-child(14) {
  min-width: 200px;
  max-width: 300px;
}
table.tabella thead th:last-child,
table.tabella tbody td:last-child {
  width: 80px;
  min-width: 80px;
  text-align: center;
}

.row-actions { white-space: nowrap; text-align: center; }
.row-actions button {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 5px 7px;
  border-radius: 6px;
  font-size: .95rem;
  transition: all var(--t-fast);
}
.row-actions .edit { color: var(--accent-light); }
.row-actions .edit:hover { background: var(--accent-glow); transform: scale(1.15); }
.row-actions .del { color: var(--danger); }
.row-actions .del:hover { background: var(--danger-glow); transform: scale(1.15); }

/* ============================================================
 * SCROLL HINT
 * ============================================================ */
.scroll-hint {
  position: sticky;
  bottom: 0;
  z-index: 5;
  flex-shrink: 0;
  font-size: .72rem;
  color: var(--accent-light);
  text-align: center;
  padding: 10px 16px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  font-style: italic;
  letter-spacing: .02em;
  font-weight: 600;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, .2);
}
body.light-theme .scroll-hint {
  background: #f8fafc;
  color: #0891b2;
  box-shadow: 0 -4px 12px rgba(15, 23, 42, .06);
}

/* ============================================================
 * TABELLE RIEPILOGO
 * ============================================================ */
.tabella-riepilogo {
  min-width: 1100px;
  width: 100%;
}
.tabella-riepilogo thead th {
  padding: 12px 14px;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 2;
}
.tabella-riepilogo tbody td {
  padding: 13px 14px;
  font-size: .82rem;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text);
}
.tabella-riepilogo tbody tr:hover td { background: var(--surface-2); }
.tabella-riepilogo tbody tr:last-child td { border-bottom: none; }
.tabella-riepilogo .dip-name { font-weight: 600; color: var(--text); }
.tabella-riepilogo .num { text-align: right; font-weight: 600; }
.tabella-riepilogo .comm-extra {
  font-size: .72rem;
  color: var(--text-subtle);
  font-weight: 400;
  display: block;
  margin-top: 2px;
}
.tabella-riepilogo tfoot td {
  padding: 14px;
  font-size: .82rem;
  font-weight: 800;
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface-3) 100%);
  border-top: 2px solid var(--accent);
  color: var(--accent-light);
  white-space: nowrap;
}
.tabella-riepilogo tfoot .num { text-align: right; color: var(--accent-light); }

/* ============================================================
 * MODAL
 * ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  z-index: 100;
  padding: 24px;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
body.light-theme .modal-overlay { background: rgba(15, 23, 42, .4); }
.modal-overlay.open { display: flex; animation: fadeIn .2s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 600px;
  box-shadow: var(--shadow-xl);
  margin: 20px auto;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  animation: modalIn .3s cubic-bezier(.16,1,.3,1);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.modal-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
  line-height: 1;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); transform: rotate(90deg); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  background: var(--surface-2);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
  flex-shrink: 0;
}
.modal-footer .btn { flex: 1; }

/* ============================================================
 * FORM
 * ============================================================ */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 11px 14px;
  font-size: .92rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  transition: all var(--t-fast);
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-subtle); }
.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover { border-color: var(--border-strong); }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--surface);
}
.form-group input[readonly] {
  background: var(--surface-3);
  color: var(--text-subtle);
  cursor: not-allowed;
}
.form-group input.data-bloccata {
  background: var(--surface-3);
  color: var(--text-subtle);
  cursor: not-allowed;
  border-style: dashed;
  opacity: 0.85;
}
.form-group input#f_data:not([readonly]) {
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  border-style: solid;
}
.form-group textarea { resize: vertical; min-height: 70px; }
.form-group select option { background: var(--surface-2); color: var(--text); }
.form-group select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--surface-3);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .grid-3 { grid-template-columns: 1fr 1fr; } }

.section-title {
  font-size: .7rem;
  font-weight: 800;
  color: var(--accent-light);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin: 24px 0 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid rgba(6, 182, 212, .2);
  display: flex;
  align-items: center;
  gap: 6px;
}
body.light-theme .section-title { color: #0891b2; }
.section-title:first-child { margin-top: 0; }

/* ============================================================
 * BOTTONI
 * ============================================================ */
.btn {
  border: none;
  border-radius: var(--r-sm);
  padding: 12px 20px;
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--t-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  letter-spacing: -.01em;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(135deg, #0891b2 0%, #22d3ee 100%);
  color: white;
  box-shadow: 0 4px 16px -3px rgba(6, 182, 212, .5);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 20px -3px rgba(6, 182, 212, .7);
  transform: translateY(-1px);
}
.btn-success {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: white;
  box-shadow: 0 4px 16px -3px rgba(16, 185, 129, .5);
}
.btn-success:hover:not(:disabled) {
  box-shadow: 0 6px 20px -3px rgba(16, 185, 129, .7);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--border-strong);
}
.btn-danger {
  background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
  color: white;
  box-shadow: 0 4px 16px -3px rgba(239, 68, 68, .5);
}
.btn-danger:hover:not(:disabled) {
  box-shadow: 0 6px 20px -3px rgba(239, 68, 68, .7);
  transform: translateY(-1px);
}
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: .78rem; }

/* ============================================================
 * COMM ITEM
 * ============================================================ */
.comm-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  margin-bottom: 10px;
  border: 1px solid var(--border);
  transition: all var(--t-fast);
}
.comm-item:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px -4px var(--accent-glow);
  transform: translateX(2px);
}
.comm-item .info { flex: 1; min-width: 0; }
.comm-item .num {
  font-weight: 700;
  color: var(--accent-light);
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
body.light-theme .comm-item .num { color: #0891b2; }
.comm-item .desc {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-trash {
  background: transparent;
  border: none;
  font-size: 1.05rem;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--danger);
  transition: all var(--t-fast);
}
.btn-trash:hover { background: var(--danger-glow); transform: scale(1.1); }

/* ============================================================
 * TOAST
 * ============================================================ */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1a1f2e;
  color: white;
  padding: 14px 24px;
  border-radius: var(--r);
  font-size: .88rem;
  font-weight: 600;
  opacity: 0;
  transition: all .3s cubic-bezier(.16,1,.3,1);
  pointer-events: none;
  z-index: 200;
  max-width: calc(100% - 40px);
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: linear-gradient(135deg, #059669 0%, #10b981 100%); border-color: rgba(16, 185, 129, .5); }
.toast.err { background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%); border-color: rgba(239, 68, 68, .5); }

/* ============================================================
 * SPINNER
 * ============================================================ */
.spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-kpi {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.loading-kpi .label {
  font-size: .78rem;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: .08em;
}
.spinner-big {
  display: inline-block;
  width: 42px;
  height: 42px;
  border: 3px solid var(--accent-glow);
  border-top-color: var(--accent-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ============================================================
 * EMPTY
 * ============================================================ */
.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 24px;
  font-size: .88rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.empty-icon { font-size: 3rem; opacity: .25; filter: grayscale(1); }

/* ============================================================
 * WRAPPER TAB + PULSANTE EMAIL
 * ============================================================ */
.segmented-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  width: 100%;
}
.segmented-wrapper .segmented { margin-bottom: 0; }

.btn-email-top {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: white;
  border: none;
  border-radius: var(--r);
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 4px 16px -4px rgba(16, 185, 129, .5);
  transition: all var(--t-fast);
  white-space: nowrap;
}
.btn-email-top:hover:not(:disabled) {
  box-shadow: 0 6px 24px -4px rgba(16, 185, 129, .7);
  transform: translateY(-1px);
}
.btn-email-top:disabled { opacity: .55; cursor: not-allowed; }

/* ============================================================
 * MULTI-ADMIN + BADGE
 * ============================================================ */
.admin-principale-only { display: none !important; }
body.is-admin-principale .admin-principale-only { display: inline-flex !important; }

.badge-prop {
  display: inline-block;
  font-size: .68rem;
  font-weight: 700;
  background: rgba(6, 182, 212, .12);
  color: var(--accent-light);
  border: 1px solid rgba(6, 182, 212, .3);
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 6px;
}
body.light-theme .badge-prop {
  background: rgba(8, 145, 178, .1);
  color: #0e7490;
  border-color: rgba(8, 145, 178, .3);
}
.badge-principale {
  display: inline-block;
  font-size: .65rem;
  font-weight: 800;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 6px;
  letter-spacing: .5px;
}
.badge-secondario {
  display: inline-block;
  font-size: .65rem;
  font-weight: 800;
  background: linear-gradient(135deg, #0891b2, #22d3ee);
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 6px;
  letter-spacing: .5px;
}

/* ============================================================
 * LOG ATTIVITÀ
 * ============================================================ */
.log-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
}
.log-item .log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.log-item .log-azione {
  font-weight: 700;
  font-size: .82rem;
  color: var(--accent-light);
  font-family: "SF Mono", Menlo, Consolas, monospace;
}
body.light-theme .log-item .log-azione { color: #0e7490; }
.log-item .log-time {
  font-size: .72rem;
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
}
.log-item .log-body {
  font-size: .78rem;
  color: var(--text);
  line-height: 1.6;
}
.log-item .log-body strong { color: var(--text-muted); margin-right: 4px; }
.log-item .log-dettagli {
  margin-top: 6px;
  padding: 6px 10px;
  background: var(--surface-3);
  border-radius: 6px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: .7rem;
  color: var(--text-muted);
  word-break: break-all;
  max-height: 80px;
  overflow-y: auto;
}

.admin-email-section { display: none; }
body.is-admin-principale .admin-email-section { display: block; }

/* ============================================================
 * LISTA MESI PER EMAIL
 * ============================================================ */
.lista-mesi-email {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mese-email-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--t-fast);
  font-family: inherit;
  font-size: .92rem;
  color: var(--text);
  text-align: left;
  width: 100%;
}
.mese-email-item:hover { border-color: var(--accent); background: var(--surface-3); }
.mese-email-item.selected {
  border-color: var(--accent);
  background: var(--accent-glow);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.mese-email-item .radio-circle {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.mese-email-item.selected .radio-circle {
  border-color: var(--accent);
  background: var(--accent);
}
.mese-email-item.selected .radio-circle::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: white;
}
.mese-email-item .mese-nome {
  flex: 1;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.mese-email-item .badge-corrente {
  font-size: .68rem;
  font-weight: 700;
  background: var(--accent-glow);
  color: var(--accent-light);
  border: 1px solid rgba(6, 182, 212, .3);
  padding: 2px 8px;
  border-radius: 10px;
}
body.light-theme .mese-email-item .badge-corrente {
  background: rgba(8, 145, 178, .1);
  color: #0e7490;
  border-color: rgba(8, 145, 178, .3);
}

/* ============================================================
 * TOOLBAR MOBILE
 * ============================================================ */
.select-mese-wrap { flex: 2 1 auto; min-width: 140px; }
.select-mese { width: 100%; }
.select-periodo { flex: 1 1 auto; min-width: 110px; }

/* ============================================================
 * HAMBURGER MENU
 * ============================================================ */
.btn-hamburger {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  color: #e2e8f0;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
  flex-shrink: 0;
  padding: 0;
}
body.light-theme .btn-hamburger {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #64748b;
}
.btn-hamburger:hover {
  background: rgba(6, 182, 212, .15);
  border-color: rgba(6, 182, 212, .4);
  color: #22d3ee;
}

.menu-mobile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 998;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.menu-mobile-overlay.open { opacity: 1; pointer-events: auto; }

.menu-mobile {
  position: fixed;
  top: 64px;
  right: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  z-index: 999;
  min-width: 220px;
  max-width: calc(100vw - 28px);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
  animation: menuSlideDown .2s cubic-bezier(.16,1,.3,1);
}
.menu-mobile.open { display: flex; }
@keyframes menuSlideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.menu-mobile-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: .88rem;
  font-weight: 600;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: all var(--t-fast);
  white-space: nowrap;
}
.menu-mobile-item:hover,
.menu-mobile-item:active {
  background: var(--surface-2);
  color: var(--accent-light);
}
.menu-mobile-item svg { flex-shrink: 0; opacity: .7; }
.menu-mobile-item:hover svg { opacity: 1; color: var(--accent-light); }
.menu-mobile-item.danger { color: var(--danger); }
.menu-mobile-item.danger:hover { background: var(--danger-glow); color: var(--danger); }
.menu-mobile-item.admin-only,
.menu-mobile-item.admin-principale-only { display: none; }
body.is-admin .menu-mobile-item.admin-only { display: flex; }
body.is-admin-principale .menu-mobile-item.admin-principale-only { display: flex; }

/* ============================================================
 * BADGE MOBILE
 * ============================================================ */
.badge-foglio-mobile { display: none; }

/* ============================================================
 * FOOTER
 * ============================================================ */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 20px 24px;
  margin: 0;
  transition: background .25s, border-color .25s;
}
.footer-content {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 12px 24px;
  font-size: .78rem;
  color: var(--text-muted);
  text-align: center;
}
.footer-item {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--t-fast);
  white-space: nowrap;
}
a.footer-item:hover {
  color: var(--accent-light);
}
body.light-theme a.footer-item:hover {
  color: var(--accent);
}
.footer-icon {
  display: none;
  color: var(--text-muted);
  text-decoration: none;
  transition: all var(--t-fast);
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.footer-icon:hover {
  color: var(--accent-light);
  border-color: var(--accent);
  background: var(--surface-3);
  transform: translateY(-2px);
}
body.light-theme .footer-icon:hover {
  color: var(--accent);
}
@media (min-width: 641px) {
  .footer-text svg {
    color: var(--accent-light);
    opacity: .8;
  }
  a.footer-text:hover svg {
    opacity: 1;
  }
  body.light-theme .footer-text svg {
    color: var(--accent);
  }
}

/* ============================================================
 * RESPONSIVE
 * ============================================================ */
@media (max-width: 640px) {
  header { padding: 14px 16px; }
  .brand-logo { width: 36px; height: 36px; }
  .brand-text h1 { font-size: .9rem; }
  .brand-text p { font-size: .66rem; }
  .badge-foglio { font-size: .66rem; padding: 5px 10px; max-width: 100px; }

  .toolbar { padding: 10px 14px; top: 66px; }
  .toolbar-content {
    display: grid !important;
    grid-template-columns: 1fr auto !important;
    grid-template-areas:
      "mese mese"
      "filtro nuovo" !important;
    gap: 8px !important;
  }
  .select-mese-wrap { 
    grid-area: mese; 
    min-width: 0 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
  }
  .select-mese-wrap .select-mese {
    flex: 1 1 auto;
    min-width: 0;
  }
  .select-periodo { grid-area: filtro; min-width: 0 !important; }
  .toolbar-content > .btn-icon:not(.primary) { display: none !important; }
  .toolbar-content > .btn-icon.primary {
    display: inline-flex !important;
    grid-area: nuovo;
    padding: 10px 16px;
    font-size: .82rem;
    font-weight: 700;
    white-space: nowrap;
  }
  .toolbar-content > .btn-icon.primary svg { display: none; }
  .toolbar-content > .btn-icon.primary::after { content: "Aggiungi ore"; }

  /* Nasconde pulsanti header su mobile */
  body .header-actions > .btn-theme { display: none !important; }
  body .header-actions > .btn-logout { display: none !important; }
  body .header-actions > .btn-install { display: none !important; }
  body .header-actions > .admin-principale-only { display: none !important; }
  body .header-actions > .btn-hamburger { display: inline-flex !important; width: 34px; height: 34px; }
  
  /* Nasconde badge foglio nell'header su mobile */
  .header-actions > .badge-foglio { display: none !important; }
  
  /* Mostra badge foglio mobile */
  .badge-foglio-mobile {
    display: inline-block;
    background: rgba(6, 182, 212, .12);
    border: 1px solid rgba(6, 182, 212, .3);
    color: #67e8f9;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: .72rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
    flex-shrink: 0;
    align-self: center;
  }
  body.light-theme .badge-foglio-mobile {
    background: rgba(8, 145, 178, .1);
    border-color: rgba(8, 145, 178, .3);
    color: #0e7490;
  }

  .container { padding: 16px 14px 0 14px; }

  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 18px;
  }
  .kpi { padding: 14px 12px; }
  .kpi .value { font-size: 1.3rem; }
  .kpi .label { font-size: .6rem; letter-spacing: .05em; }

  .segmented { padding: 4px; gap: 2px; }
  .segment { padding: 8px 14px; font-size: .78rem; }

  .card-header { padding: 14px 16px; }
  .card-header h3 { font-size: .82rem; }
  .card { max-height: calc(100vh - 240px); }

  .modal-overlay { padding: 12px; }
  .modal { max-height: calc(100vh - 24px); margin: 12px auto; border-radius: var(--r-lg); }
  .modal-header { padding: 16px 18px; }
  .modal-body { padding: 18px; }
  .modal-footer { padding: 14px 18px; }

  .toast { bottom: 90px; font-size: .82rem; padding: 12px 20px; }

  .login-box { padding: 32px 24px; }
  .login-logo { width: 64px; height: 64px; }
  .login-box h1 { font-size: 1.4rem; }

  .filtri-extra { top: 122px; padding: 12px 14px; }

  .tabella-riepilogo thead th { padding: 10px 12px; font-size: .64rem; }
  .tabella-riepilogo tbody td { padding: 12px; font-size: .78rem; }

  .btn-email-top span { display: none; }
  .btn-email-top { padding: 10px 12px; }
  .segmented-wrapper { gap: 8px; }
  
  /* Footer mobile: solo icone */
  .site-footer { padding: 14px; margin: 0; }
  .footer-content {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
    font-size: .72rem;
  }
  .footer-text { display: none !important; }
  .footer-icon { display: inline-flex; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}


/* ============================================================
 * MODAL IMPOSTA NOTIFICHE (stili condivisi con pagina)
 * ============================================================ */
.notif-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin-bottom: 20px;
}
.notif-toggle-label {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}
.notif-toggle-sub {
  font-size: .72rem;
  color: var(--text-muted);
}

.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--surface-3);
  border: 1px solid var(--border);
  transition: .25s;
  border-radius: 26px;
}
.switch-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  transition: .25s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.switch input:checked + .switch-slider {
  background: linear-gradient(135deg, #0891b2 0%, #22d3ee 100%);
  border-color: transparent;
}
.switch input:checked + .switch-slider:before {
  transform: translateX(22px);
}

.notif-giorni {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}
.notif-giorno {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 6px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--t-fast);
  user-select: none;
}
.notif-giorno:hover { border-color: var(--accent); }
.notif-giorno input { display: none; }
.notif-giorno span {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}
.notif-giorno input:checked ~ span { color: white; }

.notif-giorno.checked {
  background: linear-gradient(135deg, #0891b2 0%, #22d3ee 100%);
  border-color: transparent;
  box-shadow: 0 4px 12px -3px rgba(6, 182, 212, .5);
}

.notif-preview {
  background: linear-gradient(135deg, var(--surface-2) 0%, var(--surface-3) 100%);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 14px 16px;
  margin-top: 20px;
}
.notif-preview-title {
  font-size: .72rem;
  font-weight: 800;
  color: var(--accent-light);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 8px;
}
.notif-preview-content {
  font-size: .85rem;
  color: var(--text);
  line-height: 1.6;
  font-weight: 500;
}

@media (max-width: 480px) {
  .notif-giorni { grid-template-columns: repeat(4, 1fr); }
}