/* Escursioni v2 — un solo foglio, mobile-first. */
:root {
  --bg: #f6f4ee;
  --surface: #ffffff;
  --ink: #1c2321;
  --muted: #5f6b66;
  --line: #dcd8cc;
  --brand: #14532d;
  --brand-ink: #ffffff;
  --brand-soft: #e3efe6;
  --accent: #c2410c;
  --warn-bg: #fff4e0;
  --warn-ink: #8a4b00;
  --err: #b42318;
  --err-bg: #fdecea;
  --ok-bg: #e6f4ea;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(28, 35, 33, .06), 0 6px 20px rgba(28, 35, 33, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 var(--font); color: var(--ink); background: var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
img { max-width: 100%; height: auto; }
a { color: var(--brand); text-underline-offset: .18em; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 5vw, 2.2rem); }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
[hidden] { display: none !important; }
.sr-only, .hp { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--brand); color: #fff; padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid #f59e0b; outline-offset: 2px; }

/* ---------- barra in alto ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.admin .topbar { position: sticky; top: 0; z-index: 5; }
.brand img { display: block; height: 44px; width: auto; }
.lang-switch { display: flex; gap: 2px; background: var(--bg); border-radius: 999px; padding: 3px; }
.lang-switch a { display: inline-flex; align-items: center; justify-content: center; min-width: 38px; min-height: 36px; padding: 0 6px; border-radius: 999px; font-size: .8rem; font-weight: 600; text-decoration: none; color: var(--muted); }
.lang-switch a[aria-current] { background: var(--brand); color: var(--brand-ink); }

.wrap { width: 100%; max-width: 720px; margin: 0 auto; padding: 20px 16px 40px; flex: 1; }
.wrap.wide { max-width: 1180px; }
.wrap.narrow { max-width: 420px; }

.site-footer { text-align: center; padding: 20px 16px 28px; color: var(--muted); font-size: .85rem; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }

/* ---------- elementi comuni ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px; box-shadow: var(--shadow); margin: 0 0 18px; }
.card.center { text-align: center; padding: 32px 20px; }
.lead { font-size: 1.05rem; color: var(--muted); }
.hint { color: var(--muted); font-size: .85rem; font-weight: 400; margin: 4px 0 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .02em; }
.pre { white-space: pre-line; }
.empty { color: var(--muted); padding: 12px 0; }
.center { text-align: center; }
.tag { display: inline-block; font-style: normal; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); margin-left: 6px; vertical-align: middle; }
.tag-warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge { display: inline-block; min-width: 1.5em; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: .75rem; font-weight: 700; text-align: center; }
.muted-badge { background: var(--line); color: var(--ink); }

.flash { padding: 12px 14px; border-radius: 10px; margin: 0 0 14px; background: var(--ok-bg); }
.flash-warn { background: var(--warn-bg); color: var(--warn-ink); }
.flash-error { background: var(--err-bg); color: var(--err); font-weight: 600; }

/* ---------- bottoni ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; background: var(--surface); color: var(--ink); }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: #0f3f22; }
.btn-ghost { border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--err-bg); color: var(--err); border-color: #f3c3bd; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.btn-block { width: 100%; font-size: 1.05rem; min-height: 52px; margin-top: 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- form ---------- */
.form h2 { margin-top: 8px; }
.field { margin: 0 0 16px; border: 0; padding: 0; min-width: 0; }
fieldset.field { margin-inline: 0; }
label, legend { display: block; font-weight: 600; margin: 0 0 6px; padding: 0; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; font: inherit; font-size: 16px; color: var(--ink);
  background: #fff; border: 1px solid #c9c4b6; border-radius: 10px; appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 21px, calc(100% - 13px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: 3px solid rgba(20, 83, 45, .18); outline-offset: 0; }
input[type=checkbox], input[type=radio] { width: 22px; height: 22px; accent-color: var(--brand); flex: none; margin: 0; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--err); }
.field-error { color: var(--err); font-size: .88rem; font-weight: 600; margin: 6px 0 0; }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 400; cursor: pointer; }
.check span { padding-top: 1px; }
.grid-2, .grid-3, .grid-4 { display: grid; gap: 0 14px; }
.dob { display: grid; grid-template-columns: 1.05fr 1.8fr 1.15fr; gap: 6px; }
.dob select { padding-left: 10px; padding-right: 26px; background-position: calc(100% - 14px) 21px, calc(100% - 9px) 21px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segmented label { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px; border: 1px solid #c9c4b6; border-radius: 10px; font-weight: 500; margin: 0; cursor: pointer; background: #fff; }
.segmented label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.consent { padding: 14px; background: var(--bg); border-radius: 10px; }

/* ---------- pagina pubblica ---------- */
.hero { padding: 6px 0 14px; }
.news { margin: 0 0 18px; display: grid; gap: 10px; }
.news-item { background: var(--brand); color: #f0f7f2; border-radius: var(--radius); padding: 14px 16px; }
.news-item h3 { color: #fff; margin-bottom: 4px; }
.news-item p { margin: 0; }
.step { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; margin: 6px 0 14px; }
.step span { display: inline-flex; width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; align-items: center; justify-content: center; font-size: .95rem; }
.step:not(:first-of-type) { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.venue-list { display: grid; gap: 10px; }
.venue-card { border: 1px solid #c9c4b6; border-radius: 12px; background: #fff; overflow: hidden; }
.venue-card.is-selected, .venue-card:has(> .venue-head input:checked) { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.venue-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin: 0; font-weight: 400; cursor: pointer; }
.venue-head img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; flex: none; }
.venue-head strong { display: block; font-size: 1.05rem; }
.venue-desc { display: block; color: var(--muted); font-size: .9rem; }
.venue-when { display: none; padding: 4px 14px 14px; border-top: 1px dashed var(--line); background: #fbfaf6; }
.venue-card.is-selected .venue-when, .venue-card:has(> .venue-head input:checked) .venue-when { display: block; }
.when-title { font-weight: 600; margin: 10px 0 8px; font-size: .95rem; }
.choice { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; margin: 0 0 8px; font-weight: 400; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice.is-full { opacity: .6; cursor: not-allowed; }
.preferred { padding: 14px; border-radius: 10px; background: var(--brand-soft); }
.big-check { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 2rem; line-height: 64px; }
.prose h1 { font-size: 1.6rem; }
.prose h2 { margin-top: 1.4em; }
.prose ul { padding-left: 1.2em; }

/* ---------- area operatori ---------- */
.admin-bar { flex-wrap: wrap; padding: 8px 16px; }
.admin-bar .brand img { height: 36px; }
.admin-nav { order: 3; width: 100%; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: 0 -4px; padding-bottom: 2px; }
.admin-nav a { flex: none; padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--ink); font-weight: 600; font-size: .95rem; }
.admin-nav a[aria-current] { background: var(--brand-soft); color: var(--brand); }
.admin-user { display: flex; align-items: center; gap: 8px; }
.admin-user form { margin: 0; }
.admin-user .muted { display: none; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px; margin: 0 0 14px; }
.page-head h1 { margin: 0; }
.meta { color: var(--muted); margin: 4px 0 12px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 0 0 12px; border-bottom: 1px solid var(--line); }
.tabs a { flex: none; padding: 10px 12px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; }
.tabs a[aria-current] { color: var(--brand); border-color: var(--brand); }
.filters { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 0 0 12px; }
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin: 0 0 10px; }
.bulk-bar select { width: auto; flex: 1 1 180px; min-height: 44px; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.card .table-wrap { border: 0; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #faf9f5; }
.table tr:last-child td { border-bottom: 0; }
.w-check { width: 44px; }
.hide-sm { display: none; }
.status { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.status-to_assign { background: var(--warn-bg); color: var(--warn-ink); }
.status-assigned { background: var(--brand-soft); color: var(--brand); }
.status-present { background: var(--brand); color: #fff; }
.row { display: flex; align-items: center; gap: 12px; }
.wrap-row { flex-wrap: wrap; }
.wrap-row select, .wrap-row input { width: auto; flex: 1 1 140px; }
.grow { flex: 1; min-width: 0; }
.venue-admin-list { list-style: none; padding: 0; margin: 0 0 18px; }
.venue-admin-list .card { margin-bottom: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.venue-admin-list img, .ph { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--brand-soft); flex: none; }
.switch { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.switch span { width: 34px; height: 20px; border-radius: 999px; background: #c9c4b6; position: relative; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch[aria-checked=true] span { background: var(--brand); }
.switch[aria-checked=true] span::after { left: 16px; }
.pick-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.pick-list li { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
details.card summary { cursor: pointer; list-style: none; }
details.card summary h2 { display: inline; }
details.card summary::before { content: "▸ "; color: var(--muted); }
details[open].card summary::before { content: "▾ "; }
details.card[open] summary { margin-bottom: 12px; }
.danger-zone { margin: -6px 0 20px; }
.thumb { display: block; max-width: 160px; max-height: 120px; border-radius: 10px; margin: 0 0 8px; border: 1px solid var(--line); }
.logo-thumb { background: #fff; padding: 6px; }
.i18n-panels { display: grid; gap: 12px; margin: 0 0 16px; }
.i18n-panel { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 0; background: #fbfaf6; }
.i18n-panel legend { padding: 0 6px; }
.i18n-panel .src-tag { display: none; }
.i18n-panel.is-src { background: #fff; border-color: var(--brand); }
.i18n-panel.is-src .src-tag { display: inline-block; }
.i18n-panel.is-src .override { display: none; }
.status-list { list-style: none; padding: 0; }
.status-list li { padding: 4px 0; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.dot.ok { background: #16a34a; }
.dot.off { background: #d97706; }
.qr-card { display: grid; gap: 18px; }
.qr-box svg { width: 100%; max-width: 280px; height: auto; display: block; margin: 0 auto; }
.link-box { word-break: break-all; font-weight: 600; }

/* ---------- da 640px in su ---------- */
@media (min-width: 640px) {
  .wrap { padding: 28px 24px 48px; }
  .card { padding: 24px; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: 2fr 1.2fr 1fr 1fr; }
  .filters { grid-template-columns: 1fr 1.5fr auto; }
  .hide-sm { display: table-cell; }
  .qr-card { grid-template-columns: 280px 1fr; align-items: center; }
  .admin-user .muted { display: inline; }
}
@media (min-width: 1000px) {
  .admin-nav { order: 0; width: auto; flex: 1; margin: 0 12px; }
  .i18n-panels { grid-template-columns: 1fr 1fr; }
}

/* ---------- stampa ---------- */
.print-page { background: #fff; }
.print-list { max-width: 1000px; margin: 0 auto; padding: 24px; }
.print-head { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }
.print-head h1 { font-size: 1.5rem; margin: 0; }
.print-table td, .print-table th { padding: 8px; }
.qr-print .sheet { margin: 24px auto; background: #fff; border: 1px dashed #bbb; display: flex; flex-direction: column; align-items: center; justify-content: space-between; text-align: center; padding: 10mm; }
.qr-print.size-a5 .sheet { width: 148mm; height: 210mm; }
.qr-print.size-a6 .sheet { width: 105mm; height: 148mm; padding: 7mm; }
.sheet-logo { max-height: 28mm; width: auto; }
.size-a6 .sheet-logo { max-height: 18mm; }
.sheet-title { font-size: 26pt; margin: 4mm 0 1mm; color: var(--brand); }
.size-a6 .sheet-title { font-size: 18pt; }
.sheet-sub { font-size: 12pt; color: var(--muted); margin: 0; }
.size-a6 .sheet-sub { font-size: 9pt; }
.sheet-qr svg { width: 105mm; height: 105mm; }
.size-a6 .sheet-qr svg { width: 72mm; height: 72mm; }
.sheet-url { font-size: 13pt; font-weight: 700; margin: 0; }
.size-a6 .sheet-url { font-size: 10pt; }
.sheet-foot { font-size: 10pt; color: var(--muted); margin: 0; }
@media print {
  .no-print, .topbar, .site-footer { display: none !important; }
  body { background: #fff; }
  .qr-print .sheet { margin: 0; border: 0; }
}
@page { margin: 10mm; }
@page qra5 { size: A5 portrait; margin: 0; }
@page qra6 { size: A6 portrait; margin: 0; }
.qr-print.size-a5 .sheet { page: qra5; }
.qr-print.size-a6 .sheet { page: qra6; }

/* ---------- area operatori: bacheca, guida, telefono ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 0 0 14px; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); min-height: 44px; }
.kpi:hover { border-color: var(--brand); }
.kpi-n { font-size: 2rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-l { font-size: .85rem; color: var(--muted); }
.kpi-alert { background: var(--warn-bg); border-color: #f1c58a; }
.kpi-alert .kpi-n { color: var(--warn-ink); }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.dash-grid { display: grid; gap: 0 18px; }
.next-tours { list-style: none; padding: 0; margin: 0; }
.next-tours li + li { border-top: 1px solid var(--line); }
.next-tours a { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 0; text-decoration: none; color: var(--ink); min-height: 44px; }
.nt-date { font-weight: 700; }
.nt-venue { grid-column: 1; color: var(--muted); font-size: .9rem; }
.nt-seats { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-variant-numeric: tabular-nums; font-size: .9rem; }
.meter { grid-column: 1 / -1; height: 6px; border-radius: 999px; background: var(--brand-soft); overflow: hidden; margin-top: 4px; }
.meter span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.bar-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.bar-list li { display: grid; grid-template-columns: minmax(0, 7.5rem) 1fr 2.5rem; align-items: center; gap: 8px; min-height: 28px; }
.bar-label { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 14px; border-radius: 4px; background: transparent; }
.bar-fill { display: block; height: 100%; background: var(--brand); border-radius: 0 4px 4px 0; }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: .9rem; }
.columns { display: grid; grid-template-columns: repeat(12, 1fr); gap: 2px; align-items: end; height: 160px; padding-top: 18px; border-bottom: 1px solid var(--line); }
.col { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; position: relative; }
.col-bar { display: block; width: 70%; max-width: 28px; background: var(--brand); border-radius: 4px 4px 0 0; }
.col-val { font-size: .75rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.col-lab { position: absolute; bottom: -20px; font-size: .75rem; color: var(--muted); }
.as-table { margin-top: 28px; }
.as-table summary { cursor: pointer; color: var(--muted); font-size: .9rem; min-height: 44px; display: flex; align-items: center; }
.toc ol { margin: 0; padding-left: 1.3em; columns: 2 12rem; }
.toc li { padding: 4px 0; }
.guide h2 { scroll-margin-top: 120px; }
.guide li { margin-bottom: 6px; }
.hit { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; margin: -11px; cursor: pointer; }
.admin-nav a, .tabs a { min-height: 44px; display: inline-flex; align-items: center; }
.admin .check { min-height: 44px; align-items: center; }
.admin .bulk-bar .btn, .admin .btn-sm { min-height: 44px; }

@media (max-width: 639.98px) {
  .table.cards, .table.cards tbody, .table.cards tr, .table.cards td { display: block; width: 100%; }
  .table.cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table.cards tr { position: relative; padding: 10px 12px 10px 56px; border-bottom: 1px solid var(--line); }
  .table.cards tr:last-child { border-bottom: 0; }
  .table.cards td { border: 0; padding: 2px 0; }
  .table.cards td.hide-sm { display: block; }
  .table.cards td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .8rem; }
  .table.cards td.w-check { position: absolute; left: 6px; top: 6px; width: auto; padding: 0; }
  .table.cards td.w-check .hit { margin: 0; }
  .table.cards td.c-title { font-size: 1.05rem; padding-bottom: 4px; }
  .tours-table-nocheck tr, .table.cards:not(:has(.w-check)) tr { padding-left: 12px; }
  .bulk-bar select { flex: 1 1 100%; }
  .bulk-bar .btn { flex: 1 1 auto; }
  .quick .btn { flex: 1 1 calc(50% - 8px); padding: 0 10px; }
  .page-head .actions { width: 100%; }
}
@media (min-width: 640px) {
  .kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
}
@media (min-width: 1000px) {
  .dash-grid { grid-template-columns: 1fr 1fr; }
}
