/* ── Variables ─────────────────────────────────── */
:root {
  --primary: #8b5cf6;
  --primary-light: #a78bfa;
  --primary-dark: #7c3aed;
  --income: #10b981;
  --income-light: #d1fae5;
  --expense: #ef4444;
  --expense-light: #fee2e2;
  --savings: #6366f1;
  --savings-light: #e0e7ff;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --cushion: #c084fc;
  --cushion-light: #f3e8ff;

  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-input: #ffffff;
  --bg-section: #f1f5f9;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 2px 8px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.08), 0 8px 32px rgba(0,0,0,0.1), 0 16px 64px rgba(0,0,0,0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --sidebar-width: 220px;
  --topbar-height: 64px;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-sidebar: #1e293b;
  --bg-input: #334155;
  --bg-section: #1e293b;
  --border: #334155;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --shadow: 0 1px 2px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.6), 0 8px 32px rgba(0,0,0,0.5), 0 16px 64px rgba(0,0,0,0.4);
}

/* ── Reset ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; cursor: pointer; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: 2px solid var(--primary); outline-offset: 2px; box-shadow: 0 0 0 4px rgba(13,148,136,0.1); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ── Sidebar ───────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  left: 0; top: 0;
  background: linear-gradient(180deg, #4c1d95 0%, #3b1a63 25%, #2d1549 50%, #1f1333 75%, #1a0d2e 100%);
  border-right: 1px solid rgba(139, 92, 246, 0.3);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s;
}
[data-theme="dark"] .sidebar {
  background: linear-gradient(180deg, #1e293b 0%, #1a202c 50%, #0f172a 100%);
  border-right: 1px solid var(--border);
}
.sidebar-header {
  padding: 4px;
  margin: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #a855f7 0%, #8b5cf6 50%, #7c3aed 100%);
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4);
}
.sidebar-logo {
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: contain;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 16px 12px; display: flex; flex-direction: column; gap: 6px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-item:hover { background: rgba(139, 92, 246, 0.2); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-icon { font-size: 18px; width: 24px; text-align: center; }
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}

/* ── Main ──────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  height: var(--topbar-height);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar #sidebarToggle { display: none; }
.page-title { font-size: 20px; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.content { padding: 24px; flex: 1; max-width: 1200px; }

/* ── Cards ─────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.card-title { font-size: 16px; font-weight: 600; }

/* ── Stats Grid ────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat-card .stat-label { font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); margin-bottom: 8px; }
.stat-card .stat-value { font-size: 32px; font-weight: 800; line-height: 1.2; letter-spacing: -0.02em; margin: 8px 0 4px; }
.stat-card .stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-value.income { color: var(--income); }
.stat-value.expense { color: var(--expense); }
.stat-value.savings { color: var(--savings); }
.stat-value.primary { color: var(--primary); }

/* ── Buttons ───────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(13,148,136,0.2); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(13,148,136,0.3); transform: translateY(-1px); }
.btn-secondary { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-section); border-color: var(--text-secondary); }
.btn-danger { background: var(--expense); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-xs { padding: 4px 8px; font-size: 12px; }
.btn-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 18px;
  transition: background 0.15s;
}
.btn-icon:hover { background: var(--bg); }
.btn-icon-sm { width: 28px; height: 28px; font-size: 14px; }

/* ── Tables ────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); text-align: left; padding: 10px 12px; border-bottom: 2px solid var(--border); }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
tr:hover td { background: var(--bg-section); transition: background 0.15s ease; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.amount-income { color: var(--income); font-weight: 600; }
.amount-expense { color: var(--expense); font-weight: 600; }

/* ── Forms ─────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.form-actions-right { display: flex; gap: 8px; margin-left: auto; }

/* ── Badge ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.badge-income { background: var(--income-light); color: #065f46; }
.badge-expense { background: var(--expense-light); color: #991b1b; }
.badge-savings { background: var(--savings-light); color: #3730a3; }
.badge-default { background: var(--bg); color: var(--text-muted); }

/* ── Progress bar ──────────────────────────────── */
.progress-bar {
  height: 10px;
  background: var(--bg-section);
  border-radius: var(--radius-xs);
  overflow: hidden;
  margin-top: 10px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}
.progress-bar-lg { height: 16px; }
.progress-fill {
  height: 100%;
  border-radius: var(--radius-xs);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.progress-fill.green { background: var(--income); }
.progress-fill.red { background: var(--expense); }
.progress-fill.yellow { background: var(--warning); }
.progress-fill.purple { background: var(--savings); }

/* ── Modal ─────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.2s;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-body { padding: 24px; }

/* ── Toast ─────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  transform: translateX(calc(100% + 20px));
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.toast.show { transform: translateX(0); }
.toast-success { border-left: 4px solid var(--income); }
.toast-error { border-left: 4px solid var(--expense); }
.toast-info { border-left: 4px solid var(--primary); }

/* ── Tab System ────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}
.tab {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Filters bar ───────────────────────────────── */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
  align-items: center;
}
.filters-bar input, .filters-bar select { width: auto; min-width: 140px; }

/* ── Pagination ────────────────────────────────── */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
}
.pagination button {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--bg-card);
}
.pagination button:hover:not(:disabled) { background: var(--bg); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination-info { font-size: 13px; color: var(--text-secondary); }

/* ── Empty state ───────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; margin-bottom: 16px; }

/* ── Color indicator ───────────────────────────── */
.color-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

/* ── Toggle switch ─────────────────────────────── */
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  cursor: pointer;
  transition: 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── Theme toggle ──────────────────────────────── */
.theme-toggle { font-size: 20px; }

/* ══════════════════════════════════════════════════
   PAGINA MESE — Sezioni piano mensile
   ══════════════════════════════════════════════════ */

/* Month selector topbar */
.month-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}
.month-selector input[type="month"] {
  width: auto;
  padding: 8px 12px;
  font-size: 14px;
}

/* Section header */
.section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.section-title {
  font-size: 15px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}
.section-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 12px 0;
  border-top: 2px solid var(--border);
  margin-top: 8px;
  font-weight: 600;
  font-size: 14px;
}

/* Inline editable table */
.plan-table { width: 100%; border-collapse: collapse; table-layout: auto; }
.plan-table th {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  background: var(--bg-section);
}
.plan-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}
.plan-table tr:last-child td { border-bottom: none; }
.plan-table .col-name { min-width: 0; }
.plan-table .col-amount { width: 100px; text-align: right; white-space: nowrap; }
.plan-table .col-category { width: 140px; }
.plan-table .col-method { width: 120px; }
.plan-table .col-actions { width: 36px; text-align: center; }

/* Inline editing */
.editable-cell {
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background 0.15s;
  min-height: 28px;
  display: flex;
  align-items: center;
}
.editable-cell:hover { background: var(--bg-section); }
.editable-cell.editing {
  padding: 0;
  background: none;
}
.editable-cell input,
.editable-cell select {
  padding: 4px 6px;
  font-size: 14px;
  border-radius: 4px;
  width: 100%;
}
.editable-cell input[type="number"] { text-align: right; }

.row-add-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  font-size: 13px;
  color: var(--primary);
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s;
  margin-top: 4px;
}
.row-add-btn:hover { background: var(--bg-section); }

.delete-row-btn {
  opacity: 0;
  transition: opacity 0.15s;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px;
}
.plan-table tr:hover .delete-row-btn { opacity: 1; }
.allocation-line:hover .delete-row-btn { opacity: 1; }
.delete-row-btn:hover { color: var(--expense); }

/* ── Net Summary (Riepilogo Netto) ────────────── */
.net-summary {
  background: var(--bg-card);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}
.net-summary-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: start;
}
.net-lines { flex: 1; }
.net-line {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 15px;
}
.net-line.total {
  border-top: 2px solid var(--border);
  margin-top: 8px;
  padding-top: 12px;
  font-weight: 700;
  font-size: 18px;
}
.net-line.highlight {
  background: var(--cushion-light);
  margin: 8px -12px 0;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 18px;
  color: var(--cushion);
}
[data-theme="dark"] .net-line.highlight {
  background: rgba(139,92,246,0.15);
}
.net-line .label { color: var(--text-secondary); }
.net-line .value { font-weight: 600; font-variant-numeric: tabular-nums; }
.net-line .value.positive { color: var(--income); }
.net-line .value.negative { color: var(--expense); }

.allocation-line {
  display: flex;
  justify-content: space-between;
  padding: 4px 12px;
  font-size: 14px;
  color: var(--text-secondary);
}
.allocation-line .value { font-weight: 500; }

.net-chart { width: 200px; height: 200px; }

/* ── Weekly Tracker ────────────────────────────── */
.weeks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.week-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.week-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.week-spent {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 2px;
}
.week-remaining {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.week-bar {
  height: 6px;
  background: var(--bg-section);
  border-radius: 3px;
  overflow: hidden;
}
.week-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}
.week-spent-input {
  width: 80px;
  text-align: center;
  padding: 4px 8px;
  font-size: 16px;
  font-weight: 600;
  margin: 0 auto 4px;
  display: block;
}

/* ── Account Totals (Metodo Pagamento) ─────────── */
.account-totals-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.account-total-card {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  padding: 16px 24px;
  min-width: 200px;
}
.account-total-label { font-size: 13px; opacity: 0.85; }
.account-total-value { font-size: 24px; font-weight: 700; margin-top: 4px; }

/* ══════════════════════════════════════════════════
   PAGINA OBIETTIVI
   ══════════════════════════════════════════════════ */
.goals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.goal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.goal-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.goal-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.goal-name { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.goal-amounts { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 4px; }
.goal-meta { font-size: 13px; color: var(--text-muted); margin-top: 8px; display: flex; gap: 12px; }

/* Timeline mensile obiettivo */
.goal-timeline {
  display: flex;
  gap: 0;
  overflow-x: auto;
  padding: 8px 0;
  margin-top: 12px;
}
.timeline-cell {
  min-width: 60px;
  text-align: center;
  padding: 8px 4px;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}
.timeline-cell:last-child { border-right: none; }
.timeline-month { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.timeline-amount { font-size: 13px; font-weight: 600; margin-top: 4px; }
.timeline-amount.planned { color: var(--text-secondary); }
.timeline-amount.actual { color: var(--income); }

/* ══════════════════════════════════════════════════
   PAGINA ANALISI
   ══════════════════════════════════════════════════ */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.chart-container { position: relative; height: 300px; }

/* ══════════════════════════════════════════════════
   PAGINA IMPOSTAZIONI
   ══════════════════════════════════════════════════ */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.categories-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.category-list { display: flex; flex-direction: column; }
.category-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.category-item:hover { background: var(--bg); }
.category-left { display: flex; align-items: center; gap: 8px; }

/* Account cards */
.account-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.account-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.account-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.account-icon { font-size: 28px; }
.account-name { font-size: 16px; font-weight: 600; }
.account-type { font-size: 12px; color: var(--text-muted); text-transform: uppercase; }
.account-balance { font-size: 24px; font-weight: 700; }
.account-balance.positive { color: var(--income); }
.account-balance.negative { color: var(--expense); }

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.upload-zone:hover { border-color: var(--primary); background: rgba(13,148,136,0.04); }
.upload-zone.dragover { border-color: var(--primary); background: rgba(13,148,136,0.08); }
.upload-zone .upload-icon { font-size: 48px; margin-bottom: 12px; }
.upload-zone p { color: var(--text-secondary); }

/* ── Setup dialog (primo avvio mese) ──────────── */
.setup-dialog {
  text-align: center;
  padding: 40px;
}
.setup-dialog h2 { margin-bottom: 8px; }
.setup-dialog p { color: var(--text-secondary); margin-bottom: 24px; }
.setup-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 400px;
  margin: 0 auto;
}
.setup-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}
.setup-option:hover { border-color: var(--primary); background: rgba(13,148,136,0.04); }
.setup-option-icon { font-size: 24px; }
.setup-option-text h3 { font-size: 15px; font-weight: 600; }
.setup-option-text p { font-size: 13px; color: var(--text-muted); margin: 0; }

/* ── Utilities ────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-income { color: var(--income); }
.text-expense { color: var(--expense); }
.clickable { cursor: pointer; }
.loading { text-align: center; padding: 40px; color: var(--text-muted); }
.mb-16 { margin-bottom: 16px; }
.mt-16 { margin-top: 16px; }
.empty-text { color: var(--text-muted); font-size: 14px; }

/* dashboard grid for recent tx / top expenses */
.top-expenses-list, .recent-tx-list { display: flex; flex-direction: column; }
.top-expense-item, .recent-tx-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.top-expense-item:last-child, .recent-tx-item:last-child { border-bottom: none; }
.recent-tx-left { display: flex; align-items: center; gap: 12px; }
.recent-tx-icon { font-size: 24px; }
.recent-tx-desc { font-weight: 500; }
.recent-tx-meta { font-size: 12px; color: var(--text-muted); }
.recent-tx-amount { font-weight: 600; }
.recent-tx-amount.income { color: var(--income); }
.recent-tx-amount.expense { color: var(--expense); }
.top-expense-amount.expense { color: var(--expense); font-weight: 600; }

/* ── Animations ────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(100px); } to { opacity: 1; transform: translateX(0); } }

/* ── Responsive ────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex !important; }
  .sidebar-overlay.active { display: block; }
  .main { margin-left: 0; }
  .topbar #sidebarToggle { display: flex; }
  .content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .categories-columns { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .filters-bar { flex-direction: column; align-items: stretch; }
  .filters-bar input, .filters-bar select { width: 100%; }
  .net-summary-grid { grid-template-columns: 1fr; }
  .net-chart { width: 100%; margin-top: 16px; }
  .weeks-grid { grid-template-columns: repeat(2, 1fr); }
  .goals-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .weeks-grid { grid-template-columns: 1fr; }
}

/* ── Allocazioni editabili ─────────────────────── */
.allocation-line { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.allocation-line .editable-alloc { cursor: pointer; border-bottom: 1px dashed transparent; transition: border-color 0.2s; }
.allocation-line .editable-alloc:hover { border-bottom-color: var(--text-muted); }
.allocation-line .value { margin-left: auto; font-variant-numeric: tabular-nums; }
.allocation-line .delete-row-btn { flex-shrink: 0; }

/* ── Sezione delete button ─────────────────────── */
.delete-section-btn { opacity: 0.4; font-size: 14px; }
.delete-section-btn:hover { opacity: 1; color: var(--expense); }

/* ══════════════════════════════════════════════════════
   UI/UX ENHANCEMENTS - Modifications 4-15
   ══════════════════════════════════════════════════════ */

/* 4. Net Summary - More presence */
.net-summary {
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(13,148,136,0.03) 100%);
  border: 2px solid var(--primary);
  padding: 32px !important;
  margin-bottom: 24px !important;
  box-shadow: var(--shadow-lg) !important;
}
.net-line.total {
  margin-top: 12px !important;
  padding-top: 16px !important;
  font-size: 20px !important;
}
.net-line.highlight {
  margin: 12px -16px 0 !important;
  padding: 16px 20px !important;
  font-size: 20px !important;
  box-shadow: 0 2px 8px rgba(139,92,246,0.15) !important;
}

/* 6. Border radius consistency */
.badge { border-radius: 100px !important; }
.toggle-slider { border-radius: 100px !important; }
.week-bar { border-radius: var(--radius-xs) !important; }

/* 12. Modal improvements */
.modal-overlay {
  background: rgba(0,0,0,0.6) !important;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal {
  max-width: 600px !important;
  animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}
.modal-header {
  padding: 24px !important;
  background: var(--bg-section) !important;
}
.modal-header h3 {
  font-size: 20px !important;
  font-weight: 700 !important;
}

/* 13. Week cards consistency */
.week-card {
  padding: 20px !important;
  transition: transform 0.2s, box-shadow 0.2s !important;
  box-shadow: var(--shadow) !important;
}
.week-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg) !important;
}
.week-label {
  font-size: 12px !important;
  font-weight: 700 !important;
  letter-spacing: 0.05em;
  margin-bottom: 12px !important;
}
.week-spent {
  font-size: 24px !important;
  font-weight: 800 !important;
  margin-bottom: 4px !important;
  line-height: 1.2;
}

/* 14. Account total cards with gradient */
.account-total-card {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
  padding: 20px 24px !important;
  min-width: 220px !important;
  box-shadow: 0 4px 16px rgba(13,148,136,0.25) !important;
  transition: transform 0.2s, box-shadow 0.2s !important;
}
.account-total-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(13,148,136,0.35) !important;
}
.account-total-label {
  font-weight: 500 !important;
  opacity: 0.9 !important;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.account-total-value {
  font-size: 28px !important;
  font-weight: 800 !important;
  margin-top: 8px !important;
}

/* 15. Empty states */
.empty-state {
  padding: 64px 24px !important;
  background: var(--bg-section) !important;
  margin: 16px 0;
}
.empty-state .empty-icon {
  font-size: 64px !important;
  margin-bottom: 16px !important;
  opacity: 0.5;
  filter: grayscale(0.3);
}
.empty-state p {
  font-size: 16px !important;
  font-weight: 500 !important;
  margin-bottom: 20px !important;
  line-height: 1.5;
}

/* 3. Enhanced hover states */
.goal-card, .account-card {
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.2s !important;
}
.goal-card:hover, .account-card:hover {
  transform: translateY(-4px) !important;
  box-shadow: var(--shadow-lg) !important;
  border-color: var(--primary) !important;
}

/* Animation keyframe update */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(40px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ══════════════════════════════════════════════════════
   SPLASH SCREEN
   ══════════════════════════════════════════════════════ */
.splash-screen {
  position: fixed;
  inset: 0;
  background: #1a0d2e;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: splashFadeOut 0.8s ease 2s forwards;
  pointer-events: none;
}

.splash-content {
  animation: splashSlideUp 0.6s ease-out;
}

.splash-logo {
  max-width: min(70vw, 500px);
  height: auto;
  animation: splashPulse 2s ease-in-out infinite;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

@keyframes splashFadeOut {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

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

@keyframes splashPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

/* Mobile splash adjustments */
@media (max-width: 768px) {
  .splash-logo {
    max-width: min(75vw, 350px);
  }
}

/* ── Login Screen ──────────────────────────────── */
#loginOverlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 2.5rem;
  width: min(90vw, 380px);
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.login-card h2 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}

.login-card p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.login-card input[type="text"],
.login-card input[type="password"] {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 1rem;
  box-sizing: border-box;
}

.login-card button {
  width: 100%;
  padding: 0.75rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.login-card button:hover {
  background: var(--primary-dark);
}

body.login-active .app-layout {
  filter: blur(8px);
  pointer-events: none;
}

/* ── Piano date bar ──────────────────────────────── */
.plan-dates-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  margin-bottom: 12px;
  background: var(--card-bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  flex-wrap: wrap;
}
.plan-dates-label {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}
.plan-date-input {
  width: 140px !important;
  padding: 4px 8px !important;
  font-size: 13px !important;
}
.plan-dates-arrow {
  color: var(--text-muted);
  font-size: 16px;
}
.plan-dates-info {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 4px;
}

/* ── Colonna data items ──────────────────────────── */
.col-date {
  width: 60px;
  text-align: center;
}

/* -- Plan table responsive -- */
@media (max-width: 600px) {
  .plan-table .col-category,
  .plan-table .col-method { display: none; }
  .plan-table th.col-category,
  .plan-table th.col-method { display: none; }
  .plan-table .col-amount { width: 80px; }
  .plan-table .col-date { width: 50px; }
  .plan-table th, .plan-table td { padding: 8px 6px; font-size: 13px; }
}
