/* ============================================================
   Registro Cassa Palestra — Stile principale
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-bg:   #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-active-bg: #3b82f6;
  --sidebar-active-text: #ffffff;
  --body-bg:      #f1f5f9;
  --card-bg:      #ffffff;
  --border:       #e2e8f0;
  --text:         #0f172a;
  --text-muted:   #64748b;
  --entrata:      #16a34a;
  --uscita:       #dc2626;
  --primary:      #3b82f6;
  --primary-dark: #2563eb;
  --danger:       #ef4444;
  --radius:       8px;
  --shadow:       0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--body-bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ---- SIDEBAR ---- */
.sidebar {
  width: 220px;
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.sidebar-brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-brand .logo-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
  font-size: 18px;
}
.sidebar-brand h1 {
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}
.sidebar-brand p { color: var(--sidebar-text); font-size: 11px; }

.sidebar nav { padding: 12px 0; flex: 1; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 0;
  transition: background .15s, color .15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #cbd5e1; }
.sidebar nav a.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
}
.sidebar nav a svg { flex-shrink: 0; }

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,.07);
  color: var(--sidebar-text);
  font-size: 11px;
}

/* ---- MAIN ---- */
.main {
  margin-left: 220px;
  flex: 1;
  padding: 28px 32px;
  min-height: 100vh;
}

/* ---- PAGE HEADER ---- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h2 { font-size: 22px; font-weight: 700; }
.page-header p  { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* ---- CARDS ---- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-body { padding: 20px 24px; }
.card-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ---- STAT CARDS ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-card .label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}
.stat-card .value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}
.stat-card.entrate .value { color: var(--entrata); }
.stat-card.uscite  .value { color: var(--uscita); }
.stat-card.saldo   .value { color: var(--primary); }
.stat-card.movimenti .value { color: #7c3aed; }

/* ---- TABLE ---- */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
thead th {
  background: #f8fafc;
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

/* ---- BADGES ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-entrata { background: #dcfce7; color: #15803d; }
.badge-uscita  { background: #fee2e2; color: #b91c1c; }

.importo-entrata { color: var(--entrata); font-weight: 600; }
.importo-uscita  { color: var(--uscita);  font-weight: 600; }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, opacity .15s;
  line-height: 1;
}
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f1f5f9; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .85; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px; border-radius: 6px; background: none; border: none; cursor: pointer; color: var(--text-muted); }
.btn-icon:hover { background: #f1f5f9; color: var(--danger); }

/* ---- FILTERS ---- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
  border-radius: var(--radius) var(--radius) 0 0;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.filter-group input,
.filter-group select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  min-width: 140px;
}
.filter-group input:focus,
.filter-group select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

/* ---- FORM ---- */
.form-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 140px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.form-group input,
.form-group select,
.form-group textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.form-group textarea { resize: vertical; min-height: 70px; }

/* ---- MODAL ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 500;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 10px;
  width: 520px;
  max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---- CHART CONTAINERS ---- */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
.chart-full { margin-bottom: 20px; }
.chart-wrap { position: relative; height: 280px; }

/* ---- TOTALI BAR ---- */
.totali-bar {
  display: flex;
  gap: 20px;
  padding: 10px 16px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}
.totali-bar .t-entrate { color: var(--entrata); }
.totali-bar .t-uscite  { color: var(--uscita); }
.totali-bar .t-saldo   { color: var(--primary); }

/* ---- SETTINGS LIST ---- */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item .name { font-weight: 500; }
.list-item .meta { font-size: 12px; color: var(--text-muted); }
.list-item .actions { display: flex; gap: 4px; }

/* ---- SWITCH / TOGGLE ---- */
.toggle {
  width: 36px; height: 20px;
  background: #cbd5e1;
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  border: none;
  transition: background .2s;
  flex-shrink: 0;
}
.toggle.on { background: var(--primary); }
.toggle::after {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: transform .2s;
}
.toggle.on::after { transform: translateX(16px); }

/* ---- TOAST ---- */
#toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: #1e293b;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .25s, transform .25s;
  z-index: 1000;
  max-width: 320px;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.error { background: #b91c1c; }

/* ---- EMPTY STATE ---- */
.empty { text-align: center; padding: 48px 24px; color: var(--text-muted); font-size: 14px; }

/* ---- EXPORT BUTTONS ---- */
.export-btns { display: flex; gap: 8px; }

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  .stats-grid   { grid-template-columns: 1fr 1fr; }
  .charts-grid  { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .sidebar { width: 200px; }
  .main    { margin-left: 200px; padding: 16px; }
  .stats-grid { grid-template-columns: 1fr; }
}
