/* ===== Colori, caratteri e componenti comuni =====
   Palette del marchio: nero e oro (sempre scura, come il logo) */
:root {
  --bg: #0D0C0B;
  --surface: #171614;
  --surface-2: #211F1C;
  --ink: #F4EEE3;
  --ink-2: #B9AF9F;
  --ink-3: #857C6F;
  --line: #2F2B26;
  --accent: #C9A36B;            /* oro */
  --accent-hover: #DDBB85;
  --accent-ink: #0D0C0B;
  --accent-soft: #2B2317;
  --accent-text: #DDBB85;
  --gold: linear-gradient(135deg, #EED8AC 0%, #C9A36B 50%, #A57F4A 100%);
  --green: #7CC596;  --green-ink: #0F2117; --green-soft: #1C3024;
  --amber: #F0A266;  --amber-soft: #3A2415;
  --blue: #86B4E3;   --blue-soft: #1B2C3F;
  --red: #F08A80;    --red-soft: #3D1E1B;
  --gray: #B9AF9F;   --gray-soft: #2A2723;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .6);
  --r: 14px; --r-sm: 10px; --r-lg: 20px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --brand: "Cinzel", "Trajan Pro", Georgia, serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 84px; scrollbar-gutter: stable; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.55 var(--font); -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body:has(dialog[open]) { overflow: hidden; }
img { max-width: 100%; display: block; }
a { color: var(--accent-text); }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; font-weight: 700; }
p { margin: 0 0 1em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ----- Pulsanti ----- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 999px; border: 1px solid transparent;
  background: var(--surface-2); color: var(--ink); font-weight: 600; font-size: 15px; line-height: 1.2;
  text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--line); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--gold); color: var(--accent-ink); box-shadow: 0 2px 12px rgba(201, 163, 107, .18); }
.btn-primary:hover { background: var(--gold); filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-wa { background: var(--green); color: var(--green-ink); }
.btn-wa:hover { background: var(--green); filter: brightness(1.08); }
.btn-danger { background: transparent; color: var(--red); border-color: var(--red-soft); }
.btn-danger:hover { background: var(--red-soft); }
.btn-lg { min-height: 52px; padding: 12px 24px; font-size: 16px; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border-radius: 999px; border: 0; background: transparent; color: var(--ink);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn .i { width: 22px; height: 22px; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; }

/* ----- Moduli ----- */
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; border: 0; padding: 0; min-width: 0; }
.field > span, .field > legend { font-size: 14px; font-weight: 600; color: var(--ink-2); padding: 0; margin-bottom: 6px; }
.field > span { margin-bottom: 0; }
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea {
  width: 100%; min-height: 48px; padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); font-size: 16px; line-height: 1.4;
}
.field textarea { resize: vertical; min-height: 92px; }
.field input:focus, .field select:focus, .field textarea:focus, .search input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg label { flex: 1 1 0; position: relative; min-width: 84px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface);
  font-size: 14px; font-weight: 600; color: var(--ink-2); cursor: pointer; text-align: center;
}
.seg input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--ink-2); margin: 4px 0 14px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form-err { color: var(--red); font-size: 14px; font-weight: 600; margin: 0 0 12px; }
.form-err:empty { display: none; }

/* ----- Ricerca e filtri ----- */
.search { position: relative; display: flex; align-items: center; flex: 1; min-width: 0; }
.search .i { position: absolute; left: 15px; color: var(--ink-2); pointer-events: none; }
.search input {
  width: 100%; min-height: 48px; padding: 10px 16px 10px 44px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--surface); font-size: 16px;
}
.chips {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px; padding: 2px 16px 6px; scroll-padding-inline: 16px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 6px 14px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  font-size: 14px; font-weight: 600;
}
.chip span { font-weight: 500; opacity: .8; font-size: 13px; }
.chip[aria-pressed=true] { background: var(--gold); border-color: var(--accent); color: var(--accent-ink); }

/* ----- Etichette di stato ----- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: .01em; white-space: nowrap; line-height: 1.4;
}
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }
.badge-green  { background: var(--green-soft); color: var(--green); }
.badge-amber  { background: var(--amber-soft); color: var(--amber); }
.badge-blue   { background: var(--blue-soft); color: var(--blue); }
.badge-red    { background: var(--red-soft); color: var(--red); }
.badge-gray   { background: var(--gray-soft); color: var(--gray); }

.note { padding: 10px 14px; border-radius: var(--r-sm); font-size: 14px; margin: 0 0 14px; }
.note-amber { background: var(--amber-soft); color: var(--amber); }
.note-red   { background: var(--red-soft); color: var(--red); }
.note-green { background: var(--green-soft); color: var(--green); }

/* ----- Avvisi ----- */
.toasts {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 1000; width: min(92vw, 420px); pointer-events: none;
}
.toast {
  background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg);
  font-size: 15px; font-weight: 500; animation: toast-in .25s ease; transition: opacity .3s, transform .3s;
}
.toast.err { background: var(--red); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ----- Finestre ----- */
dialog { border: 0; padding: 0; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); max-width: 100%; }
dialog::backdrop { background: rgba(0, 0, 0, .72); }

.spinner { width: 24px; height: 24px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.vuoto { text-align: center; color: var(--ink-2); padding: 48px 16px; }
.vuoto .i { width: 40px; height: 40px; margin: 0 auto 10px; stroke-width: 1.5; color: var(--ink-3); }
.vuoto strong { display: block; color: var(--ink); font-size: 17px; margin-bottom: 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
