:root {
  --primary: #4a5fc1;
  --primary-dark: #3a4a9e;
  --bg: #f5f6fa;
  --card-bg: #ffffff;
  --text: #22263a;
  --text-muted: #6b7280;
  --border: #e2e4ea;
  --success: #2e9e5b;
  --danger: #d1495b;
  --warning: #e0a020;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  background: var(--primary);
  color: white;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h1 {
  margin: 0;
  font-size: 1.25rem;
}

nav {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

nav a {
  color: white;
  text-decoration: none;
  opacity: 0.85;
  font-size: 0.95rem;
}

nav a:hover, nav a.active {
  opacity: 1;
  text-decoration: underline;
}

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1.5rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.card h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.stat {
  text-align: center;
}

.stat .value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.stat .label {
  color: var(--text-muted);
  font-size: 0.85rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
}

tr:hover td { background: #fafbfe; }

form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  color: var(--text-muted);
  gap: 0.25rem;
  flex: 1 1 160px;
}

input, select, textarea {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
}

button {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  cursor: pointer;
  align-self: flex-end;
  height: fit-content;
}

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

button.secondary {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

button.danger {
  background: var(--danger);
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge.presente { background: #e3f6e9; color: var(--success); }
.badge.assente { background: #fbe7e9; color: var(--danger); }
.badge.giustificato { background: #fdf2e0; color: var(--warning); }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 0;
}

.actions-cell {
  display: flex;
  gap: 0.4rem;
}

.actions-cell button {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
}

#toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--text);
  color: white;
  padding: 0.7rem 1.1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

#toast.show { opacity: 0.95; }
