/* Stile della dashboard (preso dalla bozza approvata da Tiziano, dashboard/bozza.html) */
:root {
  color-scheme: light;
  --red: #D33A24; --red-dark: #A82414;
  --cream: #FBF4E7; --card: #FFFCF5; --line: #E6D5B8; --grid: #EFE4D0;
  --ink: #2A1A10; --soft: #5A4535; --muted: #8A7563;
  --wood: #8A5A34; --wood-dark: #4A2C17;
  --s1: #2a78d6; --s2: #eb6834;            /* serie: blu, arancio (validate) */
  --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --crit: #d03b3b;
  --good-text: #0a7a0a; --crit-text: #b52a2a;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; color: var(--ink); background: var(--cream) url('img/paper.webp') center top / 500px auto;
  font: 600 15px/1.45 'Nunito', system-ui, sans-serif; overflow-x: hidden; }
h1, h2, h3 { font-family: 'Kalam', cursive; font-weight: 700; margin: 0; line-height: 1.15; }
button { font: inherit; cursor: pointer; }

/* testata di legno */
.top, .tabbar { background: #3A2414 url('img/wood.webp') center / 600px auto; }
.tabbar { position: sticky; top: 0; z-index: 10; border-bottom: 4px solid var(--wood-dark); box-shadow: 0 4px 14px rgba(0,0,0,.3); }
.tabbar-in { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.top-in { max-width: 1180px; margin: 0 auto; padding: 10px 16px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.top-in .top-row:first-child { flex: 1 1 260px; }
.top-row { display: flex; align-items: center; gap: 12px; }
.top-row img { width: 78px; border-radius: 8px; border: 2px solid var(--wood-dark); }
.top-row h1 { color: #FBF4E7; font-size: 22px; text-shadow: 0 2px 4px rgba(0,0,0,.5); flex: 1; min-width: 0; }
.sample { font: 800 11px 'Nunito', sans-serif; color: var(--ink); background: var(--warn); border-radius: 10px; padding: 2px 8px;
  white-space: nowrap; }
.top-in .top-row:last-child { flex-wrap: wrap; gap: 8px; }
.period { display: flex; gap: 4px; margin-left: auto; }
.period button { white-space: nowrap; }
.period button { font-weight: 800; font-size: 13px; color: #FBF4E7; background: rgba(0,0,0,.3); border: 1.5px solid rgba(251,244,231,.35);
  border-radius: 14px; padding: 3px 10px; }
.period button[aria-pressed="true"] { background: var(--cream); color: var(--ink); border-color: var(--cream); }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; padding-top: 8px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; font-weight: 800; font-size: 14px; color: #F1E4CC; background: none; border: 0;
  padding: 8px 12px 9px; border-radius: 10px 10px 0 0; white-space: nowrap; }
.tabs button[aria-selected="true"] { background: var(--cream); color: var(--ink); }
.tabs .dot { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--crit);
  color: #fff; font-size: 11px; line-height: 18px; text-align: center; }

main { max-width: 1180px; margin: 0 auto; padding: 14px 16px 40px; }
.page { display: none; }
.page.on { display: block; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(12, 1fr); }
.c12 { grid-column: span 12; } .c8 { grid-column: span 8; } .c6 { grid-column: span 6; } .c4 { grid-column: span 4; }
@media (max-width: 900px) { .c8, .c6, .c4 { grid-column: span 12; } }

.card { background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; padding: 14px; min-width: 0;
  box-shadow: 0 2px 0 var(--line); }
.card h2 { font-size: 20px; }
.card .sub { color: var(--muted); font-size: 13px; margin: 2px 0 10px; }
.note { color: var(--muted); font-size: 12.5px; margin-top: 8px; }

/* numeri in alto */
.tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); margin-bottom: 12px; }
@media (max-width: 420px) { .tiles { grid-template-columns: 1fr 1fr; } }
.tile { background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 12px; box-shadow: 0 2px 0 var(--line); min-width: 0; }
.tile .k { color: var(--soft); font-size: 13px; line-height: 1.25; }
.tile .v { font: 800 26px/1.15 'Nunito', sans-serif; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .d { font-size: 12.5px; margin-top: 2px; color: var(--muted); }
.split { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 13px; color: var(--soft); margin-top: 3px; }
.split i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 4px; vertical-align: 0; }
.up, .tile .d.up { color: var(--good-text); } .down, .tile .d.down { color: var(--crit-text); }

/* avvisi */
.alerts { display: grid; gap: 8px; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 9px 11px; border-radius: 11px; background: #fff;
  border: 1.5px solid var(--line); border-left-width: 6px; }
.alert.crit { border-left-color: var(--crit); } .alert.serious { border-left-color: var(--serious); }
.alert.warn { border-left-color: var(--warn); } .alert.good { border-left-color: var(--good); }
.alert .ic { flex: none; width: 22px; height: 22px; border-radius: 50%; color: #fff; font: 800 13px/22px 'Nunito'; text-align: center; }
.alert.crit .ic { background: var(--crit); } .alert.serious .ic { background: var(--serious); }
.alert.warn .ic { background: var(--warn); color: var(--ink); } .alert.good .ic { background: var(--good); }
.alert b { display: block; }
.alert span { color: var(--soft); font-size: 13.5px; }
.alert .lbl { display: flex; gap: 8px; align-items: baseline; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.alert .when { margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: none; letter-spacing: 0; white-space: nowrap; }
.alert .body { flex: 1; min-width: 0; }
.alert.gone { display: none; }
/* i tasti degli avvisi (grandi abbastanza per il dito) */
.acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.acts button { min-height: 32px; font-size: 13px; font-weight: 800; border-radius: 16px; padding: 4px 12px; border: 1.5px solid var(--line); background: #fff; color: var(--ink); }
.acts button.main { background: var(--red); border-color: var(--red); color: #fff; }
.acts button.danger { background: #fff; border-color: var(--crit); color: var(--crit-text); }
.acts button.quiet { border-color: transparent; background: #f3ebde; color: var(--soft); }
.acts.end { justify-content: flex-end; margin-top: 6px; }
.acts.end button { min-height: 28px; font-size: 12.5px; padding: 3px 11px; }
.reply { margin-top: 8px; }
.reply textarea { width: 100%; min-height: 64px; font: 600 13.5px/1.4 'Nunito', sans-serif; border: 1.5px solid var(--line); border-radius: 10px; padding: 7px 9px; resize: vertical; color: var(--ink); }
.quote { margin-top: 8px; padding: 7px 10px; background: #f6efe3; border-radius: 10px; font-size: 13.5px; color: var(--ink); }
/* «Sei sicuro?» */
.modal { position: fixed; inset: 0; background: rgba(42,26,16,.55); display: none; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal.on { display: flex; }
.modal .box { background: var(--card); border-radius: 16px; border: 3px solid var(--wood); max-width: 400px; width: 100%; padding: 16px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.modal h3 { font-size: 21px; }
.modal p { color: var(--soft); margin: 8px 0 0; font-size: 14px; }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.modal .row button { min-height: 38px; font-weight: 800; border-radius: 19px; padding: 6px 16px; border: 1.5px solid var(--line); background: #fff; }
.modal .row .yes { background: var(--crit); border-color: var(--crit); color: #fff; }
/* messaggio in basso dopo un'azione, con «Annulla» */
.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; transition: .2s; z-index: 60;
  background: var(--ink); color: #FBF4E7; border-radius: 14px; padding: 9px 14px; font-size: 14px; width: max-content; max-width: calc(100% - 32px); display: flex; gap: 12px; align-items: center; }
.tabs .dot[hidden] { display: none; }
/* messaggi coi ristoratori */
.msgs { display: grid; grid-template-columns: minmax(240px, 1fr) 2fr; gap: 12px; align-items: start; }
@media (max-width: 760px) { .msgs { grid-template-columns: 1fr; } .msgs.has-open .threads, .msgs:not(.has-open) .chatcard { display: none; } }
.thr { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "n w" "l d"; gap: 0 8px; width: 100%; text-align: left; background: #fff; border: 1.5px solid var(--line); border-radius: 11px; padding: 8px 10px; margin-top: 6px; align-items: center; }
.thr.on { border-color: var(--wood); background: #fffaf0; }
.thr b { grid-area: n; } .thr .when { grid-area: w; font-size: 12px; color: var(--muted); }
.thr .last { grid-area: l; font-size: 13px; color: var(--soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.thr .dot, .thr .chip { grid-area: d; justify-self: end; }
.thr .dot { min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--crit); color: #fff; font-size: 12px; font-weight: 800; line-height: 20px; text-align: center; }
.chat-head { display: flex; align-items: center; gap: 10px; padding-bottom: 8px; border-bottom: 1.5px solid var(--line); }
.chat-head > div { flex: 1; min-width: 0; } .chat-head b { display: block; font-size: 16px; } .chat-head span { font-size: 12.5px; color: var(--muted); }
.back.sm { margin: 0; padding: 3px 11px; font-size: 18px; line-height: 1; }
.chat-list { display: flex; flex-direction: column; gap: 8px; padding: 10px 0; max-height: 420px; overflow-y: auto; }
.bub { max-width: 82%; padding: 8px 11px; border-radius: 14px; font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
.bub.him { align-self: flex-start; background: #fff; border: 1.5px solid var(--line); border-bottom-left-radius: 4px; }
.bub.me { align-self: flex-end; background: #FCE6D8; border: 1.5px solid #F1C6AE; border-bottom-right-radius: 4px; }
.bub .orig { margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.bub .tm { margin-top: 3px; font-size: 11.5px; color: var(--muted); text-align: right; }
.bub .photo { background: #f3ebde; border-radius: 9px; padding: 18px 10px; text-align: center; color: var(--soft); font-weight: 800; margin-bottom: 6px; }
.askchip { margin-top: 5px; display: inline-block; font-size: 12px; font-weight: 800; background: #fff; border-radius: 9px; padding: 1px 8px; color: var(--soft); }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 8px; }
.quick button { font-size: 12.5px; font-weight: 800; border: 1.5px solid var(--line); background: #fff; border-radius: 14px; padding: 3px 10px; color: var(--soft); }
.composer { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; min-width: 0; min-height: 42px; max-height: 120px; font: 600 15px/1.4 'Nunito', sans-serif; border: 1.5px solid var(--line); border-radius: 21px; padding: 10px 14px; resize: none; color: var(--ink); }
.composer .send { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--red); color: #fff; font-size: 17px; }
.ask { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--soft); margin-top: 8px; }
/* cerca un'Arena */
.find { font-weight: 800; font-size: 13px; color: var(--ink); background: var(--cream); border: 0; border-radius: 14px; padding: 4px 12px; white-space: nowrap; }
.search { position: fixed; inset: 0; background: rgba(42,26,16,.55); display: none; z-index: 40; padding: 16px; }
.search.on { display: block; }
.search-in { max-width: 520px; margin: 40px auto 0; background: var(--card); border: 3px solid var(--wood); border-radius: 16px; padding: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.search-row { display: flex; gap: 8px; }
.search input { flex: 1; min-width: 0; font: 700 16px 'Nunito', sans-serif; border: 2px solid var(--line); border-radius: 12px; padding: 9px 12px; color: var(--ink); }
.search .x { border: 0; background: #f3ebde; border-radius: 12px; width: 42px; font-weight: 800; color: var(--soft); }
.results { margin-top: 8px; max-height: 60vh; overflow-y: auto; display: grid; gap: 4px; }
.res { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "n c" "s c"; text-align: left; background: #fff; border: 1.5px solid var(--line); border-radius: 11px; padding: 8px 10px; gap: 0 8px; align-items: center; }
.res b { grid-area: n; } .res span { grid-area: s; color: var(--muted); font-size: 13px; } .res .chip { grid-area: c; }
.res:hover { border-color: var(--wood); }
/* la scheda dell'Arena */
.back { font-weight: 800; font-size: 14px; color: var(--ink); background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: 5px 14px; margin-bottom: 10px; }
.ar-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.ar-head h2 { font-size: 28px; }
.story { display: grid; gap: 0; }
.st { display: grid; grid-template-columns: 70px 1fr; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--grid); font-size: 13.5px; }
.st span { color: var(--muted); } .st b { font-weight: 600; }
.notes { width: 100%; min-height: 120px; font: 600 14px/1.45 'Nunito', sans-serif; border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 10px; resize: vertical; color: var(--ink); background: #fffef9; }
.link { background: none; border: 0; padding: 0; font-weight: 800; color: var(--red-dark); text-decoration: underline; text-underline-offset: 2px; text-align: left; }
.toast.on { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
.toast button { background: none; border: 0; color: #F2B66B; font-weight: 800; white-space: nowrap; }

/* liste a barre */
.bars { display: grid; gap: 7px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; gap: 8px; align-items: center; font-size: 13.5px; }
.bar-row .l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--soft); }
.bar-row .t { height: 14px; position: relative; }
.bar-row .f { position: absolute; left: 0; top: 0; bottom: 0; background: var(--s1); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-row .n { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }
.bar-row:hover .f { filter: brightness(1.1); }
.bar-row .f.warn { background: var(--serious); }
.bar-row .f.crit { background: var(--crit); }

/* imbuto */
.funnel { display: grid; gap: 6px; }
.fun-row { display: grid; grid-template-columns: minmax(110px, 34%) 1fr; gap: 8px; align-items: center; font-size: 13.5px; }
.fun-row .l { color: var(--soft); line-height: 1.2; }
.fun-row .t { position: relative; height: 26px; }
.fun-row .f { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; }
.fun-row .n { position: absolute; top: 3px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink); }
.fun-row .n small { font-weight: 600; color: var(--soft); }
.fun-row .lost { font-size: 12px; color: var(--crit-text); }

/* tabelle */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 800; font-size: 12px; padding: 4px 6px; border-bottom: 1.5px solid var(--line); }
.tbl td { padding: 6px; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; }
.tbl td.r, .tbl th.r { text-align: right; }
.scroll { overflow-x: auto; }
.chip { display: inline-block; font-size: 11.5px; font-weight: 800; border-radius: 9px; padding: 1px 7px; white-space: nowrap; }
.chip.good { background: #dff3df; color: var(--good-text); } .chip.crit { background: #f8dcdc; color: var(--crit-text); }
.chip.warn { background: #fdf0cf; color: #7a5600; } .chip.mute { background: #efe7da; color: var(--soft); }

/* grafici */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--soft); margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: #FBF4E7; font-size: 12.5px; line-height: 1.35;
  padding: 6px 9px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); opacity: 0; transition: opacity .1s; z-index: 5; }
.tip.on { opacity: 1; }
.tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }

/* quando giocano */
.heat { display: grid; grid-template-columns: 34px repeat(14, 1fr); gap: 2px; font-size: 11px; color: var(--muted); }
.heat div { aspect-ratio: 1.3; border-radius: 3px; min-width: 0; }
.heat .h { aspect-ratio: auto; text-align: center; }
.heat .d { aspect-ratio: auto; align-self: center; }
.heat-scale { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.heat-scale span { display: inline-block; width: 90px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #cde2fb, #2a78d6, #0d366b); }

/* adesso */
.live { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.live .pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0 rgba(12,163,12,.5); animation: pulse 1.6s infinite; }
@keyframes pulse { to { box-shadow: 0 0 0 10px rgba(12,163,12,0); } }
.live b { font-size: 22px; }
.reviews { display: grid; gap: 8px; }
.review { border: 1.5px solid var(--line); border-radius: 11px; padding: 8px 10px; background: #fff; font-size: 13.5px; }
.review .stars { color: #d99a00; letter-spacing: 1px; }
.review .meta { color: var(--muted); font-size: 12px; }
.review button { float: right; font-size: 12px; font-weight: 800; color: var(--red-dark); background: none; border: 1.5px solid var(--line); border-radius: 10px; padding: 1px 8px; }
#t-voucher td, #t-voucher th { padding-left: 4px; padding-right: 4px; }
.msg { font-size: 12px; font-weight: 800; color: #fff; background: var(--red); border: 0; border-radius: 10px; padding: 3px 8px; white-space: nowrap; }
.never { display: flex; flex-wrap: wrap; gap: 6px; }

/* dashboard vera: link che sembrano tasti (Chiama, WhatsApp, Email) */
.acts a.btn { display: inline-flex; align-items: center; min-height: 32px; font-size: 13px; font-weight: 800; border-radius: 16px; padding: 4px 12px; border: 1.5px solid var(--line); background: #fff; color: var(--ink); text-decoration: none; }
.acts a.btn.main { background: var(--red); border-color: var(--red); color: #fff; }
