/* ═══════════════════════════════════════════════════════════════
   FINANZE PERSONALI — Liquid Glass Design System
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg: #eef0f8;
  --glass: rgba(255, 255, 255, 0.62);
  --glass-dark: rgba(255, 255, 255, 0.45);
  --glass-border: rgba(255, 255, 255, 0.88);
  --glass-shadow: 0 8px 32px rgba(99, 102, 241, 0.10), 0 1.5px 8px rgba(0,0,0,0.06);
  --glass-shadow-hover: 0 16px 48px rgba(99, 102, 241, 0.18), 0 2px 12px rgba(0,0,0,0.10);
  --blur: blur(24px);
  --blur-sm: blur(12px);

  --radius: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;

  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-dark: #4f46e5;
  --green: #10b981;
  --green-light: #34d399;
  --red: #ef4444;
  --red-light: #fca5a5;
  --orange: #f59e0b;
  --orange-light: #fcd34d;
  --blue: #3b82f6;
  --purple: #a855f7;

  --text: #1e1b4b;
  --text-muted: #6366f1;
  --text-light: #94a3b8;
  --border: rgba(99, 102, 241, 0.15);

  --sidebar-w: 260px;
  --topbar-h: 64px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ─── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ─── Static Mesh Background ────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 60% at 10% 0%, rgba(139, 92, 246, 0.20) 0%, transparent 60%),
    radial-gradient(ellipse 60% 70% at 90% 20%, rgba(99, 102, 241, 0.16) 0%, transparent 55%),
    radial-gradient(ellipse 70% 50% at 50% 100%, rgba(16, 185, 129, 0.10) 0%, transparent 55%),
    linear-gradient(135deg, #eef0f8 0%, #f0eeff 50%, #edf5f0 100%);
  /* Nessuna animazione — risparmia GPU significativo */
}

/* ─── Layout ────────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-right: 1.5px solid var(--glass-border);
  box-shadow: 4px 0 32px rgba(99, 102, 241, 0.08);
  padding: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

.sidebar-logo-icon svg { color: white; }

.sidebar-logo-text h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.sidebar-logo-text span {
  font-size: 0.72rem;
  color: var(--text-light);
  font-weight: 400;
}

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

.nav-section {
  margin-bottom: 8px;
}

.nav-section-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-light);
  padding: 8px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  margin-bottom: 2px;
  position: relative;
}

.nav-item:hover {
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent);
  transform: translateX(3px);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.10));
  color: var(--accent);
  box-shadow: inset 2px 0 0 var(--accent);
}

.nav-item svg { flex-shrink: 0; opacity: 0.8; }
.nav-item.active svg { opacity: 1; }

.nav-badge {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ef4444;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 5px;
  line-height: 1;
  animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50%       { box-shadow: 0 0 0 5px rgba(239, 68, 68, 0); }
}

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

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  background: var(--glass);
  backdrop-filter: var(--blur-sm);
  -webkit-backdrop-filter: var(--blur-sm);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  gap: 16px;
}

.topbar-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-body {
  flex: 1;
  padding: 28px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* ─── Glass Card ────────────────────────────────────────────── */
.card {
  background: rgba(255, 255, 255, 0.82);
  border: 1.5px solid rgba(255, 255, 255, 0.92);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  transition: box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  /* Niente backdrop-filter: le card usano sfondo solido semi-trasparente */
}

.card:hover {
  box-shadow: var(--glass-shadow-hover);
}

.card-body { padding: 24px; }
.card-header {
  padding: 20px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── KPI Cards ─────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: rgba(255, 255, 255, 0.82);
  border: 1.5px solid rgba(255, 255, 255, 0.92);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--glass-shadow);
  transition: box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: -30px;
  right: -30px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  opacity: 0.12;
  transition: opacity 0.2s;
}

.kpi-card.accent::before { background: var(--accent); }
.kpi-card.green::before  { background: var(--green); }
.kpi-card.red::before    { background: var(--red); }
.kpi-card.orange::before { background: var(--orange); }

.kpi-card:hover {
  transform: translateY(-3px) scale(1.01);
  box-shadow: var(--glass-shadow-hover);
}

.kpi-card:hover::before { opacity: 0.2; }

.kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.kpi-icon.accent { background: rgba(99, 102, 241, 0.15); color: var(--accent); }
.kpi-icon.green  { background: rgba(16, 185, 129, 0.15); color: var(--green); }
.kpi-icon.red    { background: rgba(239, 68, 68, 0.15);  color: var(--red); }
.kpi-icon.orange { background: rgba(245, 158, 11, 0.15); color: var(--orange); }

.kpi-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-light);
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.kpi-value.positivo { color: var(--green); }
.kpi-value.negativo { color: var(--red); }

.kpi-sub {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: 6px;
}

/* ─── Grid Layout ───────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }

/* ─── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.btn-success {
  background: linear-gradient(135deg, var(--green), #059669);
  color: white;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}
.btn-success:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.btn-danger {
  background: linear-gradient(135deg, var(--red), #dc2626);
  color: white;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.70);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent);
  transform: translateY(-1px);
}

.btn-sm { padding: 6px 12px; font-size: 0.8rem; border-radius: 8px; }
.btn-icon { padding: 8px; border-radius: 10px; }

/* ─── Form Controls ─────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-control, .form-select {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.75);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
  background: rgba(255, 255, 255, 0.8);
}

.form-control::placeholder { color: var(--text-light); }
.form-select { cursor: pointer; }

.input-group {
  display: flex;
  gap: 0;
}

.input-group-text {
  padding: 10px 14px;
  background: rgba(99, 102, 241, 0.1);
  border: 1.5px solid var(--border);
  border-right: none;
  border-radius: 12px 0 0 12px;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
}

.input-group .form-control {
  border-radius: 0 12px 12px 0;
}

textarea.form-control { resize: vertical; min-height: 80px; }

/* ─── Tables ────────────────────────────────────────────────── */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-light);
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid rgba(99, 102, 241, 0.06);
  transition: background 0.15s;
}

tbody tr:hover { background: rgba(99, 102, 241, 0.04); }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 13px 16px;
  font-size: 0.875rem;
  color: var(--text);
  vertical-align: middle;
}

/* ─── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-entrata { background: rgba(16, 185, 129, 0.15); color: var(--green); }
.badge-uscita  { background: rgba(239, 68, 68, 0.15);  color: var(--red); }
.badge-info    { background: rgba(99, 102, 241, 0.15); color: var(--accent); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--orange); }
.badge-muted   { background: rgba(148, 163, 184, 0.2); color: var(--text-light); }

/* ─── Alerts ────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 12px;
}

.alert-success {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #065f46;
}

.alert-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #7f1d1d;
}

.alert-warning {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #78350f;
}

.alert-info {
  background: rgba(99, 102, 241, 0.10);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: #312e81;
}

/* ─── Flash messages ────────────────────────────────────────── */
.flash-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
}

.flash {
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.flash-success {
  background: rgba(16, 185, 129, 0.9);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
}

.flash-error {
  background: rgba(239, 68, 68, 0.9);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
}

.flash-warning {
  background: rgba(245, 158, 11, 0.9);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
}

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

/* ─── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 27, 75, 0.4);
  backdrop-filter: blur(6px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1.5px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 80px rgba(99, 102, 241, 0.25);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: 24px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  padding: 6px;
  border-radius: 8px;
  transition: all 0.15s;
  display: flex;
}

.modal-close:hover { background: rgba(239, 68, 68, 0.1); color: var(--red); }

.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 0 24px 24px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ─── Categoria dot ─────────────────────────────────────────── */
.cat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 600;
}

/* ─── Progress bar ──────────────────────────────────────────── */
.progress {
  height: 8px;
  background: rgba(99, 102, 241, 0.1);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-bar.green  { background: linear-gradient(90deg, var(--green), var(--green-light)); }
.progress-bar.orange { background: linear-gradient(90deg, var(--orange), var(--orange-light)); }
.progress-bar.red    { background: linear-gradient(90deg, var(--red), var(--red-light)); }
.progress-bar.accent { background: linear-gradient(90deg, var(--accent), var(--accent-light)); }

/* ─── Section header ────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
}

.section-subtitle {
  font-size: 0.83rem;
  color: var(--text-light);
  margin-top: 2px;
}

/* ─── Empty state ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-light);
}

.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

/* ─── Filters bar ───────────────────────────────────────────── */
.filters-bar {
  background: rgba(255, 255, 255, 0.70);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 20px;
}

.filters-bar .form-group { margin-bottom: 0; }
.filters-bar .form-label { font-size: 0.75rem; }
.filters-bar .form-control,
.filters-bar .form-select { padding: 8px 12px; font-size: 0.85rem; }

/* ─── Abbonamento card ──────────────────────────────────────── */
.abb-card {
  background: rgba(255, 255, 255, 0.82);
  border: 1.5px solid rgba(255, 255, 255, 0.92);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--glass-shadow);
}

.abb-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--glass-shadow-hover);
}

.abb-card.inattivo { opacity: 0.5; }

.abb-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.4rem;
}

.abb-info { flex: 1; min-width: 0; }
.abb-nome { font-weight: 700; font-size: 0.95rem; }
.abb-dettagli { font-size: 0.8rem; color: var(--text-light); margin-top: 2px; }
.abb-importo { font-size: 1.1rem; font-weight: 800; color: var(--red); white-space: nowrap; }

/* ─── Budget bar row ────────────────────────────────────────── */
.budget-row {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.budget-row:last-child { border-bottom: none; }

.budget-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.budget-row-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}

.budget-amounts {
  font-size: 0.82rem;
  color: var(--text-light);
}

/* ─── Pagination ────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  margin-top: 20px;
}

.pagination a, .pagination span {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s;
}

.pagination a {
  background: var(--glass-dark);
  color: var(--text);
  border: 1px solid var(--border);
}
.pagination a:hover { background: rgba(99,102,241,0.12); color: var(--accent); }
.pagination span.current { background: var(--accent); color: white; }

/* ─── Color picker ──────────────────────────────────────────── */
.color-swatch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.color-option {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  border: 2.5px solid transparent;
  transition: all 0.15s;
}

.color-option:hover,
.color-option.selected { border-color: var(--text); transform: scale(1.15); }

/* ─── Tipo toggles ──────────────────────────────────────────── */
.tipo-toggle {
  display: flex;
  background: rgba(99,102,241,0.07);
  border-radius: 12px;
  padding: 3px;
  gap: 2px;
}

.tipo-toggle label {
  flex: 1;
  text-align: center;
  padding: 7px 12px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  transition: all 0.2s;
  user-select: none;
}

.tipo-toggle input[type=radio] { display: none; }

.tipo-toggle input[type=radio]:checked + label.entrata {
  background: var(--green);
  color: white;
  box-shadow: 0 2px 8px rgba(16,185,129,0.3);
}

.tipo-toggle input[type=radio]:checked + label.uscita {
  background: var(--red);
  color: white;
  box-shadow: 0 2px 8px rgba(239,68,68,0.3);
}

/* ─── Icon / Emoji Picker inline ───────────────────────────── */
.icon-picker-panel {
  margin-top: 8px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,0.97);
  box-shadow: 0 8px 24px rgba(99,102,241,0.12);
  overflow: hidden;
}

.icon-picker-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: rgba(99,102,241,0.04);
}

.icon-tab {
  flex: 1;
  padding: 9px;
  font-size: 0.82rem;
  font-weight: 600;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-light);
  transition: all 0.15s;
}

.icon-tab.active {
  color: var(--accent);
  background: white;
  box-shadow: inset 0 -2px 0 var(--accent);
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 8px;
  max-height: 180px;
  overflow-y: auto;
}

.icon-grid-item {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  transition: background 0.12s;
}

.icon-grid-item:hover { background: rgba(99,102,241,0.1); }
.icon-grid-item.selected { background: rgba(99,102,241,0.18); }

.icon-preview-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: rgba(255,255,255,0.75);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  transition: all 0.15s;
}

.icon-preview-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ─── Import preview table ──────────────────────────────────── */
.preview-row-entrata { border-left: 3px solid var(--green); }
.preview-row-uscita  { border-left: 3px solid var(--red); }

/* ─── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.25); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(99,102,241,0.45); }

/* ─── Utilities ─────────────────────────────────────────────── */
.text-green  { color: var(--green) !important; }
.text-red    { color: var(--red) !important; }
.text-orange { color: var(--orange) !important; }
.text-accent { color: var(--accent) !important; }
.text-muted  { color: var(--text-light) !important; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.fw-bold { font-weight: 700; }
.fw-800  { font-weight: 800; }
.fs-sm   { font-size: 0.82rem; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.flex-1 { flex: 1; }

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .page-body { padding: 16px; }
  #hamburger { display: flex !important; }
}

@media (max-width: 768px) {
  /* Niente sidebar su mobile */
  .sidebar { display: none !important; }
  #hamburger { display: none !important; }
  /* Nascondi azioni topbar (pulsanti pagina) — solo titolo e user */
  .topbar-actions { display: none !important; }
  /* Finny full-screen */
  .topbar { padding: 10px 14px; }
  .topbar-title { font-size: 1rem; }
  .page-body { padding: 8px; }
}

@media (max-width: 500px) {
  .kpi-grid { grid-template-columns: 1fr; }
}
