:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e4e6ea;
  --text: #1a1d21;
  --text-muted: #6b7280;
  --primary: #16a34a;
  --primary-hover: #15803d;
  --destructive: #dc2626;
  --radius: 14px; /* trend: mocniej zaokrąglone karty (spójnie z aplikacją) */
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}

a {
  color: inherit;
}

h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}

.muted {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ---------------------------------------------------- strony logowania */

.auth-page {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-brand {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-brand h1 {
  font-size: 1.875rem;
  font-weight: 700;
}

.auth-brand p {
  margin: 0.25rem 0 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 24rem;
}

.card h2 {
  margin: 0 0 0.25rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.card > p {
  margin: 0 0 1.25rem;
}

/* ------------------------------------------------------------ formularze */

form {
  display: grid;
  gap: 1rem;
}

.field {
  display: grid;
  gap: 0.4rem;
}

label {
  font-size: 0.875rem;
  font-weight: 500;
}

input,
select {
  font: inherit;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  background: var(--surface);
  width: 100%;
}

input:focus,
select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: transparent;
}

button {
  font: inherit;
  font-weight: 500;
  padding: 0.55rem 1rem;
  border: none;
  border-radius: calc(var(--radius) - 4px);
  background: var(--primary);
  color: #fff;
  cursor: pointer;
}

button:hover {
  background: var(--primary-hover);
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

button.outline,
a.button-outline {
  display: block;
  text-align: center;
  text-decoration: none;
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
}

button.outline:hover,
a.button-outline:hover {
  background: var(--bg);
}

a.button-primary {
  display: block;
  text-align: center;
  text-decoration: none;
  padding: 0.55rem 1rem;
  border-radius: calc(var(--radius) - 4px);
  background: var(--primary);
  color: #fff;
  font-weight: 500;
}

a.button-primary:hover {
  background: var(--primary-hover);
}

.error {
  color: var(--destructive);
  font-size: 0.875rem;
  margin: 0;
}

/* Potwierdzenie udanego zapisu (np. ustawienia profilu). */
.success {
  color: var(--primary);
  font-size: 0.875rem;
  margin: 0;
}

/* Wiersz edycji profilu pod opieką (children.html, profile.html): pole + przycisk obok
   (globalny `form` to grid w pionie — tu nadpisujemy na rząd). */
.child-row {
  display: flex;
  gap: 0.5rem;
}

.child-row input {
  flex: 1;
  min-width: 0;
}

.child-row button {
  flex-shrink: 0;
  white-space: nowrap;
}

.form-footer {
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ------------------------------------------------------- układ aplikacji */

.app {
  display: flex;
  min-height: 100svh;
}

.sidebar {
  width: 15rem;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 1rem;
}

.sidebar-brand {
  font-size: 1.125rem;
  font-weight: 700;
  padding: 0.25rem 0.5rem;
}

.sidebar-team {
  padding: 0 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Przełącznik aktywnej grupy/podgrupy w sidebarze (team-context.js). */
.context-switch {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0 0.25rem;
}
.context-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding-left: 0.25rem;
}
.context-current {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  padding-left: 0.25rem;
}
.context-select {
  width: 100%;
  padding: 0.5rem 0.6rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
}
.context-select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

/* Lista podgrup w szczegółach grupy (team.html). */
.subgroup-card + .subgroup-card {
  margin-top: 0.6rem;
}
.subgroup-roster {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.25rem 0.75rem;
}

/* Etykieta drużyny przy wpisie na scalonych listach. */
.team-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary, #2563eb);
  background: color-mix(in srgb, var(--primary, #2563eb) 12%, transparent);
  border-radius: 999px;
}

/* Strona Drużyny — lista wierszy. */
.team-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}
.team-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  text-decoration: none;
  color: inherit;
  border-top: 1px solid var(--border);
}
.team-row:first-child {
  border-top: none;
}
.team-row:hover {
  background: color-mix(in srgb, var(--primary) 6%, transparent);
}
.team-row-name {
  font-weight: 600;
}
.team-row-count {
  margin-left: auto;
  font-size: 0.8125rem;
}
.team-row-arrow {
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
}

/* Szczegół drużyny — pudełko z linkiem zaproszenia. */
.card-box {
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.invite-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.invite-link {
  flex: 1 1 240px;
  min-width: 0;
  padding: 0.35rem 0.5rem;
  font-size: 0.8125rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg, #fff);
}
td.right,
th.right {
  text-align: right;
}

/* Grupy: chipy przydziału w rosterze i panelu grup. */
.groups-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
}
.group-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.grp-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.4rem 0.15rem 0.55rem;
  font-size: 0.8125rem;
  color: var(--primary, #2563eb);
  background: color-mix(in srgb, var(--primary, #2563eb) 12%, transparent);
  border-radius: 999px;
  white-space: nowrap;
}
.grp-chip button {
  padding: 0;
  width: 1.1rem;
  height: 1.1rem;
  line-height: 1;
  font-size: 0.95rem;
  color: inherit;
  background: transparent;
  border: none;
  border-radius: 999px;
  cursor: pointer;
}
.grp-chip button:hover {
  background: color-mix(in srgb, var(--primary, #2563eb) 22%, transparent);
}
.grp-chip.grp-manage {
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
}
.grp-count {
  padding: 0 0.35rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--text-muted) 15%, transparent);
  border-radius: 999px;
}
.grp-add {
  padding: 0.15rem 0.35rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
}

/* Wyszukiwarka „Dodaj uczestnika z puli” w widoku grupy. */
.pool-list {
  margin-top: 0.5rem;
  max-height: 16rem;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.pool-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border);
}
.pool-row:first-child {
  border-top: none;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  flex: 1;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: calc(var(--radius) - 4px);
  text-decoration: none;
  font-size: 0.9375rem;
  color: var(--text);
}

.sidebar nav a .nav-icon {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
  color: var(--text-muted);
}

.sidebar nav a:hover {
  background: var(--bg);
}

.sidebar nav a.active {
  background: var(--bg);
  font-weight: 600;
}

.sidebar nav a.active .nav-icon {
  color: var(--primary, currentColor);
}

.sidebar-user {
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  display: grid;
  gap: 0.5rem;
}

/* Nazwa + rola po lewej, zębatka (link do profilu/ustawień) po prawej. */
.sidebar-user .user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 0;
}

.sidebar-user .user-settings {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.5rem;
  color: var(--text-muted);
}

.sidebar-user .user-settings:hover {
  background: var(--bg);
  color: var(--text);
}

.sidebar-user .user-settings.active {
  background: var(--bg);
  color: var(--primary);
}

.sidebar-user .user-settings svg {
  width: 1.25rem;
  height: 1.25rem;
}

.sidebar-user .name {
  font-weight: 600;
  font-size: 0.9375rem;
}

.sidebar-user .role {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

main {
  flex: 1;
  padding: 2rem;
  max-width: 70rem;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

/* Tytuł z ikoną akcji obok (np. ołówek do zmiany nazwy grupy). */
.title-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--text-muted);
}

.icon-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

.icon-btn.icon-danger:hover {
  background: #fee2e2;
  color: #991b1b;
}

/* Wiersz tabeli prowadzący do szczegółów (np. zawodnik → participant.html). */
tr.row-link {
  cursor: pointer;
}
tr.row-link:hover td {
  background: var(--bg);
}

/* Szczegóły osoby (participant.html): etykieta + wartość w wierszach. */
.detail-row {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.55rem 0;
}
.detail-row + .detail-row {
  border-top: 1px solid var(--border);
}
.detail-row > .muted {
  flex: none;
  width: 7.5rem;
  font-size: 0.875rem;
}

/* ----------------------------------------------------------- taby strony */

.page-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin: 0 0 1.25rem;
}

.page-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  margin-bottom: -1px;
  padding: 0.5rem 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

.page-tab:hover {
  background: none;
  color: var(--text);
}

.page-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* --------------------------------------------------------------- tabele */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

th,
td {
  text-align: left;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
}

tr:last-child td {
  border-bottom: none;
}

th {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

td.center,
th.center {
  text-align: center;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--bg);
  border: 1px solid var(--border);
}

.badge.ok {
  background: #dcfce7;
  border-color: #bbf7d0;
  color: #166534;
}

.empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-muted);
}

.badge.danger {
  background: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
}

/* ------------------------------------------------------------ kalendarz */

.section-title {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 1.5rem 0 0.75rem;
}

.event-list {
  display: grid;
  gap: 0.75rem;
}

.event-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: grid;
  gap: 0.5rem;
}

.event-card.past {
  opacity: 0.85;
}

.event-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.event-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  flex: 1;
}

.etype {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.etype.training   { background: #dcfce7; color: #166534; }
.etype.match      { background: #dbeafe; color: #1e40af; }
.etype.tournament { background: #fef3c7; color: #92400e; }
.etype.meeting    { background: #ede9fe; color: #5b21b6; }

.event-meta {
  font-size: 0.875rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
}

.event-notes {
  font-size: 0.9375rem;
  margin: 0;
}

.attendee-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
}

.attendee-row .who {
  font-weight: 500;
  min-width: 9rem;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.seg button {
  background: var(--surface);
  color: var(--text);
  border: none;
  border-radius: 0;
  padding: 0.3rem 0.9rem;
  font-size: 0.8125rem;
}

.seg button:hover {
  background: var(--bg);
}

.seg button.on-going {
  background: var(--primary);
  color: #fff;
}

.seg button.on-not {
  background: var(--destructive);
  color: #fff;
}

.rpe {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.rpe select {
  width: auto;
  padding: 0.25rem 0.4rem;
}

.rpe button {
  padding: 0.3rem 0.7rem;
  font-size: 0.8125rem;
}

.summary {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.summary b {
  color: var(--text);
}

.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.8125rem;
}

.link-danger {
  background: none;
  border: none;
  color: var(--destructive);
  padding: 0.2rem 0.4rem;
  font-size: 0.8125rem;
  cursor: pointer;
}

.link-danger:hover {
  background: #fee2e2;
  border-radius: calc(var(--radius) - 4px);
}

.event-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* ------------------------------------------------------------ ogłoszenia */

.yt-embed {
  position: relative;
  width: 100%;
  max-width: 34rem;
  aspect-ratio: 16 / 9;
  border-radius: calc(var(--radius) - 2px);
  overflow: hidden;
  border: 1px solid var(--border);
}

.yt-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ----------------------------------------------------------- załączniki */

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.att-img {
  display: block;
  line-height: 0;
}

.att-img img {
  max-width: 12rem;
  max-height: 12rem;
  object-fit: cover;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--border);
}

.att-audio {
  width: 100%;
  max-width: 22rem;
  height: 2.25rem;
}

.att-file {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.9rem;
  text-decoration: none;
}

.att-file:hover {
  border-color: var(--accent, #2563eb);
}

.field .hint {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: var(--muted, #6b7280);
}

/* --------------------------------------- ogłoszenia — lista (announcements) */

.ann-list {
  display: grid;
  gap: 0.6rem;
}

.ann-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  text-decoration: none;
}

.ann-row:hover {
  border-color: #cbd5e1;
}

.ann-main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 0.2rem;
}

.ann-title {
  font-weight: 600;
}

.ann-row.unread .ann-title::before {
  content: "";
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--primary);
  margin-right: 0.45rem;
  vertical-align: middle;
}

.ann-snippet {
  font-size: 0.875rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ann-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
}

.ann-status {
  flex: none;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.ann-row .badge {
  flex: none;
}

.read-summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  padding: 0.2rem 0.3rem;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
}

.btn-link:hover {
  background: none;
  text-decoration: underline;
}

.readers {
  display: grid;
  gap: 0.35rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: calc(var(--radius) - 4px);
  padding: 0.6rem 0.8rem;
}

.readers .rl {
  display: inline-block;
  min-width: 5.5rem;
  font-weight: 600;
  color: var(--text-muted);
}

.readers .rl.ok {
  color: #166534;
}

/* dialog dodawania wydarzenia */

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  max-width: 30rem;
  width: 100%;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.dialog-body {
  padding: 1.5rem;
}

.dialog-body h2 {
  margin: 0 0 1rem;
  font-size: 1.25rem;
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

textarea {
  font: inherit;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  background: var(--surface);
  width: 100%;
  resize: vertical;
  min-height: 4rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.checkbox-row input {
  width: auto;
}

.dialog-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

.dialog-actions button {
  width: auto;
}

/* --- składy meczowe (lineups) --- */
.roster-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
  border-top: 1px dashed var(--border);
}

.roster-row .lu-role {
  width: auto;
  padding: 0.25rem 0.4rem;
  font-size: 0.8125rem;
}

.attendee-row.mine {
  font-weight: 600;
}

/* ------------------------------------------------------------ komentarze */

.comments {
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
}

.cm-toggle {
  padding-left: 0;
}

.cm-thread {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.6rem;
}

.cm {
  background: var(--bg);
  border-radius: calc(var(--radius) - 4px);
  padding: 0.5rem 0.75rem;
}

.cm-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.cm-time {
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.cm-body {
  margin-top: 0.2rem;
  font-size: 0.9375rem;
}

.cm-actions {
  margin-top: 0.35rem;
  display: flex;
  gap: 0.35rem;
}

.cm-empty {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.cm-form {
  display: grid;
  gap: 0.4rem;
}

.cm-form textarea {
  min-height: 2.75rem;
}

.cm-form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.cm-note {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* --------------------------------------------------------- tablica taktyczna */

.tactics-frame {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  /* wysoki obszar roboczy — edytor sam skaluje boisko do dostępnego miejsca */
  height: calc(100svh - 8rem);
  min-height: 32rem;
}

.tactics-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* Preload edytora: gdy trener ogląda listę, sekcja edytora jest zepchnięta
   poza ekran zamiast display:none — silnik Fluttera w iframe startuje wtedy
   w tle z niezerowym viewportem (display:none dałoby mu okno 0×0). */
#editor-section.editor-offstage {
  position: fixed;
  top: 0;
  left: -200vw;
  width: min(66rem, 100vw);
  visibility: hidden;
}

/* Pasek nad tablicą (powrót do listy — tylko trener). */
#editor-section .editor-bar {
  margin-bottom: 0.75rem;
}
#editor-section .editor-bar:not(:has(button:not([hidden]))) {
  display: none;
}

/* Aktywny edytor trenera na desktopie: pełny ekran nad panelem (liczy się
   precyzja rysowania, sidebar i nagłówek tylko zabierają miejsce). Warunek
   :has(#back-to-list) celowo ogranicza tryb do trenera — zawodnik/rodzic
   nie ma przycisku powrotu i nakładka odcięłaby go od nawigacji panelu.
   Na mobile bez zmian z tego samego powodu (dolny pasek zakładek). */
@media (min-width: 769px) {
  #editor-section:not(.editor-offstage):has(#back-to-list:not([hidden])) {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0.75rem 0.75rem;
  }
  #editor-section:not(.editor-offstage):has(#back-to-list:not([hidden]))
    .editor-bar {
    margin-bottom: 0.5rem;
  }
  #editor-section:not(.editor-offstage):has(#back-to-list:not([hidden]))
    .tactics-frame {
    flex: 1;
    height: auto;
    min-height: 0;
  }
}

/* ------------------------- taktyka dołączona do ogłoszenia/wydarzenia */

/* Pole wyboru w formularzu dodawania (ogłoszenie, wydarzenie). */
.tactic-pick {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.tactic-pick button {
  width: auto;
  flex: none;
}

.tactic-pick-name {
  font-size: 0.9rem;
}

/* Podgląd taktyki na stronie szczegółów. */
.tactic-view {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  overflow: hidden;
  max-width: 34rem;
}

.tactic-view-head {
  display: flex;
  align-items: center;
  gap: 0.5rem 0.75rem;
  flex-wrap: wrap;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.tactic-view-name {
  font-weight: 600;
}

.tactic-view-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.tactic-view-actions {
  margin-left: auto;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.tactic-view-actions a.btn-link {
  text-decoration: none;
}

.tactic-canvas {
  display: block;
  width: 100%;
  cursor: zoom-in;
}

/* Powiększony podgląd — canvas wypełnia szerokość dialogu. */
.tactic-viewer .tactic-canvas {
  cursor: default;
  border-radius: calc(var(--radius) - 4px);
}

.tactic-viewer .dialog-body h2 {
  margin-bottom: 0.75rem;
}

/* Picker: siatka miniatur biblioteki. */
dialog.dialog-wide {
  max-width: min(52rem, calc(100vw - 2rem));
}

.tactic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.75rem;
  max-height: 60vh;
  overflow-y: auto;
  margin-bottom: 1rem;
}

.tactic-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.25rem;
  padding: 0.5rem;
  text-align: left;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
}

.tactic-card:hover {
  border-color: var(--primary);
  background: var(--bg);
}

.tactic-thumb {
  display: block;
  width: 100%;
  border-radius: calc(var(--radius) - 8px);
}

.tactic-card-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.tactic-card-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ----------------------------------------- kalendarz — widok miesięczny */

.cal-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.cal-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.cal-arrow {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  line-height: 1;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
}

.cal-arrow:hover {
  background: var(--bg);
}

.cal-today {
  width: auto;
  padding: 0.35rem 0.8rem;
  font-size: 0.875rem;
}

/* Nazwa miesiąca między strzałkami; min-width, żeby strzałki nie skakały
   przy różnej długości nazw (np. „maj" vs „październik"). */
.cal-label {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  text-transform: capitalize;
  min-width: 10rem;
  text-align: center;
}

/* Jedna siatka 7 kolumn: nagłówek dni + 42 komórki jako bezpośrednie dzieci.
   Linie rysują obramowania komórek (nie gap) — dzięki temu równa się zawsze,
   niezależnie od tła komórek innego miesiąca. */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.cal-weekday,
.cal-day {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
/* Ostatnia kolumna i ostatni rząd bez zewnętrznej podwójnej linii. */
.cal-grid > :nth-child(7n) {
  border-right: none;
}
.cal-grid > :nth-last-child(-n + 7) {
  border-bottom: none;
}

.cal-weekday {
  padding: 0.5rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  text-align: right;
  background: var(--surface);
}

.cal-day {
  background: var(--surface);
  min-height: 7rem;
  padding: 0.35rem 0.4rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.cal-day.other-month {
  background: var(--bg);
}

.cal-day.other-month .cal-day-num {
  color: var(--text-muted);
  opacity: 0.6;
}

/* Komórka klikalna dla trenera (dodawanie wydarzenia w danym dniu). */
.cal-day.clickable {
  cursor: pointer;
}
.cal-day.clickable:hover {
  background: color-mix(in srgb, var(--primary) 5%, var(--surface));
}

.cal-day-num {
  align-self: flex-end;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  width: 1.6rem;
  height: 1.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
}

.cal-day.today .cal-day-num {
  background: var(--primary);
  color: #fff;
}

.cal-events {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  overflow: hidden;
}

/* Chip wydarzenia w komórce — kolor wg typu. */
.cal-chip {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  width: 100%;
  text-align: left;
  border: none;
  border-left: 3px solid currentColor;
  border-radius: 3px;
  padding: 0.15rem 0.4rem;
  font-size: 0.78rem;
  line-height: 1.3;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-decoration: none;
}

.cal-chip .t {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  flex: none;
}

.cal-chip .ttl {
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.cal-chip.training   { color: #166534; background: #dcfce7; }
.cal-chip.match      { color: #1e40af; background: #dbeafe; }
.cal-chip.tournament { color: #92400e; background: #fef3c7; }
.cal-chip.meeting    { color: #5b21b6; background: #ede9fe; }
.cal-chip.past { opacity: 0.6; }

/* ---------------------------------- kalendarz — agenda (widok mobilny) */
/* Renderowana przez calendar.js zamiast siatki, gdy ekran ≤768px. */

.cal-agenda {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.agenda-day {
  display: grid;
  grid-template-columns: 2.75rem 1fr;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--border);
}
.agenda-day:last-child {
  border-bottom: none;
}

.agenda-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 0.1rem;
}
.agenda-dow {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}
.agenda-dnum {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.15;
}
.agenda-day.today .agenda-dnum {
  background: var(--primary);
  color: #fff;
  width: 1.9rem;
  height: 1.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
}

.agenda-events {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}

.agenda-item {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  text-decoration: none;
  border-left: 3px solid currentColor;
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
}
.agenda-time {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  flex: none;
}
.agenda-name {
  flex: 1;
  min-width: 0;
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agenda-type {
  flex: none;
  font-size: 0.7rem;
  color: var(--text-muted);
}
.agenda-item.training   { color: #166534; background: #dcfce7; }
.agenda-item.match      { color: #1e40af; background: #dbeafe; }
.agenda-item.tournament { color: #92400e; background: #fef3c7; }
.agenda-item.meeting    { color: #5b21b6; background: #ede9fe; }
.agenda-item.past { opacity: 0.6; }

/* ------------------------------------------- strona wydarzenia (event.html) */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
}
.back-link:hover {
  color: var(--text);
}

.event-page {
  max-width: 42rem;
}

.event-title {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 600;
  flex: 1;
}

@media (max-width: 768px) {
  /* Toolbar: jeden wiersz — ‹ miesiąc › zajmuje wolne miejsce, „Dziś" z prawej. */
  .cal-toolbar { gap: 0.6rem; }
  .cal-nav { flex: 1; justify-content: space-between; }
  .cal-label { font-size: 1.05rem; min-width: 0; }

  /* Zapas, gdyby jednak renderowała się siatka (JS domyślnie daje agendę). */
  .cal-day {
    min-height: 4.5rem;
    padding: 0.25rem 0.2rem 0.35rem;
  }
  .cal-chip .ttl { display: none; }   /* na wąskim ekranie sam kolor + godzina */
  .cal-weekday { padding: 0.4rem 0.3rem; font-size: 0.68rem; }
}

/* --------------------------------------------------------------- mobile */

/* Górny pasek z „hamburgerem" — istnieje tylko na wąskich ekranach
   (wstrzykiwany w layout.js na każdej stronie aplikacji). */
.mobile-topbar { display: none; }
.mobile-tabbar { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 768px) {
  /* Pasek: sticky na górze, mieści przycisk menu + nazwę aplikacji. */
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 0.6rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }
  .hamburger {
    width: auto;
    padding: 0.35rem;
    display: inline-flex;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 4px);
  }
  .hamburger:hover { background: var(--bg); }
  .hamburger svg { width: 22px; height: 22px; display: block; }

  .mobile-brand { font-size: 1.0625rem; font-weight: 700; }

  /* Aktywna grupa jako tytuł paska (zamiast nazwy aplikacji) — tap otwiera
     szufladę z przełącznikiem. min-width:0 pozwala uciąć długą nazwę
     wielokropkiem zamiast rozpychać pasek. */
  .mobile-context {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    min-width: 0;
    width: auto;
    padding: 0;
    border: none;
    background: transparent;
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    text-align: left;
  }
  .mobile-context-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-context svg { width: 16px; height: 16px; flex: none; color: var(--text-muted); }

  /* Body przestaje być rzędem flex — pasek na górze, treść pod nim. */
  body.app { flex-direction: column; }

  /* Sidebar wysuwany z lewej; domyślnie schowany poza ekranem. */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 17rem;
    max-width: 84vw;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
    box-shadow: 0 0 2rem rgba(0, 0, 0, 0.15);
  }
  .sidebar.open { transform: translateX(0); }

  /* Półprzezroczyste tło pod wysuniętą szufladą. */
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
  }
  .sidebar-backdrop.visible { opacity: 1; visibility: visible; }

  /* Blokada przewijania tła, gdy szuflada otwarta. */
  body.nav-open { overflow: hidden; }

  /* Dolny pasek zakładek — ikonowe skróty jak w aplikacji mobilnej.
     Aktywna zakładka: pigułkowe tło pod ikoną (wzorzec Material 3). */
  .mobile-tabbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    background: var(--surface);
    border-top: 1px solid var(--border);
    /* Zapas na „notch"/gest systemowy na telefonach z iOS/Android. */
    padding: 0.3rem 0.25rem calc(0.3rem + env(safe-area-inset-bottom));
  }
  .mobile-tabbar .tab {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 0.15rem 0;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--text-muted);
    text-decoration: none;
    font: inherit;
    font-size: 0.6875rem;
    font-weight: 500;
    cursor: pointer;
  }
  .mobile-tabbar .tab-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.25rem;
    height: 1.75rem;
    border-radius: 999px;
    transition: background 0.15s ease;
  }
  .mobile-tabbar .tab-icon svg {
    width: 20px;
    height: 20px;
    display: block;
  }
  .mobile-tabbar .tab-label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-tabbar .tab.active {
    color: var(--text);
    font-weight: 700;
  }
  .mobile-tabbar .tab.active .tab-icon {
    background: rgba(22, 163, 74, 0.14);
    color: var(--primary);
  }

  /* Treść: mniejsze marginesy, pełna szerokość + zapas na dolny pasek,
     żeby ostatnie wiersze nie chowały się pod zakładkami. */
  main {
    padding: 1rem 1rem calc(4.75rem + env(safe-area-inset-bottom));
    max-width: 100%;
  }
  .page-header {
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
  }

  /* Przyciski akcji w nagłówkach stron („+ Nowa grupa" itp.) — kompaktowe,
     żeby nie rozpychały nagłówka obok tytułu. */
  .page-header button:not(.icon-btn):not(.link-danger) {
    padding: 0.4rem 0.75rem;
    font-size: 0.8125rem;
  }

  /* FAB — na telefonie główna akcja strony pływa w prawym dolnym rogu nad
     paskiem zakładek (wzorzec Google Calendar / Material). [hidden] nadal
     wygrywa: JS pokazuje przycisk tylko uprawnionym. Okrągły, sam „+" —
     etykieta tekstowa zostaje w DOM dla czytników (font-size: 0). */
  .page-header button.fab-mobile:not([hidden]) {
    position: fixed;
    right: 1rem;
    bottom: calc(4.25rem + env(safe-area-inset-bottom));
    z-index: 30;   /* pod topbar/tabbar (40) i szufladą sidebara (60) */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    padding: 0;
    font-size: 0;
    border-radius: 50%;
    box-shadow: 0 6px 18px rgba(22, 163, 74, 0.35);
  }
  .page-header button.fab-mobile:not([hidden])::before {
    content: "+";
    font-size: 1.9rem;
    font-weight: 400;
    line-height: 1;
    /* Optyczne wyśrodkowanie glifu „+" (siedzi odrobinę nisko w foncie). */
    margin-top: -0.15rem;
  }

  /* Zapas na dole treści, żeby FAB nie zasłaniał ostatnich wierszy list. */
  main:has(button.fab-mobile:not([hidden])) {
    padding-bottom: calc(8.25rem + env(safe-area-inset-bottom));
  }

  /* Edytor taktyki: odejmujemy też wysokość dolnego paska zakładek,
     żeby obszar roboczy mieścił się bez przewijania. */
  .tactics-frame { height: calc(100svh - 12.5rem); }

  /* Formularze dwukolumnowe składają się do jednej kolumny. */
  .row-2 { grid-template-columns: 1fr; }

  /* Dialogi trzymają margines od krawędzi ekranu. */
  dialog { max-width: calc(100vw - 1.5rem); }
  .dialog-body { padding: 1.25rem; }
}

/* Bardzo wąskie telefony — dodatkowe dokręcenie. */
@media (max-width: 400px) {
  main { padding: 0.75rem; }
  h1 { font-size: 1.3rem; }
}

/* --- Powiadomienia realtime: badge zbiorczy + toasty ---------------------- */
/* (notifications.js — pigułka przy „Powiadomienia"/dzwonku i dymki o nowościach) */

.nav-badge {
  margin-left: auto;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.toast-holder {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 100;
}
.toast {
  display: block;
  background: var(--text);
  color: var(--surface);
  padding: 0.6rem 0.9rem;
  border-radius: calc(var(--radius) - 4px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  font-size: 0.875rem;
  text-decoration: none;
  max-width: 20rem;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast.hide {
  opacity: 0;
  transform: translateY(4px);
}
@media (max-width: 768px) {
  /* Nad dolnym paskiem zakładek, nie pod kciukiem. */
  .toast-holder {
    left: 1rem;
    right: 1rem;
    bottom: calc(4.25rem + env(safe-area-inset-bottom));
  }
}

/* --- Strona „Powiadomienia": feed nowości + dzwonek w topbarze ------------ */

.ntf-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.ntf-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
}
.ntf-row:hover {
  border-color: var(--primary);
}
.ntf-row.unread {
  border-left: 3px solid var(--primary);
  background: rgba(22, 163, 74, 0.04);
}
.ntf-icon {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-muted);
}
.ntf-icon svg {
  width: 1.125rem;
  height: 1.125rem;
}
.ntf-row.unread .ntf-icon {
  color: var(--primary);
}
.ntf-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.ntf-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ntf-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}
/* Data wydarzenia — najważniejsza informacja wiersza, wyróżniona. */
.ntf-when {
  color: var(--primary);
  font-weight: 600;
}
.ntf-dot {
  flex: none;
  margin-left: auto;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 999px;
  background: var(--primary);
}

/* Dzwonek w górnym pasku mobile (badge dokleja notifications.js). */
.topbar-bell { display: none; }
@media (max-width: 768px) {
  .topbar-bell {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    width: 2.25rem;
    height: 2.25rem;
    flex: none;
    color: var(--text);
  }
  .topbar-bell svg {
    width: 22px;
    height: 22px;
  }
  .topbar-bell .nav-badge {
    position: absolute;
    top: 0;
    right: 0;
    margin-left: 0;
    min-width: 1rem;
    height: 1rem;
    font-size: 0.625rem;
  }
}

/* Baner z prośbą o zgodę na powiadomienia systemowe (notifications.js). */
.push-banner {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  cursor: default;
}
.push-banner-actions {
  display: flex;
  gap: 0.5rem;
}
.push-banner-actions button {
  font-size: 0.8125rem;
  padding: 0.35rem 0.75rem;
}
.push-banner-actions .outline {
  color: var(--surface);
  border-color: rgba(255, 255, 255, 0.4);
  background: transparent;
}
