:root {
  --primary: #a21a5a;
  --primary-dark: #7d1446;
  --primary-light: #c73e78;
  --secondary: #28235d;
  --secondary-dark: #1c1943;
  --secondary-light: #3f3a86;
  --bg: #f5f2f6;
  --surface: #ffffff;
  --border: #e5dbe2;
  --text: #2a2430;
  --text-muted: #6b6373;
  --radius: 16px;
  --radius-sm: 10px;
  --header-height: 60px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Aptos', 'Carlito', Arial, sans-serif;
}

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

h1, h2, h3 { color: var(--secondary); }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.2rem; }

/* ===== HEADER FISSO ===== */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: linear-gradient(90deg, var(--secondary), var(--primary));
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}
.app-header__brand {
  color: #fff;
  font-weight: bold;
  font-size: 1.15rem;
  letter-spacing: 0.3px;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-header__brand:hover { text-decoration: none; opacity: 0.9; }
.app-header__right {
  display: flex;
  align-items: center;
  gap: 14px;
  color: #fff;
  font-size: 0.9rem;
}
.app-header__user { opacity: 0.9; }
.app-header__logout {
  color: #fff;
  font-weight: 600;
  text-decoration: underline;
}
.app-header__logout:hover { color: #fff; opacity: 0.85; }

.page-body {
  padding: calc(var(--header-height) + 28px) 24px 48px;
  max-width: 1080px;
  margin: 0 auto;
}

.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--secondary);
  font-weight: 600;
}

/* ===== BOTTONI ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 22px;
  border-radius: 999px;
  font-weight: bold;
  border: none;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.95rem;
  font-family: inherit;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 5px 14px rgba(0, 0, 0, 0.18); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: var(--secondary-dark); color: #fff; }
.btn-outline { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: #fdf1f6; color: var(--primary); }
.btn-sm { padding: 6px 14px; font-size: 0.85rem; }

/* ===== HOMEPAGE ===== */
.hero {
  text-align: center;
  padding: 16px 0 8px;
}
.hero h1 {
  font-size: 2.1rem;
  letter-spacing: 1px;
  margin: 0 0 8px;
}
.hero p { color: var(--text-muted); margin: 0; }

.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 22px;
  max-width: 640px;
  margin: 36px auto 0;
}
.menu-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 36px 16px;
  border-radius: 28px;
  color: #fff;
  font-weight: bold;
  font-size: 1.05rem;
  text-decoration: none;
  min-height: 130px;
  box-shadow: 0 6px 18px rgba(40, 35, 93, 0.18);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.menu-card:hover { transform: translateY(-4px); text-decoration: none; box-shadow: 0 10px 24px rgba(40, 35, 93, 0.24); }
.menu-card .icon { font-size: 2.1rem; }
.menu-card--primary { background: linear-gradient(135deg, var(--primary), var(--primary-light)); }
.menu-card--secondary { background: linear-gradient(135deg, var(--secondary), var(--secondary-light)); }

/* ===== STATISTICHE HOMEPAGE ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  max-width: 900px;
  margin: 40px auto 0;
}
.stat-card {
  border-radius: var(--radius);
  padding: 22px 12px;
  text-align: center;
  color: #fff;
  box-shadow: 0 4px 14px rgba(40, 35, 93, 0.14);
}
.stat-card--primary { background: linear-gradient(135deg, var(--primary), var(--primary-light)); }
.stat-card--secondary { background: linear-gradient(135deg, var(--secondary), var(--secondary-light)); }
.stat-number {
  font-size: 2.2rem;
  font-weight: bold;
  line-height: 1.1;
}
.stat-label {
  margin-top: 6px;
  font-size: 0.9rem;
  opacity: 0.9;
}

/* ===== SEZIONI HOMEPAGE ===== */
.section-block {
  max-width: 900px;
  margin: 40px auto 0;
}
.section-block h2 {
  color: var(--secondary);
  font-size: 1.2rem;
  margin: 0 0 14px;
}

/* ===== TABELLE ===== */
.table-wrap {
  overflow-x: auto;
  margin: 0 auto 28px;
  border-radius: var(--radius);
  box-shadow: 0 3px 14px rgba(40, 35, 93, 0.08);
  background: var(--surface);
}
table.data-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 480px;
}
table.data-table th, table.data-table td {
  padding: 13px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}
table.data-table th {
  background: var(--secondary);
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
  position: sticky;
  top: 0;
}
table.data-table th:first-child { border-top-left-radius: var(--radius); }
table.data-table th:last-child { border-top-right-radius: var(--radius); }
table.data-table tbody tr:nth-child(even) { background: #f8eef3; }
table.data-table tbody tr:hover { background: #f1e0e9; }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:last-child td:first-child { border-bottom-left-radius: var(--radius); }
table.data-table tr:last-child td:last-child { border-bottom-right-radius: var(--radius); }

/* ===== FORM ===== */
.form-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 3px 14px rgba(40, 35, 93, 0.08);
  max-width: 600px;
  margin: 0 auto 28px;
}
.form-card label {
  display: block;
  margin-bottom: 16px;
  font-weight: 600;
  color: var(--secondary);
}

/* Stile globale per i campi di input/select, in modo che ogni pagina
   (dentro o fuori da .form-card, es. il form distinta) sia coerente */
input[type=text],
input[type=password],
input[type=number],
input[type=time],
input[type=date],
select {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  font-size: 1rem;
  margin-top: 6px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
}

/* ===== TAB / FILTRO CATEGORIA ===== */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}
.tab {
  display: inline-block;
  padding: 8px 20px;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
  color: var(--secondary);
  background: #fff;
  border: 1.5px solid var(--border);
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.tab:hover { text-decoration: none; background: #fdf1f6; }
.tab--active {
  background: var(--secondary);
  color: #fff;
  border-color: var(--secondary);
}

fieldset {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  padding: 16px 20px;
}
fieldset legend {
  font-weight: bold;
  color: var(--secondary);
  padding: 0 8px;
}

.checkbox-group, .radio-group {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-weight: normal;
}
.checkbox-group label, .radio-group label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-weight: normal;
  color: var(--text);
}

/* Piccoli input dentro le tabelle (es. form distinta) */
table.data-table input[type=text],
table.data-table input[type=number],
table.data-table select {
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  font-family: inherit;
  font-size: 0.9rem;
  width: 100%;
  box-sizing: border-box;
}
table.data-table .narrow { width: 60px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .app-header { padding: 0 16px; }
  .app-header__brand { font-size: 1rem; }
  .app-header__user { display: none; }
  .page-body { padding: calc(var(--header-height) + 20px) 14px 32px; }
  .menu-grid { grid-template-columns: 1fr; gap: 16px; }
  .menu-card { padding: 28px 16px; min-height: 100px; }
  .hero h1 { font-size: 1.5rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 28px; }
  .stat-card { padding: 18px 10px; }
  .stat-number { font-size: 1.7rem; }
  .form-card { padding: 20px 16px; }
  table.data-table th, table.data-table td { padding: 10px 12px; font-size: 0.88rem; }
}
