/* Stile del gestionale TcgVault: palette dal logo (menta e rosa), CSS scritto da noi, senza librerie.
   I colori di testo e sfondo rispettano il contrasto WCAG AA (4,5:1). */

/* ---------- Font (ospitati da noi, licenza SIL OFL 1.1: vedi fonts/*-OFL.txt) ---------- */

@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/inter-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/inter-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Chakra Petch"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/chakra-petch-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Chakra Petch"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/chakra-petch-latin-700-normal.woff2") format("woff2"); }

/* ---------- Token ---------- */

:root {
    color-scheme: light;

    --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-display: "Chakra Petch", "Inter", system-ui, sans-serif;

    --ground: #F6F8F7;
    --surface: #FFFFFF;
    --ink: #1E1A22;
    --ink-2: #4A4450;
    --muted: #6B6570;
    --line: #E3E7E5;
    --line-soft: #EEF1EF;
    --line-input: #D5DBD8;
    --neutral-soft: #F1F3F2;

    --primary: #C42E58;
    --primary-hover: #A83058;
    --primary-soft: #FCE8EE;
    --primary-soft-ink: #8E2549;

    --mint: #94CFBA;
    --mint-soft: #E3F3EC;
    --mint-ink: #1D5C49;
    --mint-deep: #10251E;

    --warn-soft: #FFF4DC;
    --warn-line: #F3DFAE;
    --warn-ink: #6E4A00;

    --radius: 10px;
    --radius-lg: 16px;
    --shadow-card: 0 1px 2px rgba(30, 26, 34, 0.04);
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
}

h1, h2, h3 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.15;
}

h1 { font-size: 34px; }
h2 { font-size: 20px; }

/* Blazor sposta il focus sul titolo dopo la navigazione: niente contorno su un elemento non interattivo. */
h1:focus { outline: none; }

p { margin: 0; }

a { color: var(--primary-hover); }
a:hover { color: #7E2142; }

:focus-visible {
    outline: 3px solid var(--mint);
    outline-offset: 2px;
}

.muted { color: var(--muted); }

.icon { flex: none; }

/* ---------- Struttura del gestionale ---------- */

.shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    flex: 0 0 248px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 24px 16px;
    background: var(--surface);
    border-right: 1px solid var(--line);
}

.shop-identity {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 8px 8px 20px;
    border-bottom: 1px solid var(--line);
    text-align: center;
}

.shop-mark {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border-radius: 18px;
    background: var(--mint);
    color: var(--mint-deep);
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    box-shadow: 4px 4px 0 var(--primary);
}

.shop-logo {
    display: block;
    width: 100%;
    max-width: 160px;
    max-height: 120px;
    object-fit: contain;
}

.shop-name {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.role-badge {
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--mint-soft);
    color: var(--mint-ink);
    font-size: 12px;
    font-weight: 600;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: var(--radius);
    color: var(--ink-2);
    font-weight: 500;
    text-decoration: none;
}

.nav a:hover { background: var(--neutral-soft); color: var(--ink); }

.nav a.active {
    background: var(--primary-soft);
    color: var(--primary-hover);
    font-weight: 600;
}

.sidebar-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 8px 0;
    border-top: 1px solid var(--line);
}

.sidebar-footer form { display: flex; }
.sidebar-footer .btn { flex: 1; }

.user-email {
    color: var(--muted);
    font-size: 13px;
    overflow-wrap: anywhere;
}

.wordmark {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.sidebar-footer .wordmark { color: var(--muted); font-size: 12px; }

.content {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 100%;
    max-width: 1200px;
    padding: 40px 48px;
}

/* Telefono e tablet stretti: il menu diventa una barra in alto. */
@media (max-width: 860px) {
    .shell { flex-direction: column; }

    .sidebar {
        flex: none;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 12px;
        padding: 12px 16px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .shop-identity {
        flex-direction: row;
        padding: 0;
        border-bottom: 0;
        text-align: left;
    }

    .shop-mark { width: 40px; height: 40px; border-radius: 12px; font-size: 17px; box-shadow: 3px 3px 0 var(--primary); }
    .shop-logo { width: auto; max-width: 64px; max-height: 40px; }

    .nav { flex-direction: row; order: 3; width: 100%; overflow-x: auto; }
    .nav a { flex: 1 0 auto; justify-content: center; padding: 0 10px; white-space: nowrap; }

    .sidebar-footer {
        margin: 0 0 0 auto;
        flex-direction: row;
        align-items: center;
        padding: 0;
        border-top: 0;
    }

    .sidebar-footer .user-email, .sidebar-footer .wordmark { display: none; }

    .content { padding: 24px 16px; }

    /* Sui telefoni le voci del menu stanno su una riga solo con il testo. */
    @media (max-width: 480px) {
        .nav { gap: 2px; }
        .nav .icon { display: none; }
        .nav a { padding: 0 6px; font-size: 14px; }
    }

    h1 { font-size: 28px; }
}

/* ---------- Pagine di accesso ---------- */

.auth {
    display: flex;
    flex-wrap: wrap;
    min-height: 100vh;
}

.auth-brand {
    flex: 1 1 420px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 32px;
    padding: 48px;
    background: var(--mint-soft);
    color: #2F4A41;
}

.auth-brand .wordmark { color: var(--mint-ink); font-size: 20px; }

.auth-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    text-align: center;
}

.auth-hero svg { width: min(100%, 300px); height: auto; }

.auth-hero p { max-width: 400px; font-size: 17px; }

.auth-brand small { font-size: 13px; }

.auth-main {
    flex: 1 1 480px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.auth-card .foot {
    padding-top: 20px;
    border-top: 1px solid var(--line);
    color: var(--ink-2);
    font-size: 14px;
}

.auth-card .foot a { font-weight: 600; }

@media (max-width: 860px) {
    .auth { flex-direction: column; flex-wrap: nowrap; }
    .auth-brand { flex: none; padding: 20px 16px; }
    .auth-main { flex: 1 0 auto; align-items: flex-start; }
    .auth-hero, .auth-brand small { display: none; }
    .auth-main { padding: 32px 16px; }
}

/* ---------- Intestazione di pagina ---------- */

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}

.page-header p { margin-top: 6px; color: var(--muted); }

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 14px;
}

.breadcrumb a { color: var(--muted); }

/* ---------- Bottoni ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 20px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.btn-primary { background: var(--primary); color: #FFFFFF; box-shadow: 0 6px 18px -8px rgba(196, 46, 88, 0.6); }
.btn-primary:hover { background: var(--primary-hover); color: #FFFFFF; }

.btn-secondary { background: var(--mint-soft); border-color: var(--mint); color: var(--mint-ink); }
.btn-secondary:hover { background: #D3ECE1; color: var(--mint-ink); }

.btn-dark { background: var(--ink); color: #FFFFFF; }
.btn-dark:hover { background: #3A3340; color: #FFFFFF; }

.btn-outline { background: var(--surface); border-color: var(--primary); color: var(--primary-hover); }
.btn-outline:hover { background: var(--primary-soft); color: var(--primary-hover); }

.btn-quiet { background: var(--surface); border-color: var(--line); color: var(--ink); font-weight: 500; }
.btn-quiet:hover { background: var(--neutral-soft); color: var(--ink); }

.btn-block { width: 100%; }

/* ---------- Form ---------- */

.form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field > label, fieldset > legend {
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 600;
}

input:not([type=checkbox]):not([type=radio]):not([type=hidden]), textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid var(--line-input);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
}

textarea { min-height: 110px; resize: vertical; }

input::placeholder, textarea::placeholder { color: #8C8691; }

input:focus-visible, textarea:focus-visible { border-color: var(--mint-ink); }

input[type=checkbox] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--primary);
}

.check {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    color: var(--ink-2);
    font-size: 14px;
    cursor: pointer;
}

fieldset {
    margin: 0;
    padding: 0;
    border: 0;
}

fieldset > legend { margin-bottom: 6px; padding: 0; }

/* Caselle dei giochi come "pillole" selezionabili. */
.choices {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.choice {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid var(--line-input);
    border-radius: 999px;
    background: var(--surface);
    font-size: 14px;
    cursor: pointer;
}

.choice:has(input:checked) {
    border-color: var(--mint-ink);
    background: var(--mint-soft);
    color: var(--mint-ink);
    font-weight: 600;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.search {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}

.search .field { flex: 1 1 320px; }

/* Schede di una pagina (es. tessere attive / sospese): link in GET, quella corrente con aria-current. */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--line);
}

.tabs a {
    padding: 10px 14px;
    margin-bottom: -1px;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font-weight: 500;
    text-decoration: none;
}

.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { border-bottom-color: var(--primary); color: var(--ink); font-weight: 600; }

.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 14px; top: 13px; color: var(--muted); pointer-events: none; }
/* Selettore con la stessa specificità della regola generale dei campi (input:not(...)), che
   altrimenti vince e riporta il testo sotto l'icona. */
.input-icon input:not([type=checkbox]):not([type=radio]):not([type=hidden]) { padding-left: 42px; }

/* Suggerimenti mentre si scrive (MembershipSearchBox, ADR 0013). */
.suggest { position: relative; }

.suggest-list {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 20;
    max-height: 360px;
    margin: 0;
    padding: 6px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 12px 32px -12px rgba(30, 26, 34, 0.25);
    list-style: none;
}

.suggest-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 48px;
    padding: 6px 10px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--ink);
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.suggest-item:hover, .suggest-item:focus-visible { background: var(--mint-soft); color: var(--ink); }
.suggest-item strong { display: block; font-weight: 600; }
.suggest-item small { display: block; color: var(--muted); font-size: 13px; }
.suggest-item.is-disabled { cursor: default; opacity: 0.6; }
.suggest-item.is-disabled:hover { background: none; }
.suggest-empty { padding: 10px; color: var(--muted); font-size: 14px; }

/* Classi aggiunte da Blazor ai campi e ai messaggi di validazione. */
input.invalid, textarea.invalid { border-color: var(--primary); }

.validation-message {
    color: var(--primary-soft-ink);
    font-size: 13px;
}

/* ---------- Messaggi ---------- */

.alert, ul.validation-errors {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin: 0;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
}

.alert ul { margin: 0; padding-left: 18px; }

.alert-error, ul.validation-errors { background: var(--primary-soft); color: var(--primary-soft-ink); }
ul.validation-errors { flex-direction: column; gap: 2px; padding-left: 34px; }
ul.validation-errors .validation-message { font-size: 14px; }

.alert-ok { align-items: center; background: var(--mint-soft); color: var(--mint-ink); font-weight: 500; }
.alert-warn { align-items: center; background: var(--warn-soft); color: var(--warn-ink); border: 1px solid var(--warn-line); }

.alert .icon { margin-top: 1px; }

/* ---------- Card e tabelle ---------- */

.card {
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

.card-narrow { max-width: 640px; }

.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

.table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
    font-size: 14px;
}

.table th {
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-align: left;
    text-transform: uppercase;
}

.table td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #F9FBFA; }

.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .nowrap { white-space: nowrap; }

/* Classifica (ADR 0015): filtri in riga, colonna dell'ordinamento in evidenza, primi tre marcati. */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.filters .field { flex: 1 1 180px; }
.table.leaderboard { min-width: 560px; }
.leaderboard .is-sorted { font-weight: 700; color: var(--ink); }
.leaderboard .rank { width: 4rem; font-family: var(--font-display); font-weight: 700; }
.leaderboard .is-top .rank { color: var(--primary); }

/* Su telefono la classifica sta nello schermo: niente avatar né colonna dei podi, spazi ridotti. */
@media (max-width: 600px) {
    .table.leaderboard { min-width: 0; }
    .leaderboard th, .leaderboard td { padding: 12px 8px; }
    .leaderboard .avatar, .leaderboard .col-podiums { display: none; }
    .leaderboard .rank { width: 2.5rem; }
}

/* Filtro per stagione accanto a "Statistiche" sulla scheda della tessera. */
.stats-filter { display: flex; align-items: center; gap: 8px; }
.stats-filter select { width: auto; }

.person {
    display: flex;
    align-items: center;
    gap: 12px;
}

.person a { color: var(--ink); font-weight: 600; text-decoration: none; }
.person a:hover { color: var(--primary-hover); text-decoration: underline; }
.person small { display: block; color: var(--muted); font-size: 13px; }

.avatar {
    flex: none;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--mint-soft);
    color: var(--mint-ink);
    font-size: 13px;
    font-weight: 600;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--neutral-soft);
    color: var(--ink-2);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

/* Movimenti del buono: in entrata (ricariche, rettifiche positive) e in uscita. */
.chip-in { background: var(--mint-soft); color: var(--mint-ink); font-weight: 600; }
.chip-out { background: var(--primary-soft); color: var(--primary-soft-ink); font-weight: 600; }

.amount-pill {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--mint-soft);
    color: var(--mint-ink);
    font-weight: 600;
    text-decoration: none;
    font-variant-numeric: tabular-nums;
}

.amount-zero { color: var(--muted); text-decoration: none; font-variant-numeric: tabular-nums; }

.amount-in { color: var(--mint-ink); font-weight: 600; }
.amount-out { color: var(--primary-soft-ink); font-weight: 600; }

.empty-state {
    padding: 40px 24px;
    background: var(--surface);
    border: 1px dashed var(--line-input);
    border-radius: var(--radius-lg);
    color: var(--muted);
    text-align: center;
}

/* ---------- Buono negozio ---------- */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 20px 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

.stat-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

/* Statistiche della tessera: riquadri piccoli, cinque in una riga dove c'è spazio. */
.stats-compact { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.stats-compact .stat { padding: 12px 14px; }
.stats-compact .stat-label { font-size: 11px; }
.stats-compact .stat-value { font-size: 22px; }

.history-list li { align-items: center; }
.history-event { display: flex; flex-direction: column; min-width: 0; }

.stat-available { background: var(--mint); border-color: var(--mint); }
.stat-available .stat-label { color: #1E3D33; }
.stat-available .stat-value { color: var(--mint-deep); font-size: 40px; line-height: 1.1; }

.stat-expiring { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn-ink); }
.stat-expiring .stat-label { color: var(--warn-ink); }
.stat-expiring .stat-value { color: #5E3D00; }

.stat-expired .stat-value { color: var(--ink-2); }
.stat-expired span:last-child, .stat-expiring span:last-child { font-size: 14px; }

.operations {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.operations .card { display: flex; flex-direction: column; gap: 14px; }
.operations .card form { display: flex; flex: 1; flex-direction: column; gap: 14px; }
.operations .card .btn { margin-top: auto; }

.card-restricted { border-style: dashed; border-color: #C9D0CC; }

.card-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.lock-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--neutral-soft);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.section { display: flex; flex-direction: column; gap: 12px; }

.logo-preview {
    display: grid;
    place-items: center;
    width: 200px;
    height: 150px;
    padding: 12px;
    border: 1px dashed var(--line-input);
    border-radius: var(--radius);
    background: var(--ground);
    color: var(--muted);
    font-size: 14px;
    text-align: center;
}

.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ---------- Eventi e calendario ---------- */

.field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
}

select {
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--line-input);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
}

/* Campi che dipendono dalla ricorrenza scelta: si mostrano solo quelli che servono (senza JavaScript). */
.event-form .only-weekly, .event-form .only-monthly, .event-form .only-recurring { display: none; }
.event-form:has(#rec-weekly:checked) .only-weekly { display: block; }
.event-form:has(#rec-monthly:checked) .only-monthly { display: grid; }
.event-form:has(#rec-weekly:checked, #rec-monthly:checked) .only-recurring { display: flex; }
.event-form:has(#rec-weekly:checked, #rec-monthly:checked) .only-oneoff { display: none; }
.event-form label > .only-recurring { display: none; }
.event-form:has(#rec-weekly:checked, #rec-monthly:checked) label > .only-recurring { display: inline; }

.choice:has(input[type=radio]:checked) {
    border-color: var(--mint-ink);
    background: var(--mint-soft);
    color: var(--mint-ink);
    font-weight: 600;
}

.choice input[type=radio] { margin: 0; accent-color: var(--primary); }

.month-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.month-nav h2 { min-width: 200px; text-align: center; font-size: 24px; }
.month-nav .btn { padding: 0 14px; }

.calendar {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    table-layout: fixed;
}

.calendar th {
    padding: 10px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.calendar abbr { text-decoration: none; }

.calendar td {
    height: 112px;
    padding: 6px;
    border: 1px solid var(--line-soft);
    vertical-align: top;
}

.calendar td.other-month { background: #FAFBFA; }
.calendar td.other-month .day-number { color: #A39EA8; }

.day-number {
    display: inline-grid;
    place-items: center;
    min-width: 26px;
    height: 26px;
    margin-bottom: 4px;
    border-radius: 999px;
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 600;
}

.calendar td.today .day-number { background: var(--primary); color: #FFFFFF; }

.cal-event {
    display: block;
    margin-top: 3px;
    padding: 3px 6px;
    overflow: hidden;
    border-radius: 6px;
    background: var(--mint-soft);
    color: var(--mint-deep);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.35;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cal-event:hover { background: var(--mint); color: var(--mint-deep); }
.cal-time { font-weight: 700; font-variant-numeric: tabular-nums; }

.cal-event.is-cancelled { background: var(--neutral-soft); color: var(--muted); text-decoration: line-through; }

.agenda {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.agenda-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

.agenda-date {
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 52px;
    padding: 6px 0;
    border-radius: var(--radius);
    background: var(--mint-soft);
    color: var(--mint-ink);
    line-height: 1.1;
}

.agenda-date strong { font-family: var(--font-display); font-size: 22px; }
.agenda-date span { font-size: 12px; font-weight: 600; text-transform: uppercase; }

.agenda-body {
    flex: 1 1 220px;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
}

.agenda-title { flex-basis: 100%; color: var(--ink); font-weight: 600; text-decoration: none; }
.agenda-title:hover { color: var(--primary-hover); text-decoration: underline; }
.agenda-body .muted { font-size: 14px; }
.agenda-link { flex: none; min-height: 40px; padding: 0 14px; font-size: 14px; }

.agenda-item.is-cancelled .agenda-date { background: var(--neutral-soft); color: var(--muted); }
.agenda-item.is-cancelled .agenda-title { color: var(--muted); text-decoration: line-through; }

.chip-moved { background: var(--warn-soft); color: var(--warn-ink); font-weight: 600; }

.date-summary { display: flex; flex-direction: column; gap: 10px; }
.date-summary.is-cancelled h2 { color: var(--muted); text-decoration: line-through; }
.event-description { white-space: pre-line; }

.attendance { display: flex; flex-direction: column; gap: 16px; }

.plain-list {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    list-style: none;
}

.plain-list li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line-soft);
}

.plain-list li:last-child { border-bottom: 0; }

/* Punti per posizione della classifica: campi stretti, quattro per riga dove c'è spazio. */
.points-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 12px; }

/* Codice di aggancio della tessera all'app: grande e leggibile da dettare. */
.link-code { font-size: 2rem; font-weight: 700; letter-spacing: 0.12em; font-variant-numeric: tabular-nums; margin: 0; }

/* Metriche della piattaforma: presenze per gioco. */
.metrics-games { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.metrics-games li { display: flex; gap: 8px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 14px; }

/* Personale del negozio e inviti in attesa. */
.staff-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.staff-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.staff-list li:last-child { border-bottom: 0; }
.staff-list li > span { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; min-width: 0; overflow-wrap: anywhere; }

/* Link dell'invito di un negozio (piattaforma): tutto selezionabile per copiarlo. */
.invitation-link { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9rem; }

/* Premi sul buono dei badge: nome del badge (con simbolo) e importo. */
.reward-badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.reward-badges label { display: flex; align-items: center; gap: 6px; }

/* Campo con il suo pulsante sulla stessa riga (es. nuova etichetta). */
.inline-field { display: flex; flex-wrap: wrap; gap: 8px; }
.inline-field input { flex: 1 1 200px; }

.label-list li { align-items: center; }
.label-list .muted { flex: 1; }

.attendee-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.attendee-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 6px 6px 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

/* Posizione finale accanto al nome (ADR 0014). Stessa specificità della regola generale dei campi
   (input:not(...)), che altrimenti la allargherebbe a tutta la riga. */
.attendee-list input[type=number].placement-input { flex: none; width: 4.5rem; padding: 6px 8px; text-align: center; }

.attendee-list a { flex: 1; min-width: 0; overflow: hidden; color: var(--ink); font-weight: 500; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.attendee-list a:hover { color: var(--primary-hover); text-decoration: underline; }

.btn-small { min-height: 36px; padding: 0 12px; font-size: 13px; }

.danger-zone summary {
    color: var(--primary-hover);
    font-weight: 600;
    cursor: pointer;
}

.danger-zone[open] { display: flex; flex-direction: column; gap: 12px; }

/* Sul telefono la griglia del mese non ci sta: resta l'elenco. */
@media (max-width: 860px) {
    .calendar-wrap { display: none; }
    .agenda-item { flex-wrap: wrap; }
    .agenda-link { margin-left: 68px; }
    .month-nav h2 { min-width: 0; flex: 1; font-size: 20px; }
}

/* ---------- Livello e badge (ADR 0012) ---------- */

.progress-card h3 { font-size: 17px; }

.level-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 18px;
}

.level-pill {
    flex: none;
    display: grid;
    place-items: center;
    width: 88px;
    height: 88px;
    border-radius: 22px;
    background: var(--mint);
    color: var(--mint-deep);
    box-shadow: 4px 4px 0 var(--primary);
    line-height: 1;
}

.level-pill span { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.level-pill strong { font-family: var(--font-display); font-size: 40px; }

.level-detail {
    flex: 1 1 240px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.level-detail label { font-size: 15px; }

progress {
    width: 100%;
    height: 12px;
    border: 0;
    border-radius: 999px;
    background: var(--neutral-soft);
    appearance: none;
    overflow: hidden;
}

progress::-webkit-progress-bar { background: var(--neutral-soft); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--primary); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--primary); border-radius: 999px; }

.badge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.badge {
    display: flex;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.badge-symbol {
    flex: none;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
}

.badge.is-earned { border-color: var(--mint); background: var(--mint-soft); }
.badge.is-earned .badge-symbol { background: var(--primary); color: #FFFFFF; }
.badge.is-locked .badge-symbol { background: var(--neutral-soft); color: #A39EA8; }
.badge.is-locked strong { color: var(--ink-2); }

.badge-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.badge-text small { color: var(--muted); font-size: 13px; }
.badge.is-earned .badge-state { color: var(--mint-ink); font-weight: 600; }

/* Un solo form per i pulsanti attiva/disattiva: le sezioni dentro restano distanziate come nella pagina. */
.badge-groups { display: flex; flex-direction: column; gap: 24px; }

.badge-admin {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.badge-admin .badge { align-items: center; flex-wrap: wrap; }
.badge-admin .badge-text { flex: 1 1 260px; }

.badge-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

/* Campi che dipendono da come si ottiene il badge (senza JavaScript, come per gli eventi). */
.badge-form .only-rule { display: contents; }
.badge-form:has(#achievement-2:checked) .only-rule { display: none; }
.badge-form .only-top { display: none; }
.badge-form:has(#achievement-3:checked) .only-top { display: flex; }
.badge-form .only-game, .badge-form .only-event, .badge-form .only-label { display: none; }
.badge-form:has(#scope-2:checked) .only-game,
.badge-form:has(#scope-3:checked) .only-event,
.badge-form:has(#scope-4:checked) .only-label { display: flex; }

/* ---------- Panoramica ---------- */

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.tile {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--ink);
    text-decoration: none;
    box-shadow: var(--shadow-card);
}

.tile:hover { border-color: var(--mint); color: var(--ink); }
.tile strong { font-family: var(--font-display); font-size: 20px; }
.tile span { color: var(--muted); }
.tile .icon { color: var(--primary); }

.shop-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.shop-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-height: 56px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.shop-option:hover { border-color: var(--mint-ink); background: var(--mint-soft); }

/* ---------- Errore imprevisto di Blazor ---------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 1000;
    width: 100%;
    padding: 12px 48px 12px 20px;
    background: var(--warn-soft);
    border-top: 1px solid var(--warn-line);
    color: var(--warn-ink);
}

#blazor-error-ui .dismiss {
    position: absolute;
    top: 10px;
    right: 16px;
    cursor: pointer;
}

/* Check-in con QR (ADR 0028): il QR grande, da mostrare su uno schermo o da stampare. */
.check-in-qr { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.check-in-hint { margin: 0; font-size: 18px; font-weight: 600; }
.qr-code { width: min(100%, 420px); aspect-ratio: 1; }
.qr-code svg { display: block; width: 100%; height: 100%; }
.check-in-link { margin: 0; font-size: 12px; overflow-wrap: anywhere; }
.attendee-list .muted { flex: none; font-size: 13px; }
