/* ─── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ─── Tokens ─────────────────────────────────────────────── */
:root {
  --brand:       #007A38;
  --brand-mid:   #009246;
  --brand-light: #CCEEDD;
  --brand-pale:  #E6F8EE;
  --accent:      #FF6B35;

  --surface:     #FFFFFF;
  --surface-2:   #F7F8FA;
  --text-1:      #111827;
  --text-2:      #6B7280;
  --border:      #E5E7EB;

  --sh-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --sh-md: 0 4px 12px rgba(0,0,0,.08);
  --sh-lg: 0 12px 32px rgba(0,0,0,.12);

  --r:    12px;
  --r-sm: 8px;
  --r-lg: 20px;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;

  /* legacy aliases (backward compat) */
  --green:       var(--brand-mid);
  --green-dark:  var(--brand);
  --green-light: var(--brand-light);
  --green-pale:  var(--brand-pale);
  --bg:          var(--surface-2);
  --card-bg:     var(--surface);
  --shadow:      var(--sh-sm);
  --radius:      var(--r);
  --radius-sm:   var(--r-sm);
  --text:        var(--text-1);
  --text-muted:  var(--text-2);
}

/* ─── Base ───────────────────────────────────────────────── */
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--surface-2);
  color: var(--text-1);
  min-height: 100dvh;
  line-height: 1.5;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
input, select, button, textarea { font-family: var(--font); }

/* ─── Navbar ─────────────────────────────────────────────── */
.navbar {
  background: #fff;
  color: var(--text-1);
  padding: 0 .75rem;
  display: flex;
  align-items: center;
  height: 68px;
  position: sticky;
  top: 0;
  z-index: 110;
  border-bottom: 3px solid var(--brand);
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
/* 3-colonne: sinistra | centro (logo) | destra — logo sempre centrato */
.navbar-left {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  min-width: 44px;
}
.navbar-brand {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  pointer-events: none;
  cursor: default;
}
.logo-text {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
}
.logo-text .t { color: #009246; }
.logo-text .s { color: #CE2B37; }
.navbar-right {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: .35rem;
  min-width: 44px;
  justify-content: flex-end;
}
.navbar-brand > span:not(.logo-text) { color: var(--green-dark); opacity: .75; }
.navbar-nav { display: flex; gap: .1rem; list-style: none; }
.navbar-nav a {
  color: var(--text-2);
  padding: .4rem .75rem;
  border-radius: var(--r-sm);
  font-size: .88rem;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.navbar-nav a:hover,
.navbar-nav a.active { background: var(--brand-pale); color: var(--brand); text-decoration: none; }
/* Legacy — tenuta per sicurezza ma non più iniettata */
.navbar-mobile-login { display: none !important; }

.navbar-icon-btn {
  background: var(--surface-2);
  border: none;
  color: var(--text-1);
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
}
.navbar-icon-btn:hover { background: var(--brand-light); color: var(--brand); }
.navbar-icon-btn.active { background: var(--brand-light); color: var(--brand); }

.mobile-photo-btn {
  display: none;
  padding: .45rem .65rem;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  text-decoration: none;
}
.mobile-photo-btn:hover {
  background: rgba(255,255,255,.25);
}

/* ─── Tab bar (PWA bottom nav) ───────────────────────────── */
.tab-bar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 200;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tab-bar nav { display: flex; }
.tab-bar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
  padding: .5rem .25rem .4rem;
  color: var(--text-2);
  font-size: .62rem;
  font-weight: 500;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: color .15s;
}
.tab-bar a svg { width: 22px; height: 22px; stroke: currentColor; }
.tab-bar a.active { color: var(--brand); }
@media (max-width: 767px) {
  .tab-bar { display: block; }
  body { padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
  .navbar-nav { display: none; }
  .mobile-photo-btn { display: inline-flex; }
}

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .6rem 1.2rem;
  min-height: 44px;
  border: none;
  border-radius: var(--r-sm);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s, transform .1s;
  white-space: nowrap;
  letter-spacing: -.1px;
}
.btn:active { transform: scale(.97); }
.btn:disabled, .btn[disabled] { opacity: .4; cursor: not-allowed; pointer-events: none; }
.btn-primary   { background: var(--brand-mid); color: #fff; }
.btn-primary:hover { background: var(--brand); }
.btn-secondary { background: var(--surface); color: var(--text-1); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger    { background: #DC2626; color: #fff; }
.btn-danger:hover { background: #B91C1C; }
.btn-warning   { background: #D97706; color: #fff; }
.btn-warning:hover { background: #B45309; }
.btn-success   { background: var(--brand-mid); color: #fff; }
.btn-info      { background: #0284C7; color: #fff; }
.btn-info:hover { background: #0369A1; }
.btn-sm  { padding: .35rem .7rem; font-size: .8rem; min-height: 36px; }
.btn-lg  { padding: .75rem 1.8rem; font-size: 1rem; min-height: 52px; }
.btn-block { width: 100%; }

/* ─── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--r);
  box-shadow: var(--sh-sm);
  overflow: hidden;
}
.event-card {
  display: flex;
  flex-direction: row;
  min-height: 120px;
  transition: transform .2s, box-shadow .2s;
}
.event-card:hover { transform: translateY(-2px); box-shadow: var(--sh-md); }

.event-card .flyer-wrap {
  width: 180px;
  min-width: 180px;
  aspect-ratio: 3/4;
  overflow: hidden;
  background: var(--brand-light);
}
.event-card .flyer-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .3s;
}
.event-card:hover .flyer-wrap img { transform: scale(1.04); }
.flyer-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem;
  background: var(--brand-pale);
  color: var(--brand-mid);
}

.event-card .card-body {
  padding: .85rem 1rem 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.event-card .card-title {
  font-size: .95rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: .3rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text-1);
}
.event-card .card-meta {
  font-size: .78rem;
  color: var(--text-2);
  display: flex;
  flex-direction: column;
  gap: .2rem;
  margin-top: .35rem;
}
.event-card .card-meta span { display: flex; align-items: center; gap: .3rem; }

/* ─── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 99px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .2px;
}
.badge-green     { background: var(--brand-light); color: var(--brand); }
.badge-orange    { background: #FEF3C7; color: #92400E; }
.badge-red       { background: #FEE2E2; color: #991B1B; }
.badge-blue      { background: #DBEAFE; color: #1E40AF; }
.badge-grey      { background: #F3F4F6; color: #374151; }

/* ─── Grid ───────────────────────────────────────────────── */
.events-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  padding: 1rem;
}
@media (max-width: 1023px) {
  .events-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }
}
@media (max-width: 767px) {
  .events-grid {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0;
    background: var(--surface);
    border-radius: var(--r);
    margin: .75rem;
    overflow: hidden;
    box-shadow: var(--sh-sm);
  }
  .event-card {
    border-radius: 0;
    box-shadow: none;
    border-bottom: 1px solid var(--border);
    min-height: 96px;
  }
  .event-card:last-child { border-bottom: none; }
  .event-card:hover { transform: none; box-shadow: none; }
  .event-card:active { background: var(--surface-2); }
  .event-card .flyer-wrap {
    width: 96px; min-width: 96px;
    height: auto; aspect-ratio: auto;
    border-radius: 0;
    min-height: 96px;
  }
  .event-card .card-body { padding: .65rem .85rem; }
  .event-card .card-title { font-size: .88rem; }
}


/* ─── Page header ────────────────────────────────────────── */
.page-header {
  background: linear-gradient(145deg, var(--brand) 0%, var(--brand-mid) 100%);
  color: #fff;
  padding: 2rem 1.25rem 1.75rem;
  text-align: center;
}
.page-header h1 { font-size: 1.65rem; font-weight: 700; margin-bottom: .35rem; letter-spacing: -.5px; }
.page-header p  { opacity: .8; font-size: .92rem; }
@media (max-width: 767px) {
  .page-header { padding: 1.4rem 1rem 1.6rem; border-radius: 0 0 20px 20px; }
  .page-header h1 { font-size: 1.3rem; }
}

/* ─── Upload zone ────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--r);
  padding: 2rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: background .2s, border-color .2s;
  background: var(--surface);
  position: relative;
}
.upload-zone:hover,
.upload-zone.drag-over { background: var(--brand-pale); border-color: var(--brand-mid); }
.upload-zone .upload-icon { font-size: 2.5rem; margin-bottom: .5rem; }
.upload-zone p { color: var(--text-2); font-size: .9rem; }

/* ─── Form ───────────────────────────────────────────────── */
.form-group { margin-bottom: .9rem; }
.form-group label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  margin-bottom: .3rem;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.form-control {
  width: 100%;
  padding: .6rem .85rem;
  min-height: 44px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: .95rem;
  transition: border-color .15s, box-shadow .15s;
  background: var(--surface);
  color: var(--text-1);
  -webkit-appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--brand-mid);
  box-shadow: 0 0 0 3px rgba(46,139,87,.12);
}

/* ─── Filter bar ─────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: .4rem;
  padding: .55rem .85rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 68px;
  z-index: 90;
  align-items: center;
}
.filter-bar input, .filter-bar select {
  padding: .42rem .7rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: .85rem;
  background: var(--surface);
  color: var(--text-1);
  min-height: 38px;
  -webkit-appearance: none;
}
.filter-bar input:focus, .filter-bar select:focus {
  outline: none; border-color: var(--brand-mid);
}
@media (max-width: 767px) {
  .filter-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: .45rem .75rem;
    gap: .35rem;
  }
  .filter-bar::-webkit-scrollbar { display: none; }
  .filter-bar input[type="text"] { min-width: 130px; flex-shrink: 0; }
  .filter-bar select,
  .filter-bar .date-pill,
  .filter-bar .advanced-toggle-btn { flex-shrink: 0; }
  .filter-bar .filter-vsep { flex-shrink: 0; }
  .filter-bar .filter-clear { display: none; }
}

/* ─── Filter extras ──────────────────────────────────────── */
.filter-sep  { font-size: .75rem; color: var(--text-2); white-space: nowrap; }
.filter-vsep { width: 1px; height: 18px; background: var(--border); flex-shrink: 0; }
.filter-clear { font-size: .75rem; color: var(--text-2); cursor: pointer; padding: .3rem .4rem; }
.filter-clear:hover { color: var(--brand); }
.date-pill {
  padding: .3rem .65rem;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  font-size: .78rem;
  cursor: pointer;
  white-space: nowrap;
  background: var(--surface);
  color: var(--text-2);
  transition: all .15s;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
}
.date-pill:hover:not(.active) { border-color: var(--brand-mid); color: var(--brand); }
.date-pill.active { background: var(--brand-mid); color: #fff; border-color: var(--brand-mid); }
.advanced-toggle-btn {
  padding: .3rem .6rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: .75rem;
  cursor: pointer;
  background: var(--surface);
  color: var(--text-2);
  white-space: nowrap;
  min-height: 34px;
}
.advanced-toggle-btn.open { border-color: #999; color: var(--text-1); }
.advanced-panel {
  display: none;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  padding: .5rem .85rem;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
}
.advanced-panel.open { display: flex; }
.advanced-panel input[type="date"] {
  color-scheme: light;
  padding: .34rem .6rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: .85rem;
  background: var(--surface);
  min-height: 38px;
}
.advanced-panel label { font-size: .8rem; color: var(--text-2); }
.view-toggle { display: flex; gap: .25rem; margin-left: auto; flex-shrink: 0; }
.view-btn {
  padding: .34rem .7rem;
  border-radius: var(--r-sm);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  transition: all .15s;
  min-height: 34px;
}
.view-btn.active { background: var(--brand-mid); color: #fff; border-color: var(--brand-mid); }

/* ─── Count bar ──────────────────────────────────────────── */
#count-bar {
  padding: .35rem 1rem;
  font-size: .76rem;
  color: var(--text-2);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

/* ─── Map ────────────────────────────────────────────────── */
#map { height: 100%; width: 100%; }
.map-popup-img { width: 100%; border-radius: 6px; margin-bottom: .5rem; max-height: 120px; object-fit: cover; }
.map-popup h4  { margin-bottom: .25rem; font-size: .9rem; font-weight: 600; }
.map-popup p   { font-size: .8rem; color: #555; margin: .12rem 0; }
.leaflet-popup-content { min-width: 170px; }

/* ─── Modal / Bottom sheet ───────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  max-width: 540px;
  width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: var(--sh-lg);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--surface);
  z-index: 1;
}
.modal-header h3 { font-size: 1.05rem; font-weight: 700; }
.modal-header-controls { display: flex; align-items: center; gap: .5rem; }
.modal-actions { display: flex; align-items: center; gap: .35rem; }

/* ── Desktop: two-column modal ── */
@media (min-width: 768px) {
  .modal {
    max-width: 900px;
    width: 92vw;
    max-height: 88dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-radius: 16px;
  }
  .modal-header {
    flex-shrink: 0;
    justify-content: flex-end;
    border-bottom: none;
    padding: .55rem .8rem;
    position: static;
  }
  /* Hide mobile-only elements on desktop */
  .modal-header h3,
  .modal-header .modal-actions { display: none; }

  .modal-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    overflow: hidden;
    flex: 1;
    min-height: 0;
    padding: 0;
  }
  .modal-col-left {
    background: #111;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0 0 0 16px;
  }
  .modal-col-left #modal-media { width: 100%; height: 100%; }
  .modal-col-left #modal-media > img {
    width: 100%; height: 100%;
    object-fit: cover; display: block;
  }
  .modal-col-left .modal-gallery { max-height: 100%; height: 100%; }
  .modal-col-left .modal-gallery-item img { height: 100%; max-height: 100%; }
  .modal-col-right {
    overflow-y: auto;
    padding: 1.5rem 1.75rem;
  }
  /* Desktop title and actions (rendered in body) */
  .modal-desk-title {
    font-size: 1.35rem; font-weight: 700;
    line-height: 1.3; margin-bottom: .7rem;
  }
  .modal-desk-actions {
    display: flex; gap: .4rem; margin-bottom: 1.1rem;
  }
}
@media (max-width: 767px) {
  .modal-col-left, .modal-col-right { display: contents; }
  .modal-desk-title, .modal-desk-actions { display: none; }
}
/* ── Form modal: single-column centered dialog (resets two-column) ── */
@media (min-width: 768px) {
  .modal.modal-form {
    max-width: 620px;
    width: 94vw;
    max-height: 90dvh;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    border-radius: var(--r-lg);
  }
  .modal.modal-form .modal-header {
    flex-shrink: 0;
    position: sticky;
    top: 0;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--border);
    justify-content: space-between;
    background: var(--surface);
    z-index: 1;
  }
  .modal.modal-form .modal-header h2,
  .modal.modal-form .modal-header h3 { display: block; }
  .modal.modal-form .modal-header .modal-actions { display: flex; }
  .modal.modal-form .modal-body {
    display: block;
    overflow-y: visible;
    flex: 1;
    padding: 1.2rem;
  }
}
.icon-btn,
.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.08);
  background: rgba(0,0,0,.03);
  color: var(--text);
  cursor: pointer;
  font-size: 0;
  transition: background .15s, transform .15s, border-color .15s;
  text-decoration: none;
}
.icon-btn:hover,
.icon-link:hover {
  background: rgba(0,0,0,.06);
  transform: translateY(-1px);
}
.icon-btn img,
.icon-link img,
.action-btn img {
  width: 18px;
  height: 18px;
  display: block;
}
.icon-btn.icon-emoji,
.action-btn.icon-emoji {
  font-size: 1.1rem;
}
.modal-body { padding: 1.2rem; }
.modal-footer { padding: 1rem 1.2rem; border-top: 1px solid var(--border); display: flex; gap: .6rem; justify-content: flex-end; }
.btn-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text-2); line-height: 1; padding: .2rem; }
@media (max-width: 767px) {
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal {
    border-radius: 20px 20px 0 0;
    max-height: 92dvh;
    animation: sheetUp .28s cubic-bezier(.4,0,.2,1);
  }
  .modal-header::before {
    content: '';
    display: block; position: absolute;
    top: 7px; left: 50%; transform: translateX(-50%);
    width: 36px; height: 4px;
    background: var(--border); border-radius: 2px;
  }
  .modal-header {
    position: relative;
    padding-top: 1.4rem;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0;
  }
  /* Controls (✕ + icone) in alto a destra */
  .modal-header-controls {
    margin-left: auto;
    flex-direction: column-reverse; /* ✕ in cima, icone sotto */
    align-items: flex-end;
    gap: .45rem;
  }
  /* Titolo: riga intera sotto i controlli */
  .modal-header h3 {
    order: 2;
    width: 100%;
    font-size: 1.1rem;
    line-height: 1.35;
    padding-top: .65rem;
    white-space: normal;
  }
}
@keyframes sheetUp {
  from { transform: translateY(48px); opacity: .7; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ─── Preview image ──────────────────────────────────────── */
.flyer-preview-wrap {
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--sh-sm);
}
.flyer-preview-wrap img { width: 100%; height: 100%; object-fit: cover; background: #000; }

/* ─── Toast ──────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 5rem; right: 1rem; z-index: 9999;
  display: flex; flex-direction: column; gap: .4rem;
}
.toast {
  background: #1F2937;
  color: #fff;
  padding: .7rem 1rem;
  border-radius: var(--r-sm);
  font-size: .86rem;
  animation: slideIn .25s ease;
  display: flex; align-items: center; gap: .45rem;
  max-width: 300px;
  box-shadow: var(--sh-md);
}
.toast.success { background: var(--brand); }
.toast.error   { background: #DC2626; }
.toast.warning { background: #D97706; }
@keyframes slideIn { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── Spinner / Loading ──────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 26px; height: 26px;
  border: 2.5px solid var(--brand-light);
  border-top-color: var(--brand-mid);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto;
}

/* ─── AI Loading overlay ─────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: 1rem;
}
.ai-loading-card {
  background: #fff;
  border-radius: 28px;
  box-shadow: 0 24px 64px rgba(0,0,0,.13), 0 0 0 1px rgba(0,0,0,.04);
  padding: 2rem 1.75rem 1.5rem;
  width: 100%; max-width: 296px;
  display: flex; flex-direction: column; align-items: center; gap: 1.1rem;
  animation: aiCardIn .32s cubic-bezier(.34,1.46,.64,1);
}
@keyframes aiCardIn {
  from { opacity: 0; transform: scale(.85); }
  to   { opacity: 1; transform: scale(1); }
}
.ai-loading-icon {
  position: relative; width: 72px; height: 72px;
  display: flex; align-items: center; justify-content: center;
}
.ai-loading-icon::before {
  content: '';
  position: absolute; inset: -8px; border-radius: 50%;
  background: radial-gradient(circle, rgba(0,146,70,.18) 0%, rgba(0,146,70,0) 70%);
  animation: logoHalo 1.8s ease-in-out infinite;
}
@keyframes logoHalo {
  0%,100% { transform: scale(1); opacity: .7; }
  50%      { transform: scale(1.35); opacity: 0; }
}
.ai-loading-icon-inner {
  width: 72px; height: 72px; border-radius: 18px;
  display: block; object-fit: cover;
  animation: logoPulse 1.8s ease-in-out infinite;
  box-shadow: 0 4px 18px rgba(0,100,50,.18);
}
@keyframes logoPulse {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.07); }
}
.ai-loading-title {
  font-size: 1rem; font-weight: 700; color: var(--text-1);
  text-align: center; margin-bottom: .2rem;
}
.ai-loading-subtitle {
  font-size: .82rem; color: var(--text-2); text-align: center;
  min-height: 1.2em; line-height: 1.4;
}
.ai-steps {
  width: 100%; display: flex; flex-direction: column; gap: .55rem;
  padding: .75rem 1rem;
  background: var(--surface-2);
  border-radius: var(--r);
}
.ai-step {
  display: flex; align-items: center; gap: .7rem;
  font-size: .83rem; color: var(--border);
  transition: color .4s;
}
.ai-step-dot {
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
  background: var(--border);
  transition: background .4s;
  position: relative;
}
.ai-step.active { color: var(--brand); font-weight: 600; }
.ai-step.active .ai-step-dot {
  background: var(--brand);
  animation: dotPulse 1.1s ease-in-out infinite;
}
@keyframes dotPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(0,122,56,.4); }
  55%      { box-shadow: 0 0 0 6px rgba(0,122,56,0); }
}
.ai-step.done { color: var(--text-2); }
.ai-step.done .ai-step-dot { background: var(--brand); }
.ai-step.done .ai-step-dot::after {
  content: '';
  position: absolute;
  left: 4px; top: 2px;
  width: 4px; height: 7px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(35deg);
}
.ai-loading-timer {
  font-size: .75rem; color: var(--text-2);
  min-height: 1.1em; letter-spacing: .03em;
}

/* ─── Status chips ───────────────────────────────────────── */
.status-pending   { background: #FEF9C3; color: #854D0E; }
.status-approved  { background: var(--brand-light); color: var(--brand); }
.status-rejected  { background: #FEE2E2; color: #991B1B; }
.status-duplicate { background: #DBEAFE; color: #1E40AF; }
.status-non_target { background: #FDE68A; color: #92400E; }
.status-scaduta              { background: #F3F4F6; color: #4B5563; }
.status-data_da_confermare  { background: #FFEDD5; color: #9A3412; }
.status-parked               { background: #E5E7EB; color: #374151; }

/* ─── Admin layout ───────────────────────────────────────── */
.admin-layout { display: flex; min-height: calc(100dvh - 52px); }
.sidebar {
  width: 210px; flex-shrink: 0;
  background: var(--brand); color: #fff;
  padding: 1rem 0; display: flex; flex-direction: column;
}
.sidebar-item {
  display: flex; align-items: center; gap: .55rem;
  padding: .65rem 1.1rem; cursor: pointer;
  font-size: .88rem; font-weight: 500;
  transition: background .15s;
  border-left: 3px solid transparent;
  color: rgba(255,255,255,.8);
}
.sidebar-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-item.active { background: rgba(255,255,255,.15); border-left-color: #fff; font-weight: 600; color: #fff; }
.sidebar-section { padding: .6rem 1.1rem .2rem; font-size: .68rem; color: rgba(255,255,255,.45); letter-spacing: 1px; text-transform: uppercase; margin-top: .6rem; }
.admin-main { flex: 1; padding: 1.5rem; overflow-y: auto; min-width: 0; }

/* ─── Admin stats ────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .85rem; margin-bottom: 1.4rem; }
.stat-card { background: var(--surface); border-radius: var(--r); padding: 1rem 1.1rem; box-shadow: var(--sh-sm); }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: .75rem; color: var(--text-2); margin-top: .3rem; }
.stat-card[data-section] { cursor: pointer; transition: box-shadow .15s, transform .1s; }
.stat-card[data-section]:hover { box-shadow: var(--sh-md); transform: translateY(-1px); }

/* ─── Admin table ────────────────────────────────────────── */
.admin-table-wrap { background: var(--surface); border-radius: var(--r); box-shadow: var(--sh-sm); overflow: hidden; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.admin-table th { background: var(--brand-pale); padding: .65rem .8rem; text-align: left; font-size: .74rem; color: var(--text-2); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; border-bottom: 2px solid var(--border); }
.admin-table td { padding: .6rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--brand-pale); }
.admin-table tr.selected td { background: #ECFDF5; }
.cb { width: 16px; height: 16px; cursor: pointer; accent-color: var(--brand-mid); }
th.cb-col, td.cb-col { width: 36px; padding-left: 1rem; }
.flyer-thumb { width: 40px; height: 52px; object-fit: cover; border-radius: 4px; }
.flyer-thumb-placeholder { width: 40px; height: 52px; border-radius: 4px; background: var(--brand-pale); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.actions { display: flex; gap: .25rem; flex-wrap: wrap; }

/* ─── Admin filter bar ───────────────────────────────────── */
.admin-filter-bar { display: flex; gap: .55rem; margin-bottom: .8rem; flex-wrap: wrap; align-items: center; }
.admin-filter-bar select, .admin-filter-bar input {
  padding: .42rem .75rem; border: 1.5px solid var(--border);
  border-radius: var(--r-sm); font-size: .86rem; min-height: 38px;
  background: var(--surface); color: var(--text-1);
}
.admin-filter-bar select:focus, .admin-filter-bar input:focus { outline: none; border-color: var(--brand-mid); }

/* ─── Bulk bar ───────────────────────────────────────────── */
.bulk-bar {
  display: none; align-items: center; gap: .7rem;
  background: #14532D; color: #fff;
  padding: .65rem 1rem; border-radius: var(--r-sm);
  margin-bottom: .75rem; flex-wrap: wrap;
}
.bulk-bar.visible { display: flex; }
.bulk-bar .bulk-count { font-weight: 600; font-size: .9rem; flex: 1; }
.bulk-bar .btn { font-size: .8rem; padding: .3rem .75rem; min-height: 34px; }

/* ─── Admin detail tabs ──────────────────────────────────── */
.det-tab {
  padding: .55rem 1.1rem; border: none; background: transparent;
  font-size: .88rem; cursor: pointer; color: var(--text-2);
  border-bottom: 3px solid transparent; font-family: var(--font);
}
.det-tab.active { color: var(--brand); border-bottom-color: var(--brand-mid); font-weight: 700; }
.det-tab:hover:not(.active) { background: var(--brand-pale); }

/* ─── Unified event edit modal ───────────────────────────── */
.modal.modal-event-edit {
  max-width: 820px;
  width: 96vw;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg);
  overflow: hidden;
}
.edit-tab-panel {
  flex: 1;
  overflow-y: auto;
  display: block;
}
@media (max-width: 600px) {
  .modal.modal-event-edit { max-height: 100dvh; border-radius: 0; width: 100vw; }
}

/* ─── Admin login ────────────────────────────────────────── */
#login-screen { position: fixed; inset: 0; background: var(--brand-pale); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.login-box { background: var(--surface); border-radius: var(--r-lg); padding: 2.5rem 2rem; box-shadow: var(--sh-lg); max-width: 360px; width: 100%; text-align: center; }
.login-box h2 { font-size: 1.4rem; margin-bottom: .2rem; font-weight: 700; }
.login-box p  { color: var(--text-2); font-size: .88rem; margin-bottom: 1.4rem; }

/* ─── Admin mobile bottom nav ────────────────────────────── */
.mobile-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  background: var(--brand);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -1px 0 rgba(0,0,0,.15);
}
.mobile-nav-items { display: flex; justify-content: space-around; }
.mobile-nav-item {
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
  color: rgba(255,255,255,.65); font-size: .6rem; font-weight: 500;
  padding: .5rem .4rem; cursor: pointer; flex: 1;
  transition: color .15s;
}
.mobile-nav-item.active { color: #fff; }
.mobile-nav-item span:first-child { font-size: 1.2rem; line-height: 1.2; }

/* ─── Admin responsive ───────────────────────────────────── */
@media (max-width: 700px) {
  .sidebar { display: none; }
  .mobile-nav { display: block; }
  .admin-main { padding: 1rem .75rem calc(60px + env(safe-area-inset-bottom, 0px) + 1rem); }
  .admin-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .admin-table { min-width: 560px; }
  .admin-table td:nth-child(4), .admin-table th:nth-child(4) { display: none; }
  .admin-table td:nth-child(5), .admin-table th:nth-child(5) { display: none; }
  .admin-filter-bar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .admin-filter-bar::-webkit-scrollbar { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
  .stat-card .stat-value { font-size: 1.5rem; }
  .field-row { flex-direction: column; }
}

/* ─── Search advanced toggle ────────────────────────────── */
.sp-filter-btn {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f5f5f5;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.sp-filter-btn.active { background: var(--brand-pale); border-color: var(--brand); color: var(--brand); }
.sp-advanced { display: flex; flex-direction: column; gap: .45rem; padding-top: .2rem;
               max-height: 0; overflow: hidden; opacity: 0; pointer-events: none;
               transition: max-height .25s ease, opacity .2s ease; }
.sp-advanced.open { max-height: 300px; opacity: 1; pointer-events: auto; }

/* ─── Bottom Navigation Bar ─────────────────────────────── */
.bottom-nav {
  display: none;
}
@media (max-width: 767px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(50px + env(safe-area-inset-bottom, 0px));
    background: #fff;
    border-top: 1px solid var(--border);
    z-index: 300;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -1px 10px rgba(0,0,0,.08);
  }
  .bottom-nav-item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-muted);
    text-decoration: none;
    padding: 0;
    transition: color .15s;
    -webkit-tap-highlight-color: transparent;
  }
  .bottom-nav-item.active,
  .bottom-nav-item.active svg { color: var(--brand); stroke: var(--brand); }
  .bottom-nav-item:active { opacity: .65; }
  /* Navbar: nasconde il toggle vista su mobile (gestito dalla bottom nav) */
  #navbar-view-btn { display: none !important; }
  /* Evita che il contenuto finisca sotto la barra fissa */
  body:has(.bottom-nav) { padding-bottom: calc(50px + env(safe-area-inset-bottom, 0px)); }

  /* ── Bottone "Aggiungi" sollevato ──────────────────────── */
  .bottom-nav { overflow: visible; }
  .bn-add {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    padding: 0;
    margin-top: -14px;
    -webkit-tap-highlight-color: transparent;
  }
  .bn-add-circle {
    width: 50px; height: 50px;
    border-radius: 50%;
    background: var(--brand);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 3px 14px rgba(232,93,38,.42);
    color: #fff;
    transition: transform .15s, box-shadow .15s;
  }
  .bn-add:active .bn-add-circle {
    transform: scale(.91);
    box-shadow: 0 1px 6px rgba(232,93,38,.28);
  }
  .bn-add-label {
    font-size: .6rem; font-weight: 700; color: var(--brand);
    margin-top: 2px; letter-spacing: .3px; text-transform: uppercase;
  }

  /* Nasconde il FAB dove c'è già il bottone nella bottom nav */
  body:has(.bottom-nav) .fab-photo { display: none; }
}

/* ─── FAB (Floating Action Button) ──────────────────────── */
.fab-photo {
  position: fixed;
  bottom: 1.75rem;
  right: 1.5rem;
  z-index: 150;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .85rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-size: .92rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(255,107,53,.35);
  transition: transform .15s, box-shadow .15s, padding .3s ease, width .3s ease;
  white-space: nowrap;
  letter-spacing: -.1px;
  overflow: hidden;
}
.fab-photo:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(255,107,53,.45);
}
.fab-photo:active { transform: scale(.96); }

/* Icon-only state: compact pill */
.fab-photo--icon-only { padding: .85rem; }
.fab-photo--icon-only .fab-expand-label { display: none; }

/* Expanded state: show label */
.fab-photo--expanded { padding: .85rem 1.4rem; }
.fab-photo--expanded .fab-expand-label { display: inline; }

.fab-expand-label { display: none; }

@media (max-width: 767px) {
  .fab-photo {
    bottom: calc(50px + env(safe-area-inset-bottom, 0px) + .75rem);
    right: 1rem;
    padding: .75rem;
  }
  .fab-photo--icon-only { padding: .75rem; }
  .fab-photo--expanded  { padding: .75rem 1.2rem; font-size: .88rem; }
}

/* ─── Navbar hamburger ───────────────────────────────────── */
.navbar-hamburger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: none;
  border-radius: var(--r-sm);
  color: var(--brand);
  cursor: pointer;
  padding: .4rem .6rem;
  font-size: 1.2rem;
  line-height: 1;
}
.navbar-hamburger:hover { background: var(--brand-light); }
@media (max-width: 767px) {
  .tab-bar          { display: none !important; }
  body              { padding-bottom: 0 !important; }
  .navbar-hamburger { display: inline-flex; }
  .navbar-nav       { display: none !important; }
  .mobile-photo-btn { display: none !important; }
}

/* ─── Nav drawer (slide-in da sinistra) ───────────────────── */
.nav-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 400;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.nav-drawer-overlay.open { display: block; }
.nav-drawer {
  position: fixed;
  top: 0;
  left: -100%;
  width: min(75vw, 280px);
  height: 100dvh;
  background: var(--surface);
  z-index: 401;
  transition: left .28s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0,0,0,.18);
  overflow-y: auto;
}
.nav-drawer.open { left: 0; }
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 1.25rem;
  background: var(--brand);
  color: #fff;
  flex-shrink: 0;
}
.drawer-brand { font-size: 1.1rem; font-weight: 700; letter-spacing: -.3px; }
.drawer-close-btn {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: .95rem;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s;
}
.drawer-close-btn:hover { background: rgba(255,255,255,.3); }
.drawer-links {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: .4rem 0;
}
.drawer-links a,
.drawer-user a {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .85rem 1.25rem;
  color: var(--text-1);
  font-size: .95rem;
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.drawer-links a:hover, .drawer-user a:hover { background: var(--surface-2); text-decoration: none; }
.drawer-links a.active, .drawer-user a.active { color: var(--brand); font-weight: 700; }
.drawer-user {
  border-bottom: 2px solid var(--border);
  padding: .4rem 0;
}
.drawer-user a:last-child { border-bottom: none; }
.drawer-login-btn { color: var(--brand) !important; font-weight: 700 !important; }
.drawer-sagrini-chip {
  margin-left: auto;
  font-size: .76rem; font-weight: 700;
  background: rgba(245,158,11,.14);
  color: #92400e;
  border-radius: 99px; padding: .12rem .55rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.drawer-social {
  display: flex;
  gap: 8px;
  padding: .9rem 1.25rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.drawer-social a {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: center;
  padding: .5rem;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--gray-2);
  text-decoration: none;
  background: var(--surface-2);
  transition: background .15s, color .15s;
}
.drawer-social a:hover { background: var(--surface-3, #e5e7eb); color: var(--gray-1); }

/* ─── Search wrap (inline clear button) ─────────────────── */
.search-wrap {
  flex: 1;
  min-width: 160px;
  position: relative;
  display: flex;
  align-items: center;
}
.search-wrap input {
  width: 100%;
  padding-right: 1.8rem !important;
}
.search-clear {
  position: absolute;
  right: .4rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-2);
  font-size: .8rem;
  padding: .25rem;
  line-height: 1;
  display: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s;
}
.search-clear:hover { background: var(--border); color: var(--text-1); }

/* ─── Filter bar – expand button (mobile only) ───────────── */
.filter-expand-btn {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-2);
  cursor: pointer;
  padding: .35rem .5rem;
  min-height: 38px;
  flex-shrink: 0;
  transition: border-color .12s, color .12s;
}
.filter-expand-btn:hover { border-color: var(--brand-mid); color: var(--brand); }
.filter-expand-btn svg { transition: transform .22s ease; }
.filter-expand-btn.open svg { transform: rotate(180deg); }
@media (max-width: 767px) {
  .filter-expand-btn { display: inline-flex; }
  /* nasconde tutto tranne search-wrap, view-toggle e expand btn */
  .filter-bar .filter-extra { display: none !important; }
  /* quando espanso */
  .filter-bar.mob-expanded { flex-wrap: wrap; overflow-x: hidden; }
  .filter-bar.mob-expanded .filter-extra { display: flex !important; }
  .filter-bar.mob-expanded select.filter-extra { display: block !important; }
}
@media (min-width: 768px) {
  .filter-expand-btn { display: none !important; }
  .filter-bar .filter-extra { display: flex !important; }
  .filter-bar select.filter-extra { display: block !important; }
}

/* ─── Map bottom sheet (mobile Airbnb style) ─────────────── */
@media (max-width: 767px) {
  #view-map {
    position: fixed;
    top: calc(68px + var(--sp-h, 0px));
    left: 0; right: 0;
    bottom: calc(50px + env(safe-area-inset-bottom, 0px));
    z-index: 1;
    overflow: hidden;
    transition: top .18s ease;
  }
  #map-container {
    position: absolute !important;
    inset: 0 !important;
    height: 100% !important;
    z-index: 1;
  }
  .map-sheet {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    z-index: 2;
    background: var(--surface);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 45%;
    will-change: height;
    touch-action: none;
  }
  .map-sheet-handle {
    width: 44px; height: 5px;
    background: var(--border);
    border-radius: 2px;
    margin: 10px auto 2px;
    flex-shrink: 0;
    cursor: grab;
    touch-action: none;
    position: relative; /* necessario per ::before */
  }
  /* area hit allargata (più facile da toccare) */
  .map-sheet-handle::before {
    content: '';
    position: absolute;
    top: -14px; left: -20px; right: -20px; height: 44px;
    cursor: grab;
  }
  .map-sheet-header {
    padding: .45rem 1rem .4rem;
    font-size: .78rem;
    color: var(--text-2);
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: .5rem;
    cursor: grab;
    touch-action: none; /* tutta la header strip è trascinabile */
    user-select: none;
  }
  .sheet-reset-btn {
    margin-left: auto;
    background: none;
    border: 1px solid var(--border);
    border-radius: 99px;
    color: var(--brand);
    font-size: .7rem;
    font-weight: 600;
    padding: .15rem .5rem;
    cursor: pointer;
    white-space: nowrap;
  }
  .map-sheet-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y; /* scroll libero nel body */
  }
}
@media (min-width: 768px) {
  .map-sheet { display: none !important; }
}

/* ─── Sheet event cards ──────────────────────────────────── */
.sheet-event-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
  -webkit-tap-highlight-color: transparent;
}
.sheet-event-item:active { background: var(--surface-2); }
.sheet-event-flyer {
  width: 52px; height: 52px;
  border-radius: var(--r-sm);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--brand-pale);
}
.sheet-event-flyer img { width: 100%; height: 100%; object-fit: cover; }
.sheet-flyer-ph {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
}
.sheet-event-info { flex: 1; min-width: 0; }
.sheet-event-title {
  font-size: .88rem; font-weight: 600; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text-1);
}
.sheet-event-meta {
  font-size: .73rem; color: var(--text-2); margin-top: .15rem;
  display: flex; flex-direction: column; gap: .1rem;
}

/* ─── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── Misc ───────────────────────────────────────────────── */
.field-row { display: flex; gap: 1rem; }
.field-row .form-group { flex: 1; }

/* ─── SAGRINI ─── */

.sagrini-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 20px;
  background: rgba(255, 193, 7, 0.12);
  text-decoration: none; color: var(--text-1, #333);
  font-weight: 600; font-size: 0.85rem;
  transition: background 0.2s, transform 0.2s;
  margin-right: 4px;
}
.sagrini-badge:hover { background: rgba(255, 193, 7, 0.25); transform: scale(1.05); }
.sagrini-icon { font-size: 1rem; }

.sagrini-bump { animation: sagrini-bump 0.6s ease; }
@keyframes sagrini-bump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.4); color: #f59e0b; }
  100% { transform: scale(1); }
}

.sagrini-toast {
  position: fixed; top: 20px; right: 20px; z-index: 10000;
  padding: 12px 20px; background: #1a1a1a; color: #fff;
  border-radius: 14px; box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  transform: translateX(120%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 280px;
}
.sagrini-toast.show { transform: translateX(0); }
.sagrini-toast-content { display: flex; align-items: center; gap: 8px; }
.sagrini-toast-icon { font-size: 1.3rem; animation: sagrini-coin-spin 0.8s ease; }
@keyframes sagrini-coin-spin {
  0%   { transform: rotateY(0); }
  50%  { transform: rotateY(180deg); }
  100% { transform: rotateY(360deg); }
}
.sagrini-toast-text { font-weight: 700; font-size: 0.95rem; }
.sagrini-toast-milestone {
  margin-top: 6px; padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.15);
  font-size: 0.8rem; color: #fbbf24;
}
@media (max-width: 767px) {
  .sagrini-toast { top: auto; bottom: 70px; right: 12px; left: 12px; max-width: none; }
}

/* ─── SAGRINI profilo ─── */

.sagrini-header { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.sagrini-balance-big { font-size: 2rem; font-weight: 800; color: var(--text-1); }
.sagrini-level-badge {
  padding: 4px 12px; border-radius: 20px; font-size: 0.85rem; font-weight: 600;
}
.sagrini-level-esploratore { background: #f3f4f6; color: #6b7280; }
.sagrini-level-contributor  { background: #fef3c7; color: #92400e; }
.sagrini-level-ambassador   { background: #fde68a; color: #78350f; }

.sagrini-progress-wrap { margin-bottom: 12px; }
.sagrini-progress-bar { height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; margin-bottom: 6px; }
.sagrini-progress-fill { height: 100%; background: linear-gradient(to right, #fbbf24, #f59e0b); border-radius: 4px; transition: width 0.5s ease; }
.sagrini-progress-label { font-size: 0.8rem; color: var(--text-2); margin: 0; }
.sagrini-max-level { color: var(--brand); font-weight: 600; margin-bottom: 12px; }

.sagrini-milestones { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.sagrini-milestone-chip { padding: 4px 10px; background: #fef9c3; color: #854d0e; border-radius: 20px; font-size: 0.8rem; font-weight: 600; }

.sagrini-history-title { font-size: 0.9rem; font-weight: 600; color: var(--text-2); margin: 16px 0 8px; text-transform: uppercase; letter-spacing: 0.04em; }
.sagrini-history { list-style: none; padding: 0; margin: 0; }
.sagrini-history-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border, #e5e7eb); gap: 8px; }
.sagrini-history-label { font-size: 0.9rem; color: var(--text-1); flex: 1; }
.sagrini-history-right { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.sagrini-history-amount { font-weight: 700; font-size: 0.9rem; color: var(--text-2); }
.sagrini-history-amount.positive { color: #16a34a; }
.sagrini-history-date { font-size: 0.75rem; color: var(--text-2); }
.sagrini-empty, .sagrini-login-prompt { color: var(--text-2); font-size: 0.9rem; margin: 0; }
