:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efede7;
  --text: #17191c;
  --muted: #6b6f76;
  --border: #e2dfd7;
  --accent: #15803d;
  --accent-ink: #ffffff;
  --accent-soft: #dcfce7;
  --danger: #b91c1c;
  --plus: #15803d;
  --minus: #b91c1c;
  --bar: #15803d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 16px rgba(0, 0, 0, .05);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111315;
    --surface: #1a1d20;
    --surface-2: #23272b;
    --text: #eceef0;
    --muted: #9aa1a8;
    --border: #2e3338;
    --accent: #22c55e;
    --accent-ink: #06210f;
    --accent-soft: #143322;
    --danger: #f87171;
    --plus: #4ade80;
    --minus: #f87171;
    --bar: #22c55e;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); }
img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: Oswald, Inter, sans-serif; font-weight: 600; letter-spacing: .01em; line-height: 1.15; margin: 0 0 .5em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); text-transform: uppercase; }
h2 { font-size: 1.3rem; text-transform: uppercase; }
h3 { font-size: 1.05rem; }
.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
main.wrap { flex: 1; padding-top: 24px; padding-bottom: 48px; }

/* ---------- Header ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-family: Oswald, sans-serif; font-size: 1.25rem; text-transform: uppercase; color: var(--text); text-decoration: none; margin-right: auto; }
.brand-mark { width: 26px; height: 26px; background: var(--accent); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M22 6l-14 7-6 16 9 4 3-6v31h36V27l3 6 9-4-6-16-14-7c-2 5-6 8-10 8s-8-3-10-8z'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M22 6l-14 7-6 16 9 4 3-6v31h36V27l3 6 9-4-6-16-14-7c-2 5-6 8-10 8s-8-3-10-8z'/%3E%3C/svg%3E") center / contain no-repeat; }
.nav { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.nav a, .nav button { color: var(--text); text-decoration: none; padding: 8px 12px; border-radius: 8px; font: inherit; font-weight: 500; background: none; border: 0; cursor: pointer; }
.nav a:hover, .nav button:hover { background: var(--surface-2); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav .nav-admin { color: var(--accent); }
.menu-btn { display: none; background: none; border: 1px solid var(--border); color: var(--text); border-radius: 8px; font-size: 1.2rem; padding: 4px 10px; cursor: pointer; }
@media (max-width: 760px) {
  .menu-btn { display: block; }
  .nav { display: none; width: 100%; flex-direction: column; align-items: stretch; padding-bottom: 12px; }
  .nav.open { display: flex; }
}

.footer { display: flex; justify-content: space-between; gap: 12px; padding-top: 20px; padding-bottom: 28px; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--border); flex-wrap: wrap; }
.muted-link { color: var(--muted); }

/* ---------- Comuni ---------- */
.hero { margin-bottom: 20px; }
.hero p { color: var(--muted); margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.stack > * + * { margin-top: 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; min-height: 40px; }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--danger); }
.btn-sm { padding: 5px 10px; min-height: 32px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }
.badge { display: inline-block; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.plus { color: var(--plus); }
.minus { color: var(--minus); }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.error-box { border: 1px solid var(--danger); color: var(--danger); border-radius: var(--radius); padding: 14px 16px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; z-index: 100; max-width: calc(100% - 32px); box-shadow: var(--shadow); }

/* ---------- Form ---------- */
label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; min-height: 40px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=checkbox] { width: auto; min-height: 0; }
.check { display: flex; gap: 8px; align-items: center; font-size: .95rem; color: var(--text); font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

/* ---------- Filtri catalogo ---------- */
.filters { display: grid; grid-template-columns: 2fr repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
@media (max-width: 760px) { .filters { grid-template-columns: 1fr 1fr; } .filters .search { grid-column: 1 / -1; } }
.result-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; color: var(--muted); font-size: .9rem; flex-wrap: wrap; }

/* ---------- Griglia maglie ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
@media (max-width: 480px) { .grid { grid-template-columns: 1fr 1fr; gap: 10px; } }
.shirt-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: var(--text); display: flex; flex-direction: column; box-shadow: var(--shadow); transition: transform .12s ease; }
.shirt-card:hover { transform: translateY(-2px); }
.shirt-img { aspect-ratio: 4 / 5; background: var(--surface-2); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.shirt-img img { width: 100%; height: 100%; object-fit: cover; }
.shirt-img .placeholder { width: 46%; opacity: .25; }
.shirt-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.shirt-team { font-family: Oswald, sans-serif; font-size: 1.05rem; text-transform: uppercase; line-height: 1.2; }
.shirt-meta { color: var(--muted); font-size: .82rem; }
.shirt-badges { display: flex; gap: 4px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }
.shirt-money { font-size: .8rem; display: flex; justify-content: space-between; color: var(--muted); }

/* ---------- Dettaglio ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
@media (max-width: 860px) { .detail { grid-template-columns: 1fr; } }
.gallery-main { background: var(--surface-2); border-radius: var(--radius); overflow: hidden; aspect-ratio: 4 / 5; display: flex; align-items: center; justify-content: center; cursor: zoom-in; }
.gallery-main img { width: 100%; height: 100%; object-fit: contain; }
.gallery-main .placeholder { width: 35%; opacity: .25; }
.thumbs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.thumbs button { padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; width: 68px; height: 84px; background: var(--surface-2); cursor: pointer; }
.thumbs button.active { border-color: var(--accent); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.info-table { width: 100%; border-collapse: collapse; }
.info-table th, .info-table td { text-align: left; padding: 9px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.info-table th { color: var(--muted); font-weight: 500; width: 40%; }
.back { display: inline-block; margin-bottom: 14px; text-decoration: none; color: var(--muted); }
.admin-panel { border: 1px dashed var(--accent); }
.photo-admin { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.photo-admin figure { margin: 0; background: var(--surface-2); border-radius: 8px; overflow: hidden; }
.photo-admin img { aspect-ratio: 4 / 5; object-fit: cover; width: 100%; }
.photo-admin figcaption { display: flex; gap: 4px; padding: 6px; justify-content: space-between; }
.upload-list { list-style: none; padding: 0; margin: 10px 0 0; font-size: .88rem; }
.upload-list li { padding: 3px 0; }
.ig-embed { max-width: 540px; }
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .92); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 16px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ---------- Statistiche ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 24px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi-label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.kpi-value { font-family: Oswald, sans-serif; font-size: 1.7rem; line-height: 1.2; margin-top: 2px; }
.kpi-sub { font-size: .82rem; color: var(--muted); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
@media (max-width: 400px) { .stats-grid { grid-template-columns: 1fr; } }
.bars { display: flex; flex-direction: column; gap: 7px; }
.bar-row { display: grid; grid-template-columns: minmax(80px, 34%) 1fr auto; gap: 10px; align-items: center; font-size: .86rem; }
.bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--bar); border-radius: 999px; }
.bar-num { font-variant-numeric: tabular-nums; color: var(--muted); text-align: right; min-width: 2.5em; }
.stat-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.stat-table td, .stat-table th { padding: 6px 4px; border-bottom: 1px solid var(--border); text-align: left; }
.stat-table th { color: var(--muted); font-weight: 600; }
.stat-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-table a { color: var(--text); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--muted); font: inherit; font-size: .8rem; padding: 4px 10px; cursor: pointer; }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ---------- Wishlist ---------- */
.wish-list { display: flex; flex-direction: column; gap: 10px; }
.wish { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.wish-main { flex: 1; min-width: 200px; }
.wish-title { font-weight: 600; font-size: 1.02rem; }
.prio-1 { border-left: 4px solid var(--accent); }
.prio-3 { opacity: .8; }

.login-box { max-width: 380px; margin: 40px auto; }
.table-wrap { overflow-x: auto; }
