:root {
  --bg: #0f1420;
  --panel: #1a2233;
  --panel2: #212b40;
  --line: #2e3a55;
  --text: #e8edf5;
  --muted: #8fa0bd;
  --accent: #2fd46c;
  --accent2: #4d8bff;
  --gold: #ffd23f;
  --loss: #ff5c5c;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 600px at 20% -10%, #1b2a4a 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  padding: 24px 16px 60px;
}
.wrap { max-width: 1100px; margin: 0 auto; }
.header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: .5px; }
h1 .ball { display: inline-block; width: 18px; height: 18px; border-radius: 50%;
  background: conic-gradient(#111 0 20%, #fff 0 40%, #111 0 60%, #fff 0 80%, #111 0); margin-right: 8px; }
.subtitle { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.toplink { color: var(--muted); text-decoration: none; font-size: 13px; white-space: nowrap; padding: 8px 0; }
.toplink:hover { color: var(--text); }

.tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button {
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  padding: 10px 16px; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent2); font-weight: 600; }
.tab-content { display: none; }
.tab-content.active { display: block; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 20px;
}
.card h2 { margin: 0 0 12px; font-size: 17px; color: var(--text); }

.teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.team-field {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 12px;
}
.team-field > label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.media-row { display: flex; gap: 14px; margin-bottom: 12px; align-items: flex-end; }
.upload {
  position: relative; width: 48px; height: 48px; border-radius: 50%; overflow: hidden;
  cursor: pointer; border: 2px dashed var(--line); background: var(--bg);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.upload[data-field="emblem"] { width: 76px; height: 76px; }
.upload:hover { border-color: var(--accent2); }
.upload img { width: 100%; height: 100%; object-fit: cover; display: block; }
.upload .ph { font-size: 20px; color: var(--muted); font-weight: 700; }
.upload[data-field="emblem"] .ph { font-size: 30px; }
.upload svg { display: block; }
.upload .remove {
  position: absolute; top: 1px; right: 1px; width: 18px; height: 18px; line-height: 16px;
  background: rgba(0,0,0,.65); color: #fff; border: none; border-radius: 50%;
  cursor: pointer; font-size: 12px; padding: 0; display: none; text-align: center;
}
.upload:hover .remove { display: block; }
.team-field .row { margin-bottom: 8px; }
.team-field .row:last-child { margin-bottom: 0; }
.team-field .row span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.team-field .row input {
  width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 14px;
}
.team-field .row input:focus { outline: none; border-color: var(--accent2); }

.round { margin-bottom: 18px; }
.round h3 { font-size: 13px; color: var(--muted); margin: 0 0 8px; text-transform: uppercase; letter-spacing: .5px; }
.match {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: 10px; padding: 8px 12px; border-radius: 8px; background: var(--panel2);
  border: 1px solid transparent; margin-bottom: 6px; min-width: 0;
}
.match.edit { grid-template-columns: 1fr auto auto auto 1fr; }
.match.played { border-color: var(--line); }
.match .team { min-width: 0; }
.match .team .club-line, .match .team .player-line { display: flex; align-items: center; gap: 6px; }
.match .team.home .club-line, .match .team.home .player-line { justify-content: flex-end; }
.match .team .club, .match .team .player { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.match .team .club { font-size: 14px; font-weight: 600; }
.match .team .player { font-size: 11px; color: var(--muted); }
img.emblem { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
img.avatar { width: 15px; height: 15px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.emblem.ph { width: 32px; height: 32px; border-radius: 50%; background: var(--line); color: var(--text);
  font-size: 15px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; font-weight: 700; }
.match .score { font-size: 15px; font-weight: 700; padding: 4px 12px; border-radius: 7px;
  background: var(--bg); min-width: 62px; text-align: center; }
.match .score.dash { color: var(--muted); font-weight: 400; }
.match input {
  width: 46px; height: 32px; text-align: center; font-size: 15px;
  border-radius: 7px; border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
.match input:focus { outline: none; border-color: var(--accent); }
.dash { color: var(--muted); }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 8px; text-align: center; font-size: 14px; }
th { color: var(--muted); font-weight: 600; font-size: 12px; border-bottom: 1px solid var(--line); }
td.team-cell { text-align: left; }
td.team-cell .club-line, td.team-cell .player-line { display: flex; align-items: center; gap: 7px; }
td.team-cell .player-line { margin-left: 43px; }
td.team-cell .club { font-weight: 600; white-space: nowrap; }
td.team-cell .player { font-size: 11px; color: var(--muted); white-space: nowrap; }
td.team-cell img.emblem { width: 36px; height: 36px; }
td.team-cell img.avatar { width: 18px; height: 18px; }
td.team-cell .emblem.ph { width: 36px; height: 36px; font-size: 16px; }
tr.lead td { background: rgba(47, 212, 108, .08); }
tr.podium td { background: rgba(77, 139, 255, .06); }
td.pts { font-weight: 700; color: var(--gold); }
td.pos { color: var(--muted); font-weight: 700; }
.pos-medal { color: var(--gold) !important; }
.hint { font-size: 12px; color: var(--muted); margin-top: 12px; line-height: 1.6; }
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.toolbar button {
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); cursor: pointer; font-size: 13px;
}
.toolbar button:hover { border-color: var(--accent2); }
.toolbar button.danger:hover { border-color: var(--loss); color: var(--loss); }
.status { font-size: 12px; color: var(--muted); margin-left: auto; }
.status.ok { color: var(--accent); }
.status.err { color: var(--loss); }
.count { color: var(--muted); font-size: 13px; margin-top: 14px; }
.filter { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filter label { font-size: 13px; color: var(--muted); }
.filter select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding: 9px 36px 9px 12px; border-radius: 8px; border: 1px solid var(--line);
  background-color: var(--panel2);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238fa0bd' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  color: var(--text); font-size: 14px; min-width: 200px; cursor: pointer;
}
.filter select:hover { border-color: var(--accent2); }
.filter select:focus { outline: none; border-color: var(--accent2); box-shadow: 0 0 0 3px rgba(77, 139, 255, .18); }
