:root {
  --teal-300: #7FCFC4;
  --teal-500: #2A9D8F;
  --teal-700: #1F7A6E;
  --ink-900: #1B2422;
  --steel-300: #E3E8E6;
  --bg: #F4F6F5;
  --card-bg: #FFFFFF;
  --text-main: #1B2422;
  --text-muted: #6B7876;
  --danger: #C0453A;
  --warning: #D68A2A;
  --radius: 10px;
}

* { box-sizing: border-box; }

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

a { color: var(--teal-700); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  border-bottom: 1px solid var(--steel-300);
  padding: 10px 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 18px; }
.topbar-brand { font-weight: 700; color: var(--teal-700); text-decoration: none; font-size: 1.1rem; }
.topbar-nav { display: flex; gap: 4px; }
.topbar-nav a {
  text-decoration: none;
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 0.92rem;
}
.topbar-nav a.active, .topbar-nav a:hover { background: var(--steel-300); }
.topbar-right { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; color: var(--text-muted); }

.container { max-width: 1000px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  margin-bottom: 16px;
}
.card h2 {
  font-size: 0.78rem;
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 700;
}

.form-section { border-top: 1px solid var(--steel-300); padding-top: 12px; margin-top: 12px; }
.form-section:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.form-section-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--teal-700);
  font-weight: 700;
  margin-bottom: 8px;
}

.prossimo-riga { display: flex; justify-content: space-between; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--steel-300); cursor: pointer; gap: 10px; }
.prossimo-riga:last-child { border-bottom: none; }
.prossimo-riga:hover { background: var(--bg); }
.prossimo-data { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.prossimo-ora { font-weight: 700; font-size: 0.95rem; }

.btn {
  display: inline-block;
  border: 1px solid var(--steel-300);
  background: #fff;
  color: var(--text-main);
  padding: 9px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.92rem;
  text-decoration: none;
  text-align: center;
}
.btn:hover { background: var(--steel-300); }
.btn-primary { background: var(--teal-500); color: #fff; border-color: var(--teal-500); }
.btn-primary:hover { background: var(--teal-700); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: #fff; }
.btn-danger:hover { background: #fdeceb; }
.btn-link-muted { background: none; border: none; color: var(--text-muted); text-decoration: underline; cursor: pointer; padding: 4px 0; }
.btn-sm { padding: 5px 10px; font-size: 0.82rem; }
.btn-block { width: 100%; }

.form-group { margin-bottom: 12px; }
.form-group label { display: block; margin-bottom: 4px; font-size: 0.85rem; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--steel-300);
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  background: #fff;
  color: var(--text-main);
}
.form-row { display: flex; gap: 10px; }
.form-row > .form-group { flex: 1; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-prenotato { background: #E4F0FE; color: #2563A8; }
.badge-completato { background: #E3F5EE; color: var(--teal-700); }
.badge-annullato { background: #F1F1F1; color: var(--text-muted); }
.badge-no_show { background: #FCEBEA; color: var(--danger); }
.badge-pagato { background: #E3F5EE; color: var(--teal-700); }
.badge-non-pagato { background: #FDF1E2; color: var(--warning); }

.toast-container { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink-900); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 0.88rem; box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.toast.err { background: var(--danger); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 16px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: #fff; border-radius: var(--radius); padding: 20px;
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
}
.modal h3 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* Agenda: griglia mensile */
.agenda-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.agenda-mese-label { font-weight: 700; font-size: 1.05rem; min-width: 160px; text-align: center; }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 0.78rem; color: var(--text-muted); margin-bottom: 4px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-day {
  background: #fff; border-radius: 8px; padding: 6px; min-height: 64px;
  display: flex; flex-direction: column; gap: 4px; cursor: pointer;
  border: 1px solid var(--steel-300);
}
.cal-day:hover { border-color: var(--teal-500); }
.cal-day.altro-mese { opacity: 0.4; }
.cal-day.oggi { border-color: var(--teal-500); border-width: 2px; }
.cal-day-num { font-size: 0.82rem; font-weight: 600; }
.cal-ev-indicatore {
  align-self: flex-start;
  background: var(--teal-300);
  color: var(--teal-700);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 600;
}

.popup-giorno-riga {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 8px; border-bottom: 1px solid var(--steel-300);
  cursor: pointer;
}
.popup-giorno-riga:hover { background: var(--bg); }
.popup-giorno-riga:last-child { border-bottom: none; }

table.tabella-semplice { width: 100%; border-collapse: collapse; }
table.tabella-semplice th, table.tabella-semplice td {
  text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--steel-300); font-size: 0.9rem;
}
table.tabella-semplice th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; }
.table-responsive { overflow-x: auto; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--ink-900); padding: 16px; }
.login-card { background: #fff; border-radius: 14px; padding: 28px; width: 100%; max-width: 360px; }
.login-card h1 { color: var(--teal-700); font-size: 1.3rem; margin-top: 0; }
.login-hint { color: var(--text-muted); font-size: 0.82rem; }

.avviso-box { background: #FDF1E2; border: 1px solid var(--warning); border-radius: 8px; padding: 10px 12px; font-size: 0.85rem; margin-bottom: 12px; }

@media (max-width: 640px) {
  .topbar-nav a span.label { display: none; }
  .container { padding: 10px; }
  .cal-day { min-height: 52px; padding: 4px; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { max-width: 100%; border-radius: 14px 14px 0 0; max-height: 92vh; }
  .form-row { flex-direction: column; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
}
