/* ============================================================
   KAKEBO — style.css  (unico file CSS dell'app)
   Mobile-first · Bootstrap 5 · Inter font
   ============================================================
   INDICE
   ──────────────────────────────────────────────────────────
   1.  CSS Variables (Design tokens)
   2.  Reset & Base
   3.  Loading overlay
   4.  Alert / Message overlays
   5.  Layout wrapper
   6.  Sidebar (desktop)
   7.  Content wrapper
   8.  Topbar desktop
   9.  Topbar mobile
   10. Bottom Navigation (mobile)
   11. Cards
   12. Stats cards
   13. Month navigation
   14. Stats bar
   15. Toggle buttons Entrate/Uscite
   16. Tipo-toggle (Entrata/Uscita input)
   17. Movement list
   18. FAB (Floating Action Button)
   19. Buttons
   20. Forms
   21. Category chips
   22. Categoria list
   23. Causali list
   24. Login page
   25. Search bar
   26. Dropdown
   27. Text colors
   28. Modals
   29. Table
   30. Charts
   31. Elenco statistiche
   32. Container spacing
   33. Badge valuta
   34. Movimenti ricorrenti
   35. Empty state
   36. Utility
   37. Select2 override
   38. Autocomplete (jQuery UI)
   39. Responsive breakpoints
   40. PWA safe areas
   ──────────────────────────────────────────────────────────
*/

:root {
  --primary: #4361ee;
  --primary-dark: #2d46c4;
  --primary-light: #eef0fd;
  --accent: #7209b7;
  --income: #06d6a0;
  --income-bg: #e8faf5;
  --expense: #ef233c;
  --expense-bg: #fde8eb;
  --neutral: #8b8fa8;
  --bg: #f4f6ff;
  --surface: #ffffff;
  --surface-2: #f8f9ff;
  --border: #e8eaf6;
  --text: #1e2235;
  --text-muted: #8b8fa8;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow-sm: 0 2px 8px rgba(67,97,238,.08);
  --shadow: 0 4px 20px rgba(67,97,238,.12);
  --shadow-lg: 0 8px 32px rgba(67,97,238,.18);
  --nav-height: 64px;
  --topbar-height: 60px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: .2s ease;
}

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

html {
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;  /* previene scroll orizzontale su tutta l'app */
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ── Loading overlay ─────────────────────────────────────── */
.loading {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(4px);
  display: none;
  place-items: center;
  display: none;
}
.loading.show { display: grid; }
.loading-spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Alert/Message overlays ──────────────────────────────── */
.alert-avviso,
.msg-avviso {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(30,34,53,.5);
  backdrop-filter: blur(4px);
  padding: 16px;
}
.alert-avviso.show,
.msg-avviso.show { display: flex; }

.alert-avviso .container,
.msg-avviso .container {
  width: 100%;
  max-width: 480px;
}

.alert-avviso .content,
.msg-avviso .content {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  animation: slideUp .25s ease;
}

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

.txt-content { margin-bottom: 16px; font-size: 15px; color: var(--text); }

/* ── Layout: Wrapper ─────────────────────────────────────── */
#wrapper {
  display: flex;
  min-height: 100vh;
}

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

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}

.sidebar-brand img { width: 34px; height: 34px; }

.sidebar-brand-text {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -.4px;
}

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

.sidebar-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 8px 16px;
}

.sidebar .nav-item { list-style: none; }

.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14px;
  border-radius: 0;
  transition: all var(--transition);
  position: relative;
  text-decoration: none;
}

.sidebar .nav-link:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.sidebar .nav-item.active .nav-link {
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 600;
}

.sidebar .nav-item.active .nav-link::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

.sidebar .nav-link i {
  width: 20px;
  text-align: center;
  font-size: 16px;
}

.collapse-inner {
  padding: 4px 0 4px 52px;
}

.collapse-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-xs);
  transition: all var(--transition);
  text-decoration: none;
}

.collapse-item:hover { color: var(--primary); background: var(--primary-light); }

/* ── Content Wrapper ─────────────────────────────────────── */
#content-wrapper {
  flex: 1;
  min-width: 0;          /* blocca l'espansione flex quando i figli overflow */
  margin-left: 240px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.content {
  flex: 1;
  min-width: 0;          /* permette al figlio di restringersi in un flex column */
  padding: 0 0 100px;
}

/* ── Topbar (desktop) ────────────────────────────────────── */
.topbar-desktop {
  position: sticky;
  top: 0;
  z-index: 99;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--topbar-height);
  display: flex;
  flex-wrap: nowrap;       /* evita che i flex-item vadano a capo */
  align-items: center;
  padding: 0 24px;
  box-shadow: var(--shadow-sm);
}

/* forza i dropdown della topbar in position:absolute
   (Bootstrap senza navbar-expand-* li lascia static) */
.topbar-desktop .dropdown-menu { position: absolute; }

.topbar-desktop .navbar-nav {
  margin-left: auto;
  flex-shrink: 0;          /* impedisce alla navbar-nav di restringersi */
}

.topbar-desktop .nav-link {
  color: var(--text-muted);
  padding: 8px 10px;
  font-size: 16px;
  border-radius: var(--radius-xs);
  transition: all var(--transition);
}

.topbar-desktop .nav-link:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.img-profile {
  width: 36px; height: 36px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  background-color: var(--primary-light);
  border: 2px solid var(--border);
}

.badge-counter {
  position: absolute;
  top: 4px; right: 4px;
  min-width: 18px; height: 18px;
  font-size: 10px;
  padding: 0 4px;
  line-height: 18px;
  border-radius: 9px;
  background: var(--expense);
  color: #fff;
  font-weight: 700;
}

.saldo-container {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.saldo-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: .8px;
  text-transform: uppercase;
}

.saldo-valore {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.4px;
}

/* ── Mobile Topbar ───────────────────────────────────────── */
.topbar-mobile {
  position: sticky;
  top: 0;
  z-index: 99;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  box-shadow: var(--shadow-sm);
}

.topbar-mobile {
  flex-wrap: nowrap;   /* titolo non va a capo quando si apre il dropdown */
}
.topbar-mobile .dropdown-menu { position: absolute; }  /* stesso fix del desktop */
.topbar-mobile .navbar-nav {
  margin-left: auto;
  flex-shrink: 0;
}

/* Mese floating nella topbar mobile — visibile solo via JS */
.topbar-month-pill {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: .01em;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease;
  white-space: nowrap;
}
.topbar-month-pill.visible { opacity: 1; }

.topbar-mobile .nav-link {
  color: var(--text-muted);
  padding: 8px;
  font-size: 18px;
}

.btn-back {
  margin-right: 8px;
}

.btn-back a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  transition: all var(--transition);
}

.btn-back a:hover { background: var(--border); }

/* ── Bottom Navigation (mobile) ──────────────────────────── */
.navbar-mobile {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 200;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(67,97,238,.08);
  padding: 0;
  justify-content: space-around;
  align-items: stretch;
  height: var(--nav-height);
  padding-bottom: env(safe-area-inset-bottom);
}

.navbar-mobile .item {
  flex: 1;
  display: flex;
}

.navbar-mobile .item a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 20px;
  gap: 3px;
  transition: all var(--transition);
  padding: 8px 0;
  position: relative;
}

.navbar-mobile .item.active a {
  color: var(--primary);
}

.navbar-mobile .item.active a::after {
  content: '';
  position: absolute;
  top: 0; left: 25%; right: 25%;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 4px 4px;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 0;
  overflow: hidden;
}

.card-body { padding: 20px; }
.card-header {
  padding: 16px 20px;
  background: transparent;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

/* ── Stats Cards ─────────────────────────────────────────── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.stat-card .label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 4px;
}

.stat-card .value {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.4px;
}

/* ── Month Navigation ────────────────────────────────────── */
.scroll-months-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px 0;
}

.scroll-months-controls .month-year {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  min-width: 160px;
  text-align: center;
  letter-spacing: -.2px;
}

.scroll-months-controls .arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.scroll-months-controls .arrow:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: var(--shadow);
}

/* ── Stats Bar ───────────────────────────────────────────── */
.statistiche {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.statistiche .label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
}

.statistiche-entrate { font-size: 18px; font-weight: 800; color: var(--income) !important; }
.statistiche-uscite  { font-size: 18px; font-weight: 800; color: var(--expense) !important; }
.statistiche-media-giorno { font-size: 18px; font-weight: 800; }

/* ── Toggle buttons (Entrate/Uscite) ────────────────────── */
.btn-toogle {
  padding: 14px 8px;
  cursor: pointer;
  transition: all var(--transition);
  background: transparent;
}

.btn-toogle:first-child { border-right: 1px solid var(--border); }

.btn-toogle-selected {
  background: var(--bg);
}

/* ── Movement List ───────────────────────────────────────── */
.movement-day-group {
  margin-bottom: 8px;
}

.movement-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.movement-day-total {
  font-size: 13px;
  font-weight: 700;
}

.movement-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
  text-decoration: none;
  color: var(--text);
}

.movement-item:first-of-type { border-radius: var(--radius) var(--radius) 0 0; }
.movement-item:last-of-type  { border-radius: 0 0 var(--radius) var(--radius); border-bottom: none; }
.movement-item:only-of-type  { border-radius: var(--radius); border-bottom: none; }

.movement-item:hover { background: var(--bg); color: var(--text); }

.movement-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
  color: #fff;
}

.movement-info { flex: 1; min-width: 0; }

.movement-causale {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.movement-categoria {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.movement-amount {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.3px;
  flex-shrink: 0;
}

.movement-amount.income { color: var(--income); }
.movement-amount.expense { color: var(--expense); }

/* ── FAB (Floating Action Button) ───────────────────────── */
.btn-floating {
  position: fixed;
  bottom: calc(var(--nav-height) + 20px);
  right: 20px;
  z-index: 150;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 22px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  cursor: pointer;
  text-decoration: none;
}

.btn-floating:hover {
  background: var(--primary-dark);
  color: #fff;
  transform: scale(1.05);
  box-shadow: 0 12px 40px rgba(67,97,238,.35);
}

.btn-floating-2 {
  position: fixed;
  bottom: calc(var(--nav-height) + 88px);
  right: 20px;
  z-index: 150;
  width: 44px; height: 44px;
  border-radius: 50%;
  /* outline: bordo rosso trasparente di default — meno aggressivo visivamente */
  background: var(--surface);
  border: 2px solid var(--expense);
  color: var(--expense);
  font-size: 16px;
  box-shadow: 0 2px 10px rgba(239,35,60,.15);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  cursor: pointer;
}

.btn-floating-2:hover,
.btn-floating-2:active {
  background: var(--expense);
  color: #fff;
  border-color: var(--expense);
  box-shadow: 0 6px 20px rgba(239,35,60,.35);
  transform: scale(1.05);
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 20px;
  transition: all var(--transition);
  border: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
  color: #fff;
  box-shadow: var(--shadow);
}

.btn-danger {
  background: var(--expense);
  color: #fff;
}

.btn-danger:hover { opacity: .88; color: #fff; }

.btn-secondary {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--border); color: var(--text); }

.btn-block { width: 100%; }

/* ── Forms ───────────────────────────────────────────────── */
.form-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 6px;
}

.form-control, .form-select {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 15px;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(67,97,238,.15);
  outline: none;
}

.form-group { margin-bottom: 16px; }

/* ── Category Chips ──────────────────────────────────────── */
.categoria-select[type="radio"] { display: none; }

label.categoria-select {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 64px; height: 64px;
  border-radius: 16px;
  cursor: pointer;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  transition: all var(--transition);
  margin: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  opacity: .65;
}

label.categoria-select i {
  font-size: 20px;
  margin: 0;
}

label.categoria-select span {
  font-size: 9px;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 58px;
}

input.categoria-select:checked + label.categoria-select {
  opacity: 1;
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--primary);
}

/* ── Categoria list (categorie.php) ──────────────────────── */
.categoria-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  color: var(--text);
}

.categoria-card:hover {
  box-shadow: var(--shadow);
  transform: translateX(2px);
  color: var(--text);
}

.categoria-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
}

.categoria-info { flex: 1; }
.categoria-nome {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.categoria-budget {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Pagina Analisi ──────────────────────────────────────── */
.analisi-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.analisi-card {
  padding: 16px;
}
.analisi-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.form-label-sm {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: block;
}
.flex-1 { flex: 1; min-width: 0; }

/* Breakdown item */
.analisi-breakdown-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.analisi-breakdown-item:last-child { border-bottom: none; }

/* Tabella confronto */
.confronto-header, .confronto-row {
  display: grid;
  grid-template-columns: 1fr repeat(3, 80px);
  gap: 4px;
  align-items: center;
  padding: 8px 0;
  font-size: 13px;
}
.confronto-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--border);
}
.confronto-row { border-bottom: 1px solid var(--border); }
.confronto-row:last-child { border-bottom: none; }
.confronto-totale { font-weight: 700; padding-top: 10px; }
.confronto-col { text-align: right; }

/* ── Dashboard analisi categorie ────────────────────────── */
.section-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Legenda donut */
.legenda-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.legenda-item:last-child { border-bottom: none; }
.legenda-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legenda-nome { flex: 1; font-weight: 500; }
.legenda-perc { font-size: 12px; min-width: 32px; text-align: right; }
.legenda-importo { font-weight: 600; font-size: 13px; }

/* Budget bars */
.budget-categoria-item { border-radius: var(--radius-sm) !important; }
.budget-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.budget-bar-fill {
  height: 100%;
  background: var(--income);
  border-radius: 3px;
  transition: width .5s ease;
}
.budget-bar-fill--warn { background: #f4a261; }
.budget-bar-fill--over { background: var(--expense); }
.badge-over {
  font-size: 11px;
  font-weight: 700;
  color: var(--expense);
  background: var(--expense-bg);
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
}

/* ── Chip selezione categoria (pagina categorie) ─────────── */
.categorie-chips-scroll {
  display: flex;
  gap: 8px;
  width: 100%;           /* vincola alla larghezza del parent così overflow-x funziona */
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.categorie-chips-scroll::-webkit-scrollbar { display: none; }

.categoria-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all var(--transition);
}
.categoria-chip:hover { border-color: var(--primary); color: var(--primary); }
.categoria-chip.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(67,97,238,.25);
  font-weight: 700;
}
.categoria-chip.active .chip-dot { opacity: .85; }
.chip-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.categoria-totale-bar {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  border: 1px solid var(--border);
}
.categoria-totale-bar .expense { color: var(--expense); }
.categoria-totale-bar .income  { color: var(--income);  }

/* ── Causali rapide (chip quick-select) ──────────────────── */
/* ── Icon picker (modifica categoria) ───────────────────── */
.icon-picker {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.icon-picker-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid transparent;
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  transition: all var(--transition);
}
.icon-picker-btn:hover { border-color: var(--primary); color: var(--primary); }
.icon-picker-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.causali-rapide {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.causale-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  user-select: none;
}
.causale-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}
.causale-chip.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

/* ── Causali list ────────────────────────────────────────── */
.causale-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.causale-item:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.causale-item:last-child  { border-radius: 0 0 var(--radius) var(--radius); border-bottom: none; }

.causale-nome { font-size: 14px; font-weight: 500; }
.causale-actions { display: flex; gap: 8px; }
.causale-actions a { color: var(--text-muted); font-size: 14px; padding: 4px 8px; }
.causale-actions a:hover { color: var(--primary); }

/* ── Login Page ──────────────────────────────────────────── */
body.accedi {
  background: linear-gradient(135deg, #4361ee 0%, #7209b7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border-radius: 24px;
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: slideUp .3s ease;
}

.login-logo {
  width: 64px; height: 64px;
  margin: 0 auto 20px;
  display: block;
}

.login-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  text-align: center;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 32px;
}

/* ── Search bar ──────────────────────────────────────────── */
#ricerca {
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

/* ── Dropdown ────────────────────────────────────────────── */
.dropdown-menu {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 6px;
  font-size: 14px;
}

.dropdown-item {
  border-radius: var(--radius-xs);
  padding: 10px 14px;
  color: var(--text);
  font-weight: 500;
  transition: all var(--transition);
}

.dropdown-item:hover { background: var(--primary-light); color: var(--primary); }

.dropdown-divider { border-color: var(--border); margin: 4px 0; }

/* ── Text colors ─────────────────────────────────────────── */
.text-success { color: var(--income) !important; }
.text-danger  { color: var(--expense) !important; }
.text-muted   { color: var(--text-muted) !important; }
.text-primary { color: var(--primary) !important; }

/* ── Modals ──────────────────────────────────────────────── */
.modal-content {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  border-bottom: 1px solid var(--border);
  padding: 20px 24px;
}

.modal-title { font-weight: 700; color: var(--text); }
.modal-body  { padding: 20px 24px; }
.modal-footer { border-top: 1px solid var(--border); padding: 16px 24px; }

/* ── Table ───────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* ── Charts container ────────────────────────────────────── */
canvas { max-width: 100%; }

.messaggio-info {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 32px 16px;
}

/* ── Elenco statistiche (card row) ───────────────────────── */
.elenco-statistiche .card {
  border-radius: var(--radius-sm);
  padding: 14px;
}
.elenco-statistiche label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}
.elenco-statistiche .valore {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.3px;
}

/* ── Container fluid spacing ─────────────────────────────── */
.container-fluid {
  padding: 20px 16px;
}

/* ── Valore valuta badge ──────────────────────────────────── */
.valore-valuta {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  margin-left: 4px;
}

/* ── Tipo switch (entrata/uscita) ────────────────────────── */
.tipo-toggle {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
  margin-bottom: 16px;
}

.tipo-toggle-btn {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-muted);
}

.tipo-toggle-btn.active-expense {
  background: var(--expense);
  color: #fff;
  box-shadow: 0 2px 8px rgba(239,35,60,.3);
}

.tipo-toggle-btn.active-income {
  background: var(--income);
  color: #fff;
  box-shadow: 0 2px 8px rgba(6,214,160,.3);
}

/* ── Ricorrenti ──────────────────────────────────────────── */
.ricorrente-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
}
.ricorrente-item:last-child { border-bottom: none; }
.ricorrente-item:hover { background: var(--bg); }

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

/* ── Skeleton loading ────────────────────────────────────── */
@keyframes skeleton-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}
.skeleton-line {
  border-radius: 6px;
  background: linear-gradient(90deg, var(--border) 25%, #eef0fb 50%, var(--border) 75%);
  background-size: 800px 100%;
  animation: skeleton-shimmer 1.4s infinite linear;
}
.skeleton-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.skeleton-item:last-child { border-bottom: none; }
.skeleton-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
}
.skeleton-text { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.skeleton-text .line-1 { height: 14px; width: 55%; }
.skeleton-text .line-2 { height: 11px; width: 35%; }
.skeleton-amount { width: 60px; height: 14px; border-radius: 6px; }

/* ── Utility ─────────────────────────────────────────────── */
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.rounded-card { border-radius: var(--radius); }
.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin: 20px 0 10px;
}

/* ── Search input in ricerca collapse ────────────────────── */
#ricerca .form-control { background: var(--bg); }

/* ── Select2 override ────────────────────────────────────── */
.select2-container--default .select2-selection--single {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  height: 46px;
  display: flex;
  align-items: center;
  padding: 0 14px;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  font-size: 15px;
  color: var(--text);
  padding: 0;
  line-height: normal;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
  top: 12px; right: 10px;
}
.select2-dropdown {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.select2-container--default .select2-results__option--highlighted {
  background: var(--primary-light);
  color: var(--primary);
}

/* ── Autocomplete input (causale) ────────────────────────── */
.ui-autocomplete {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow) !important;
  padding: 4px !important;
  z-index: 9999 !important;
}
.ui-menu-item-wrapper {
  border-radius: var(--radius-xs) !important;
  padding: 8px 12px !important;
  font-family: var(--font) !important;
  font-size: 14px !important;
}
.ui-state-active {
  background: var(--primary-light) !important;
  color: var(--primary) !important;
  border: none !important;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Tablet & above */
@media (min-width: 768px) {
  .navbar-mobile { display: none !important; }
  .topbar-mobile { display: none !important; }
  .topbar-desktop { display: flex !important; }
  .sidebar { display: flex !important; }

  .btn-floating {
    bottom: 24px;
  }
  .btn-floating-2 {
    bottom: 92px;
  }

  .container-fluid { padding: 24px; }
}

/* Mobile only */
@media (max-width: 767px) {
  .navbar-mobile { display: flex !important; }
  .topbar-mobile { display: flex !important; }
  .topbar-desktop { display: none !important; }
  .sidebar { display: none !important; }

  #content-wrapper { margin-left: 0 !important; }

  .content { padding-bottom: calc(var(--nav-height) + 80px); }

  .container-fluid { padding: 14px 12px; }
}

/* Large screens */
@media (min-width: 1400px) {
  .sidebar { width: 260px; }
  #content-wrapper { margin-left: 260px; }
}

/* ── PWA safe areas ──────────────────────────────────────── */
@supports (padding: env(safe-area-inset-bottom)) {
  .navbar-mobile {
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  }
  .content {
    padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 80px);
  }
}
