/* ============================================================
   style.css  —  Finanze Famigliari Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── Reset & Base ─────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Colors */
  --bg-deep: #080d1a;
  --bg-base: #0f172a;
  --bg-card: rgba(30, 27, 75, 0.55);
  --bg-card-hover: rgba(30, 27, 75, 0.8);
  --bg-input: rgba(30, 27, 75, 0.7);
  --bg-modal: #12194a;

  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-dim: rgba(99, 102, 241, 0.18);
  --accent-glow: rgba(99, 102, 241, 0.5);
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --pink: #ec4899;

  --text-primary: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --border: rgba(99, 102, 241, 0.2);
  --border-bright: rgba(99, 102, 241, 0.45);

  /* Sizes */
  --sidebar-w: 260px;
  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 20px;

  /* Transitions */
  --tr: .25s cubic-bezier(.4, 0, .2, 1);
  --tr-fast: .15s cubic-bezier(.4, 0, .2, 1);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow: hidden;
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--accent-dim);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* ── Background ambient glow ─────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 60% 50% at 20% 10%, rgba(99, 102, 241, .18) 0%, transparent 70%),
    radial-gradient(ellipse 40% 40% at 80% 80%, rgba(236, 72, 153, .12) 0%, transparent 70%);
  pointer-events: none;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: rgba(15, 23, 42, .85);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(24px);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--tr);
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 28px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--pink) 100%);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  font-size: 20px;
  box-shadow: 0 0 20px var(--accent-glow);
  flex-shrink: 0;
}

.sidebar-logo-text h1 {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  background: linear-gradient(135deg, #e0e7ff 0%, var(--accent-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-logo-text span {
  font-size: 11px;
  color: var(--text-dim);
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 18px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  cursor: pointer;
  border-radius: 0;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--tr-fast);
  position: relative;
  user-select: none;
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--accent-dim);
}

.nav-item.active {
  color: #e0e7ff;
  background: linear-gradient(90deg, rgba(99, 102, 241, .25) 0%, transparent 100%);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), var(--pink));
  border-radius: 0 3px 3px 0;
}

.nav-icon {
  font-size: 18px;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.sidebar-users {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.avatar-1 {
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
}

.avatar-2 {
  background: linear-gradient(135deg, var(--pink), #f97316);
}

/* ── Main content ─────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  height: 100vh;
  overflow-y: auto;
  padding: 32px;
  position: relative;
  z-index: 1;
}

.page {
  display: none;
  animation: fadeUp .3s ease;
}

.page.active {
  display: block;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-header {
  margin-bottom: 28px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 26px;
  font-weight: 800;
}

.page-title span {
  color: var(--accent-light);
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  backdrop-filter: blur(16px);
  transition: all var(--tr);
}

.card:hover {
  border-color: var(--border-bright);
}

.card-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* ── KPI Grid ─────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(16px);
  position: relative;
  overflow: hidden;
  transition: all var(--tr);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
  border-color: var(--border-bright);
}

.kpi-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
}

.kpi-card.income::after {
  background: linear-gradient(90deg, var(--success), #34d399);
}

.kpi-card.expense::after {
  background: linear-gradient(90deg, var(--pink), #f97316);
}

.kpi-card.balance::after {
  background: linear-gradient(90deg, var(--accent), var(--pink));
}

.kpi-card.balance.negative::after {
  background: linear-gradient(90deg, var(--danger), #f97316);
}

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -.5px;
}

.kpi-value.positive {
  color: var(--success);
}

.kpi-value.negative {
  color: var(--danger);
}

.kpi-value.neutral {
  background: linear-gradient(135deg, var(--accent-light), var(--pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.kpi-icon {
  position: absolute;
  right: 18px;
  top: 18px;
  font-size: 26px;
  opacity: .25;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
}

/* ── Charts grid ──────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.chart-wrap {
  position: relative;
  height: 280px;
}

.chart-empty {
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  padding-top: 40px;
}

/* ── Alert banner ─────────────────────────────────────────── */
.alert-banner {
  display: none;
  align-items: center;
  gap: 12px;
  background: rgba(239, 68, 68, .12);
  border: 1px solid rgba(239, 68, 68, .35);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 20px;
  font-size: 14px;
  color: #fca5a5;
}

.alert-banner.show {
  display: flex;
}

/* ── Toolbar ──────────────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* Sub-containers: transparent on desktop (children flow into toolbar row) */
.toolbar-filter-row,
.toolbar-chips,
.toolbar-row {
  display: contents;
}

/* Desktop sizing for toolbar sub-items */
.toolbar-filter-row .search-input-wrap {
  min-width: 160px;
  flex: 1;
}

.toolbar-filter-row .select {
  min-width: 120px;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--tr-fast);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #8b5cf6 100%);
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-bright);
  color: var(--text-muted);
}

.btn-outline:hover {
  color: var(--text-primary);
  border-color: var(--accent-light);
  background: var(--accent-dim);
}

.btn-danger {
  background: rgba(239, 68, 68, .15);
  border: 1px solid rgba(239, 68, 68, .35);
  color: #fca5a5;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, .25);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
}

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, .6);
  backdrop-filter: blur(12px);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  background: rgba(15, 23, 42, .5);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid rgba(99, 102, 241, .07);
  transition: background var(--tr-fast);
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--accent-dim);
}

tbody td {
  padding: 12px 16px;
  color: var(--text-primary);
  vertical-align: middle;
}

.td-actions {
  display: flex;
  gap: 6px;
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}

.badge-indigo {
  background: rgba(99, 102, 241, .2);
  color: var(--accent-light);
}

.badge-green {
  background: rgba(16, 185, 129, .2);
  color: #6ee7b7;
}

.badge-pink {
  background: rgba(236, 72, 153, .2);
  color: #f9a8d4;
}

.badge-orange {
  background: rgba(245, 158, 11, .2);
  color: #fcd34d;
}

.badge-gray {
  background: rgba(100, 116, 139, .2);
  color: #94a3b8;
}

/* ── Progress bar ─────────────────────────────────────────── */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-bar-bg {
  flex: 1;
  height: 7px;
  border-radius: 99px;
  background: rgba(99, 102, 241, .15);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--pink));
  border-radius: 99px;
  transition: width .6s ease;
}

.progress-label {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ── Forms & Inputs ───────────────────────────────────────── */
.input,
.select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  padding: 9px 13px;
  width: 100%;
  transition: border-color var(--tr-fast), box-shadow var(--tr-fast);
  outline: none;
}

.input:focus,
.select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .2);
}

.select option {
  background: #12194a;
}

.input::placeholder {
  color: var(--text-dim);
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(8, 13, 26, .75);
  backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--bg-modal);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  padding: 28px 28px 24px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn .25s ease;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(30px) scale(.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 20px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  transition: all var(--tr-fast);
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--accent-dim);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

/* ── Toast ────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #1e1b4b;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  padding: 13px 18px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .4);
  animation: toastIn .3s ease;
  min-width: 260px;
}

.toast.success {
  border-color: rgba(16, 185, 129, .5);
}

.toast.error {
  border-color: rgba(239, 68, 68, .5);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(30px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(30px);
  }
}

/* ── Sezione Impostazioni ─────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  backdrop-filter: blur(16px);
}

.settings-card h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Mobile hamburger ─────────────────────────────────────── */
.hamburger {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, .5);
  backdrop-filter: blur(4px);
}

/* ── Totale row ───────────────────────────────────────────── */
.total-row td {
  font-weight: 700;
  color: var(--accent-light);
  border-top: 1px solid var(--border-bright) !important;
}

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-dim);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: .5;
}

.empty-state p {
  font-size: 14px;
}

/* ── Search bar ───────────────────────────────────────────── */
.search-input-wrap {
  position: relative;
}

.search-input-wrap .input {
  padding-left: 34px;
}

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 14px;
  pointer-events: none;
}

/* ── File status badge ────────────────────────────────────── */
.file-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  white-space: nowrap;
}

.file-badge.connected {
  background: rgba(16, 185, 129, .2);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, .35);
}

.file-badge.disconnected {
  background: rgba(100, 116, 139, .15);
  color: var(--text-dim);
  border: 1px solid rgba(100, 116, 139, .25);
}

/* ── GDrive card highlight ────────────────────────────────── */
.gdrive-card {
  border-color: rgba(99, 102, 241, .4) !important;
  background: rgba(30, 27, 75, .7) !important;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop.open {
    display: block;
  }

  .hamburger {
    display: flex;
  }

  .main {
    margin-left: 0;
    padding: 72px 16px 24px;
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Bottom navigation (mobile only) ─────────────────────── */
.bottom-nav {
  display: none;
}

/* ── Modal slide-up animation ─────────────────────────────── */
@keyframes modalSlideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ── Mobile-specific enhancements ────────────────────────── */
@media (max-width: 768px) {

  /* ── Bottom Nav ── */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: rgba(10, 15, 35, .97);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 2px;
    min-height: 56px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-dim);
    transition: color var(--tr-fast);
    -webkit-tap-highlight-color: transparent;
  }

  .bottom-nav-item.active {
    color: var(--accent-light);
  }

  .bottom-nav-item.active .bottom-nav-icon {
    filter: drop-shadow(0 0 6px rgba(99, 102, 241, .6));
  }

  .bottom-nav-icon {
    font-size: 20px;
    line-height: 1;
  }

  .bottom-nav-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .02em;
  }

  /* ── Hide hamburger — bottom nav replaces it ── */
  .hamburger {
    display: none !important;
  }

  /* ── Main content: extra bottom padding for bottom nav ── */
  .main {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  /* ── Inputs: 16px prevents iOS auto-zoom ── */
  .input,
  .select {
    font-size: 16px;
    padding: 11px 13px;
  }

  /* ── Touch targets: min 44px for buttons ── */
  .btn {
    min-height: 44px;
    padding: 10px 16px;
  }

  .btn-sm {
    min-height: 36px;
    padding: 7px 12px;
    font-size: 12px;
  }

  /* ── Table action buttons: easier to tap ── */
  .td-actions .btn {
    min-height: 36px;
    padding: 6px 10px;
  }

  /* ── Modal: slide up from bottom ── */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    max-width: 100%;
    width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 88vh;
    animation: modalSlideUp .3s cubic-bezier(.4, 0, .2, 1);
    padding: 24px 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }

  /* ── Modal handle indicator ── */
  .modal::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, .15);
    border-radius: 99px;
    margin: 0 auto 20px;
  }

  /* ── Toast: move to top on mobile ── */
  #toast-container {
    top: 16px;
    bottom: auto;
    left: 16px;
    right: 16px;
    align-items: stretch;
  }

  .toast {
    min-width: unset;
    width: 100%;
    animation: none;
  }

  /* ── Page header: compact on mobile ── */
  .page-header {
    margin-bottom: 18px;
  }

  .page-title {
    font-size: 22px;
  }

  /* ── KPI values: slightly smaller to fit ── */
  .kpi-value {
    font-size: 22px;
  }

  /* ── Form grid: always single column on mobile ── */
  .form-grid {
    grid-template-columns: 1fr;
  }

  /* ── Toolbar: riorganizzazione mobile ── */
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  /* Sub-container: diventano flex box reali su mobile */
  .toolbar-filter-row,
  .toolbar-chips,
  .toolbar-row {
    display: flex !important;
    width: 100%;
    gap: 8px;
    align-items: center;
  }

  /* Riga filtri: search occupa più spazio, select si dividono il resto */
  .toolbar-filter-row .search-input-wrap {
    flex: 2;
    min-width: 0;
  }

  .toolbar-filter-row .select {
    flex: 1;
    min-width: 0;
    width: auto !important;
    font-size: 15px;
  }

  /* Chip strip: scroll orizzontale per le azioni secondarie */
  .toolbar-chips {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }

  .toolbar-chips::-webkit-scrollbar {
    display: none;
  }

  .toolbar-chips .btn {
    flex-shrink: 0;
    width: auto !important;
    white-space: nowrap;
    min-height: 40px;
    padding: 6px 14px;
    font-size: 13px;
  }

  /* Toolbar-row: toggle chip + CTA affiancati */
  .toolbar-row .btn-outline {
    flex-shrink: 0;
    width: auto !important;
    white-space: nowrap;
    min-height: 44px;
  }

  .toolbar-row .btn-primary {
    flex: 1;
    justify-content: center;
    min-height: 44px;
  }

  /* CTA esplicita: sempre larghezza piena */
  .toolbar-cta {
    width: 100% !important;
    justify-content: center;
  }

  /* ── Table: better reading on small screens ── */
  tbody td {
    padding: 10px 12px;
  }

  thead th {
    padding: 10px 12px;
  }
}

@media (max-width: 480px) {
  /* ── Extra compact for very small phones ── */
  .main {
    padding-left: 12px;
    padding-right: 12px;
  }

  .card {
    padding: 16px;
  }

  .kpi-card {
    padding: 14px;
  }
}