:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --ink: #1c2430;
  --ink-soft: #5b6675;
  --line: #e4e8ee;
  --brand: #1f8a4c;
  --brand-dark: #166b3a;
  --accent: #f5a623;
  --danger: #c0392b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(20, 30, 45, .08), 0 8px 24px rgba(20, 30, 45, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

a { color: var(--brand-dark); }

.wrap {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Header ---------- */
.site-header {
  background: var(--ink);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
}
.brand {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  gap: 9px;
}
.brand-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 4px rgba(31, 138, 76, .25);
}
.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.main-nav a {
  color: #d7dce3;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: .95rem;
}
.main-nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.main-nav .nav-cta {
  background: var(--brand);
  color: #fff;
  font-weight: 600;
}
.main-nav .nav-cta:hover { background: var(--brand-dark); }
.main-nav .nav-logout { color: #ff9a8f; }
.nav-toggle {
  display: none;
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

/* ---------- Layout ---------- */
.main-content { padding: 28px 20px 60px; }

.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: 1.6rem; }

h2 { font-size: 1.15rem; margin: 0 0 14px; }

.grid {
  display: grid;
  gap: 20px;
}
@media (min-width: 760px) {
  .grid.cols-2 { grid-template-columns: 1fr 1fr; }
}

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card > h2:first-child { margin-top: 0; }

.muted { color: var(--ink-soft); }
.small { font-size: .85rem; }
.empty {
  color: var(--ink-soft);
  padding: 16px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

/* ---------- Lists / events ---------- */
.event-list { list-style: none; margin: 0; padding: 0; }
.event-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.event-list li:last-child { border-bottom: 0; }
.event-when {
  min-width: 116px;
  font-weight: 600;
  font-size: .9rem;
}
.event-main { flex: 1; }
.event-main .sub { color: var(--ink-soft); font-size: .85rem; }

.tag {
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef1f5;
  color: var(--ink-soft);
}
.tag.partita { background: rgba(31, 138, 76, .12); color: var(--brand-dark); }
.tag.allenamento { background: rgba(245, 166, 35, .16); color: #9a6400; }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}
table.data th, table.data td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data th {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--ink-soft);
}
table.data tbody tr:hover { background: #fafbfc; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Badges ---------- */
.result { font-weight: 700; }
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 700;
  color: #fff;
}
.badge.V { background: var(--brand); }
.badge.N { background: #8a94a3; }
.badge.P { background: var(--danger); }
.badge.soft {
  background: #eef1f5;
  color: var(--ink-soft);
}

.rating {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.rating.hi { color: var(--brand-dark); }
.rating.lo { color: var(--danger); }

/* ---------- Stat grid ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}
.stat {
  background: #fafbfc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}
.stat .n {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stat .l {
  font-size: .78rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .03em;
}

/* ---------- Player identity ---------- */
.player-row { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: #e6e9ef;
  flex: none;
}
.avatar.lg { width: 96px; height: 96px; }
.profile-head {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.profile-head h1 { margin: 0 0 2px; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 14px; max-width: 380px; }
.form label {
  display: grid;
  gap: 5px;
  font-size: .9rem;
  font-weight: 600;
}
.form input, .form select, .form textarea {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  width: 100%;
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: 2px solid rgba(31, 138, 76, .35);
  border-color: var(--brand);
}
.btn {
  font: inherit;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

.auth-card { max-width: 440px; margin: 40px auto; }

/* ---------- Flash ---------- */
.flash {
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: .92rem;
  border: 1px solid transparent;
}
.flash-error { background: #fdecea; color: #8f2c22; border-color: #f5c6c0; }
.flash-success { background: #e8f6ee; color: #1c6b3f; border-color: #bfe4cd; }
.flash-info { background: #eaf1fb; color: #274b7a; border-color: #c5d8f2; }

/* ---------- Admin ---------- */
.admin-links { list-style: none; margin: 0; padding: 0; }
.admin-links li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.admin-links li:last-child { border-bottom: 0; }
.admin-links a { font-weight: 600; text-decoration: none; }
.pill {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef1f5;
  color: var(--ink-soft);
}

/* ---------- Admin tabs ---------- */
.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}
.admin-tabs a {
  text-decoration: none;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: .9rem;
  padding: 7px 12px;
  border-radius: 8px;
}
.admin-tabs a:hover { background: #eef1f5; color: var(--ink); }
.admin-tabs a.active { background: var(--brand); color: #fff; }

/* ---------- Admin forms / editor ---------- */
.form-grid {
  display: grid;
  gap: 14px 18px;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .form-grid.two { grid-template-columns: 1fr 1fr; }
  .form-grid .full { grid-column: 1 / -1; }
}
.form-grid label { display: grid; gap: 5px; font-size: .9rem; font-weight: 600; }
.form-grid input, .form-grid select, .form-grid textarea {
  font: inherit;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  width: 100%;
}
.form-grid textarea { min-height: 70px; resize: vertical; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; align-items: center; }

.inline-check { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .9rem; }
.inline-check input { width: auto; }

.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn-danger { background: #fff; border-color: #e2b6b0; color: var(--danger); }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: #eef1f5; color: var(--ink); }

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

table.data td.editcell { padding: 6px 8px; }
table.data input.mini {
  font: inherit;
  width: 64px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: right;
}
table.data input.mini.wide { width: 100%; text-align: left; }
table.data select.mini {
  font: inherit;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.banner {
  background: #fff8e6;
  border: 1px solid #f0d68a;
  color: #7a5b00;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: .9rem;
}
.banner a { font-weight: 700; }

.subcard {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: #fafbfc;
  margin-top: 14px;
}
.subcard h3 { margin: 0 0 10px; font-size: 1rem; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 22px 0;
  color: var(--ink-soft);
  font-size: .85rem;
  text-align: center;
}

/* ---------- Mobile nav ---------- */
@media (max-width: 640px) {
  .nav-toggle { display: block; }
  .main-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    padding-bottom: 10px;
  }
  .main-nav.open { display: flex; }
  .header-inner { flex-wrap: wrap; }
}
