*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, sans-serif;
  background: #f5f6f8;
  color: #1a1a2e;
  min-height: 100vh;
}

.hidden { display: none !important; }
.page { min-height: 100vh; }

.error-msg {
  background: #fee2e2;
  color: #b91c1c;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
}

.success-msg {
  background: #dcfce7;
  color: #15803d;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
}

/* ── Login ── */
#page-login {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-wrap {
  display: flex;
  align-items: center;
  gap: 40px;
}

.login-logo {
  width: 150px;
  height: 150px;
  object-fit: contain;
  flex-shrink: 0;
}

.login-box {
  background: #fff;
  border: 1px solid #e0e3ea;
  border-radius: 12px;
  padding: 40px 36px;
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-box h1 {
  font-size: 22px;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 8px;
  text-align: center;
}

.login-box h1 span { color: #3b7fd4; }

.login-box input {
  padding: 10px 12px;
  border: 1px solid #e0e3ea;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.login-box input:focus { border-color: #3b7fd4; }

.login-box button {
  padding: 10px;
  background: #3b7fd4;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.15s;
}

.login-box button:hover { background: #2f6ab8; }

/* ── App shell ── */
#page-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Top bar ── */
#topbar {
  background: #1e2a3a;
  color: #fff;
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  flex-shrink: 0;
  justify-content: space-between;
}

#app-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

#app-title span { color: #5ba3f5; }

#user-menu-wrap { position: relative; }

#user-menu-btn {
  background: transparent;
  border: none;
  color: #e2e8f0;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background 0.15s;
}

#user-menu-btn:hover { background: rgba(255,255,255,0.1); }

.user-chevron { font-size: 10px; color: #94a3b8; }

#user-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: #fff;
  border: 1px solid #e0e3ea;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  min-width: 180px;
  z-index: 100;
  overflow: hidden;
}

#user-menu button {
  display: block;
  width: 100%;
  padding: 10px 16px;
  text-align: left;
  background: transparent;
  border: none;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
  transition: background 0.15s;
}

#user-menu button:hover { background: #f5f6f8; }

/* ── App body ── */
#app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ── */
#sidebar {
  width: 200px;
  background: #fff;
  border-right: 1px solid #e0e3ea;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 12px 0;
}

.nav-group { margin-bottom: 8px; }

.nav-group-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #94a3b8;
  padding: 8px 16px 4px;
}

.nav-item {
  display: block;
  width: 100%;
  padding: 8px 16px 8px 24px;
  background: transparent;
  border: none;
  text-align: left;
  font-size: 13px;
  color: #4b5563;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  border-left: 3px solid transparent;
}

.nav-item:hover { background: #f5f7ff; color: #1a1a2e; }

.nav-item.active {
  background: #eef3ff;
  color: #3b7fd4;
  border-left-color: #3b7fd4;
  font-weight: 600;
}

/* ── Content ── */
#content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.section { display: block; }

/* ── Calendar toolbar ── */
.calendar-toolbar {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-controls button {
  min-width: 32px;
  height: 32px;
  border: 1px solid #e0e3ea;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  color: #374151;
  transition: background 0.15s;
}

.nav-controls button:hover { background: #f5f6f8; }

#period-label {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a2e;
  min-width: 220px;
  margin-left: 4px;
}

/* ── Calendar card ── */
.calendar-card {
  background: #fff;
  border: 1px solid #e0e3ea;
  border-radius: 12px;
  overflow: hidden;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

.month-day-header {
  padding: 10px 0;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #6b7280;
  background: #f9fafb;
  border-bottom: 1px solid #e0e3ea;
  border-right: 1px solid #e0e3ea;
}

.month-day-header:last-child { border-right: none; }

.month-cell {
  min-height: 90px;
  padding: 8px 10px;
  border-bottom: 1px solid #e0e3ea;
  border-right: 1px solid #e0e3ea;
  cursor: pointer;
  transition: background 0.1s;
}

.month-cell:nth-child(5n) { border-right: none; }
.month-cell:hover { background: #f5f7ff; }
.month-cell.other-month .day-num { color: #c4c9d4; }
.month-cell.today { background: #eef3ff; }
.month-cell.today .day-num {
  background: #3b7fd4;
  color: #fff;
  border-radius: 50%;
}

.day-num {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

.week-day-header {
  padding: 12px 10px 10px;
  border-bottom: 1px solid #e0e3ea;
  border-right: 1px solid #e0e3ea;
  background: #f9fafb;
  text-align: center;
  cursor: pointer;
  transition: background 0.1s;
}

.week-day-header:hover { background: #f0f2f5; }
.week-day-header:last-child { border-right: none; }

.week-day-name {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #6b7280;
  margin-bottom: 4px;
}

.week-day-num {
  font-size: 22px;
  font-weight: 600;
  color: #374151;
  line-height: 1;
}

.week-day-header.today .week-day-num,
.week-day-header.today .week-day-name { color: #3b7fd4; }

.week-body-col {
  min-height: 400px;
  border-right: 1px solid #e0e3ea;
  padding: 8px;
}

.week-body-col:last-child { border-right: none; }

.daily-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e0e3ea;
  background: #f9fafb;
}

.daily-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: #1a1a2e;
}

.daily-body {
  padding: 16px 20px;
  min-height: 400px;
}

.daily-placeholder {
  text-align: center;
  color: #9ca3af;
  font-size: 14px;
  padding: 60px 0;
}

/* ── Section header ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.section-header button {
  padding: 8px 16px;
  background: #3b7fd4;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.section-header button:hover { background: #2f6ab8; }

/* ── Table ── */
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #e0e3ea;
  border-radius: 12px;
  overflow: hidden;
  font-size: 13px;
}

th {
  background: #f9fafb;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: #6b7280;
  border-bottom: 1px solid #e0e3ea;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f2f5;
  color: #374151;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #f9fafb; }

td button {
  padding: 4px 10px;
  border: 1px solid #e0e3ea;
  background: #fff;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  margin-right: 4px;
  transition: background 0.15s;
}

td button:hover { background: #f0f2f5; }
td button.danger { color: #b91c1c; border-color: #fca5a5; }
td button.danger:hover { background: #fee2e2; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}

.badge-active    { background: #dcfce7; color: #15803d; }
.badge-suspended { background: #fee2e2; color: #b91c1c; }

/* ── Color dot in table ── */
.color-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-block;
  border: 2px solid rgba(0,0,0,0.1);
}

/* ── Forms ── */
.form-box {
  background: #fff;
  border: 1px solid #e0e3ea;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-box h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.form-box label {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-box input {
  padding: 9px 12px;
  border: 1px solid #e0e3ea;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.form-box input:focus { border-color: #3b7fd4; }

.form-row { display: flex; gap: 12px; }
.form-row > div { flex: 1; display: flex; flex-direction: column; gap: 4px; }

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #374151;
}

.form-actions { display: flex; gap: 8px; margin-top: 4px; }

/* ── Color picker ── */
.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s;
  outline: none;
}

.color-swatch:hover { transform: scale(1.15); }

.color-swatch.selected {
  border-color: #1a1a2e;
  transform: scale(1.15);
}

/* ── Buttons ── */
.btn-primary {
  padding: 9px 18px;
  background: #3b7fd4;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover { background: #2f6ab8; }

.btn-secondary {
  padding: 9px 18px;
  background: #fff;
  color: #374151;
  border: 1px solid #e0e3ea;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:hover { background: #f5f6f8; }

/* ── Modal ── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

#modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 28px 32px;
  width: 380px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#modal-box h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

#modal-box label {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

#modal-box input {
  padding: 9px 12px;
  border: 1px solid #e0e3ea;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

#modal-box input:focus { border-color: #3b7fd4; }

/* ── List toolbar ── */
.list-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.list-toolbar input {
  flex: 1;
  min-width: 200px;
  padding: 9px 12px;
  border: 1px solid #e0e3ea;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.list-toolbar input:focus { border-color: #3b7fd4; }

.sort-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #6b7280;
}

.sort-btn {
  padding: 5px 10px;
  border: 1px solid #e0e3ea;
  background: #fff;
  border-radius: 6px;
  font-size: 12px;
  color: #4b5563;
  cursor: pointer;
  transition: all 0.12s;
}

.sort-btn:hover { background: #f5f6f8; }
.sort-btn.active { background: #eef3ff; color: #3b7fd4; border-color: #3b7fd4; font-weight: 600; }

#sort-dir-btn {
  width: 28px;
  height: 28px;
  border: 1px solid #e0e3ea;
  background: #fff;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
}

#sort-dir-btn:hover { background: #f5f6f8; }
#sort-dir-btn.desc { transform: scaleY(-1); }

/* ── Patient list ── */
#patient-list {
  background: #fff;
  border: 1px solid #e0e3ea;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
}

.patient-row {
  display: grid;
  grid-template-columns: 1fr 60px 160px 180px 80px 80px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid #f0f2f5;
  font-size: 13px;
  gap: 12px;
}

.patient-row:last-child { border-bottom: none; }
.patient-row:hover { background: #f9fafb; }

.patient-row-header {
  background: #f9fafb;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
  border-bottom: 1px solid #e0e3ea;
}

.patient-row-header:hover { background: #f9fafb; }

.patient-name { font-weight: 500; color: #1a1a2e; }
.patient-sesso { color: #6b7280; }
.patient-phone { color: #374151; font-variant-numeric: tabular-nums; }
.patient-pref { color: #374151; }
.patient-gruppo {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  background: #e0f2fe;
  color: #0369a1;
}

.patient-empty {
  padding: 48px;
  text-align: center;
  color: #9ca3af;
  font-size: 14px;
}

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
}

.pagination button {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid #e0e3ea;
  background: #fff;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.12s;
}

.pagination button:hover { background: #f5f6f8; }
.pagination button.active { background: #3b7fd4; color: #fff; border-color: #3b7fd4; font-weight: 600; }
.pagination button:disabled { opacity: 0.4; cursor: default; }

/* ── Patient form ── */
.patient-form-box {
  background: #fff;
  border: 1px solid #e0e3ea;
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 16px;
}

.patient-form-box h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  color: #1a1a2e;
}

.patient-form-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.patient-form-grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-field label {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-field input, .form-field select {
  padding: 8px 10px;
  border: 1px solid #e0e3ea;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.form-field input:focus, .form-field select:focus { border-color: #3b7fd4; }
.form-field input.error { border-color: #f87171; }

.field-error {
  font-size: 11px;
  color: #b91c1c;
  margin-top: 2px;
}

/* preferenza quick buttons */
.pref-quick {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.pref-quick button {
  padding: 4px 10px;
  border: 1px solid #e0e3ea;
  background: #f9fafb;
  border-radius: 99px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.12s;
}

.pref-quick button:hover { background: #eef3ff; border-color: #3b7fd4; color: #3b7fd4; }

/* delete zone */
.delete-zone {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  background: #fff5f5;
}

.delete-zone p {
  font-size: 12px;
  color: #7f1d1d;
  margin-bottom: 8px;
}

.delete-zone .delete-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.delete-zone input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}

.btn-danger {
  padding: 7px 16px;
  background: #dc2626;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-danger:hover { background: #b91c1c; }
.btn-danger:disabled { background: #fca5a5; cursor: default; }

/* ── Availability grid ── */
.availability-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e0e3ea;
}

.availability-section h4 {
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
}

.availability-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.avail-day {
  background: #f9fafb;
  border: 1px solid #e0e3ea;
  border-radius: 8px;
  padding: 10px;
}

.avail-day-name {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #374151;
  margin-bottom: 8px;
  text-align: center;
}

.avail-slot {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
}

.avail-slot input[type="time"] {
  flex: 1;
  padding: 5px 6px;
  border: 1px solid #e0e3ea;
  border-radius: 5px;
  font-size: 12px;
  outline: none;
  min-width: 0;
  transition: border-color 0.15s;
}

.avail-slot input[type="time"]:focus { border-color: #3b7fd4; }
.avail-slot input[type="time"].error { border-color: #f87171; }

.avail-sep {
  font-size: 11px;
  color: #9ca3af;
  flex-shrink: 0;
}

.avail-remove {
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color 0.12s, background 0.12s;
}

.avail-remove:hover { color: #dc2626; background: #fee2e2; }

.avail-add {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 4px;
  border: 1px dashed #d1d5db;
  background: transparent;
  border-radius: 5px;
  font-size: 18px;
  color: #9ca3af;
  cursor: pointer;
  transition: all 0.12s;
  margin-top: 2px;
}

.avail-add:hover { border-color: #3b7fd4; color: #3b7fd4; background: #eef3ff; }
.avail-add:disabled { opacity: 0.3; cursor: default; }

.avail-error {
  font-size: 11px;
  color: #b91c1c;
  margin-top: 4px;
  min-height: 14px;
}

.avail-save-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avail-save-msg {
  font-size: 12px;
  color: #15803d;
}

/* ── Patient detail ── */
.detail-back {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.detail-back h2 {
  font-size: 20px;
  font-weight: 700;
  color: #1a1a2e;
}

.detail-block {
  background: #fff;
  border: 1px solid #e0e3ea;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 20px;
}

.detail-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: #f9fafb;
  border-bottom: 1px solid #e0e3ea;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
}

/* ── Therapy list ── */
.therapy-row {
  display: grid;
  grid-template-columns: 160px 160px 80px 80px 120px 100px auto;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid #f0f2f5;
  font-size: 13px;
  gap: 12px;
  cursor: pointer;
  transition: background 0.1s;
}

.therapy-row:last-child { border-bottom: none; }
.therapy-row:hover { background: #f9fafb; }

.therapy-row-header {
  background: #f9fafb;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
  border-bottom: 1px solid #e0e3ea;
  cursor: default;
}

.therapy-row-header:hover { background: #f9fafb; }

.therapy-empty {
  padding: 40px;
  text-align: center;
  color: #9ca3af;
  font-size: 14px;
}

/* therapy status badges */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}

.status-tobestarted { background: #f0f9ff; color: #0369a1; }
.status-started     { background: #dcfce7; color: #15803d; }
.status-completed   { background: #f3f4f6; color: #6b7280; }
.status-refused     { background: #fee2e2; color: #b91c1c; }

/* ── Therapy form ── */
.therapy-form-box {
  background: #f9fafb;
  border-bottom: 1px solid #e0e3ea;
  padding: 20px;
}

.therapy-form-box h3 {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 14px;
}

.therapy-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.therapy-form-grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

/* ── Convenzioni table ── */
.conv-name-input {
  padding: 5px 8px;
  border: 1px solid #e0e3ea;
  border-radius: 5px;
  font-size: 13px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s;
}

.conv-name-input:focus { border-color: #3b7fd4; }

/* ── PDF upload ── */
.pdf-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.pdf-row a {
  color: #3b7fd4;
  font-size: 13px;
  text-decoration: none;
}

.pdf-row a:hover { text-decoration: underline; }

/* ── Waiting list ── */
.list-toolbar select {
  padding: 8px 10px;
  border: 1px solid #e0e3ea;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  background: #fff;
  color: #374151;
  transition: border-color 0.15s;
}

.list-toolbar select:focus { border-color: #3b7fd4; }

.wl-row {
  display: grid;
  grid-template-columns: 1fr 160px 160px 120px 160px 120px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid #f0f2f5;
  font-size: 13px;
  gap: 12px;
  cursor: pointer;
  transition: background 0.1s;
}

.wl-row:last-child { border-bottom: none; }
.wl-row:hover { background: #f5f7ff; }

.wl-row-header {
  background: #f9fafb;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
  border-bottom: 1px solid #e0e3ea;
  cursor: default;
}

.wl-row-header:hover { background: #f9fafb; }

.wl-empty {
  padding: 48px;
  text-align: center;
  color: #9ca3af;
  font-size: 14px;
}

.wl-list-wrap {
  background: #fff;
  border: 1px solid #e0e3ea;
  border-radius: 12px;
  overflow: hidden;
}

/* ── Calendar therapist selector ── */
.therapist-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 16px;
}

.therapist-selector label {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.therapist-selector select {
  padding: 6px 10px;
  border: 1px solid #e0e3ea;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  background: #fff;
  color: #374151;
  transition: border-color 0.15s;
  min-width: 180px;
}

.therapist-selector select:focus { border-color: #3b7fd4; }

/* ── Calendar group boxes ── */
.cal-group-box {
  position: absolute;
  left: 2px;
  right: 2px;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
  z-index: 1;
}

.cal-group-M { background: #3b7fd4; }
.cal-group-F { background: #e91e63; }

/* time grid for week/day views */
.time-grid {
  display: grid;
  grid-template-columns: 48px repeat(5, 1fr);
}

.time-grid-day {
  display: grid;
  grid-template-columns: 48px 1fr;
}

.time-label {
  font-size: 10px;
  color: #9ca3af;
  text-align: right;
  padding-right: 6px;
  padding-top: 2px;
  height: 60px;
  border-right: 1px solid #e0e3ea;
}

.time-slot-cell {
  height: 60px;
  border-bottom: 1px solid #f0f2f5;
  border-right: 1px solid #e0e3ea;
  position: relative;
}

.time-slot-cell:last-child { border-right: none; }
.time-slot-cell:hover { background: #f5f7ff; }

/* ── Group form ── */
.group-form-box {
  background: #fff;
  border: 1px solid #e0e3ea;
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 16px;
}

.group-form-box h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
  color: #1a1a2e;
}

.group-form-fields {
  display: flex;
  gap: 20px;
  align-items: flex-end;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.group-form-fields .form-field { min-width: 160px; }

.slot-label {
  display: inline-block;
  padding: 7px 12px;
  background: #f0f2f5;
  border-radius: 6px;
  font-size: 13px;
  color: #374151;
  min-width: 140px;
}

/* ── Group week grid (for creation) ── */
.group-week-grid {
  border: 1px solid #e0e3ea;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 4px;
}

.gwg-header {
  display: grid;
  grid-template-columns: 48px repeat(5, 1fr);
  background: #f9fafb;
  border-bottom: 1px solid #e0e3ea;
}

.gwg-header-cell {
  padding: 6px 0;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
  border-right: 1px solid #e0e3ea;
}

.gwg-header-cell:last-child { border-right: none; }
.gwg-header-corner { border-right: 1px solid #e0e3ea; }

.gwg-row {
  display: grid;
  grid-template-columns: 48px repeat(5, 1fr);
  border-bottom: 1px solid #f0f2f5;
}

.gwg-row:last-child { border-bottom: none; }

.gwg-time {
  font-size: 10px;
  color: #9ca3af;
  text-align: right;
  padding: 4px 6px 0 0;
  border-right: 1px solid #e0e3ea;
  background: #fafafa;
}

.gwg-cell {
  height: 36px;
  border-right: 1px solid #f0f2f5;
  cursor: pointer;
  transition: background 0.1s;
}

.gwg-cell:last-child { border-right: none; }
.gwg-cell.avail  { background: #e0f2fe; }
.gwg-cell.avail:hover  { background: #bae6fd; }
.gwg-cell.unavail { background: #fee2e2; cursor: not-allowed; }
.gwg-cell.unavail:hover { background: #fecaca; }
.gwg-cell.selected { background: #3b7fd4 !important; }

.gwg-cell.occupied {
  background: #fee2e2;
  border: 2px solid #dc2626;
  cursor: default;
}

/* ── Mobile ── */
@media (max-width: 768px) {
  #hamburger-btn { display: flex; align-items: center; }

  #sidebar {
    position: fixed;
    left: -220px;
    top: 48px;
    bottom: 0;
    z-index: 100;
    transition: left 0.25s ease;
    box-shadow: 2px 0 12px rgba(0,0,0,0.15);
  }

  #sidebar.open {
    left: 0;
  }

  #sidebar-overlay.open { display: block; }

  .login-wrap { flex-direction: column; gap: 20px; }
  .login-logo { width: 100px; height: 100px; }

  .hide-on-mobile { display: none !important; }

  /* hide admin/patient nav groups for therapists on mobile handled via JS */

  /* calendar toolbar stacked */
  .calendar-toolbar { flex-wrap: wrap; gap: 8px; }

  /* patient/therapy tables scroll horizontally */
  .patient-row, .therapy-row, .wl-row {
    font-size: 12px;
    gap: 8px;
  }

  #content { padding: 12px; }
}

/* ── Planning ── */
.planning-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.planning-row1 { margin-bottom: 8px; }
.planning-row1 h2 { font-size: 16px; font-weight: 700; color: #1a1a2e; }

.planning-row2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.planning-row3 {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #fff;
  border: 1px solid #e0e3ea;
  border-radius: 10px;
  padding: 10px 16px;
  margin-bottom: 12px;
  white-space: nowrap;
  overflow-x: auto;
}

.planning-control-item {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.planning-control-item label {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.planning-control-item select {
  padding: 5px 8px;
  border: 1px solid #e0e3ea;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  background: #fff;
}

.plan-freq-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.plan-freq-wrap span {
  font-weight: 700;
  font-size: 14px;
  min-width: 16px;
  color: #3b7fd4;
}

.plan-pref-val {
  font-size: 13px;
  color: #374151;
  font-style: italic;
}

.planning-week-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}

.planning-week-nav span {
  font-size: 13px;
  font-weight: 600;
  color: #1a1a2e;
  min-width: 180px;
  text-align: center;
}

.week-nav-btn-lg {
  width: 40px;
  height: 40px;
  border: 1px solid #e0e3ea;
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 22px;
  color: #374151;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.week-nav-btn-lg:hover { background: #f5f6f8; }

/* ── Plan slot grid ── */
.plan-grid {
  display: grid;
  grid-template-columns: 48px repeat(5, 1fr);
  background: #fff;
  border: 1px solid #e0e3ea;
  border-radius: 12px;
  overflow: hidden;
}

.plan-grid-corner {
  background: #f9fafb;
  border-bottom: 1px solid #e0e3ea;
  border-right: 1px solid #e0e3ea;
}

.plan-grid-day-header {
  background: #f9fafb;
  border-bottom: 1px solid #e0e3ea;
  border-right: 1px solid #e0e3ea;
  padding: 8px 4px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
}

.plan-grid-day-header.today { color: #3b7fd4; }
.plan-grid-day-header:last-child { border-right: none; }

.plan-grid-time {
  font-size: 10px;
  color: #9ca3af;
  text-align: right;
  padding: 6px 6px 0 0;
  border-right: 1px solid #e0e3ea;
  border-bottom: 1px solid #f0f2f5;
  background: #fafafa;
  height: 44px;
}

.plan-grid-cell {
  border: 1px solid #0f2f5f;
  padding: 3px;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.plan-slot-box {
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  opacity: 0.75;
  transition: opacity 0.12s, transform 0.12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.plan-slot-box:hover { opacity: 0.9; transform: scale(1.03); }
.plan-slot-box.selected {
  opacity: 1;
  outline: 3px solid #1a1a2e;
  filter: brightness(0.7);
  position: relative;
}
.plan-slot-box.selected::after {
  content: '✓';
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  font-weight: 900;
  color: #fff;
}
.plan-slot-box.plan-slot-limit { outline: 2px solid #f59e0b; }

.planning-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ── Preview ── */
.planning-preview-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: #374151;
  background: #fff;
  border: 1px solid #e0e3ea;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
}

.preview-week {
  margin-bottom: 16px;
}

.preview-week-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
  margin-bottom: 8px;
}

.preview-week-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preview-slot-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid #e0e3ea;
  border-radius: 99px;
  padding: 5px 14px;
  font-size: 13px;
  color: #374151;
}

/* ── Suspend zone ── */
.suspend-zone {
  margin-top: 24px;
  padding: 14px 16px;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  background: yellow;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  white-space: nowrap;
}

.suspend-zone p {
  font-size: 12px;
  color: #7f1d1d;
  white-space: nowrap;
}

/* ── Planning occupied slots ── */
.plan-slot-occupied {
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 11px;
  font-weight: 500;
  color: #6b7280;
  background: #e5e7eb;
  border: 1px solid #d1d5db;
  cursor: default;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ── Info label ── */
.info-label {
  color: #6b7280;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 3px;
}

/* ── Month view content ── */
.month-hour-line {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  line-height: 1.4;
  flex-wrap: wrap;
}

.month-hour-label {
  color: #9ca3af;
  font-size: 9px;
  min-width: 16px;
}

.month-warn {
  color: #dc2626;
  font-size: 10px;
}

.month-summary {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  padding: 2px 0;
}

.month-vacation {
  font-size: 10px;
  font-weight: 600;
  color: #dc2626;
  background: #fee2e2;
  border-radius: 3px;
  padding: 1px 4px;
  margin-top: 2px;
}

/* ── Non-selectable slot no hover ── */
.plan-slot-no-hover:hover {
  opacity: 0.75 !important;
  transform: none !important;
}

/* ── Month summary lines ── */
.month-summary-line {
  font-size: 10px;
  color: var(--color-text-primary, #374151);
  line-height: 1.5;
  padding: 0 2px;
}

.month-summary-line .month-warn {
  color: #dc2626;
}

/* ── Prime Disponibilità ── */
.dispon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.dispon-therapist {
  background: #fff;
  border: 1px solid #e0e3ea;
  border-radius: 10px;
  overflow: hidden;
  min-width: 22em;
}

.dispon-name {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
}

.dispon-slots {
  padding: 8px 14px;
}

.dispon-slot {
  font-size: 12px;
  color: #374151;
  padding: 4px 0;
  border-bottom: 1px solid #f0f0f0;
}

.dispon-slot:last-child { border-bottom: none; }

/* ── Topbar structure ── */
#structure-wrap {
  margin-left: auto;
  margin-right: 12px;
}

#topbar-structure {
  cursor: pointer;
}

/* ── Phone links ── */
.phone-link {
  text-decoration: none;
  cursor: pointer;
  margin-left: 4px;
  vertical-align: middle;
  font-size: 14px;
}

/* ── Uso table ── */
.uso-header {
  margin-bottom: 12px;
}

.uso-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
  border: 1px solid #e0e3ea;
  border-radius: 10px;
  overflow: hidden;
}

.uso-table th {
  background: #f9fafb;
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #6b7280;
  border-bottom: 2px solid #e5e7eb;
}

.uso-table td {
  padding: 8px 14px;
  border-bottom: 1px solid #f0f2f5;
  text-align: center;
  color: #9ca3af;
}

.uso-table td:first-child { text-align: left; color: #6b7280; font-size: 12px; }
.uso-table tr:last-child td { border-bottom: none; }
.uso-count { font-weight: 700 !important; color: #1a1a2e !important; font-size: 15px !important; }

@media print { .no-print { display: none !important; } }

/* ── Avvisi ── */
.avvisi-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
}

.avviso-card {
  background: #fff;
  border: 1px solid #e0e3ea;
  border-radius: 12px;
  padding: 16px;
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}

.avviso-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.avviso-patient {
  font-size: 15px;
  font-weight: 700;
  color: #1a1a2e;
}

.avviso-type {
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}

.avviso-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.avviso-notes {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #e0e3ea;
  border-radius: 6px;
  padding: 8px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  color: #374151;
  outline: none;
  transition: border-color .15s;
}

.avviso-notes:focus { border-color: #3b7fd4; }

.avviso-actions {
  display: flex;
  justify-content: flex-end;
}

.avviso-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #6b7280;
  margin-bottom: 4px;
}

