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

/* ─── Tokens ─────────────────────────────────────────────── */
:root {
  --brand:       #1E6B3E;
  --brand-mid:   #2E8B57;
  --brand-light: #D4EDDA;
  --brand-pale:  #F0FAF3;
  --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);
}
/* 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;
}
.navbar-brand img {
  height: 44px;
  display: block;
  max-width: 220px;
  object-fit: contain;
}
.navbar-right {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: .35rem;
  min-width: 44px;
  justify-content: flex-end;
}
.navbar-brand span { 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-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: 52px;
  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; }
.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 ──────────────────────────────────── */
.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;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; flex-direction: column; gap: .8rem;
  font-size: .9rem; color: var(--text-2);
  backdrop-filter: blur(4px);
}

/* ─── 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; }

/* ─── 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); }

/* ─── 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; }
}

/* ─── 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 1.4rem;
  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;
  white-space: nowrap;
  letter-spacing: -.1px;
}
.fab-photo:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(255,107,53,.45);
}
.fab-photo:active { transform: scale(.96); }
.fab-label-desktop { display: inline; }
.fab-label-mobile  { display: none; }
@media (max-width: 767px) {
  .fab-photo {
    bottom: 1.25rem;
    right: 1rem;
    padding: .75rem 1.2rem;
    font-size: .88rem;
  }
  .fab-label-desktop { display: none; }
  .fab-label-mobile  { display: inline; }
}

/* ─── Navbar hamburger ───────────────────────────────────── */
.navbar-hamburger {
  display: none;
  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 !important; }
  .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; }

/* ─── 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: 52px;
    left: 0; right: 0;
    bottom: 0;
    z-index: 1;
    overflow: hidden;
  }
  #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; }
