:root {
  --green: #0f3d2e;
  --green-2: #17553f;
  --gold: #b8913a;
  --gold-soft: #f1e6c8;
  --red: #9b2335;
  --cream: #faf6ee;
  --ink: #1e1e1e;
  --muted: #6b6b6b;
  --line: #e4dccb;
  --ok: #1b7f4b;
  --warn: #b7791f;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(15, 61, 46, .12);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--cream); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; color: var(--green); margin: 0 0 .5rem; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.3rem; }
a { color: var(--green-2); }
.muted { color: var(--muted); }
.center { text-align: center; }
.hidden { display: none !important; }

/* top bar */
.topbar {
  background: var(--green); color: #fff; display: flex; align-items: center; gap: .75rem;
  padding: .6rem 1rem; position: sticky; top: 0; z-index: 20;
  border-bottom: 4px solid var(--gold);
}
.topbar a { color: #fff; text-decoration: none; }
.brand { display: flex; align-items: center; gap: .6rem; font-family: Georgia, serif; font-weight: 700; font-size: 1.1rem; }
.brand img { height: 46px; width: auto; }
.topbar .spacer { flex: 1; }
.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.topbar nav a { padding: .35rem .65rem; border-radius: 999px; font-size: .92rem; }
.topbar nav a.active, .topbar nav a:hover { background: rgba(255,255,255,.16); }
.topbar .who { font-size: .85rem; opacity: .85; }
.linkbtn { background: none; border: 0; color: #fff; font: inherit; cursor: pointer; padding: .35rem .65rem; border-radius: 999px; }
.linkbtn:hover { background: rgba(255,255,255,.16); }

.container { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.narrow { max-width: 520px; }

/* cards */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.stat { text-align: center; padding: 1rem .5rem; }
.stat .n { font: 700 2.2rem/1 Georgia, serif; color: var(--green); }
.stat .l { font-size: .85rem; color: var(--muted); margin-top: .3rem; }
.grid.stats.three { grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.grid.stats.three .stat { padding: .8rem .2rem; }
.grid.stats.three .stat .n { font-size: 1.8rem; }
.grid.stats.three .stat .l { font-size: .75rem; }
.bar { height: 8px; border-radius: 99px; background: var(--gold-soft); overflow: hidden; margin-top: .6rem; }
.bar > i { display: block; height: 100%; background: var(--gold); }

/* big tiles (home operatore) */
.tiles { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem;
  min-height: 190px; border-radius: 22px; text-decoration: none; color: #fff; text-align: center; padding: 1.2rem;
  box-shadow: var(--shadow); border: 0; font: inherit;
}
.tile svg { width: 64px; height: 64px; }
.tile .t { font: 700 1.5rem Georgia, serif; }
.tile .s { opacity: .85; font-size: .95rem; }
.tile.green { background: linear-gradient(145deg, var(--green-2), var(--green)); }
.tile.red { background: linear-gradient(145deg, #b3293d, var(--red)); }
.tile:active { transform: scale(.98); }

/* buttons & forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  background: var(--green); color: #fff; border: 0; border-radius: 12px; padding: .7rem 1.1rem;
  font: 600 1rem system-ui; cursor: pointer; text-decoration: none; min-height: 44px;
}
.btn:hover { background: var(--green-2); }
.btn.gold { background: var(--gold); } .btn.gold:hover { background: #a07e2f; }
.btn.red { background: var(--red); }
.btn.ghost { background: transparent; color: var(--green); border: 1.5px solid var(--green); }
.btn.sm { padding: .35rem .7rem; min-height: 34px; font-size: .88rem; border-radius: 9px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
label { display: block; font-weight: 600; margin: .8rem 0 .25rem; font-size: .92rem; }
input[type=text], input[type=password], input[type=email], input[type=search], input[type=tel], input[type=file], select, textarea {
  width: 100%; padding: .7rem .8rem; border: 1.5px solid var(--line); border-radius: 12px; font: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(184,145,58,.35); border-color: var(--gold); }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1; min-width: 160px; }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
.check input { width: 20px; height: 20px; }

.flash { padding: .75rem 1rem; border-radius: 12px; margin-bottom: .8rem; font-weight: 500; }
.flash.ok { background: #e3f4ea; color: #145c37; }
.flash.error { background: #fbe4e7; color: #7d1a28; }

/* table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: .6rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: .94rem; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.chip { display: inline-block; padding: .15rem .55rem; border-radius: 99px; font-size: .78rem; font-weight: 600; }
.chip.ok { background: #e3f4ea; color: #145c37; }
.chip.no { background: #eee; color: #666; }
.chip.warn { background: #fdf0d5; color: #8a5a00; }
.actions { display: flex; gap: .35rem; flex-wrap: wrap; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem;
  background: radial-gradient(circle at 20% 10%, #1d6b50 0, var(--green) 55%, #082a1f 100%); }
.login-card { background: #fff; border-radius: 24px; padding: 1.6rem; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.35); border-top: 6px solid var(--gold); }
.login-card .logo { display: block; margin: 0 auto .9rem; height: 130px; width: auto; max-width: 100%; box-sizing: border-box; background: var(--green); border-radius: 16px; padding: 10px 22px; }
.divider { text-align: center; color: var(--muted); margin: 1rem 0; font-size: .85rem; position: relative; }
.divider:before, .divider:after { content: ""; position: absolute; top: 50%; width: 38%; height: 1px; background: var(--line); }
.divider:before { left: 0; } .divider:after { right: 0; }
.btn.ms { background: #fff; color: #2f2f2f; border: 1.5px solid #8c8c8c; }
.ms-logo { width: 18px; height: 18px; display: inline-grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.ms-logo i { display: block; }

/* scanner */
.scan-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.scan-head h1 { margin: 0; flex: 1; font-size: 1.4rem; }
.viewport { position: relative; border-radius: 20px; overflow: hidden; background: #000; min-height: 260px; box-shadow: var(--shadow); }
#reader { width: 100%; }
#reader video { border-radius: 20px; }
.viewport .hint { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.55); color: #fff; text-align: center; padding: .4rem; font-size: .85rem; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(155,35,53,.5); } 50% { box-shadow: 0 0 0 10px rgba(155,35,53,0); } }
.tabs { display: flex; gap: .4rem; margin: .8rem 0; }
.tabs button { flex: 1; padding: .6rem; border: 1.5px solid var(--green); background: #fff; color: var(--green); border-radius: 12px; font: 600 .95rem system-ui; cursor: pointer; }
.tabs button.active { background: var(--green); color: #fff; }
.results { display: grid; gap: .6rem; margin-top: .8rem; }
.res-item { display: flex; justify-content: space-between; gap: .6rem; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: .7rem .9rem; }
.res-item .nm { font-weight: 700; }

/* esito a tutto schermo */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.2rem; text-align: center; color: #fff; }
.sheet.ready { background: linear-gradient(160deg, #17553f, #0f3d2e); }
.sheet.registered { background: linear-gradient(160deg, #1f9a5c, #14703f); }
.sheet.done { background: linear-gradient(160deg, #b3293d, #7d1a28); }
.sheet.blocked { background: linear-gradient(160deg, #c98a1b, #96660f); }
.sheet .status { font-size: 1rem; letter-spacing: .12em; text-transform: uppercase; opacity: .9; }
.sheet .icon { font-size: 4rem; line-height: 1; margin: .4rem 0; }
.sheet .who { font: 700 clamp(2rem, 9vw, 3.4rem)/1.1 Georgia, serif; margin: .2rem 0; word-break: break-word; }
.sheet .sub { font-size: 1.15rem; opacity: .92; margin: .15rem 0; }
.sheet .detail { margin-top: .8rem; background: rgba(0,0,0,.2); padding: .6rem 1rem; border-radius: 12px; max-width: 520px; }
.sheet .btns { margin-top: 1.6rem; display: grid; gap: .7rem; width: 100%; max-width: 420px; }
.sheet .btn { font-size: 1.25rem; min-height: 60px; border-radius: 16px; }
.sheet .btn.white { background: #fff; color: var(--green); }
.sheet .btn.outline { background: transparent; border: 2px solid rgba(255,255,255,.8); color: #fff; }
.checkname { font-size: .9rem; opacity: .85; margin-top: .6rem; }

/* ticket pubblico */
.ticket-page { max-width: 460px; margin: 0 auto; padding: 1rem; }
.ticket { background: #fff; border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); text-align: center; }
.ticket .head { background: var(--green); color: #fff; padding: 1.2rem 1rem; border-bottom: 5px solid var(--gold); }
.ticket .head .co { font: 700 1.6rem Georgia, serif; }
.ticket .head .logo-epiu { display:block; height:110px; width:auto; max-width:100%; margin:0 auto .5rem; }
.ticket .loghi-top { display:flex; align-items:center; justify-content:center; gap:1.6rem; padding:.9rem 1rem; background:#fff; }
.ticket .loghi-top img { max-height:40px; max-width:44%; width:auto; }
.ticket .head .ev { color: #f0dca0; }
.ticket .body { padding: 1.2rem; }
.ticket .nm { font: 700 1.8rem/1.15 Georgia, serif; color: var(--ink); }
.ticket img.qr { width: 100%; max-width: 320px; margin: 1rem auto; display: block; border: 3px solid var(--gold); border-radius: 18px; padding: 8px; background: #fff; }
.ticket .code { font: 700 1.6rem ui-monospace, monospace; letter-spacing: .12em; color: var(--green); }

.badge-qr { text-align: center; }
.badge-qr img { width: 100%; max-width: 340px; }

.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.5rem 1rem; }

@media (max-width: 640px) {
  .topbar .who { display: none; }
  h1 { font-size: 1.45rem; }
}
@media print {
  .topbar, .noprint, .footer { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
