:root {
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --text: #1C1C1E;
  --muted: #8E8E93;
  --border: rgba(60, 60, 67, 0.12);
  --accent: #007AFF;
  --accent-press: #0066D6;
  --danger: #FF3B30;
  --ok: #34C759;
  --warn: #FF9500;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 8px 24px rgba(0,0,0,0.04);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100dvh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}
.wrap-wide { max-width: 960px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0 8px;
}
.topbar .brand {
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
  text-decoration: none;
}
.topbar nav { display: flex; gap: 14px; align-items: center; font-size: 15px; }

.large-title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 8px 0 6px;
  line-height: 1.15;
}
.subtitle {
  color: var(--muted);
  font-size: 16px;
  margin: 0 0 20px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 18px;
  margin-bottom: 14px;
}
.card-link {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: transform 0.12s ease;
}
.card-link:active { transform: scale(0.985); }
.card-link:hover { text-decoration: none; }
.card h2, .card h3 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.card p { margin: 0; color: var(--muted); font-size: 15px; }
.card .meta {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  -webkit-appearance: none;
}
.btn:hover { background: var(--accent-press); text-decoration: none; color: #fff; }
.btn:active { transform: scale(0.98); }
.btn-secondary {
  background: rgba(0,122,255,0.12);
  color: var(--accent);
}
.btn-secondary:hover { background: rgba(0,122,255,0.18); color: var(--accent); }
.btn-danger { background: var(--danger); }
.btn-ghost {
  background: transparent;
  color: var(--accent);
  padding: 8px 10px;
}
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 14px; border-radius: 10px; }

.flash-list { list-style: none; padding: 0; margin: 0 0 14px; }
.flash {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 15px;
}
.flash-error { background: #FFE5E5; color: #B00020; }
.flash-ok { background: #E5F8EC; color: #0B6B2F; }

.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: #F9F9FB;
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-size: 17px;
  color: var(--text);
  outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0,122,255,0.18);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 520px) {
  .form-row { grid-template-columns: 1fr; }
  .large-title { font-size: 28px; }
}

.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* Month grid */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.month-nav h2 { margin: 0; font-size: 20px; font-weight: 650; }
.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 6px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
}
.days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.day-cell {
  aspect-ratio: 1;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 500;
  background: transparent;
  color: var(--muted);
}
.day-cell.free {
  background: var(--card);
  color: var(--accent);
  font-weight: 700;
  box-shadow: var(--shadow);
  text-decoration: none;
}
.day-cell.free:active { transform: scale(0.96); }
.day-cell.today:not(.free) {
  box-shadow: inset 0 0 0 2px var(--border);
  color: var(--text);
}
.day-cell.today.free {
  box-shadow: 0 0 0 2px var(--accent), var(--shadow);
}
.day-cell.empty { visibility: hidden; }

.slot-list { display: flex; flex-direction: column; gap: 8px; }
.slot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  font-weight: 600;
  font-size: 17px;
}
.slot:hover { text-decoration: none; }
.slot span.chev { color: var(--muted); font-weight: 400; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
}
.badge-attesa { background: #FFF3E0; color: #A65B00; }
.badge-confermata { background: #E5F8EC; color: #0B6B2F; }
.badge-annullata { background: #F2F2F7; color: #636366; }

.empty {
  text-align: center;
  padding: 36px 18px;
  color: var(--muted);
}
.empty h3 { color: var(--text); margin: 0 0 8px; font-size: 20px; }
.empty .btn { margin-top: 14px; }

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}
table.data th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
table.data td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(0,0,0,0.05);
  color: var(--text);
  font-size: 14px;
  font-weight: 550;
  text-decoration: none;
}
.pill.active { background: var(--accent); color: #fff; }
.pill:hover { text-decoration: none; }

.footer-note {
  margin-top: 28px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.login-card {
  max-width: 400px;
  margin: 48px auto;
}

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.section-title {
  font-size: 13px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 22px 0 10px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat .n { font-size: 28px; font-weight: 700; color: var(--accent); }
.stat .l { font-size: 12px; color: var(--muted); margin-top: 2px; }

@media (max-width: 520px) {
  .stat-row { grid-template-columns: 1fr; }
}
