:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3350;
  --accent: #4f8ef7;
  --accent2: #f7a94f;
  --green: #3ecf6e;
  --red: #e05c5c;
  --yellow: #f7c94f;
  --text: #e8eaf0;
  --muted: #7b8098;
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── NAV ── */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 0;
  height: 52px;
}
nav .team-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
}
nav .team-switcher .team-btn {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  padding: 3px 10px;
  border-radius: calc(var(--radius) - 2px);
  white-space: nowrap;
  text-decoration: none;
  transition: background .15s, color .15s;
}
nav .team-switcher .team-btn:hover {
  color: var(--text);
  text-decoration: none;
}
nav .team-switcher .team-btn.active {
  background: var(--accent);
  color: #fff;
}
nav .brand {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  margin-right: 32px;
  white-space: nowrap;
}
nav .brand span { color: var(--accent); }
nav a.nav-link {
  color: var(--muted);
  padding: 0 14px;
  height: 52px;
  display: flex;
  align-items: center;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  transition: color .15s, border-color .15s;
}
nav a.nav-link:hover,
nav a.nav-link.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  text-decoration: none;
}

/* ── LAYOUT ── */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px;
}

h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.subtitle { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
h2 { font-size: 16px; font-weight: 600; margin-bottom: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* ── CARDS ── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
}
.card .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.card .value { font-size: 28px; font-weight: 700; }
.card .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.card.green .value { color: var(--green); }
.card.yellow .value { color: var(--yellow); }
.card.red .value { color: var(--red); }
.card.blue .value { color: var(--accent); }

/* ── TABLE ── */
.section { margin-bottom: 40px; }

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  background: var(--surface2);
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
thead th.r { text-align: right; }
thead th.group-header { text-align: center; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
thead th.sub { font-size: 10px; padding: 5px 8px; color: var(--muted); }
td.group-left  { border-left:  1px solid var(--border); }
td.group-right { border-right: 1px solid var(--border); }
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
tbody tr:hover { background: var(--surface); }
td {
  padding: 9px 12px;
  color: var(--text);
  vertical-align: middle;
}
td.r { text-align: right; font-variant-numeric: tabular-nums; }
td.muted { color: var(--muted); }
td.green { color: var(--green); }
td.red { color: var(--red); }
td.yellow { color: var(--yellow); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green { background: #1a3d2b; color: var(--green); }
.badge-red { background: #3d1a1a; color: var(--red); }
.badge-yellow { background: #3d331a; color: var(--yellow); }
.badge-blue { background: #1a2a3d; color: var(--accent); }
.badge-gray { background: var(--surface2); color: var(--muted); }

/* ── WIN BAR ── */
.winbar {
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  min-width: 80px;
}
.winbar .w { background: var(--green); }
.winbar .d { background: var(--yellow); }
.winbar .l { background: var(--red); }

/* ── FILTERS ── */
.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  align-items: center;
}
.filters label { font-size: 12px; color: var(--muted); }
.filters select, .filters input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
}
.filters select:focus, .filters input:focus {
  outline: none;
  border-color: var(--accent);
}
.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.btn:hover { opacity: .85; }

/* ── PLAYER DETAIL ── */
.player-header {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 28px;
}
.player-avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; color: var(--accent);
  flex-shrink: 0;
}
.player-meta h1 { margin-bottom: 4px; }
.player-meta .sub { color: var(--muted); font-size: 13px; }

.detail-link { color: var(--muted); font-size: 13px; text-decoration: none; opacity: .6; }
.detail-link:hover { opacity: 1; color: var(--accent); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } }

/* ── SCORE ── */
.score {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.score .sep { color: var(--muted); margin: 0 3px; }

/* ── PAGINATION / BACK ── */
.back { margin-bottom: 20px; }
.back a { color: var(--muted); font-size: 13px; }
.back a:hover { color: var(--text); }

/* ── RANK ── */
.rank { color: var(--muted); font-weight: 600; }
.rank-1 { color: var(--yellow); }
.rank-2 { color: #a8a8a8; }
.rank-3 { color: #cd7f32; }

.pct-bar {
  display: inline-block;
  height: 4px;
  background: var(--accent);
  border-radius: 2px;
  vertical-align: middle;
  margin-left: 6px;
  opacity: .6;
}

/* ── NAHRAJ ZÁPIS ── */
.upload-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 480px;
  margin: 32px 0;
}
.upload-label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
}
.upload-label input[type=file] {
  padding: 10px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
}
.upload-label input[type=file]:hover { border-color: var(--accent); }
.upload-label span { font-size: 13px; color: var(--muted); }
.btn-primary {
  padding: 10px 24px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-start;
}
.btn-primary:hover { opacity: .85; }
.ocr-result {
  margin-top: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 720px;
}
.ocr-result h2 { margin-bottom: 16px; font-size: 16px; color: var(--accent); }
.ocr-result pre {
  white-space: pre-wrap;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}
.ocr-error {
  margin-top: 16px;
  padding: 12px 16px;
  background: #2d1a1a;
  border: 1px solid var(--red);
  border-radius: var(--radius);
  color: var(--red);
  font-size: 14px;
}
.ocr-parsed {
  margin-top: 32px;
  max-width: 720px;
}
.ocr-parsed h2 { margin-bottom: 20px; }
.ocr-parsed h3 { margin: 24px 0 10px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.parsed-header { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; }
.parsed-row { display: flex; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--border); }
.parsed-row:last-child { border-bottom: none; }
.parsed-label { min-width: 90px; color: var(--muted); font-size: 13px; }
.parsed-val { color: var(--text); font-size: 13px; }
.parsed-val.skore { font-size: 18px; font-weight: 700; color: var(--accent); }
.parsed-soupisky { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.parsed-soupisky > div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.parsed-section-title { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.parsed-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; font-size: 13px; }
.parsed-table th { background: var(--surface2); color: var(--muted); text-align: left; padding: 8px 12px; font-weight: 600; font-size: 12px; text-transform: uppercase; }
.parsed-table td { padding: 7px 12px; border-top: 1px solid var(--border); }
.td-win { color: var(--green); font-weight: 700; }
.td-loss { color: var(--red); }
.raw-toggle { margin-top: 24px; }
.raw-toggle summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 8px 0; }
.raw-text { margin-top: 12px; white-space: pre-wrap; font-size: 12px; color: var(--muted); line-height: 1.6; background: var(--surface); padding: 16px; border-radius: var(--radius); border: 1px solid var(--border); }

/* ── FORMA ─────────────────────────────────────────────────────────────────── */
.forma-section { margin-bottom: 40px; }

/* Forma tečky */
.fdot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  cursor: default;
  flex-shrink: 0;
}
.fdot-w  { background: rgba(62,207,110,.18); color: var(--green); border: 1.5px solid var(--green); }
.fdot-d  { background: rgba(247,201,79,.15); color: var(--yellow); border: 1.5px solid var(--yellow); }
.fdot-l  { background: rgba(224,92,92,.15);  color: var(--red);    border: 1.5px solid var(--red); }
.fdot-empty { background: var(--surface2); color: var(--border); border: 1.5px solid var(--border); }
.fdot-inline { width: 22px; height: 22px; font-size: 10px; }

/* Týmová forma */
.team-forma-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 12px; }
.team-forma-dots { display: flex; gap: 6px; }
.team-forma-stats { display: flex; gap: 10px; align-items: center; }

/* Statistiky forma (V/R/P) */
.fstat-w  { color: var(--green);  font-weight: 700; font-size: 14px; }
.fstat-d  { color: var(--yellow); font-weight: 700; font-size: 14px; }
.fstat-l  { color: var(--red);    font-weight: 700; font-size: 14px; }
.fstat-pct { color: var(--accent); font-weight: 700; font-size: 16px; }

/* Grafický pruh W/R/P */
.forma-bar-wrap { flex: 1 1 120px; min-width: 80px; }
.forma-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface2);
  border: 1px solid var(--border);
}
.fb-w { background: var(--green); }
.fb-d { background: var(--yellow); }
.fb-l { background: var(--red); }

/* Mřížka hráčských karet */
.player-forma-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

/* Karta hráče */
.player-forma-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pfc-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pfc-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  flex: 1;
}
.pfc-name:hover { color: var(--accent); text-decoration: none; }
.pfc-winpct { font-weight: 700; font-size: 18px; }

.trend-arrow { font-size: 13px; }
.trend-up   { color: var(--green); }
.trend-down { color: var(--red); }

.pfc-dots { display: flex; gap: 5px; flex-wrap: nowrap; }

.pfc-stats {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

/* SVG sparkline */
.sparkline {
  display: block;
  width: 100%;
  height: 32px;
  overflow: visible;
}

@media (max-width: 600px) {
  .player-forma-grid { grid-template-columns: 1fr; }
  .team-forma-row { gap: 10px; }
}

/* ── HAMBURGER ── */
.nav-links { display: flex; align-items: center; }
.nav-burger { display: none; }

/* ── MOBILNÍ BREAKPOINT ── */
@media (max-width: 768px) {
  nav {
    flex-wrap: wrap;
    height: auto;
    padding: 0 16px;
    position: relative;
  }
  .team-switcher { order: 1; margin: 10px 0; margin-right: auto; }
  .brand { order: 2; font-size: 14px; margin-right: 0; padding: 10px 0; }

  .nav-burger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    order: 3;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px 0 10px 12px;
    margin-left: auto;
  }
  .nav-burger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: opacity .2s;
  }
  .nav-burger:hover span { background: var(--accent); }

  .nav-links {
    display: none;
    flex-direction: column;
    align-items: stretch;
    order: 4;
    width: 100%;
    border-top: 1px solid var(--border);
    padding: 8px 0;
  }
  .nav-links.open { display: flex; }
  .nav-links .nav-link {
    height: auto;
    padding: 12px 4px;
    border-bottom: none;
    border-left: 3px solid transparent;
    font-size: 14px;
  }
  .nav-links .nav-link.active,
  .nav-links .nav-link:hover {
    border-bottom-color: transparent;
    border-left-color: var(--accent);
    background: var(--surface2);
    padding-left: 12px;
  }

  main { padding: 16px 12px; }
  h1 { font-size: 18px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
  .card { padding: 14px 12px; }
  .card .value { font-size: 22px; }
  .player-header { flex-direction: column; gap: 12px; }
  .filters { gap: 8px; }
  .filters select, .filters input { font-size: 12px; padding: 5px 8px; }
  .parsed-soupisky { grid-template-columns: 1fr; }
}

/* TOP historické statistiky */
.top-table { width: 100%; }
.top-table th.top1 { color: #f5c518; }
.top-table th.top2 { color: #aaa; }
.top-table th.top3 { color: #cd7f32; }
.top-label { font-weight: 600; white-space: nowrap; }
.top-cell { padding: 6px 10px; }
.top-name { font-weight: 600; }
.top-cnt  { color: var(--muted, #888); font-size: 12px; margin-left: 4px; }
