/* ═══ ZMIENNE ═══ */
:root {
  --bg: #f2f6fb;
  --row-even: #fff;
  --row-odd: #f7fafc;
  --text: #0e1b2b;
  --divider: #cfd7e3;
  --accent: #0f6fff;
  --radius: 12px;
  --rowH: 86px;
  --ct-sz: #0ea5e9;
  --ct-w: #f59e0b;
  --ct-z: #7c3aed;
  --ct-a: #ef4444;
  --panel-bg: #0f1628;
  --panel-border: #1f2b46;
  --input-bg: #0b1222;
  --input-border: #223055;
  --panel-text: #e5ecf8;
}

/* ═══ RESET / BASE ═══ */
html, body { height: 100%; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: #10131a linear-gradient(180deg, #10131a, #121828 50%, #0e1424);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ═══ LAYOUT ═══ */
.app {
  flex: 1 0 auto;
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 18px;
  padding: 18px;
  box-sizing: border-box;
  align-items: start;
}

@media (max-width: 1400px) {
  .app { grid-template-columns: 340px 1fr; }
}
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    padding: 10px;
  }
  .stage-wrap { order: -1; }
}

/* ═══ LINKI-PRZYCISKI ═══ */
a.btn, a.btn.secondary {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

/* ═══ PANEL ═══ */
.panel {
  background: var(--panel-bg);
  color: var(--panel-text);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 16px;
  position: sticky;
  top: 18px;
}

.panel .row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
}

/* ═══ UJEDNOLICONE INPUTY ═══ */
.panel input[type="number"],
.panel input[type="text"],
.panel select,
.text,
.select,
.db-search {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--panel-text);
  border-radius: 8px;
  padding: 8px 10px;
}

.db-search { width: 100%; }

/* ═══ PRZYCISKI ═══ */
.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
}

.btn.secondary { background: #223055; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ═══ SEPARATORY ═══ */
.sep { border: none; border-top: 1px solid #253052; margin: 14px 0; }
.note { font-size: 12px; color: #a9b6cb; }
.note-top { margin-top: 8px; }

/* ═══ ROWS — inline styles przeniesione do klas ═══ */
/* ✅ Wszędzie takie same przyciski w nawigacji */
.row.nav {
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 0;
  margin-bottom: 12px;
}

.row.nav .btn {
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
}
.actions-row { gap: 10px; flex-wrap: wrap; }
.club-row { gap: 8px; flex-wrap: wrap; }
.club-select { min-width: 220px; }

/* ═══ SEKCJE ROZWIJANE ═══ */
.sec,
.help {
  margin-top: 12px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 12px;
  padding: 10px;
}

.sec summary,
.help summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 800;
  color: var(--panel-text);
  list-style: none;
}

.sec summary::-webkit-details-marker,
.help summary::-webkit-details-marker { display: none; }

/* Chevron przez CSS */
.sec summary::before,
.help summary::before {
  content: "▾";
  display: inline-block;
  transition: transform .2s ease;
}

.sec:not([open]) summary::before,
.help:not([open]) summary::before {
  transform: rotate(-90deg);
}

/* ═══ STAGE ═══ */
.stage-wrap {
  overflow: auto;
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
}

.stage {
  box-sizing: border-box;
  width: 1920px;
  height: 1080px;
  padding: 24px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.stage.exporting .sort-btn { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.title {
  font-weight: 800;
  font-size: 38px;
  color: #10243a;
  margin: 0;
}

/* ═══ BOARD ═══ */
.board {
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(16, 24, 40, .08);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.board-header {
  display: grid;
  grid-template-columns: 110px 96px 110px 1fr 150px;
  align-items: center;
  padding: 0 16px;
  height: 76px;
  border-bottom: 1px solid var(--divider);
  font-weight: 700;
  font-size: 20px;
  color: #334155;
  background: #f8fafc;
}

.header-pos { padding-left: 8px; }
.board-header .th-cc { text-align: center; justify-self: center; }
.header-right { display: flex; align-items: center; justify-content: center; gap: 8px; }

.sort-btn {
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
  color: #0b2239;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
}

/* ═══ ROWS ═══ */
#rows {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-auto-rows: var(--rowH);
}

.row-item {
  position: relative;
  display: grid;
  grid-template-columns: 110px 96px 110px 1fr 150px;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid #eef2f7;
}

.row-item:nth-child(odd) { background: var(--row-odd); }
.row-item:nth-child(even) { background: var(--row-even); }
.row-item.selected { outline: 3px solid rgba(15, 111, 255, .45); outline-offset: -3px; }
.row-item.db-over { outline: 3px dashed #0f6fff; outline-offset: -3px; }

.pos {
  font-weight: 800;
  font-size: 28px;
  color: #243244;
  display: flex;
  gap: 10px;
  align-items: center;
  cursor: grab;
  user-select: none;
}

.club { display: flex; align-items: center; gap: 6px; }

.logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  background: #f2f4f7;
  border-radius: 12px;
  border: 1px solid #e5e8ef;
}

.cc-cell { display: flex; align-items: center; justify-content: center; }

.name {
  font-size: 24px;
  font-weight: 700;
  outline: none;
  cursor: text;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.name[contenteditable][data-ph]:empty::before {
  content: attr(data-ph);
  color: #94a3b8;
}

.goals {
  font-weight: 900;
  font-size: 24px;
  text-align: center;
  color: #082038;
  border-left: 2px solid var(--divider);
  padding-left: 16px;
  cursor: text;
}

.gval:focus { outline: none; }

/* ═══ CC PICKER (przycisk w wierszu) ═══ */
.cc { position: relative; }

.cc-btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  min-width: 64px;
  padding: 0 12px;
  border: 1px solid #d8e1ee;
  border-radius: 12px;
  background: #f8fafc;
  font-weight: 800;
  color: #273146;
  text-transform: uppercase;
  cursor: pointer;
}

.cc-btn[data-cc="SZ"] { background: #e7f3ff; border-color: #cfe5ff; color: #0b2239; }
.cc-btn[data-cc="W"]  { background: #fff3da; border-color: #fde2b1; color: #5a3a00; }
.cc-btn[data-cc="Z"]  { background: #f2e9ff; border-color: #e0d2ff; color: #3a1f6b; }
.cc-btn[data-cc="A"]  { background: #ffe8e8; border-color: #ffd0d0; color: #6b1f1f; }

/* ═══ GLOBALNE MENU CC ═══ */
.ccg-menu {
  position: fixed;
  z-index: 1000;
  display: none;
  background: #fff;
  border: 1px solid #e5e8ef;
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(16, 24, 40, .18);
  padding: 8px;
  min-width: 220px;
}

.ccg-menu.open { display: block; }
.ccg-list { display: grid; gap: 6px; }

.ccg-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: #fff;
  border: 0;
  text-align: left;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  color: #0b2239;
}

.ccg-opt:hover { background: #f6f8fb; }

.ccg-chip {
  min-width: 42px;
  height: 28px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.ccg-chip.sz { background: #e7f3ff; border-color: #cfe5ff; color: #0b2239; }
.ccg-chip.w  { background: #fff3da; border-color: #fde2b1; color: #5a3a00; }
.ccg-chip.z  { background: #f2e9ff; border-color: #e0d2ff; color: #3a1f6b; }
.ccg-chip.a  { background: #ffe8e8; border-color: #ffd0d0; color: #6b1f1f; }

.ccg-label { font-weight: 700; color: #334155; }

/* ═══ BAZA ZAWODNIKÓW ═══ */
.pdb-list {
  display: grid;
  gap: 8px;
  margin: 10px 0;
  max-height: 260px;
  overflow: auto;
}

.pdb-item {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  column-gap: 10px;
  align-items: center;
  background: linear-gradient(180deg, #0b1222, #0e1730);
  border: 1px solid var(--input-border);
  color: var(--panel-text);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: grab;
  transition: .15s border-color, .15s background;
}

.pdb-item:hover { border-color: #2a3c6b; background: #0f1c39; }
.pdb-item[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

.pdb-badge {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--badge, #5b9dff);
  color: #eaf2ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
}

.pdb-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pdb-cc {
  justify-self: end;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 12px;
  color: #fff;
}

.pdb-cc[data-cc="SZ"] { background: var(--ct-sz); }
.pdb-cc[data-cc="W"]  { background: var(--ct-w); }
.pdb-cc[data-cc="Z"]  { background: var(--ct-z); }
.pdb-cc[data-cc="A"]  { background: var(--ct-a); }

/* ═══ FILTRY KRAJÓW ═══ */
.country-filter {
  display: flex;
  gap: 8px;
  margin: 6px 0 8px;
  flex-wrap: wrap;
}

.country-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
  border: 1px solid #d8e1ee;
  background: #f8fafc;
  color: #273146;
  cursor: pointer;
  transition: .15s transform, .15s background, .15s border-color;
}

.country-pill:hover { transform: translateY(-1px); }

#pdbCcFilter .country-pill[data-cc="SZ"] { background: #e7f3ff; border-color: #cfe5ff; color: #0b2239; }
#pdbCcFilter .country-pill[data-cc="W"]  { background: #fff3da; border-color: #fde2b1; color: #5a3a00; }
#pdbCcFilter .country-pill[data-cc="Z"]  { background: #f2e9ff; border-color: #e0d2ff; color: #3a1f6b; }
#pdbCcFilter .country-pill[data-cc="A"]  { background: #ffe8e8; border-color: #ffd0d0; color: #6b1f1f; }

#pdbCcFilter .country-pill.active {
  box-shadow: 0 2px 0 rgba(16, 24, 40, .06), inset 0 0 0 1px rgba(16, 24, 40, .05);
}

#pdbCcFilter .country-pill.clear {
  background: var(--input-bg);
  border: 1px dashed var(--input-border);
  color: var(--panel-text);
}

/* ═══ AUTOCOMPLETE ═══ */
.ac {
  position: fixed;
  z-index: 1000;
  display: none;
  background: #fff;
  border: 1px solid #e5e8ef;
  border-radius: 10px;
  box-shadow: 0 12px 24px rgba(16, 24, 40, .18);
  padding: 6px;
  max-height: 220px;
  overflow: auto;
  min-width: 240px;
}

.ac-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: transparent;
  border: 0;
  text-align: left;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  color: #0b2239;
}

.ac-item:hover,
.ac-item.selected { background: #f1f5f9; }

.ac-badge {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--badge, #2b67ff);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
}

.ac-text {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ac-tags { margin-left: 6px; opacity: .9; }

/* ═══ ERROR ═══ */
.db-error {
  background: #311b1b;
  color: #ffd9d9;
  border: 1px solid #5b2b2b;
  border-radius: 10px;
  padding: 8px 10px;
  margin: 8px 0;
  font-size: 13px;
}

/* ═══ POMOC ═══ */
.help-grid { margin-top: 10px; display: grid; gap: 10px; }

.help-sec {
  background: var(--panel-bg);
  border: 1px dashed var(--input-border);
  border-radius: 10px;
  padding: 8px 10px;
  color: #d7e1f3;
}

.help-sec h4 {
  margin: 0 0 6px;
  font-size: 12px;
  color: #a9b6cb;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.help-sec ul { margin: 0; padding-left: 18px; }
.help-sec li { margin: 4px 0; font-size: 13px; line-height: 1.25; }

/* ═══ FOOTER ═══ */
.site-footer {
  padding: 12px 18px 18px;
  text-align: right;
  font-weight: 700;
  color: #a9b6cb;
}
/* ═══ PANEL — scroll gdy za wysoki ═══ */
.panel {
  background: var(--panel-bg);
  color: var(--panel-text);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 16px;
  position: sticky;
  top: 18px;

  /* ✅ NOWE */
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #223055 transparent;
}

.panel::-webkit-scrollbar { width: 6px; }
.panel::-webkit-scrollbar-track { background: transparent; }
.panel::-webkit-scrollbar-thumb { background: #223055; border-radius: 3px; }
.panel::-webkit-scrollbar-thumb:hover { background: #2a3c6b; }

/* ═══ STAGE-WRAP ═══ */
.stage-wrap {
  overflow: hidden;  /* ✅ zmiana z auto na hidden */
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
}