/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --green-dark:   #1a3a2a;
  --green:        #2d7a3a;
  --green-light:  #4caf50;
  --green-pale:   #e8f5e9;
  --accent:       #f39c12;
  --accent-pale:  #fef9e7;
  --red:          #e74c3c;
  --red-pale:     #fdecea;
  --blue:         #2980b9;
  --blue-pale:    #d6eaf8;
  --purple:       #8e44ad;
  --purple-pale:  #f3e5f5;
  --gray:         #95a5a6;
  --gray-pale:    #f2f3f4;
  --text:         #1a1a1a;
  --text-muted:   #666;
  --border:       #e0e0e0;
  --card-bg:      #ffffff;
  --bg:           #f5f7f5;
  --header-h:     56px;
  --nav-h:        64px;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 2px 8px rgba(0,0,0,.08);
  --shadow-lg:    0 4px 20px rgba(0,0,0,.12);
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-top: var(--header-h);
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}

/* ── Typography ───────────────────────────────────────── */
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1.1rem;  font-weight: 600; }
p  { line-height: 1.6; color: var(--text-muted); }
a  { color: var(--green); text-decoration: none; }

/* ── Header ───────────────────────────────────────────── */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  background: var(--green-dark);
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 100%; padding: 0 1rem;
  max-width: 900px; margin: 0 auto;
}
.logo { color: #fff; font-size: 1.1rem; font-weight: 700; }
.header-right { display: flex; align-items: center; gap: .5rem; }
.user-chip {
  font-size: .75rem; color: rgba(255,255,255,.8);
  display: flex; align-items: center; gap: .25rem;
}
.btn-icon {
  color: #fff; font-size: 1.2rem; padding: .4rem;
  border-radius: 50%; transition: background .2s;
}
.btn-icon:hover { background: rgba(255,255,255,.15); }

/* ── Bottom Nav ───────────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex; align-items: stretch;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -2px 8px rgba(0,0,0,.06);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--gray); gap: 2px; font-size: .7rem;
  transition: color .2s;
}
.nav-item.active { color: var(--green); }
.nav-item.nav-measure { color: var(--accent); }
.nav-item.nav-measure.active { color: var(--accent); }
.nav-icon { font-size: 1.3rem; line-height: 1; }

/* ── Main Content ─────────────────────────────────────── */
.main { max-width: 900px; margin: 0 auto; padding: 1rem; }
.page-title {
  display: flex; align-items: center; gap: .5rem;
  margin-bottom: 1rem;
}
.page-title h1 { font-size: 1.3rem; }

/* ── Cards ────────────────────────────────────────────── */
.card {
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  margin-bottom: 1rem;
}
.card-header {
  padding: .9rem 1rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h2, .card-header h3 { margin: 0; }
.card-body { padding: 1rem; }

/* ── Grid ─────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; }
@media (max-width: 480px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
}

/* ── Stat Cards ───────────────────────────────────────── */
.stat-card {
  background: var(--card-bg); border-radius: var(--radius-sm);
  padding: 1rem; box-shadow: var(--shadow);
  text-align: center;
}
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--green); }
.stat-card .stat-label { font-size: .8rem; color: var(--text-muted); margin-top: .2rem; }

/* ── Score Ring ───────────────────────────────────────── */
.score-ring {
  width: 64px; height: 64px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.1rem; color: #fff;
  flex-shrink: 0;
}

/* ── Player List ──────────────────────────────────────── */
.player-list { list-style: none; }
.player-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1rem; border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.player-item:last-child { border-bottom: none; }
.player-item:hover { background: var(--gray-pale); }
.player-item a { display: flex; align-items: center; gap: .75rem; flex: 1; color: var(--text); }
.player-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--green); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem; flex-shrink: 0;
}
.player-info { flex: 1; min-width: 0; }
.player-name { font-weight: 600; font-size: .95rem; }
.player-meta { font-size: .78rem; color: var(--text-muted); }

/* ── Badges ───────────────────────────────────────────── */
.badge {
  display: inline-block; padding: .2rem .55rem;
  border-radius: 20px; font-size: .72rem; font-weight: 600;
}
.badge-green  { background: var(--green-pale);  color: var(--green); }
.badge-red    { background: var(--red-pale);    color: var(--red); }
.badge-orange { background: var(--accent-pale); color: #a04000; }
.badge-gray   { background: var(--gray-pale);   color: var(--gray); }
.badge-blue   { background: var(--blue-pale);   color: var(--blue); }
.badge-purple { background: var(--purple-pale); color: var(--purple); }

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .65rem 1.1rem; border-radius: var(--radius-sm);
  font-size: .9rem; font-weight: 600; cursor: pointer;
  border: none; transition: all .2s; text-decoration: none;
  white-space: nowrap;
}
.btn-primary   { background: var(--green);  color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-secondary { background: var(--gray-pale); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger    { background: var(--red); color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-accent    { background: var(--accent); color: #fff; }
.btn-sm { padding: .4rem .7rem; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-lg { padding: .9rem 1.4rem; font-size: 1rem; }

/* ── Forms ────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block; font-size: .85rem; font-weight: 600;
  margin-bottom: .4rem; color: var(--text);
}
.form-label span { color: var(--gray); font-weight: 400; margin-left: .3rem; }
.form-control {
  width: 100%; padding: .75rem 1rem;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 1rem; font-family: inherit; background: #fff;
  transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none;
}
.form-control:focus {
  outline: none; border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(45,122,58,.15);
}
.form-control.is-invalid { border-color: var(--red); }
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: .3rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 400px) { .form-row { grid-template-columns: 1fr; } }

/* ── Login Page ───────────────────────────────────────── */
body.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 1rem;
  background: linear-gradient(135deg, var(--green-dark), var(--green));
  padding-top: 0; padding-bottom: 0;
}
.login-card {
  background: #fff; border-radius: 1.2rem;
  padding: 2rem; width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo {
  text-align: center; font-size: 3rem; margin-bottom: .5rem;
}
.login-title {
  text-align: center; font-size: 1.4rem; font-weight: 700;
  margin-bottom: .3rem;
}
.login-sub {
  text-align: center; font-size: .85rem; color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* ── Flash Messages ───────────────────────────────────── */
.flash {
  position: fixed; top: calc(var(--header-h) + .5rem);
  left: 50%; transform: translateX(-50%);
  padding: .75rem 1.25rem; border-radius: var(--radius-sm);
  font-size: .9rem; font-weight: 600; z-index: 200;
  box-shadow: var(--shadow-lg); white-space: nowrap;
  animation: slideDown .3s ease;
}
.flash-success { background: var(--green); color: #fff; }
.flash-error   { background: var(--red);   color: #fff; }
@keyframes slideDown { from { opacity:0; transform: translateX(-50%) translateY(-10px); } }

/* ── Tables ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th {
  background: var(--green-pale); color: var(--green-dark);
  padding: .65rem .8rem; text-align: left; font-size: .78rem;
  font-weight: 700; letter-spacing: .03em; white-space: nowrap;
}
td { padding: .65rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-pale); }

/* ── Progress Bar ─────────────────────────────────────── */
.progress-bar {
  height: 8px; background: var(--border); border-radius: 4px; overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 4px; transition: width .6s ease;
}

/* ── Pitch ────────────────────────────────────────────── */
.pitch-wrap {
  background: #2d7a3a; border-radius: var(--radius);
  padding: 1rem; aspect-ratio: 7/10; position: relative;
  border: 3px solid #1a3a2a;
  max-width: 400px; margin: 0 auto;
}
.pitch-line {
  position: absolute; background: rgba(255,255,255,.4);
}
.pitch-center-h {
  left: 0; right: 0; top: 50%; height: 2px;
}
.pitch-box-top {
  left: 20%; right: 20%; top: 0; height: 18%; border: 2px solid rgba(255,255,255,.4);
  border-top: none; background: transparent;
}
.pitch-box-bot {
  left: 20%; right: 20%; bottom: 0; height: 18%; border: 2px solid rgba(255,255,255,.4);
  border-bottom: none; background: transparent;
}
.pitch-player {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  cursor: default;
}
.pitch-player-dot {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .65rem; font-weight: 700; color: #fff;
  border: 2px solid rgba(255,255,255,.7);
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
  text-align: center; line-height: 1.1;
}
.pitch-player-name {
  font-size: .6rem; color: #fff; font-weight: 600;
  text-shadow: 0 1px 3px rgba(0,0,0,.8);
  max-width: 60px; text-align: center; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

/* ── Profile ──────────────────────────────────────────── */
.profile-header {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.25rem; background: var(--green-dark);
  color: #fff; border-radius: var(--radius) var(--radius) 0 0;
}
.profile-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--green); display: flex; align-items: center;
  justify-content: center; font-size: 1.5rem; font-weight: 700;
  border: 3px solid rgba(255,255,255,.3); flex-shrink: 0;
}
.profile-name { font-size: 1.2rem; font-weight: 700; }
.profile-meta { font-size: .82rem; opacity: .8; margin-top: .2rem; }

/* ── Metric Entry ─────────────────────────────────────── */
.metric-group {
  background: var(--gray-pale); border-radius: var(--radius-sm);
  padding: .75rem; margin-bottom: .5rem;
}
.metric-group-title {
  font-size: .78rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: .5rem;
}
.metric-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.metric-input-wrap { display: flex; flex-direction: column; gap: .25rem; }
.metric-input-wrap label { font-size: .78rem; color: var(--text-muted); }
.metric-val {
  padding: .5rem .65rem; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: .95rem; background: #fff;
  width: 100%; -webkit-appearance: none;
}
.metric-val:focus {
  outline: none; border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(45,122,58,.15);
}

/* ── Score Grid ───────────────────────────────────────── */
.score-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem;
  margin: .75rem 0;
}
.score-item {
  text-align: center; padding: .6rem .3rem;
  border-radius: var(--radius-sm); background: var(--gray-pale);
}
.score-item .val { font-size: 1.3rem; font-weight: 700; }
.score-item .lbl { font-size: .68rem; color: var(--text-muted); margin-top: .1rem; }

/* ── Chart ────────────────────────────────────────────── */
.chart-wrap { position: relative; height: 220px; margin: .5rem 0; }

/* ── Team Card ────────────────────────────────────────── */
.team-card {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem; background: var(--card-bg);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: .75rem; text-decoration: none; color: var(--text);
  transition: box-shadow .2s;
}
.team-card:hover { box-shadow: var(--shadow-lg); }
.team-icon {
  width: 48px; height: 48px; border-radius: var(--radius-sm);
  background: var(--green); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.team-info h3 { margin-bottom: .2rem; }
.team-info p  { font-size: .82rem; }

/* ── Tabs ─────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 1rem; }
.tab-btn {
  padding: .6rem 1rem; font-size: .88rem; font-weight: 600;
  color: var(--text-muted); cursor: pointer; background: none;
  border: none; border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: all .2s;
}
.tab-btn.active { color: var(--green); border-bottom-color: var(--green); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Empty State ──────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 3rem 1rem; color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: .75rem; }
.empty-state p { font-size: .95rem; }

/* ── Search ───────────────────────────────────────────── */
.search-bar {
  display: flex; gap: .5rem; margin-bottom: 1rem;
}
.search-bar input { flex: 1; }

/* ── Trend Indicators ─────────────────────────────────── */
.trend-up   { color: var(--green-light); font-weight: 700; }
.trend-down { color: var(--red);         font-weight: 700; }
.trend-flat { color: var(--gray);        font-weight: 700; }

/* ── Admin specific ───────────────────────────────────── */
.admin-section { margin-bottom: 2rem; }
.admin-section h2 { margin-bottom: .75rem; }

/* ── Utility ──────────────────────────────────────────── */
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: .85rem; }
.flex        { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.w-full { width: 100%; }
.hidden { display: none; }
