:root {
  --bg: #07100e; --bg2: #0c1a17; --card: #10231f; --card2: #163029; --line: #21463d;
  --ink: #ecf5f0; --ink2: #a5c2b9; --ink3: #6f9087;
  --ball: #d7f24c; --ball-ink: #0a1210; --teal: #4fd3c4; --orange: #f2a65a; --red: #ef6a55; --blue: #6aa8ff;
  --radius: 18px; --tab-h: 66px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.4 Inter, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--teal); }
h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 18px; font-weight: 750; }
h3 { font-size: 15px; font-weight: 700; }
.muted { color: var(--ink2); } .dim { color: var(--ink3); } .small { font-size: 13px; } .tiny { font-size: 11.5px; }
.num { font-variant-numeric: tabular-nums; }

/* layout */
#app { max-width: 560px; margin: 0 auto; padding: calc(var(--safe-t) + 12px) 16px calc(var(--tab-h) + var(--safe-b) + 24px); }
.top { display: flex; align-items: center; gap: 10px; margin: 4px 0 16px; min-height: 40px; }
.top .grow { flex: 1; min-width: 0; }
.top .back { width: 40px; height: 40px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); display: grid; place-items: center; cursor: pointer; flex: none; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; } .row.wrap { flex-wrap: wrap; } .row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; } .ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 2px 10px; }
.section-title h2 { font-size: 16px; }
.section-title a, .link { color: var(--ball); font-size: 13px; font-weight: 600; text-decoration: none; cursor: pointer; background: none; border: 0; padding: 0; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card.tap { cursor: pointer; transition: transform .08s; } .card.tap:active { transform: scale(.985); }
.card.hero { background: radial-gradient(130% 120% at 100% 0%, rgba(215,242,76,.16), transparent 55%), linear-gradient(160deg, #15372f, #0d201c); }
.card.flat { background: var(--bg2); }
.list { display: flex; flex-direction: column; } .list > * + * { border-top: 1px solid var(--line); }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 2px; }
.empty { text-align: center; color: var(--ink3); padding: 26px 10px; font-size: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--card2); font-weight: 650; cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:active { filter: brightness(1.15); } .btn[disabled] { opacity: .45; pointer-events: none; }
.btn.primary { background: var(--ball); color: var(--ball-ink); border-color: var(--ball); }
.btn.ghost { background: transparent; } .btn.danger { background: transparent; color: var(--red); border-color: rgba(239,106,85,.5); }
.btn.block { width: 100%; } .btn.sm { min-height: 36px; padding: 0 12px; font-size: 13.5px; border-radius: 11px; }
.btn.icon { width: 42px; padding: 0; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.quick button { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 6px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer; font-weight: 650; font-size: 13.5px; }
.quick button .ico { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: rgba(215,242,76,.12); color: var(--ball); }

/* chips, badges */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--ball); color: var(--ball-ink); border-color: var(--ball); }
.day { flex: none; width: 54px; border: 1px solid var(--line); background: var(--card); border-radius: 15px; padding: 8px 0; text-align: center; cursor: pointer; }
.day b { display: block; font-size: 19px; } .day span { font-size: 11px; color: var(--ink2); text-transform: uppercase; letter-spacing: .04em; }
.day.on { background: var(--ball); border-color: var(--ball); color: var(--ball-ink); } .day.on span { color: var(--ball-ink); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--card2); color: var(--ink2); white-space: nowrap; }
.badge.ok { background: rgba(79,211,196,.15); color: var(--teal); } .badge.warn { background: rgba(242,166,90,.16); color: var(--orange); }
.badge.bad { background: rgba(239,106,85,.16); color: var(--red); } .badge.ball { background: rgba(215,242,76,.15); color: var(--ball); }
.seg { display: flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 10px; padding: 9px 6px; font-weight: 650; font-size: 13.5px; color: var(--ink2); cursor: pointer; }
.seg button.on { background: var(--card2); color: var(--ink); box-shadow: 0 1px 0 rgba(255,255,255,.04) inset; }

/* avatar */
.av { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 750; font-size: 14px; flex: none; color: #08120f; }
.av.sm { width: 28px; height: 28px; font-size: 11px; } .av.lg { width: 64px; height: 64px; font-size: 22px; }
.av.empty { background: transparent !important; border: 1.5px dashed var(--line); color: var(--ink3); }
.avs { display: flex; } .avs .av { border: 2px solid var(--card); } .avs .av + .av { margin-left: -9px; }
.level { display: inline-grid; place-items: center; min-width: 40px; padding: 3px 7px; border-radius: 9px; background: rgba(215,242,76,.14); color: var(--ball); font-weight: 800; font-size: 13px; }

/* forms */
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink2); font-weight: 600; }
.in, select.in, textarea.in { width: 100%; min-height: 46px; background: var(--bg2); border: 1px solid var(--line); border-radius: 13px; padding: 10px 13px; outline: none; font-size: 15.5px; }
.in:focus { border-color: var(--teal); }
textarea.in { min-height: 80px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--ink2); cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--ball); flex: none; margin-top: 1px; }
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: .2s; cursor: pointer; }
.switch span::after { content: ''; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--ball); } .switch input:checked + span::after { transform: translateX(20px); background: var(--ball-ink); }

/* griglia prenotazioni */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.slot { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 9px 4px; text-align: center; cursor: pointer; font-weight: 700; font-variant-numeric: tabular-nums; }
.slot small { display: block; font-size: 11px; font-weight: 600; color: var(--ink2); margin-top: 1px; }
.slot.free:active { background: var(--ball); color: var(--ball-ink); }
.slot { position: relative; }
.slot.deal { border-color: var(--ball); box-shadow: inset 0 0 0 1px rgba(215,242,76,.35); }
.slot.deal small { color: var(--ball); font-weight: 800; }
.deal-tag { position: absolute; top: -7px; right: -5px; background: var(--ball); color: var(--ball-ink); font-style: normal; font-size: 10px; font-weight: 900; padding: 1px 5px; border-radius: 6px; }
.heat { display: grid; gap: 3px; font-size: 11px; }
.heat .c { border-radius: 5px; height: 26px; display: grid; place-items: center; font-weight: 700; color: var(--ink); cursor: pointer; border: 0; }
.heat .h { color: var(--ink3); text-align: center; align-self: center; }
.slot.busy, .slot.past, .slot.blocked { opacity: .35; cursor: default; text-decoration: line-through; }
.slot.mine { opacity: 1; text-decoration: none; border-color: var(--teal); color: var(--teal); }
.court-h { display: flex; align-items: center; gap: 8px; margin: 18px 2px 10px; }
.court-h h3 { font-size: 15px; }

/* agenda gestore */
.agenda { position: relative; display: grid; gap: 0; border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; background: var(--bg2); }
.agenda .hdr { position: sticky; top: 0; background: var(--card); font-size: 12px; font-weight: 700; padding: 8px 6px; text-align: center; border-bottom: 1px solid var(--line); z-index: 1; }
.agenda .hr { font-size: 11px; color: var(--ink3); padding: 2px 6px; border-top: 1px solid rgba(33,70,61,.5); height: 30px; }
.agenda .col { position: relative; border-left: 1px solid var(--line); }
.agenda .bk { position: absolute; left: 3px; right: 3px; border-radius: 9px; padding: 5px 7px; font-size: 11.5px; line-height: 1.25; overflow: hidden; cursor: pointer; background: rgba(79,211,196,.18); border: 1px solid rgba(79,211,196,.45); }
.agenda .bk.unpaid { background: rgba(242,166,90,.16); border-color: rgba(242,166,90,.5); }
.agenda .bk.block { background: repeating-linear-gradient(45deg, #1b2c28, #1b2c28 6px, #142320 6px, #142320 12px); border-color: var(--line); color: var(--ink2); }
.agenda .bk.pending { border-style: dashed; }

/* KPI */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.kpi .v { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .l { font-size: 12px; color: var(--ink2); font-weight: 600; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 110px; padding-top: 8px; }
.bars div { flex: 1; background: var(--ball); border-radius: 5px 5px 2px 2px; min-height: 2px; position: relative; opacity: .9; }
.bars div.zero { background: var(--line); }
.bars-x { display: flex; gap: 4px; } .bars-x span { flex: 1; text-align: center; font-size: 10px; color: var(--ink3); }
.meter { height: 8px; border-radius: 99px; background: var(--bg2); overflow: hidden; } .meter i { display: block; height: 100%; background: var(--teal); border-radius: 99px; }

/* tabellone */
.bracket { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 6px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.bracket .round { display: flex; flex-direction: column; justify-content: space-around; gap: 10px; min-width: 190px; }
.bracket .round > .dim { text-align: center; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.game { background: var(--card); border: 1px solid var(--line); border-radius: 13px; overflow: hidden; cursor: pointer; }
.game .t { display: flex; align-items: center; gap: 8px; padding: 8px 10px; font-size: 13px; }
.game .t + .t { border-top: 1px solid var(--line); }
.game .t.win { font-weight: 800; color: var(--ball); }
.game .t .sc { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--ink2); letter-spacing: .08em; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.table th { text-align: left; color: var(--ink3); font-weight: 650; font-size: 12px; padding: 6px 4px; }
.table td { padding: 9px 4px; border-top: 1px solid var(--line); }
.table td.r, .table th.r { text-align: right; }
.form { display: inline-flex; gap: 3px; } .form i { width: 18px; height: 18px; border-radius: 5px; display: grid; place-items: center; font-style: normal; font-size: 10px; font-weight: 800; }
.form i.V { background: rgba(79,211,196,.2); color: var(--teal); } .form i.P { background: rgba(239,106,85,.18); color: var(--red); }

/* tab bar */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(9,20,17,.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabs nav { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); height: var(--tab-h); }
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--ink3); text-decoration: none; font-size: 11px; font-weight: 650; }
.tabs a.on { color: var(--ball); }
.tabs a svg { width: 24px; height: 24px; }

/* sheet */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; animation: fade .18s; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92dvh; overflow-y: auto; background: var(--bg2); border-top: 1px solid var(--line); border-radius: 24px 24px 0 0; padding: 10px 16px calc(20px + var(--safe-b)); animation: up .24s cubic-bezier(.2,.8,.2,1); max-width: 560px; margin: 0 auto; }
.sheet .grab { width: 42px; height: 5px; background: var(--line); border-radius: 9px; margin: 0 auto 14px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } } @keyframes fade { from { opacity: 0; } }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + var(--safe-b) + 14px); z-index: 60; background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 13px; font-weight: 650; font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 8px 30px rgba(0,0,0,.4); animation: up .2s; }
.toast.err { background: var(--red); color: #fff; }
.demo-bar { background: rgba(215,242,76,.1); border: 1px dashed rgba(215,242,76,.4); color: var(--ball); border-radius: 12px; padding: 7px 12px; font-size: 12.5px; font-weight: 600; margin-bottom: 12px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.spinner { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--ball); border-radius: 50%; animation: spin .7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.ball { width: 64px; height: 64px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #f3ffc4, var(--ball) 55%, #9db545); box-shadow: 0 0 0 6px rgba(215,242,76,.12), 0 14px 40px rgba(215,242,76,.25); position: relative; }
.ball::after { content: ''; position: absolute; inset: 9px; border-radius: 50%; border: 3px solid rgba(255,255,255,.6); border-left-color: transparent; border-right-color: transparent; transform: rotate(35deg); }
.pay-fake { background: #fff; color: #1a1f36; border-radius: 18px; padding: 18px; }
.pay-fake .in { background: #f6f8fa; border-color: #e3e8ee; color: #1a1f36; }
.pay-fake .btn.primary { background: #635bff; border-color: #635bff; color: #fff; }
.pm-logo { width: 46px; height: 28px; border-radius: 7px; display: grid; place-items: center; font-size: 10.5px; font-weight: 900; letter-spacing: .03em; color: #fff; flex: none; }
.pm-stripe { background: #1a1f36; } .pm-satispay { background: #f94c43; font-size: 15px; } .pm-paypal { background: #003087; }
.promo { background: linear-gradient(135deg, rgba(242,166,90,.18), rgba(215,242,76,.1)); border-color: rgba(242,166,90,.45); }

@media (min-width: 700px) { .slots { grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
