/* Sondaggi Ordine - stile istituzionale sobrio, nessuna risorsa esterna */
:root {
  /* Palette ricavata dallo stemma del Collegio dei Procuratori (1687) */
  --bg: #fbf7ea;          /* pergamena chiara */
  --surface: #ffffff;
  --ink: #2e1d1a;         /* bruno dei contorni */
  --muted: #6f5c50;
  --line: #ead9a8;        /* bordi dorati */
  --line-strong: #d9c07a;
  --accent: #b5262a;      /* rosso vermiglio delle foglie */
  --accent-ink: #ffffff;
  --accent-soft: #fbe9e4;
  --gold: #e9a23b;        /* arancio-oro dell'acanto */
  --gold-soft: #fdf4d3;   /* giallo del cartiglio */
  --navy: #7a2a20;        /* bruno-rosso per numeri e segni grafici */
  --ok-bg: #e9f2e1; --ok: #3f6b26;       /* verde delle foglie */
  --err-bg: #fbe5e2; --err: #a3201f;
  --info-bg: #e8eef8; --info: #2d4f8a;   /* blu del manto */
  --bar: #b5262a; --track: #f3e8c8;
  --radius: 10px; --shadow: 0 1px 2px rgba(86,35,31,.06), 0 3px 10px rgba(86,35,31,.05);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1311; --surface: #251b18; --ink: #f2e8da; --muted: #bba99a;
    --line: #40302a; --line-strong: #5a4337;
    --accent: #e0574b; --accent-soft: #3b211e; --gold: #e2ae5a; --gold-soft: #33281b;
    --navy: #e9a07f; --ok-bg: #1f2e19; --ok: #a6d38a; --err-bg: #3b1d1b; --err: #f3a49b;
    --info-bg: #1c2638; --info: #a9c1ec; --bar: #e0574b; --track: #3a2c25;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--sans); }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.25; margin: 0; }
h1 { color: var(--navy); }
h1 { font-size: 1.75rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
p { margin: 0; }
code { background: var(--gold-soft); padding: 0 .3em; border-radius: 4px; font-size: .9em; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 28px; padding-bottom: 40px; }

.topbar { background: var(--surface); color: var(--ink); position: relative; box-shadow: var(--shadow); }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--gold) 55%, #f6e680 100%); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; min-height: 84px; gap: 12px; padding-bottom: 4px; }
.brand { display: flex; align-items: center; gap: 14px; color: var(--ink); text-decoration: none; }
.brand-logo { height: 64px; width: auto; display: block; }
.brand strong { display: block; font-family: var(--serif); font-size: 1.15rem; color: var(--navy); letter-spacing: .01em; }
.brand small { display: block; color: var(--muted); font-size: .82rem; font-variant: small-caps; letter-spacing: .06em; }
@media (max-width: 520px) { .brand-logo { height: 48px; } .brand strong { font-size: 1rem; } .topbar-inner { min-height: 68px; } }
.topbar .btn-ghost { color: var(--ink); }
.hero-logo { display: block; margin: 0 auto 18px; width: 200px; max-width: 70%; height: auto; }
.footer { color: var(--muted); font-size: .85rem; padding-bottom: 32px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card-narrow { max-width: 520px; margin: 40px auto; }
.center { text-align: center; }
.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 20px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin-top: 6px; }
.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 2fr 2fr; gap: 12px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 820px) { .grid-main, .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.crumb { margin-bottom: 8px; font-size: .9rem; } .crumb a { text-decoration: none; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .nowrap { white-space: nowrap; }
.lead { font-size: 1.08rem; } .pre { white-space: pre-line; }
.hint { font-size: .85rem; color: var(--muted); }
.err { color: var(--err); }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .9rem; }

label { display: block; font-weight: 600; font-size: .92rem; }
label > input, label > textarea, label > select { margin-top: 6px; }
input, textarea, select { width: 100%; font: inherit; font-weight: 400; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 8px; padding: 9px 11px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent;
  box-shadow: 0 0 0 4px var(--accent-soft); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: auto; }
input[type=file] { padding: 7px; }
.input-sm { width: 90px; padding: 6px 9px; }
.input-md { max-width: 180px; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row input { flex: 1; min-width: 0; }
.preview-bar { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; }
label.check { font-weight: 400; display: flex; align-items: center; gap: 6px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: .92rem;
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; text-decoration: none; }
.btn { border-color: var(--line-strong); }
.btn:hover { border-color: var(--gold); background: var(--gold-soft); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.1); border-color: var(--accent); background: var(--accent); }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-danger:hover { background: var(--err); border-color: var(--err); filter: brightness(1.1); }
.btn:disabled:hover { background: var(--surface); border-color: var(--line-strong); }
.btn-primary:disabled:hover { background: var(--accent); }
.btn-danger-ghost { color: var(--err); }
.btn-sm { padding: 6px 11px; font-size: .85rem; }
.btn-lg { padding: 13px 26px; font-size: 1.02rem; }
.btn-icon { padding: 4px 9px; font-size: .9rem; }
.actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; font-size: .95rem; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-errore { background: var(--err-bg); color: var(--err); }
.flash-info { background: var(--info-bg); color: var(--info); }
/* Risposte di prova (sondaggio in bozza): giallo cartiglio con bordo oro, ben distinto. */
.flash-prova { background: var(--gold-soft); color: var(--ink); border-left: 4px solid var(--gold); }
.flash-prova form { margin-top: 8px; }

.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  background: var(--track); color: var(--muted); letter-spacing: .02em; }
.badge-aperto { background: var(--ok-bg); color: var(--ok); }
.badge-chiuso { background: var(--accent-soft); color: var(--accent); }
.badge-bozza { background: var(--info-bg); color: var(--info); }

.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line); }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--navy); font-weight: 600; background: var(--gold-soft); }
.table tbody tr:hover { background: var(--bg); }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table a { font-weight: 600; text-decoration: none; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
@media (max-width: 700px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--gold); border-radius: var(--radius); padding: 14px 16px; }
.stat-label { display: block; font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { display: block; font-family: var(--serif); font-size: 1.7rem; font-variant-numeric: tabular-nums; color: var(--navy); }
.step { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent);
  color: var(--surface); font-family: var(--sans); font-size: .8rem; margin-right: 6px; vertical-align: 2px; }
.job { padding: 10px 12px; border-radius: 8px; background: var(--gold-soft); border: 1px solid var(--line); font-size: .92rem; }
.job-running { background: var(--info-bg); color: var(--info); }
details summary { cursor: pointer; font-weight: 600; font-size: .92rem; }
details > * + * { margin-top: 10px; }
.danger-zone { border-color: var(--err-bg); border-left: 4px solid var(--err); }
.danger-zone > * + * { margin-top: 8px; }
.email-preview { white-space: pre-wrap; font: .82rem/1.5 ui-monospace, Menlo, Consolas, monospace; background: var(--gold-soft);
  border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 0; max-height: 360px; overflow: auto; }
.qlist { padding-left: 1.2em; margin: 0; } .qlist li + li { margin-top: 8px; }

/* editor domande */
.qcard { border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 8px; padding: 14px; background: var(--bg); }
.qcard > * + * { margin-top: 10px; }
.qcard-head { display: flex; align-items: center; gap: 6px; }
.spacer { flex: 1; }
.qnum { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 6px; background: var(--accent);
  color: var(--surface); font: 600 .82rem var(--sans); margin-right: 4px; vertical-align: 2px; }
.builder-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding-top: 6px; border-top: 1px dashed var(--line); }

/* risultati */
.qtitle { font-size: 1.08rem; }
.bars > * + * { margin-top: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 2fr) 3fr 110px; gap: 12px; align-items: center; font-size: .93rem; }
.bar-track { height: 14px; background: var(--track); border-radius: 4px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--bar), #d2453a); border-radius: 4px 0 0 4px; }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) { .bar-row { grid-template-columns: 1fr 90px; } .bar-track { grid-column: 1 / -1; grid-row: 2; } }
.open-answers { list-style: none; padding: 0; margin: 0; max-height: 420px; overflow: auto; }
.open-answers li { padding: 10px 12px; border-left: 3px solid var(--gold); background: var(--bg); border-radius: 4px; white-space: pre-line; }
.open-answers li + li { margin-top: 8px; }

/* compilazione */
.vote { max-width: 760px; margin: 0 auto; }
.vote-head > * + * { margin-top: 12px; }
.vote-head { margin-bottom: 24px; }
.anon-note { font-size: .9rem; background: var(--gold-soft); color: var(--ink); padding: 12px 14px; border-radius: 8px;
  border: 1px solid var(--line); border-left: 4px solid var(--gold); }
fieldset.qfield { margin-left: 0; margin-right: 0; margin-bottom: 0; min-width: 0; }
fieldset.qfield > * + * { margin-top: 10px; }
fieldset.qfield legend { float: left; width: 100%; padding: 0; font-family: var(--serif); font-size: 1.1rem; font-weight: 600; margin-bottom: 6px; }
fieldset.qfield legend + * { clear: both; }
.has-error { border-color: var(--err); border-left: 4px solid var(--err); }
.choice { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; cursor: pointer; }
.choice input { margin-top: 4px; }
.choice:hover { border-color: var(--gold); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--gold-soft); box-shadow: inset 3px 0 0 var(--accent); }
.scale { display: flex; gap: 8px; flex-wrap: wrap; }
.scale-opt { position: relative; }
.scale-opt input { position: absolute; opacity: 0; }
.scale-opt span { display: grid; place-items: center; width: 46px; height: 46px; border: 1px solid var(--line); border-radius: 8px;
  font-weight: 600; cursor: pointer; font-variant-numeric: tabular-nums; }
.scale-opt span:hover { border-color: var(--gold); }
.scale-opt input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.scale-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.scale-labels { display: flex; justify-content: space-between; gap: 12px; }
.w0 { width: 0%; }
.w2 { width: 2%; }
.w4 { width: 4%; }
.w6 { width: 6%; }
.w8 { width: 8%; }
.w10 { width: 10%; }
.w12 { width: 12%; }
.w14 { width: 14%; }
.w16 { width: 16%; }
.w18 { width: 18%; }
.w20 { width: 20%; }
.w22 { width: 22%; }
.w24 { width: 24%; }
.w26 { width: 26%; }
.w28 { width: 28%; }
.w30 { width: 30%; }
.w32 { width: 32%; }
.w34 { width: 34%; }
.w36 { width: 36%; }
.w38 { width: 38%; }
.w40 { width: 40%; }
.w42 { width: 42%; }
.w44 { width: 44%; }
.w46 { width: 46%; }
.w48 { width: 48%; }
.w50 { width: 50%; }
.w52 { width: 52%; }
.w54 { width: 54%; }
.w56 { width: 56%; }
.w58 { width: 58%; }
.w60 { width: 60%; }
.w62 { width: 62%; }
.w64 { width: 64%; }
.w66 { width: 66%; }
.w68 { width: 68%; }
.w70 { width: 70%; }
.w72 { width: 72%; }
.w74 { width: 74%; }
.w76 { width: 76%; }
.w78 { width: 78%; }
.w80 { width: 80%; }
.w82 { width: 82%; }
.w84 { width: 84%; }
.w86 { width: 86%; }
.w88 { width: 88%; }
.w90 { width: 90%; }
.w92 { width: 92%; }
.w94 { width: 94%; }
.w96 { width: 96%; }
.w98 { width: 98%; }
.w100 { width: 100%; }
.center .btn-row { justify-content: center; }
/* Barra utente nell'intestazione dell'area amministrativa. */
.usernav { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; justify-content: flex-end; }
.usernav form { margin: 0; }
/* Registro delle azioni: filtri e cronologia del sondaggio. */
.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; margin-bottom: 14px; }
.filters label { flex: 1 1 150px; }
.filters .btn-row { flex: 0 0 auto; }
.history { list-style: none; padding: 0; margin: 0; }
.history li + li { margin-top: 6px; }
