/* ═══════════════════════════════════════════════════════════
   ALPB Umpire Intel — Global Stylesheet
   Dark theme matching existing ALPB design language
   ═══════════════════════════════════════════════════════════ */

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

:root {
  --bg:           #0d1117;
  --bg-card:      #161b22;
  --bg-card-2:    #1c2431;
  --bg-hover:     #1e2d3d;
  --border:       #30363d;
  --border-light: #21262d;
  --text:         #e6edf3;
  --text-muted:   #8b949e;
  --text-dim:     #656d76;
  --accent:       #58a6ff;
  --accent-dim:   #1f6feb;
  --green:        #3fb950;
  --red:          #f85149;
  --orange:       #d29922;
  --purple:       #bc8cff;
  --font:         'DM Sans', system-ui, -apple-system, sans-serif;
  --radius:       8px;
  --radius-sm:    4px;
  --shadow:       0 4px 24px rgba(0,0,0,0.4);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ─────────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.5rem;
  height: 52px;
  background: #161b22;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.05em;
  text-decoration: none;
  flex-shrink: 0;
}

.nav-desktop {
  display: flex;
  gap: .2rem;
  align-items: center;
  flex: 1;
}

.nav-desktop a {
  padding: .35rem .7rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: color .15s, background .15s;
}
.nav-desktop a:hover,
.nav-desktop a.active { color: var(--text); background: var(--bg-hover); }

.header-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-shrink: 0;
}

.header-user span {
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Hamburger ───────────────────────────────────────────────── */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  margin-left: auto;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-muted);
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.side-menu {
  position: fixed;
  top: 52px; right: 0; bottom: 0;
  width: 220px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform .25s ease;
  z-index: 200;
  overflow-y: auto;
}
.side-menu.open { transform: translateX(0); }
.side-menu nav ul { list-style: none; padding: 1rem 0; }
.side-menu nav li a {
  display: block;
  padding: .65rem 1.25rem;
  color: var(--text-muted);
  font-size: 14px;
  transition: background .15s, color .15s;
}
.side-menu nav li a:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 150;
}
.overlay.visible { display: block; }

@media (max-width: 768px) {
  .nav-desktop { display: none; }
  .hamburger   { display: flex; }
}

/* ── Main layout ─────────────────────────────────────────────── */
.main-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}

.card h4 {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .85rem;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem .9rem;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: default; }

.btn-primary {
  background: var(--accent-dim);
  color: #fff;
  border-color: var(--accent-dim);
}
.btn-primary:hover:not(:disabled) { background: var(--accent); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }

.btn-danger {
  background: transparent;
  color: var(--red);
  border-color: var(--red);
}
.btn-danger:hover:not(:disabled) { background: var(--red); color: #fff; }

.btn-sm {
  padding: .25rem .55rem;
  font-size: 12px;
}

.btn-watch {
  background: #0d4f8c;
  color: #fff;
  border-color: #1a6db3;
}
.btn-watch:hover { background: #1a6db3; }

.btn-composite {
  background: #3d1f6e;
  color: #fff;
  border-color: #5c3299;
}
.btn-composite:hover { background: #5c3299; }

/* ── Filters panel ───────────────────────────────────────────── */
.filters-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.filters-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem 1rem;
  align-items: flex-end;
}

.filters-grid > div {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}

.filters-grid label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.filters-grid input,
.filters-grid select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: .4rem .6rem;
  min-width: 120px;
  outline: none;
  transition: border-color .15s;
}
.filters-grid input:focus,
.filters-grid select:focus { border-color: var(--accent); }
.filters-grid select option { background: var(--bg-card); }

/* ── Charts row ──────────────────────────────────────────────── */
.charts-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.chart-card h4 {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .75rem;
}

/* ── Stat pill row ───────────────────────────────────────────── */
.stat-pills {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1.25rem;
}
.stat-pill {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1.1rem;
  min-width: 130px;
}
.stat-pill .label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .25rem;
}
.stat-pill .value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.1;
}
.stat-pill .sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: .15rem;
}
.value.green { color: var(--green); }
.value.red   { color: var(--red);   }
.value.blue  { color: var(--accent); }
.value.orange { color: var(--orange); }

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead tr { background: var(--bg-hover); }
.data-table th {
  padding: .55rem .75rem;
  text-align: left;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}
.data-table th:hover { color: var(--text); }
.data-table th.sort-asc::after  { content: ' ↑'; color: var(--accent); }
.data-table th.sort-desc::after { content: ' ↓'; color: var(--accent); }
.data-table td {
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
  color: var(--text);
}
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }

.data-table .rank-cell { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.data-table .ump-link  { color: var(--accent); font-weight: 600; cursor: pointer; }
.data-table .ump-link:hover { text-decoration: underline; }
.data-table .acc-good  { color: var(--green); font-weight: 700; }
.data-table .acc-ok    { color: var(--orange); font-weight: 600; }
.data-table .acc-bad   { color: var(--red); font-weight: 600; }
.data-table .favor-pos { color: var(--red);    font-size: 12px; }
.data-table .favor-neg { color: var(--accent); font-size: 12px; }

/* ── Tabs ────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: .25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
  overflow-x: auto;
}
.tab-btn {
  padding: .6rem 1rem;
  border: none;
  background: none;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover  { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Auth pages ──────────────────────────────────────────────── */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: var(--bg);
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 400px;
}

.auth-card .logo-big {
  text-align: center;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: .1em;
  margin-bottom: .25rem;
  color: var(--text);
}

.auth-card .sub-title {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 1.75rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  margin-bottom: 1rem;
}
.form-group label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.form-group input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: .6rem .8rem;
  width: 100%;
  outline: none;
  transition: border-color .15s;
}
.form-group input:focus { border-color: var(--accent); }

.auth-card .btn { width: 100%; justify-content: center; padding: .65rem; font-size: 14px; margin-top: .5rem; }
.auth-err { color: var(--red); font-size: 13px; margin-bottom: .75rem; display: none; }
.auth-link { text-align: center; margin-top: 1rem; font-size: 13px; color: var(--text-muted); }
.auth-link a { color: var(--accent); }

/* ── Canvas plate view ───────────────────────────────────────── */
.plate-canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1.3;
  max-height: 480px;
}
.plate-canvas-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.canvas-tooltip {
  position: fixed;
  pointer-events: none;
  background: #1c2431;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .5rem .7rem;
  font-size: 12px;
  color: var(--text);
  z-index: 999;
  display: none;
  white-space: nowrap;
  box-shadow: var(--shadow);
}

/* ── Miss table ──────────────────────────────────────────────── */
.miss-badge {
  display: inline-block;
  padding: .15rem .4rem;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
}
.miss-badge.phantom { background: rgba(248,81,73,.15); color: var(--red); }
.miss-badge.robbery { background: rgba(88,166,255,.15); color: var(--accent); }

/* ── Rank card ───────────────────────────────────────────────── */
.rank-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 200px;
  text-align: center;
  gap: .6rem;
}
.rank-card .rank-num { font-size: 3rem; font-weight: 800; color: var(--accent); }
.rank-card .rank-of  { font-size: 1rem; color: var(--text-muted); }
.rank-card .rank-pct { font-size: 1.3rem; font-weight: 700; color: var(--green); }

/* ── Catcher section ─────────────────────────────────────────── */
.framing-bar-wrap { display: flex; align-items: center; gap: .5rem; }
.framing-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--bg);
  flex: 1;
  overflow: hidden;
  position: relative;
}
.framing-bar .fill {
  position: absolute;
  top: 0; bottom: 0;
  border-radius: 4px;
}
.fill.pos { background: var(--green); left: 50%; }
.fill.neg { background: var(--red);   right: 50%; }

/* ── Dashboard summary cards ─────────────────────────────────── */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .85rem;
  margin-bottom: 1.5rem;
}
.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.summary-card .sc-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .4rem;
}
.summary-card .sc-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.summary-card .sc-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: .3rem;
}

/* ── Loading spinner ─────────────────────────────────────────── */
.spinner-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Video / image overlay ───────────────────────────────────── */
.media-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.media-overlay.show { display: flex; }
.media-overlay .close-btn {
  position: absolute;
  top: 1rem; right: 1.25rem;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  opacity: .8;
}
.media-overlay .close-btn:hover { opacity: 1; }
.media-overlay video {
  max-width: 92vw;
  max-height: 85vh;
  border-radius: var(--radius);
}
.media-overlay img {
  max-width: 92vw;
  max-height: 85vh;
  border-radius: var(--radius);
  object-fit: contain;
}

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem;
  font-size: 14px;
}

/* ── Section header ──────────────────────────────────────────── */
.section-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .85rem;
}
.section-hdr h3 {
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Accuracy pct color helpers ──────────────────────────────── */
.pct-good  { color: var(--green);  font-weight: 700; }
.pct-ok    { color: var(--orange); font-weight: 600; }
.pct-bad   { color: var(--red);    font-weight: 600; }

/* ── Utility ─────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-sm    { font-size: 12px; }
.mt-1  { margin-top: .5rem; }
.mt-2  { margin-top: 1rem; }
.mb-1  { margin-bottom: .5rem; }
.mb-2  { margin-bottom: 1rem; }
.flex  { display: flex; }
.gap-1 { gap: .5rem; }
.items-center { align-items: center; }
