:root {
  --brand: #7a2e1f;
  --brand-ink: #fff;
  --bg: #f7f2eb;
  --surface: #fff;
  --ink: #2b211c;
  --muted: #7a6c63;
  --line: #e7ddd2;
  --ok: #1f7a4d;
  --ok-bg: #e3f4ea;
  --warn: #9a6200;
  --warn-bg: #fff2d6;
  --err: #b3261e;
  --err-bg: #fde7e5;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink); line-height: 1.45; font-size: 16px; }
a { color: var(--brand); }
h1 { font-size: 1.6rem; margin: .2em 0 .6em; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 .7em; display: flex; gap: .5em; align-items: center; flex-wrap: wrap; }
h3 { font-size: 1rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }
code { background: #f1ebe4; padding: 0 .3em; border-radius: 4px; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 18px 16px 60px; }
.wrap.narrow { max-width: 560px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.hp { position: absolute; left: -9999px; }

/* Barra superiore */
.topbar { background: var(--brand); color: var(--brand-ink); display: flex; align-items: center; gap: 16px; padding: 8px 16px; position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.topbar .brand { display: flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; font-weight: 700; }
.topbar .brand img { width: 30px; height: 30px; border-radius: 8px; background: #fff; }
.topbar nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.topbar nav a { color: inherit; text-decoration: none; padding: 7px 11px; border-radius: 9px; opacity: .85; white-space: nowrap; }
.topbar nav a.on, .topbar nav a:hover { background: rgba(255,255,255,.16); opacity: 1; }
.topbar .logout { margin: 0; }
@media (max-width: 720px) {
  .topbar { gap: 6px 12px; padding: 8px 12px 6px; }
  .topbar nav { order: 3; flex-basis: 100%; margin: 0 -6px; }
  .topbar .logout { margin-left: auto; font-size: .85rem; }
}
.link { background: none; border: 0; color: inherit; cursor: pointer; font: inherit; opacity: .85; padding: 0; }

/* Componenti */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 9px 14px; border-radius: 10px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: #cdbfb1; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--err); border-color: #f0c4bf; }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn.big { padding: 14px 18px; font-size: 1.05rem; width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; margin: 0; }
.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; background: #eef3ff; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--err-bg); color: var(--err); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }
.flash ul { margin: 0; padding-left: 18px; }

.badge { display: inline-block; font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: #eee; color: #555; white-space: nowrap; }
.badge.s-active { background: var(--ok-bg); color: var(--ok); }
.badge.s-pending { background: var(--warn-bg); color: var(--warn); }
.badge.s-revoked { background: var(--err-bg); color: var(--err); }
.badge.s-none { background: #eee9e4; color: var(--muted); }

/* Form */
.form label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; font-weight: 600; margin-bottom: 12px; }
.form input:not([type=checkbox]):not([type=radio]), .form select, .form textarea, .filters input, .filters select, .search input, .scan-bar select {
  font: inherit; font-weight: 400; padding: 10px 12px; border: 1px solid #d9cdc0; border-radius: 10px; background: #fff; width: 100%; color: var(--ink);
}
.form input[type=color] { padding: 2px; height: 42px; }
.form .check, .check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; display: flex; }
.check input[type=checkbox], .check input[type=radio] { margin-top: 3px; width: 18px; height: 18px; flex: none; accent-color: var(--brand); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid2 .span2 { grid-column: span 2; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } .grid2 .span2 { grid-column: auto; } }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.filters input[type=search] { flex: 1 1 260px; width: auto; }
.filters select { width: auto; }

/* Tabelle e liste */
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.table th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fbf8f4; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: #fcf9f6; }
.table.compact td, .table.compact th { padding: 6px 8px; }
.table td.num { font-variant-numeric: tabular-nums; font-weight: 700; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list li > a { display: flex; flex-direction: column; text-decoration: none; color: inherit; flex: 1; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-decoration: none; color: inherit; }
.stat b { display: block; font-size: 2rem; color: var(--brand); }
.big-number { font-size: 2.2rem; font-weight: 800; margin: 0; color: var(--brand); }
.danger-zone { margin-top: 20px; }
.danger-zone summary, details summary { cursor: pointer; color: var(--muted); margin: 8px 0; }

/* Pagine pubbliche */
.hero { text-align: center; margin: 18px 0; }
.hero-logo { width: 84px; height: 84px; border-radius: 22px; background: #fff; box-shadow: 0 4px 18px rgba(0,0,0,.08); }

.member-card { background: var(--brand); color: #fff; border-radius: 22px; padding: 20px; box-shadow: 0 12px 34px rgba(60, 20, 10, .25); margin: 10px 0 18px; }
.member-card.s-revoked, .member-card.s-none { filter: grayscale(.75); }
.mc-head { display: flex; gap: 12px; align-items: center; }
.mc-head img { width: 44px; height: 44px; border-radius: 12px; background: #fff; }
.mc-assoc { font-weight: 700; }
.mc-sub { opacity: .8; font-size: .9rem; }
.mc-name { font-size: 1.5rem; font-weight: 800; margin: 18px 0 10px; }
.mc-row { display: flex; gap: 18px; flex-wrap: wrap; }
.mc-row span { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; opacity: .75; }
.mc-row b { font-size: 1.1rem; }
.mc-qr { background: #fff; border-radius: 16px; padding: 12px; margin: 18px auto 8px; max-width: 270px; }
.mc-qr svg { display: block; width: 100%; height: auto; }
.mc-foot { text-align: center; opacity: .8; font-size: .85rem; }
.wallet-buttons { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.gwallet { display: inline-flex; align-items: center; gap: 10px; background: #000; color: #fff; text-decoration: none; padding: 12px 20px; border-radius: 999px; font-weight: 600; }
.gw-icon { width: 22px; height: 18px; border-radius: 4px; background: linear-gradient(180deg, #4285f4 0 25%, #34a853 25% 50%, #fbbc04 50% 75%, #ea4335 75%); }
.homescreen { max-width: 420px; text-align: left; }

/* Scanner */
.scanner { max-width: 640px; margin: 0 auto; }
.scan-bar { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 10px; }
.scan-bar label { flex: 1; font-size: .85rem; font-weight: 600; display: flex; flex-direction: column; gap: 4px; }
.check.auto { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: .85rem; margin: 16px 0 10px; color: var(--muted); }
.camera { position: relative; background: #1b1411; border-radius: var(--radius); overflow: hidden; aspect-ratio: 4/3; max-height: 46vh; width: 100%; display: flex; align-items: center; justify-content: center; }
.camera video { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.camera .frame { position: absolute; width: 58%; aspect-ratio: 1; border: 3px solid rgba(255,255,255,.75); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.25); pointer-events: none; }
.camera #start { position: relative; z-index: 2; width: auto; }
.camera.running #start { display: none; }
.camera:not(.running) .frame { display: none; }
.result { border-radius: var(--radius); padding: 16px; margin: 12px 0; min-height: 96px; background: #fff; border: 1px solid var(--line); transition: background .15s; }
.result p { margin: .2em 0; }
.result .who { font-size: 1.45rem; font-weight: 800; }
.result .what { font-size: 1.1rem; font-weight: 700; }
.result.idle { color: var(--muted); display: flex; align-items: center; justify-content: center; }
.result.ok { background: var(--ok-bg); border-color: #a9dcbf; color: #0f4d2f; }
.result.warn { background: var(--warn-bg); border-color: #f2d28d; color: #6b4300; }
.result.err { background: var(--err-bg); border-color: #f2b8b2; color: #7d1a14; }
.result .btn.big { margin-top: 10px; }
.counter { text-align: center; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.search { margin-top: 8px; }
#search-results li .btn { flex: none; }

/* Area personale */
.otp { font-size: 1.6rem !important; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }
.link-inline { background: none; border: 0; padding: 0; color: var(--brand); text-decoration: underline; cursor: pointer; font: inherit; }
.member-switch { display: flex; gap: 6px; justify-content: center; margin-bottom: 8px; flex-wrap: wrap; }
.member-switch a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); background: #fff; }
.member-switch a.on { background: var(--brand); color: #fff; border-color: var(--brand); }
#logout { margin-top: 18px; }

/* Verbale stampabile */
.verbale { background: #fff; max-width: 780px; margin: 0 auto; padding: 40px 48px; font-family: Georgia, "Times New Roman", serif; line-height: 1.55; color: #111; }
.verbale h1 { font-size: 1.35rem; text-align: center; }
.verbale .sub { text-align: center; margin-top: -8px; }
.verbale ol.soci { columns: 2; column-gap: 32px; }
.verbale .firme { display: flex; justify-content: space-between; margin-top: 56px; }
.verbale .firme div { width: 42%; border-top: 1px solid #333; padding-top: 6px; text-align: center; }
.print-bar { max-width: 780px; margin: 16px auto; display: flex; gap: 8px; justify-content: flex-end; }
@media print { .print-bar { display: none; } body { background: #fff; } .verbale { padding: 0; } }

/* Magazzino */
.subnav { display: flex; gap: 4px; overflow-x: auto; margin: 0 0 14px; border-bottom: 1px solid var(--line); }
.subnav a { padding: 8px 12px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.subnav a.on { color: var(--brand); border-color: var(--brand); font-weight: 600; }
.table tr.low td { background: var(--warn-bg); }
.table tfoot th { text-align: left; }
.table tfoot th.num, .table th.num, .table td.num { text-align: right; }
.count-list { list-style: none; padding: 0; margin: 0 0 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.count-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.count-list li:last-child { border-bottom: 0; }
.count-list li.changed { background: var(--warn-bg); }
.ci-name { display: flex; flex-direction: column; }
.stepper { display: flex; align-items: center; gap: 6px; flex: none; }
.stepper .btn { width: 42px; height: 42px; padding: 0; font-size: 1.3rem; }
.form .stepper input, .stepper input { width: 70px; text-align: center; font-size: 1.1rem; padding: 8px 4px; }
.buy-table input { width: 100%; max-width: 120px; font: inherit; padding: 8px 10px; border: 1px solid #d9cdc0; border-radius: 10px; }
.buy-table tbody tr { cursor: default; }

/* Secondo fattore */
.steps { padding-left: 20px; }
.steps li { margin-bottom: 12px; }
.mfa-qr { width: 200px; margin: 10px 0; background: #fff; padding: 8px; border: 1px solid var(--line); border-radius: 12px; }
.mfa-qr svg { display: block; width: 100%; height: auto; }
.recovery { columns: 2; font-size: 1.1rem; }
.recovery code { background: none; letter-spacing: .05em; }
.topbar .logout a.link { color: inherit; text-decoration: none; }

/* Spese */
.cols.wide-left { grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); }
@media (max-width: 860px) { .cols.wide-left { grid-template-columns: 1fr; } }
.doc-previews, .doc-grid { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.doc-thumb { position: relative; width: 88px; height: 88px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-thumb button { position: absolute; top: 2px; right: 2px; border: 0; background: rgba(0,0,0,.6); color: #fff; border-radius: 999px; width: 22px; height: 22px; cursor: pointer; }
.doc-grid img { width: 140px; height: 180px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.doc-pdf { display: inline-flex; align-items: center; justify-content: center; width: 140px; height: 180px; border: 1px solid var(--line); border-radius: 10px; background: #fbf8f4; font-weight: 700; text-decoration: none; }
.who-paid { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 4px 0 14px; }
.who-paid legend { font-weight: 600; font-size: .9rem; padding: 0 4px; }
.who-paid select { margin-left: 6px; font: inherit; padding: 4px 6px; border-radius: 8px; border: 1px solid #d9cdc0; }
.cat-row { display: grid; grid-template-columns: 1.2fr 1.4fr 1.6fr auto auto; gap: 6px; align-items: center; }
.cat-row input:not([type=checkbox]), .cat-row select { font: inherit; padding: 6px 8px; border: 1px solid #d9cdc0; border-radius: 8px; width: 100%; }
@media (max-width: 760px) { .cat-row { grid-template-columns: 1fr; } }
.alert-card { border-color: #f2b8b2; background: var(--err-bg); }

/* Fase 3: report serata, prima nota, ricevute */
.neg { color: #b3261e !important; }
.income-table input { width: 100%; min-width: 70px; text-align: right; }
.income-table td { vertical-align: middle; }
.receipt-text { white-space: pre-wrap; font-family: inherit; margin: 0; }
.verbale.ricevute { padding-top: 24px; }
.ricevuta { border: 1px solid #999; padding: 20px 24px; margin-bottom: 8px; page-break-inside: avoid; }
.ricevuta .r-head { display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid #ccc; padding-bottom: 8px; margin-bottom: 12px; }
.ricevuta .r-num { text-align: right; }
.ricevuta .firme { margin-top: 32px; }
.ricevuta .firme div:first-child { border: 0; }
.r-cut { text-align: center; color: #888; font-size: .8rem; margin: 18px 0; border-top: 1px dashed #aaa; padding-top: 4px; }
.page-head h2 { margin: 0; }
.flash.warn a, .flash a { color: inherit; }
/* Barra di navigazione: niente barra di scorrimento visibile, voci più compatte sugli schermi medi */
.topbar nav { scrollbar-width: none; }
.topbar nav::-webkit-scrollbar { display: none; }
@media (max-width: 1320px) { .topbar nav a { padding: 7px 8px; font-size: .92rem; } }
form.inline select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font: inherit; font-size: .9rem; max-width: 260px; }

/* Fase 4: rendiconto, riunioni, libri, RUNTS */
.scroll-x { overflow-x: auto; }
.modd { width: 100%; border-collapse: collapse; font-size: .86rem; min-width: 860px; }
.modd td, .modd th { padding: 3px 6px; vertical-align: top; }
.modd .num { text-align: right; white-space: nowrap; width: 90px; }
.modd .prev { color: #777; }
.modd .sep { width: 18px; }
.modd tr.head th { text-align: left; border-bottom: 2px solid #333; }
.modd tr.head th.num { text-align: right; }
.modd tr.sec td { font-weight: 700; padding-top: 12px; border-bottom: 1px solid #bbb; }
.modd tr.tot td { font-weight: 700; border-top: 1px solid #bbb; }
.modd tr.res td { font-style: italic; }
.modd tr.grand td { font-weight: 700; border-top: 2px solid #333; }
.verbale.wide { max-width: 1100px; }
.print-bar.wide { max-width: 1100px; }
.libro { width: 100%; border-collapse: collapse; font-size: .78rem; }
.libro th, .libro td { border: 1px solid #999; padding: 3px 5px; text-align: left; vertical-align: top; }
.libro thead { display: table-header-group; }
.libro tr { page-break-inside: avoid; }
.verbale-libro + .verbale-libro { page-break-before: always; margin-top: 48px; border-top: 1px dashed #aaa; padding-top: 24px; }
@media print { .verbale-libro + .verbale-libro { border: 0; margin-top: 0; padding-top: 0; } .verbale.wide, .verbale { max-width: none; } }
.grid4 { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .grid4 { grid-template-columns: 1fr 1fr; } }
fieldset.checks { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; margin: 0 0 12px; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.checklist li:last-child { border-bottom: 0; }
.checklist .mark { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: #eee; font-weight: 700; flex: none; }
.checklist li.done .mark { background: #dff3e4; color: #1e7a3c; }
.checklist li.late .mark { background: #fbe1df; color: #b3261e; }
.checklist .what { flex: 1 1 320px; }
.check-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.check-form input { padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: .85rem; }
details.card > summary { cursor: pointer; }
.verbale ol { margin-top: 0; }
