:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 1rem 1.5rem;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-900);
}

.brand-icon {
  background: var(--primary-light);
  color: var(--primary);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.header-links a {
  color: var(--gray-600);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  border: 1px solid var(--gray-200);
}

.header-links a:hover {
  color: var(--primary);
  background: var(--primary-light);
  border-color: var(--primary);
}

/* Main Container */
.container {
  max-width: 1080px;
  margin: 2rem auto;
  padding: 0 1.25rem;
  flex: 1;
  width: 100%;
}

/* Admin Container & Header - Fullscreen / Full-width */
.container.admin-container {
  max-width: 100%;
  padding: 0 2rem;
  margin: 1.5rem auto;
}

.header-inner.admin-header-inner {
  max-width: 100%;
  padding: 0 0.5rem;
}

/* Intro Banner */
.intro-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 2rem;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}

.intro-card h1 {
  font-size: 1.75rem;
  color: var(--gray-900);
  margin-bottom: 0.5rem;
}

.intro-card p {
  color: var(--gray-600);
  font-size: 1rem;
}

/* Controls / Filters */
.filters-bar {
  background: white;
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.filter-label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--gray-700);
}

.date-select {
  padding: 0.6rem 1rem;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--gray-800);
  background: white;
  outline: none;
  cursor: pointer;
  min-height: 42px;
  transition: border-color 0.2s;
}

.date-select:focus {
  border-color: var(--primary);
}

/* Legend */
.legend {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  font-size: 0.85rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--gray-600);
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
}

.dot-available {
  background: white;
  border: 2px solid var(--primary);
}

.dot-locked {
  background: var(--warning);
}

.dot-booked {
  background: var(--gray-300);
}

/* Slots Grid */
.slots-container {
  margin-top: 1rem;
}

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

/* Slot Card */
.slot-card {
  position: relative;
  background: white;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 1.2rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  min-height: 105px;
}

.slot-card.available {
  border-color: #93c5fd;
  background: white;
}

.slot-card.available:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.slot-card.available:active {
  transform: translateY(0);
}

/* Locked Card (qualcuno sta prenotando) */
.slot-card.locked {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.slot-card.locked:hover {
  border-color: var(--warning);
  box-shadow: var(--shadow-sm);
}

/* Booked Card (Grigio e disabilitato) */
.slot-card.booked {
  background: #f1f5f9 !important;
  border: 1px dashed #cbd5e1 !important;
  color: #94a3b8 !important;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none !important;
  opacity: 0.7;
}

.slot-time {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.slot-status-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-available {
  background: var(--primary-light);
  color: var(--primary);
}

.badge-locked {
  background: #fef3c7;
  color: #b45309;
}

.badge-booked {
  background: #e2e8f0;
  color: #64748b;
}

/* Empty or Loading State */
.empty-state {
  background: white;
  border-radius: var(--radius-md);
  padding: 3.5rem 1.5rem;
  text-align: center;
  border: 1px dashed var(--gray-300);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.empty-state p {
  color: var(--gray-500);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: white;
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  max-height: calc(100dvh - 2rem);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  transform: scale(0.96);
  transition: transform 0.2s ease;
}

.modal-overlay.active .modal-box {
  transform: scale(1);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--gray-900);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--gray-400);
  line-height: 1;
  transition: color 0.15s;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 36px;
}

.modal-close-btn:hover {
  color: var(--gray-800);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.lock-timer-banner {
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  font-size: 0.85rem;
  color: #92400e;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.35rem;
}

.form-group label .required {
  color: var(--danger);
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 1rem; /* 16px impedisce l'auto-zoom su Safari iOS */
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--primary);
}

.modal-footer {
  padding: 1rem 1.5rem;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-shrink: 0;
}

.btn {
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-secondary {
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
  background: var(--gray-100);
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Alert / Notice Modal (es. "Qualcuno sta tentando di prenotare questo posto") */
.alert-box {
  text-align: center;
  padding: 2rem 1.5rem;
}

.alert-icon-wrap {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  margin: 0 auto 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.alert-icon-warning {
  background: #fef3c7;
  color: #d97706;
}

.alert-icon-success {
  background: #dcfce7;
  color: #16a34a;
}

.alert-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 0.5rem;
}

.alert-message {
  color: var(--gray-600);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

/* Admin Dashboard Elements */
.admin-badge {
  background: #fef3c7;
  color: #92400e;
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-weight: 700;
}

.admin-table-wrap {
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
  margin-top: 1.5rem;
  width: 100%;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.92rem;
}

.admin-table th {
  background: var(--gray-50);
  color: var(--gray-700);
  font-weight: 600;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

.admin-table td {
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--gray-200);
  color: var(--gray-800);
}

.admin-table th.col-checkbox,
.admin-table td.col-checkbox {
  width: 44px;
  text-align: center;
  padding: 0.85rem 0.5rem;
}

.admin-table input[type="checkbox"] {
  width: 17px;
  height: 17px;
  cursor: pointer;
  accent-color: var(--primary);
  vertical-align: middle;
}

.admin-table tr:hover td {
  background: #fafafa;
}

.admin-table tr.row-selected td {
  background: #eff6ff;
}

.admin-table tr.row-selected:hover td {
  background: #dbeafe;
}

/* Modalità Schermo Intero per la tabella */
.admin-table-wrap:fullscreen,
.admin-table-wrap:-webkit-full-screen,
.admin-table-wrap.table-fullscreen-mode {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  background: white;
  padding: 1.5rem;
  overflow: auto;
  border-radius: 0;
  border: none;
  margin: 0;
}

.admin-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

/* Config / Endpoint bar */
.endpoint-bar {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  color: var(--gray-600);
}

.endpoint-bar code {
  background: white;
  padding: 0.15rem 0.4rem;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-family: monospace;
}

/* Footer */
.app-footer {
  margin-top: auto;
  text-align: center;
  padding: 1.5rem;
  color: var(--gray-400);
  font-size: 0.85rem;
  border-top: 1px solid var(--gray-200);
  background: white;
}

/* Login Card & Form */
.login-card {
  max-width: 480px;
  margin: 3rem auto;
}

/* Slot Generator Form */
.generate-slots-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  align-items: flex-end;
}

.generate-slots-form .form-group {
  margin: 0;
}

.generate-slots-form .btn {
  height: 42px;
}

/* Contact Links (Phone & Email) */
.contact-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  font-size: 0.88rem;
  transition: background-color 0.15s, color 0.15s;
}

.contact-link:hover,
.contact-link:active {
  background: #dbeafe;
  color: var(--primary-hover);
}

.text-muted {
  color: var(--gray-400);
}

/* Mobile Select All Label in Filters Bar */
.mobile-select-all-label {
  display: none;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  user-select: none;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  min-height: 38px;
}

.mobile-select-all-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Touch & tap highlights */
button, select, input, a, .slot-card {
  -webkit-tap-highlight-color: rgba(37, 99, 235, 0.1);
}

/* ============================================================
   RESPONSIVE MEDIA QUERIES
   ============================================================ */

/* Tablet & Mobile (<= 768px) */
@media (max-width: 768px) {
  .container {
    margin: 1.25rem auto;
    padding: 0 1rem;
  }

  .container.admin-container {
    padding: 0 1rem;
    margin: 1rem auto;
  }

  .header-inner.admin-header-inner {
    padding: 0;
  }

  .intro-card {
    padding: 1.25rem 1rem;
    margin-bottom: 1.25rem;
  }

  .intro-card h1 {
    font-size: 1.45rem;
  }

  .intro-card p {
    font-size: 0.92rem;
  }

  /* Barra filtri */
  .filters-bar {
    padding: 1rem;
    margin-bottom: 1rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }

  .filter-group {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
  }

  .filter-group .date-select {
    flex: 1 1 200px;
  }

  .admin-actions-group {
    justify-content: space-between;
  }

  .mobile-select-all-label {
    display: inline-flex;
  }

  .legend {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.75rem 1.25rem;
    font-size: 0.82rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--gray-100);
    width: 100%;
  }

  /* TRASFORMAZIONE TABELLA ADMIN IN CARD VIEW */
  .admin-table-wrap:not(.table-fullscreen-mode):not(:fullscreen):not(:-webkit-full-screen) {
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: visible;
    margin-top: 1rem;
  }

  .admin-table-wrap:not(.table-fullscreen-mode):not(:fullscreen):not(:-webkit-full-screen) .admin-table {
    display: block;
    width: 100%;
    border: none;
  }

  .admin-table-wrap:not(.table-fullscreen-mode):not(:fullscreen):not(:-webkit-full-screen) .admin-table thead {
    display: none;
  }

  .admin-table-wrap:not(.table-fullscreen-mode):not(:fullscreen):not(:-webkit-full-screen) .admin-table tbody {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    width: 100%;
  }

  .admin-table-wrap:not(.table-fullscreen-mode):not(:fullscreen):not(:-webkit-full-screen) .admin-table tr {
    display: block;
    background: white;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--gray-200);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
  }

  .admin-table-wrap:not(.table-fullscreen-mode):not(:fullscreen):not(:-webkit-full-screen) .admin-table tr:hover td {
    background: transparent;
  }

  .admin-table-wrap:not(.table-fullscreen-mode):not(:fullscreen):not(:-webkit-full-screen) .admin-table tr.row-selected {
    border-color: var(--primary);
    background: #f0f7ff;
    box-shadow: 0 0 0 1px var(--primary), var(--shadow-sm);
  }

  .admin-table-wrap:not(.table-fullscreen-mode):not(:fullscreen):not(:-webkit-full-screen) .admin-table tr.row-selected td {
    background: transparent;
  }

  /* Empty / Loading message */
  .admin-table-wrap:not(.table-fullscreen-mode):not(:fullscreen):not(:-webkit-full-screen) .admin-table td[colspan] {
    display: block;
    width: 100%;
    text-align: center !important;
    background: white;
    border-radius: var(--radius-md);
    border: 1px dashed var(--gray-300);
    padding: 2.5rem 1rem !important;
  }

  /* Singole celle */
  .admin-table-wrap:not(.table-fullscreen-mode):not(:fullscreen):not(:-webkit-full-screen) .admin-table td:not([colspan]) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.9rem;
    color: var(--gray-800);
  }

  /* Etichette data-label a sinistra */
  .admin-table-wrap:not(.table-fullscreen-mode):not(:fullscreen):not(:-webkit-full-screen) .admin-table td:not([colspan]):not(.col-checkbox):not(.col-actions)::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--gray-500);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-right: 0.75rem;
    flex-shrink: 0;
  }

  /* Intestazione card: checkbox */
  .admin-table-wrap:not(.table-fullscreen-mode):not(:fullscreen):not(:-webkit-full-screen) .admin-table td.col-checkbox {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.6rem;
    padding: 0 0 0.5rem 0;
    margin-bottom: 0.4rem;
    border-bottom: 1.5px solid var(--gray-200);
    width: 100%;
    text-align: left;
  }

  .admin-table-wrap:not(.table-fullscreen-mode):not(:fullscreen):not(:-webkit-full-screen) .admin-table td.col-checkbox::after {
    content: "Seleziona slot";
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gray-600);
  }

  .admin-table-wrap:not(.table-fullscreen-mode):not(:fullscreen):not(:-webkit-full-screen) .admin-table td.col-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
  }

  /* Note su card */
  .admin-table-wrap:not(.table-fullscreen-mode):not(:fullscreen):not(:-webkit-full-screen) .admin-table td.col-notes {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    max-width: 100%;
    text-align: left;
  }

  /* Azioni card: pulsanti touch ergonomici */
  .admin-table-wrap:not(.table-fullscreen-mode):not(:fullscreen):not(:-webkit-full-screen) .admin-table td.col-actions {
    display: block;
    padding-top: 0.75rem;
    margin-top: 0.4rem;
    border-bottom: none;
    border-top: 1.5px solid var(--gray-200);
    width: 100%;
  }

  .admin-table-wrap:not(.table-fullscreen-mode):not(:fullscreen):not(:-webkit-full-screen) .admin-table td.col-actions .admin-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
  }

  .admin-table-wrap:not(.table-fullscreen-mode):not(:fullscreen):not(:-webkit-full-screen) .admin-table td.col-actions .admin-actions .btn {
    width: 100%;
    min-height: 42px;
    font-size: 0.88rem;
    justify-content: center;
  }
}

/* Smartphone medio/piccolo (<= 640px) */
@media (max-width: 640px) {
  .app-header {
    padding: 0.75rem 1rem;
  }

  .brand-title {
    font-size: 1.05rem;
    gap: 0.6rem;
  }

  .brand-icon {
    width: 36px;
    height: 36px;
    font-size: 1.15rem;
  }

  .admin-header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .admin-header-inner .header-links {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
  }

  .admin-header-inner .header-links a {
    flex: 1;
    text-align: center;
    padding: 0.45rem 0.6rem;
    font-size: 0.82rem;
  }

  .admin-header-inner .header-links #btnLogout {
    min-height: 36px;
  }

  .login-card {
    margin: 1.5rem auto;
    width: 100%;
  }

  /* Form generazione slot */
  .generate-slots-form {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .generate-slots-form .form-group:first-child {
    grid-column: 1 / -1; /* Data a larghezza intera */
  }

  .generate-slots-form .form-group:nth-child(4) {
    grid-column: 1 / -1; /* Durata a larghezza intera */
  }

  .generate-slots-form #btnGenerate {
    grid-column: 1 / -1; /* Pulsante a larghezza intera */
    height: 44px;
    font-size: 0.95rem;
  }

  /* Griglia slot orari: 2 colonne comode */
  .slots-grid {
    grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
    gap: 0.65rem;
  }

  .slot-card {
    padding: 0.85rem 0.5rem;
    min-height: 85px;
    gap: 0.3rem;
  }

  .slot-time {
    font-size: 0.95rem;
    white-space: nowrap;
  }

  .slot-status-badge {
    font-size: 0.68rem;
    padding: 0.15rem 0.45rem;
  }
}

/* Smartphone compatto (<= 480px) */
@media (max-width: 480px) {
  .container {
    padding: 0 0.75rem;
    margin: 0.75rem auto;
  }

  .container.admin-container {
    padding: 0 0.75rem;
    margin: 0.75rem auto;
  }

  .intro-card {
    padding: 1rem 0.85rem;
  }

  .intro-card h1 {
    font-size: 1.25rem;
  }

  /* Modale Responsive & Scrollable con tastiera aperta */
  .modal-overlay {
    padding: 0.5rem;
  }

  .modal-box {
    border-radius: var(--radius-md);
    max-height: calc(100dvh - 1rem);
  }

  .modal-header {
    padding: 0.85rem 1rem;
  }

  .modal-title {
    font-size: 1.05rem;
  }

  .modal-body {
    padding: 1rem 0.85rem;
  }

  .modal-footer {
    padding: 0.75rem 0.85rem;
    flex-direction: column-reverse;
    gap: 0.5rem;
  }

  .modal-footer .btn {
    width: 100%;
    min-height: 44px;
    font-size: 0.95rem;
  }

  .lock-timer-banner {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }

  /* Alert modal */
  .alert-box {
    padding: 1.5rem 1rem;
  }

  .alert-icon-wrap {
    width: 52px;
    height: 52px;
    font-size: 1.6rem;
    margin-bottom: 1rem;
  }

  .alert-title {
    font-size: 1.15rem;
  }

  .alert-message {
    font-size: 0.88rem;
    margin-bottom: 1.25rem;
  }

  .alert-box .btn {
    width: 100%;
    min-height: 42px;
  }
}

/* Smartphone molto piccoli (<= 360px) */
@media (max-width: 360px) {
  .slots-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .slot-card {
    padding: 0.75rem 0.35rem;
  }

  .slot-time {
    font-size: 0.85rem;
  }

  .generate-slots-form {
    grid-template-columns: 1fr;
  }
}
