/* ========================================================
   Doctor-Radar: Modern Mobile-First Theme & Styles
   ======================================================== */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --accent: #0284c7;

  /* Pin Colors */
  --color-visited: #10b981;
  --color-visited-dark: #059669;
  --color-visited-bg: #ecfdf5;

  --color-unvisited: #ef4444;
  --color-unvisited-dark: #dc2626;
  --color-unvisited-bg: #fef2f2;

  --color-pharmacy: #06b6d4;
  --color-pharmacy-dark: #0891b2;
  --color-pharmacy-bg: #ecfeff;

  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.12);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none !important;
  overscroll-behavior-y: none !important;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-size: 15px;
}

.hidden {
  display: none !important;
}

/* ==================== SCHERMATA LOGIN ==================== */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: radial-gradient(circle at 50% 20%, #1e293b 0%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
  text-align: center;
}

.brand-badge {
  position: relative;
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: #eff6ff;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.radar-pulse {
  position: absolute;
  inset: -6px;
  border: 2px solid #3b82f6;
  border-radius: 26px;
  opacity: 0.6;
  animation: pulse-ring 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 0.2; }
  100% { transform: scale(0.9); opacity: 0.8; }
}

.login-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #0f172a;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  margin-bottom: 24px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.form-group label, .form-row label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #475569;
  margin-bottom: 6px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper i {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: #94a3b8;
}

.input-wrapper input, .form-row input, .form-row select, .form-row textarea {
  width: 100%;
  padding: 12px 14px 12px 42px;
  font-size: 14px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #f8fafc;
  color: var(--text-main);
  transition: all 0.2s ease;
}

.form-row input, .form-row select, .form-row textarea {
  padding-left: 14px;
}

.input-wrapper input:focus, .form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.error-banner {
  background: var(--color-unvisited-bg);
  border: 1px solid #fca5a5;
  color: var(--color-unvisited-dark);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.success-banner {
  background: #ecfdf5;
  border: 1px solid #86efac;
  color: #065f46;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: white;
  border: none;
  padding: 13px 20px;
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-primary:active {
  transform: scale(0.98);
  background: var(--primary-dark);
}

.w-full {
  width: 100%;
}

.login-footer {
  margin-top: 20px;
  font-size: 11px;
  color: #94a3b8;
  letter-spacing: 0.3px;
}

/* ==================== APP LAYOUT & VIEWS ==================== */
.app-layout {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none !important;
  overscroll-behavior-y: none !important;
}

.app-view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: none !important;
  overscroll-behavior-y: none !important;
  background: var(--bg-app);
}

.app-view.hidden {
  display: none !important;
}

#view-map {
  z-index: 1;
}

#view-settings {
  z-index: 2000;
  background: #f8fafc;
}

.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  box-shadow: var(--shadow-sm);
  width: 100%;
  max-width: 100vw;
  min-width: 0;
  overflow-x: hidden;
  padding-top: env(safe-area-inset-top, 0px);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-card);
  border-bottom: 1px solid #f1f5f9;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-icon-menu {
  background: transparent;
  border: none;
  color: var(--text-main);
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  z-index: 10;
}

.btn-icon-menu:active {
  background: #f1f5f9;
  transform: scale(0.96);
}

.btn-icon-menu i {
  width: 24px;
  height: 24px;
}

.brand-icon-sm {
  width: 34px;
  height: 34px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-icon-sm i {
  width: 20px;
  height: 20px;
}

.brand-text h2 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.3px;
  line-height: 1.1;
  color: var(--text-main);
}

.user-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  background: #e0f2fe;
  color: #0369a1;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-action-add {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.btn-action-add-pharmacy {
  background: #ecfeff !important;
  color: #0891b2 !important;
  border-color: #a5f3fc !important;
}

.nav-item-icon.icon-cyan {
  background: #ecfeff !important;
  color: #0891b2 !important;
}

.btn-icon-soft {
  background: #f1f5f9;
  border: none;
  color: #64748b;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Controls (Selector & Search) */
.header-controls {
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  border-bottom: 1px solid #f1f5f9;
}

.selects-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 3;
  min-width: 0;
}

.selects-row .select-wrapper {
  flex: 1;
  min-width: 160px;
}

.header-controls .search-wrapper {
  flex: 2;
  min-width: 240px;
}

/* Tablet refinement (769px to 1099px) */
@media (min-width: 769px) and (max-width: 1099px) {
  .header-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 8px 14px;
  }

  .selects-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
    gap: 8px;
  }

  .selects-row .select-wrapper {
    min-width: 0;
  }

  .header-controls .search-wrapper {
    width: 100%;
    min-width: 0;
  }
}

.select-wrapper, .search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.select-icon, .search-icon {
  position: absolute;
  left: 12px;
  width: 17px;
  height: 17px;
  color: #64748b;
  pointer-events: none;
}

.styled-select, .search-wrapper input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-color);
  background: #f8fafc;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  appearance: none;
  transition: all 0.2s;
}

.styled-select:focus, .search-wrapper input:focus {
  outline: none;
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn-clear {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
}

/* Filter Bar Desktop / Tablet */
.filter-bar {
  padding: 6px 16px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
}

.toggle-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  overflow: visible;
  padding: 0;
}


.toggle-group:active {
  cursor: grabbing;
}

.toggle-group::-webkit-scrollbar {
  height: 5px;
  display: block;
}

.toggle-group::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
}

.toggle-group::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 4px;
}

.toggle-chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: #ffffff;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: all 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.toggle-chip:active {
  transform: scale(0.97);
}

.toggle-chip.active.is-unvisited {
  background: var(--color-unvisited-bg);
  border-color: #fca5a5;
  color: var(--color-unvisited-dark);
}

.toggle-chip.active.is-visited {
  background: var(--color-visited-bg);
  border-color: #86efac;
  color: var(--color-visited-dark);
}

.toggle-chip.active.is-recall-toggle {
  background: #fffbeb;
  border-color: #fde68a;
  color: #b45309;
}

.toggle-chip.active.is-da-censire {
  background: #fef3c7;
  border-color: #fcd34d;
  color: #92400e;
}

.toggle-chip.active.is-pharmacy {
  background: var(--color-pharmacy-bg);
  border-color: #a5f3fc;
  color: var(--color-pharmacy-dark);
}

.toggle-chip.active.is-pediatra,
.toggle-chip.active.is-pediatra-asl {
  background: #f5f3ff;
  border-color: #ddd6fe;
  color: #7c3aed;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-unvisited { background: var(--color-unvisited); }
.dot-visited { background: var(--color-visited); }
.dot-recall { background: #f59e0b; }
.dot-da-censire { background: #d97706; }
.dot-pharmacy { background: var(--color-pharmacy); }
.dot-pediatra,
.dot-pediatra-asl { background: #7c3aed; }

.badge-count {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 5px;
  background: rgba(0,0,0,0.06);
  border-radius: var(--radius-full);
}

/* Header Quick Date Range Filter (Directly Visible) */
.filter-date-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: var(--radius-full);
  padding: 3px 10px 3px 12px;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.filter-date-group:hover,
.filter-date-group:focus-within {
  background: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.15);
}

.date-filter-title {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #1e40af;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.date-filter-title i {
  width: 14px;
  height: 14px;
  color: var(--primary);
}

.date-input-pair {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.date-field {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.date-field-label {
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
}

.header-date-input {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  color: #1e293b;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}

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

.btn-date-clear {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #b91c1c;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s, background 0.15s;
}

.btn-date-clear:hover {
  background: #fecaca;
  transform: scale(1.1);
}

.btn-date-clear i {
  width: 12px;
  height: 12px;
}

.popup-microarea-badge {
  font-size: 11px;
  font-weight: 800;
  color: #1e40af;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 4px 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

/* Scrolling Chips for Specializzazioni */
.specialization-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.specialization-chips::-webkit-scrollbar { display: none; }

.spec-chip {
  background: #f1f5f9;
  border: 1px solid transparent;
  color: #475569;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.spec-chip.active {
  background: var(--primary);
  color: white;
}

/* ==================== MAP VIEWPORT ==================== */
.map-viewport {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  overscroll-behavior: none !important;
  overscroll-behavior-y: none !important;
}

#map {
  width: 100%;
  height: 100%;
  z-index: 10;
  overscroll-behavior: none !important;
  overscroll-behavior-y: none !important;
}

.map-floating-controls {
  position: absolute;
  right: 14px;
  bottom: calc(30px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 500;
}

.fab-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.fab-filters {
  background: var(--primary);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

.fab-filters:active {
  background: var(--primary-dark);
}

.fab-btn:active {
  transform: scale(0.95);
  background: #f8fafc;
}

.stats-pill {
  position: absolute;
  bottom: calc(14px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(8px);
  color: #ffffff;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 500;
  box-shadow: var(--shadow-md);
  white-space: nowrap;
}

.stats-pill i {
  width: 14px;
  height: 14px;
  color: #38bdf8;
}

/* ==================== CUSTOM LEAFLET MARKER PINS ==================== */
.custom-pin-wrapper {
  background: transparent !important;
  border: none !important;
}

.custom-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid #ffffff;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.22));
  transition: transform 0.15s ease, filter 0.15s ease;
}

.custom-pin:hover {
  transform: rotate(-45deg) scale(1.12);
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.35));
  z-index: 1000;
}

.custom-pin i, .custom-pin svg {
  transform: rotate(45deg);
  width: 16px;
  height: 16px;
  color: #ffffff;
}

.pin-unvisited {
  background: var(--color-unvisited);
}

.pin-visited {
  background: var(--color-visited);
}

.pin-pharmacy {
  background: var(--color-pharmacy);
  border-radius: 10px;
  transform: none;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}
.pin-pharmacy:hover {
  transform: scale(1.12);
}
.pin-pharmacy i, .pin-pharmacy svg {
  transform: none;
}

/* ==================== PIN MEDICI ASL (MMG) ==================== */
.custom-pin.pin-asl {
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid #ffffff;
}

.custom-pin.pin-asl.pin-asl-unvisited {
  background: linear-gradient(135deg, #7e22ce 0%, #a855f7 100%);
  filter: drop-shadow(0 3px 6px rgba(126, 34, 206, 0.45));
}
.custom-pin.pin-asl.pin-asl-unvisited:hover {
  transform: rotate(-45deg) scale(1.15);
  filter: drop-shadow(0 5px 10px rgba(126, 34, 206, 0.65));
}

.custom-pin.pin-asl.pin-asl-visited {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  outline: 2.5px solid #9333ea;
  filter: drop-shadow(0 3px 6px rgba(16, 185, 129, 0.45));
}
.custom-pin.pin-asl.pin-asl-visited:hover {
  transform: rotate(-45deg) scale(1.15);
  filter: drop-shadow(0 5px 10px rgba(16, 185, 129, 0.65));
}

.popup-badge.badge-asl {
  background: #f5f3ff;
  color: #7c3aed;
  border: 1px solid #ddd6fe;
  font-weight: 700;
}

.popup-badge.badge-asl-codice {
  background: #f1f5f9;
  color: #475569;
  font-family: monospace;
  font-size: 11px;
}

/* ==================== PIN PEDIATRI (VIOLA) ==================== */
.custom-pin.pin-pediatra,
.custom-pin.pin-pediatra-asl {
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid #ffffff;
}

.custom-pin.pin-pediatra.pin-pediatra-unvisited,
.custom-pin.pin-pediatra-asl.pin-pediatra-asl-unvisited {
  background: linear-gradient(135deg, #7c3aed 0%, #9333ea 100%);
  filter: drop-shadow(0 3px 6px rgba(124, 58, 237, 0.45));
}
.custom-pin.pin-pediatra.pin-pediatra-unvisited:hover,
.custom-pin.pin-pediatra-asl.pin-pediatra-asl-unvisited:hover {
  transform: rotate(-45deg) scale(1.15);
  filter: drop-shadow(0 5px 10px rgba(124, 58, 237, 0.65));
}

.custom-pin.pin-pediatra.pin-pediatra-visited,
.custom-pin.pin-pediatra-asl.pin-pediatra-asl-visited {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  outline: 2.5px solid #7c3aed;
  filter: drop-shadow(0 3px 6px rgba(16, 185, 129, 0.45));
}
.custom-pin.pin-pediatra.pin-pediatra-visited:hover,
.custom-pin.pin-pediatra-asl.pin-pediatra-asl-visited:hover {
  transform: rotate(-45deg) scale(1.15);
  filter: drop-shadow(0 5px 10px rgba(16, 185, 129, 0.65));
}

.popup-badge.badge-pediatra,
.popup-badge.badge-pediatra-asl {
  background: #f5f3ff;
  color: #7c3aed;
  border: 1px solid #ddd6fe;
  font-weight: 700;
}

.popup-badge.badge-intramoenia {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  font-weight: 700;
}

.popup-badge.badge-studio-privato {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #86efac;
  font-weight: 700;
}

/* ==================== LEAFLET POPUP CARD ==================== */
.leaflet-popup {
  margin-bottom: 24px !important;
  z-index: 1000 !important;
}

.leaflet-popup-content-wrapper {
  border-radius: 16px !important;
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.28) !important;
  padding: 0 !important;
  max-height: none !important;
  overflow: visible !important;
  border: 1px solid rgba(226, 232, 240, 0.8) !important;
}

.leaflet-popup-content {
  margin: 0 !important;
  width: 290px !important;
  max-width: 88vw !important;
  max-height: none !important;
  overflow: visible !important;
}

/* Pulsante Chiudi 'X' del Popup: Centrato in alto a destra, pulito e senza sovrapposizioni */
.leaflet-popup-close-button {
  width: 28px !important;
  height: 28px !important;
  top: 10px !important;
  right: 10px !important;
  background: #ffffff !important;
  border: 1.5px solid #cbd5e1 !important;
  border-radius: 50% !important;
  color: #334155 !important;
  font-size: 20px !important;
  font-weight: 700 !important;
  line-height: 24px !important;
  text-align: center !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  z-index: 500 !important;
  padding: 0 !important;
  transition: all 0.2s ease !important;
}

.leaflet-popup-close-button:hover,
.leaflet-popup-close-button:active {
  background: #fee2e2 !important;
  border-color: #ef4444 !important;
  color: #b91c1c !important;
  transform: scale(1.1) !important;
  box-shadow: 0 3px 8px rgba(239, 68, 68, 0.3) !important;
}

.popup-card {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.popup-header {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-right: 32px; /* Spazio protetto per il pulsante X */
}

.popup-badge {
  align-self: flex-start;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.badge-unvisited { background: #fee2e2; color: #b91c1c; }
.badge-visited { background: #dcfce7; color: #15803d; }
.badge-da-censire { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge-pharmacy { background: #cffafe; color: #0e7490; }

.custom-pin.pin-visited.is-da-censire {
  background: #10b981;
  border: 2px solid #ffffff;
  outline: 2.5px solid #f59e0b;
  filter: drop-shadow(0 2px 6px rgba(245, 158, 11, 0.6));
}

.popup-name {
  font-size: 14.5px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.25;
}

.popup-spec {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  line-height: 1.2;
}

.popup-meta {
  font-size: 11.5px;
  color: #475569;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-top: 1px solid #f1f5f9;
  padding-top: 6px;
}

.meta-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.25;
}

.meta-item i {
  width: 13px;
  height: 13px;
  color: #94a3b8;
  flex-shrink: 0;
  margin-top: 2px;
}

.meta-studio-privato-highlight {
  background: #ecfdf5 !important;
  border: 1.5px solid #6ee7b7 !important;
  border-radius: 6px !important;
  padding: 6px 8px !important;
  margin: 4px 0 !important;
  color: #065f46 !important;
  font-size: 11.5px !important;
  line-height: 1.35 !important;
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.15) !important;
}

.meta-studio-privato-highlight i {
  color: #059669 !important;
  width: 15px !important;
  height: 15px !important;
}

.meta-intramoenia-info {
  background: #f0f9ff !important;
  border: 1px solid #bae6fd !important;
  border-radius: 6px !important;
  padding: 5px 7px !important;
  margin: 3px 0 !important;
  color: #0369a1 !important;
  font-size: 11px !important;
  line-height: 1.3 !important;
}

.meta-intramoenia-info i {
  color: #0284c7 !important;
}

.popup-actions {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 2px;
}

.btn-navigate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #2563eb;
  color: #ffffff !important;
  border: 1px solid #1d4ed8;
  padding: 7px 10px;
  border-radius: var(--radius-md);
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 2px 5px rgba(37, 99, 235, 0.25);
  transition: all 0.2s ease;
}

.btn-navigate:active {
  background: #1d4ed8;
  transform: translateY(1px);
}

.btn-call {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.booking-row {
  display: flex;
  gap: 5px;
  width: 100%;
}

.btn-booking {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 8px;
  border-radius: var(--radius-md);
  font-size: 11.5px;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-booking i {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.btn-miodottore {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}
.btn-miodottore:active, .btn-miodottore:hover {
  background: #dbeafe;
  transform: translateY(1px);
}

.btn-doctolib {
  background: #f0fdfa;
  color: #0f766e;
  border: 1px solid #99f6e4;
}
.btn-doctolib:active, .btn-doctolib:hover {
  background: #ccfbf1;
  transform: translateY(1px);
}

.btn-update-visit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #f8fafc;
  color: #334155;
  border: 1px solid #cbd5e1;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.btn-edit-doctor {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #f1f5f9;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-edit-doctor:active {
  background: #e2e8f0;
  transform: translateY(1px);
}

/* ==================== BOTTOM SHEET MODALS ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.bottom-sheet {
  background: #ffffff;
  width: 100%;
  max-width: 540px;
  border-radius: 24px 24px 0 0;
  padding: 12px 20px calc(24px + var(--safe-bottom));
  box-shadow: 0 -10px 40px rgba(0,0,0,0.25);
  max-height: 88dvh;
  max-height: 88svh;
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scroll-padding-bottom: 140px;
  animation: slide-up 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: #cbd5e1;
  border-radius: var(--radius-full);
  margin: 0 auto 12px;
}

.sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 10px;
}

.sheet-title-group h3 {
  font-size: 18px;
  font-weight: 800;
  color: #0f172a;
}

.sheet-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.badge-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  background: #e0e7ff;
  color: #3730a3;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  margin-bottom: 4px;
}

.btn-close-sheet {
  background: #f1f5f9;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  cursor: pointer;
}

.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.radio-status-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.status-option input {
  display: none;
}

.status-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.status-option input:checked + .is-visited-box {
  border-color: var(--color-visited);
  background: var(--color-visited-bg);
  color: var(--color-visited-dark);
}

.status-option input:checked + .is-pending-box {
  border-color: var(--color-unvisited);
  background: var(--color-unvisited-bg);
  color: var(--color-unvisited-dark);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.resolution-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
}

.sheet-actions {
  margin-top: 10px;
}

/* Tablet and Desktop layout upgrades */
@media (min-width: 768px) {
  .header-controls {
    flex-direction: row;
  }
  .select-wrapper {
    width: 320px;
  }
  .search-wrapper {
    flex: 1;
  }
  .bottom-sheet {
    border-radius: 20px;
    margin-bottom: 40px;
  }
}

/* ==================== PANNELLO CONFIGURAZIONE & IMPOSTAZIONI ==================== */
.settings-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: 75vh;
  overflow-y: auto;
  padding-bottom: 20px;
}

.settings-section {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.settings-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.settings-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #0f172a;
}

.settings-section-title i {
  width: 18px;
  height: 18px;
  color: var(--primary);
}

.settings-section-title h4 {
  font-size: 14px;
  font-weight: 800;
  margin: 0;
}

.settings-section-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-text-sm {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 4px;
}

.btn-text-sm:hover {
  text-decoration: underline;
}

.sep {
  color: #cbd5e1;
  font-size: 10px;
}

.settings-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.4;
}

.settings-specs-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}

@media (min-width: 560px) {
  .settings-specs-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.spec-toggle-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.spec-toggle-item:hover {
  border-color: #cbd5e1;
  background: #f1f5f9;
}

.spec-toggle-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.spec-toggle-item.is-excluded {
  opacity: 0.5;
  background: #f8fafc;
  text-decoration: line-through;
}

/* Recall Alert Config */
.recall-config-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-row-inline {
  display: flex;
  align-items: center;
  gap: 12px;
}

.form-row-inline label {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

.input-days-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.input-number-sm {
  width: 75px;
  padding: 8px 10px;
  font-size: 15px;
  font-weight: 800;
  text-align: center;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #ffffff;
}

.days-unit {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.recall-preview-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-md);
  font-size: 12px;
  color: #92400e;
}

.dot-recall {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.25);
  flex-shrink: 0;
}

/* Marker Recall Orange */
.custom-pin.is-recall {
  background: #f59e0b !important;
  border-color: #ffffff !important;
  filter: drop-shadow(0 2px 6px rgba(245, 158, 11, 0.5)) !important;
}

.badge-recall {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Settings Password Form */
.settings-pwd-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: #e2e8f0;
  color: #1e293b;
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: #cbd5e1;
}

/* PWA Install Guide */
.pwa-install-guide {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pwa-guide-item {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.pwa-platform-header {
  font-size: 13px;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 6px;
}

.pwa-steps {
  margin: 0;
  padding-left: 20px;
  font-size: 12px;
  color: #475569;
  line-height: 1.5;
}

.pwa-steps li {
  margin-bottom: 4px;
}

/* ==================== MENU SLIDER (MOBILE DRAWER) ==================== */
.btn-icon-menu {
  background: transparent;
  border: none;
  color: #1e293b;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease;
  margin-right: 2px;
}

.btn-icon-menu:hover {
  background: #f1f5f9;
}

.btn-icon-menu i {
  width: 22px;
  height: 22px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

.drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.drawer-panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 360px;
  max-width: 88vw;
  background: #ffffff;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 28px rgba(0, 0, 0, 0.22);
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.drawer-panel.is-open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: #0f172a;
  color: #ffffff;
}

.drawer-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.drawer-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

.drawer-avatar i {
  width: 20px;
  height: 20px;
}

.drawer-header h3 {
  font-size: 15px;
  font-weight: 800;
  margin: 0;
  color: #ffffff;
}

.drawer-user-role {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 600;
}

.btn-close-drawer {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #ffffff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-close-drawer:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ==================== DRAWER NAVIGATION MENU ==================== */
.drawer-nav-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 14px;
}

.drawer-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: #ffffff;
  border: 1px solid var(--border-color);
  text-align: left;
  cursor: pointer;
  width: 100%;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.drawer-nav-item:active {
  background: #f1f5f9;
  transform: scale(0.99);
}

.drawer-nav-item.active {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.nav-item-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #eff6ff;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-item-icon.icon-green { background: #ecfdf5; color: #059669; }
.nav-item-icon.icon-indigo { background: #e0e7ff; color: #4338ca; }
.nav-item-icon.icon-amber { background: #fef3c7; color: #d97706; }

.nav-item-text {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.nav-title {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
}

.nav-desc {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}

.nav-arrow {
  width: 18px;
  height: 18px;
  color: #94a3b8;
  flex-shrink: 0;
}

.drawer-quick-territory {
  padding: 10px 14px 14px;
  border-top: 1px solid #f1f5f9;
  margin-top: 4px;
}

.drawer-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.drawer-section-title i {
  width: 16px;
  height: 16px;
  color: var(--primary);
}

.select-full {
  width: 100%;
}

.drawer-footer {
  margin-top: auto;
  padding: 16px 14px;
  border-top: 1px solid #e2e8f0;
}

.btn-logout-drawer {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-logout-drawer:hover {
  background: #fecaca;
}

/* ==================== VISTA CONFIGURAZIONE DEDICATA (#view-settings) ==================== */
.settings-page-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.btn-back-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  color: #1e293b;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-back-nav:active {
  background: #e2e8f0;
}

.settings-page-title {
  text-align: center;
  flex: 1;
}

.settings-page-title h2 {
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.settings-page-subtitle {
  font-size: 11px;
  color: #64748b;
  display: block;
}

.btn-save-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--primary);
  border: none;
  color: #ffffff;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-save-nav:active {
  background: var(--primary-dark);
}

.settings-page-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.settings-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  padding: 18px;
}

.settings-card-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.settings-card-title {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.card-icon-wrapper {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-icon-wrapper i {
  width: 22px;
  height: 22px;
}

.icon-card-blue { background: #eff6ff; color: #2563eb; }
.icon-card-amber { background: #fffbeb; color: #d97706; }
.icon-card-green { background: #ecfdf5; color: #059669; }
.icon-card-purple { background: #f5f3ff; color: #7c3aed; }

.settings-card-title h3 {
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.2px;
}

.settings-hint {
  font-size: 12.5px;
  color: #64748b;
  margin-top: 3px;
  line-height: 1.4;
}

.settings-section-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
}

.btn-text-sm {
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  color: #334155;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn-text-sm:active {
  background: #e2e8f0;
}

.settings-specs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px 2px;
}

.spec-toggle-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  cursor: pointer;
  transition: all 0.15s;
}

.spec-toggle-item:hover {
  background: #ffffff;
  border-color: #cbd5e1;
}

.spec-toggle-item.is-excluded {
  opacity: 0.5;
  background: #f1f5f9;
  text-decoration: line-through;
  color: #94a3b8;
}

.recall-config-box {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.form-row-inline label {
  font-size: 13.5px;
  font-weight: 700;
  color: #334155;
}

.input-days-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.input-number-sm {
  width: 70px;
  padding: 8px 10px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  background: #ffffff;
}

.days-unit {
  font-size: 13px;
  color: #64748b;
  font-weight: 600;
}

.recall-preview-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 12.5px;
  color: #b45309;
  font-weight: 600;
}

.settings-pwd-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-large {
  padding: 14px 20px;
  font-size: 15px;
}

.settings-bottom-action {
  margin-top: 10px;
  margin-bottom: 30px;
}

/* ==================== MENU SLIDER / MOBILE DRAWER ==================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.drawer-panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 86vw;
  max-width: 360px;
  background: #ffffff;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 28px rgba(0, 0, 0, 0.25);
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.drawer-panel.is-open {
  transform: translateX(0);
}

.drawer-header {
  padding: 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.drawer-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.drawer-avatar i {
  width: 22px;
  height: 22px;
}

.drawer-user-info h3 {
  font-size: 15px;
  font-weight: 800;
  color: #0f172a;
}

.drawer-user-role {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  display: block;
}

.btn-close-drawer {
  background: transparent;
  border: none;
  color: #64748b;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-close-drawer:active {
  background: #e2e8f0;
}

.drawer-scroll-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.drawer-nav-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.drawer-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #ffffff;
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  width: 100%;
}

.drawer-nav-item:active, .drawer-nav-item.active {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.nav-item-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #f1f5f9;
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-item-icon.icon-green { background: #ecfdf5; color: #059669; }
.nav-item-icon.icon-indigo { background: #e0e7ff; color: #4338ca; }
.nav-item-icon.icon-amber { background: #fef3c7; color: #d97706; }

.nav-item-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.nav-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
}

.nav-desc {
  font-size: 11px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-arrow {
  width: 16px;
  height: 16px;
  color: #94a3b8;
  flex-shrink: 0;
}

.drawer-section {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.drawer-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #475569;
  padding-bottom: 4px;
  border-bottom: 1px solid #e2e8f0;
}

.drawer-section-title i {
  width: 14px;
  height: 14px;
  color: var(--primary);
}

.form-group-drawer {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group-drawer label {
  font-size: 11.5px;
  font-weight: 700;
  color: #475569;
}

.select-full {
  width: 100% !important;
}

.drawer-toggles-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.drawer-toggles-grid .toggle-chip {
  width: 100%;
  justify-content: space-between;
  padding: 8px 10px;
  font-size: 12px;
}

.drawer-apply-action {
  margin-top: 4px;
}

.drawer-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  background: #f8fafc;
}

.btn-logout-drawer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fecaca;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.btn-logout-drawer:active {
  background: #fecaca;
}

.btn-header-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid #bfdbfe;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-header-filters:active {
  background: #dbeafe;
  transform: scale(0.97);
}

.btn-header-filters i {
  width: 16px;
  height: 16px;
}

.drawer-panel-right {
  left: auto;
  right: 0;
  transform: translateX(100%);
  box-shadow: -4px 0 28px rgba(0, 0, 0, 0.25);
}

.drawer-panel-right.is-open {
  transform: translateX(0);
}

.drawer-avatar-blue {
  background: #eff6ff !important;
  color: var(--primary) !important;
  border: 1px solid #bfdbfe;
}

.nav-item-icon.icon-blue {
  background: #eff6ff;
  color: #2563eb;
}

.drawer-scroll-body,
.settings-page-content,
.bottom-sheet {
  overscroll-behavior: contain !important;
  overscroll-behavior-y: contain !important;
  -webkit-overflow-scrolling: touch;
}

/* ==================== RESPONSIVE RULES ==================== */
@media (max-width: 768px) {
  .desktop-only {
    display: none !important;
  }

  .mobile-only {
    display: flex !important;
  }

  .header-top {
    height: 52px;
    padding: 6px 12px;
    border-bottom: none;
  }

  .app-header {
    border-bottom: 1px solid var(--border-color);
  }

  .app-brand {
    gap: 8px;
  }

  .brand-icon-sm {
    width: 30px;
    height: 30px;
  }

  .brand-text h2 {
    font-size: 15px;
  }

  .user-badge {
    font-size: 9px;
    padding: 1px 5px;
  }
}

@media (min-width: 769px) {
  #btn-toggle-menu {
    display: none !important;
  }
  .mobile-only {
    display: none !important;
  }
  .drawer-panel, .drawer-panel-right, .drawer-backdrop {
    display: none !important;
  }
}

/* ==================== PULL-TO-REFRESH CLASSICO SWIPE ==================== */
.ptr-indicator {
  position: fixed;
  top: -80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99999;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.2);
  border: 1.5px solid var(--border-color);
  pointer-events: none;
  transition: top 0.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
  opacity: 0;
}

.ptr-indicator.ptr-visible {
  opacity: 1;
}

.ptr-spinner-box {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ptr-icon {
  width: 18px;
  height: 18px;
  transition: transform 0.08s linear;
}

.ptr-icon.ptr-spinning {
  animation: ptr-spin 0.75s linear infinite;
}

@keyframes ptr-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.ptr-text {
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
}

/* ==================== POSIZIONE ATTUALE MODERNA (GPS) ==================== */
.custom-gps-icon-container {
  background: transparent !important;
  border: none !important;
}

.user-gps-marker {
  position: relative;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-gps-pulse {
  position: absolute;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.35);
  animation: gps-pulse-anim 2s infinite cubic-bezier(0.215, 0.61, 0.355, 1);
  pointer-events: none;
}

.user-gps-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #2563eb;
  border: 3px solid #ffffff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.6), 0 0 0 1px rgba(37, 99, 235, 0.2);
  position: relative;
  z-index: 2;
  cursor: pointer;
}

@keyframes gps-pulse-anim {
  0% {
    transform: scale(0.4);
    opacity: 0.9;
  }
  70% {
    transform: scale(1.6);
    opacity: 0;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

/* Sleek compact card popup for GPS location */
.custom-gps-popup .leaflet-popup-content-wrapper {
  background: #0f172a !important;
  color: #ffffff !important;
  border-radius: 16px !important;
  padding: 0 !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35) !important;
  border: 1.5px solid rgba(56, 189, 248, 0.4) !important;
}

.custom-gps-popup .leaflet-popup-content {
  margin: 10px 14px !important;
  line-height: 1.3 !important;
  white-space: nowrap !important;
}

.custom-gps-popup .leaflet-popup-tip-container {
  display: none !important;
}

.gps-location-popup-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gps-popup-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.gps-popup-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
}

.gps-dot-mini {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 6px #38bdf8;
}

.gps-popup-microarea {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #f8fafc;
}

.gps-popup-microarea strong {
  color: #38bdf8;
  font-weight: 700;
}

.gps-popup-microarea i {
  width: 14px;
  height: 14px;
  color: #38bdf8;
}

/* ==================== MIGLIORIE TASTIERA & SCROLL FRAME ==================== */
.sheet-body {
  padding-bottom: clamp(60px, 15vh, 120px);
}

.keyboard-active .bottom-sheet {
  max-height: 94dvh;
  max-height: 94svh;
}

.keyboard-active .sheet-body {
  padding-bottom: 220px !important;
}

/* ==================== PULSANTI ELIMINA MEDICO / FARMACIA ==================== */
.btn-delete-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  padding: 5px 10px;
  border-radius: var(--radius-md);
  border: 1px solid #fecaca;
  background-color: #fff1f2;
  color: #e11d48;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 2px;
}

.btn-delete-item:hover, .btn-delete-item:active {
  background-color: #ffe4e6;
  border-color: #fda4af;
  color: #be123c;
}

.btn-delete-item i {
  width: 14px;
  height: 14px;
}

/* ==================== EXPORT MODAL CARDS ==================== */
.export-radio-card {
  transition: border-color 0.2s, background-color 0.2s;
}

.export-radio-card:has(input:checked) {
  border-color: #3b82f6 !important;
  background-color: #eff6ff !important;
}

.export-radio-card:has(input[value="current"]:checked) {
  border-color: #10b981 !important;
  background-color: #ecfdf5 !important;
}

/* ==================== SUPPORTO IPHONE / IOS PWA STANDALONE ==================== */
@media all and (display-mode: standalone) {
  .app-header {
    padding-top: max(env(safe-area-inset-top, 0px), 32px);
  }
  .drawer-panel,
  .drawer-panel-right {
    padding-top: max(env(safe-area-inset-top, 0px), 24px);
  }
  .settings-page-header {
    padding-top: max(env(safe-area-inset-top, 0px), 24px);
  }
}

/* Classe specifica impostata al caricamento su iPhone salvato su Home Screen */
body.ios-standalone .app-header,
html.ios-standalone .app-header {
  padding-top: max(env(safe-area-inset-top, 0px), 48px) !important;
}

body.ios-standalone .drawer-panel,
body.ios-standalone .drawer-panel-right,
html.ios-standalone .drawer-panel,
html.ios-standalone .drawer-panel-right {
  padding-top: max(env(safe-area-inset-top, 0px), 48px) !important;
}

body.ios-standalone .settings-page-header,
html.ios-standalone .settings-page-header {
  padding-top: max(env(safe-area-inset-top, 0px), 48px) !important;
}



