/* ==========================================================================
   Siatkówka Piastów — arkusz stylów
   Paleta: Pantone 2026 „Cloud Dancer” (#F0EEE9) — miękka mleczno-perowa,
   złamana biel, minimalizm. Kolor jest zarezerwowany dla STATUSÓW zajęć:
   zieleń = gramy, czerwień = odwołane, złamana czerń = zapisy trwają.
   Motywy: auto (wg systemu), jasny, ciemny — przełączane przyciskiem w nagłówku.
   ========================================================================== */

/* ------------------------------------------------------------ motyw jasny -- */

:root {
  color-scheme: light;

  /* powierzchnie — mleczna biel w duchu Cloud Dancer */
  --bg:        #f0eee9;   /* Cloud Dancer — tło strony */
  --bg-2:      #e7e4dd;
  --surface:   #fdfcfa;   /* karty: bielsze od tła, inaczej zlewają się z poświatą */
  --surface-2: #f4f2ee;   /* uniesienie / hover */
  --surface-3: #eae7e1;   /* wgłębienia, paski */
  --glow:      rgba(255, 255, 255, .5);

  --line:      rgba(35, 33, 30, .16);
  --line-soft: rgba(35, 33, 30, .09);

  --text:      #23211e;   /* espresso — nie czysta czerń */
  --muted:     #6e6862;
  --muted-2:   #8d867e;

  /* akcent = złamana czerń; kolor nie jest tu ozdobą */
  --accent:      #2e2a26;
  --accent-ink:  #faf9f6;
  --accent-soft: rgba(46, 42, 38, .07);
  --accent-line: rgba(46, 42, 38, .22);

  /* statusy — jedyne nasycone barwy w interfejsie */
  --ok:          #1f7a4d;
  --ok-ink:      #ffffff;
  --ok-soft:     rgba(31, 122, 77, .09);
  --ok-line:     rgba(31, 122, 77, .34);

  --danger:      #b3261e;
  --danger-ink:  #ffffff;
  --danger-soft: rgba(179, 38, 30, .08);
  --danger-line: rgba(179, 38, 30, .32);

  --warn:        #8a6a16;  /* ostrzeżenia: domyślne hasła, limity */
  --warn-soft:   rgba(138, 106, 22, .10);
  --warn-line:   rgba(138, 106, 22, .30);

  /* tło zwiniętego paska minionej środy — ma nieść sam kolor statusu */
  --ok-tint:     #d7e9de;
  --danger-tint: #f4d8d2;

  /* najbliższa środa — jaśniejsza od pozostałych kart */
  --next-bg:   #ffffff;
  --next-line: rgba(35, 33, 30, .26);

  --topbar-bg: rgba(240, 238, 233, .86);
  --input-bg:  #ffffff;
  --sticky-bg: #edeadf;
  --shadow:    0 1px 2px rgba(35, 33, 30, .05), 0 14px 34px -20px rgba(35, 33, 30, .35);
  --shadow-sm: 0 1px 2px rgba(35, 33, 30, .06);

  --court: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='420' viewBox='0 0 420 420'%3E%3Cg fill='none' stroke='%2323211e' stroke-opacity='0.055' stroke-width='2'%3E%3Crect x='34' y='74' width='352' height='272' rx='8'/%3E%3Cline x1='210' y1='74' x2='210' y2='346'/%3E%3Cline x1='96' y1='74' x2='96' y2='346'/%3E%3Cline x1='324' y1='74' x2='324' y2='346'/%3E%3C/g%3E%3Cg fill='none' stroke='%2323211e' stroke-opacity='0.04' stroke-width='2'%3E%3Ccircle cx='210' cy='210' r='62'/%3E%3Cpath d='M152 178c40-14 84-6 116 22M268 242c-40 14-84 6-116-22'/%3E%3C/g%3E%3C/svg%3E");

  --radius:    16px;
  --radius-sm: 11px;
  --ease:      cubic-bezier(.22, .8, .28, 1);
}

/* ------------------------------------------------------------ motyw ciemny --
   Dwie ścieżki, ten sam zestaw tokenów:
   1) ustawienie systemowe — o ile użytkownik nie wybrał jawnie jasnego,
   2) jawny wybór „ciemny” przyciskiem (atrybut data-theme na <html>).        */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg:        #14120f;   /* ciepła, złamana czerń */
    --bg-2:      #1b1814;
    --surface:   #221e19;   /* karty jaśniejsze od tła */
    --surface-2: #2a251f;
    --surface-3: #332d26;
    --glow:      rgba(240, 238, 233, .05);

    --line:      rgba(240, 238, 233, .15);
    --line-soft: rgba(240, 238, 233, .08);

    --text:      #f0eee9;   /* Cloud Dancer jako tekst */
    --muted:     #a9a29a;
    --muted-2:   #8b847c;

    --accent:      #f0eee9;
    --accent-ink:  #1a1714;
    --accent-soft: rgba(240, 238, 233, .09);
    --accent-line: rgba(240, 238, 233, .26);

    --ok:          #1f7f52;
    --ok-ink:      #ffffff;
    --ok-soft:     rgba(31, 127, 82, .16);
    --ok-line:     rgba(61, 169, 116, .40);

    --danger:      #c43a2f;
    --danger-ink:  #ffffff;
    --danger-soft: rgba(196, 58, 47, .15);
    --danger-line: rgba(224, 87, 76, .42);

    --warn:        #d8ac4a;
    --warn-soft:   rgba(216, 172, 74, .13);
    --warn-line:   rgba(216, 172, 74, .32);

    --ok-tint:     #16301f;
    --danger-tint: #3a1e19;

    --next-bg:   #2e2822;
    --next-line: rgba(240, 238, 233, .24);

    --topbar-bg: rgba(20, 18, 15, .86);
    --input-bg:  #1b1815;
    --sticky-bg: #241f1a;
    --shadow:    0 1px 2px rgba(0, 0, 0, .4), 0 16px 36px -22px rgba(0, 0, 0, .9);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);

    --court: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='420' viewBox='0 0 420 420'%3E%3Cg fill='none' stroke='%23f0eee9' stroke-opacity='0.045' stroke-width='2'%3E%3Crect x='34' y='74' width='352' height='272' rx='8'/%3E%3Cline x1='210' y1='74' x2='210' y2='346'/%3E%3Cline x1='96' y1='74' x2='96' y2='346'/%3E%3Cline x1='324' y1='74' x2='324' y2='346'/%3E%3C/g%3E%3Cg fill='none' stroke='%23f0eee9' stroke-opacity='0.032' stroke-width='2'%3E%3Ccircle cx='210' cy='210' r='62'/%3E%3Cpath d='M152 178c40-14 84-6 116 22M268 242c-40 14-84 6-116-22'/%3E%3C/g%3E%3C/svg%3E");
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg:        #14120f;
  --bg-2:      #1b1814;
  --surface:   #221e19;
  --surface-2: #2a251f;
  --surface-3: #332d26;
  --glow:      rgba(240, 238, 233, .05);

  --line:      rgba(240, 238, 233, .15);
  --line-soft: rgba(240, 238, 233, .08);

  --text:      #f0eee9;
  --muted:     #a9a29a;
  --muted-2:   #8b847c;

  --accent:      #f0eee9;
  --accent-ink:  #1a1714;
  --accent-soft: rgba(240, 238, 233, .09);
  --accent-line: rgba(240, 238, 233, .26);

  --ok:          #1f7f52;
  --ok-ink:      #ffffff;
  --ok-soft:     rgba(31, 127, 82, .16);
  --ok-line:     rgba(61, 169, 116, .40);

  --danger:      #c43a2f;
  --danger-ink:  #ffffff;
  --danger-soft: rgba(196, 58, 47, .15);
  --danger-line: rgba(224, 87, 76, .42);

  --warn:        #d8ac4a;
  --warn-soft:   rgba(216, 172, 74, .13);
  --warn-line:   rgba(216, 172, 74, .32);

  --ok-tint:     #16301f;
  --danger-tint: #3a1e19;

  --next-bg:   #2e2822;
  --next-line: rgba(240, 238, 233, .24);

  --topbar-bg: rgba(20, 18, 15, .86);
  --input-bg:  #1b1815;
  --sticky-bg: #241f1a;
  --shadow:    0 1px 2px rgba(0, 0, 0, .4), 0 16px 36px -22px rgba(0, 0, 0, .9);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);

  --court: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='420' viewBox='0 0 420 420'%3E%3Cg fill='none' stroke='%23f0eee9' stroke-opacity='0.045' stroke-width='2'%3E%3Crect x='34' y='74' width='352' height='272' rx='8'/%3E%3Cline x1='210' y1='74' x2='210' y2='346'/%3E%3Cline x1='96' y1='74' x2='96' y2='346'/%3E%3Cline x1='324' y1='74' x2='324' y2='346'/%3E%3C/g%3E%3Cg fill='none' stroke='%23f0eee9' stroke-opacity='0.032' stroke-width='2'%3E%3Ccircle cx='210' cy='210' r='62'/%3E%3Cpath d='M152 178c40-14 84-6 116 22M268 242c-40 14-84 6-116-22'/%3E%3C/g%3E%3C/svg%3E");
}

/* ------------------------------------------------------------------ baza -- */

* { box-sizing: border-box; }

/* Atrybut `hidden` musi zawsze wygrywać z regułami typu `.modal { display: grid }`,
   inaczej ukryte elementy (np. pusty modal) zostają na ekranie i blokują stronę. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
  transition: background-color .3s var(--ease), color .3s var(--ease);
}

/* ------------------------------------------------------------------- tło --
   Spokojne: jedna miękka poświata i ledwo widoczny cień boiska. Bez ruchu.  */

.bg {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background: radial-gradient(130% 100% at 50% -20%, var(--bg-2) 0%, var(--bg) 58%, var(--bg) 100%);
}

.bg .court {
  position: absolute; inset: -10%;
  background-image: var(--court);
  background-size: 560px 560px;
  transform: rotate(-6deg);
  mask-image: radial-gradient(85% 75% at 50% 34%, #000 12%, transparent 100%);
  -webkit-mask-image: radial-gradient(85% 75% at 50% 34%, #000 12%, transparent 100%);
}

/* poświata — monochromatyczna, statyczna; kolor zostaje dla statusów.
   Trzymamy ją słabą i wysoko, żeby nie rozjaśniała tła do koloru kart. */
.bg .glow { position: absolute; border-radius: 50%; filter: blur(110px); opacity: .45; }
.bg .g1 { width: 60vw; height: 40vw; top: -26vw; left: 8vw; background: radial-gradient(closest-side, var(--glow), transparent); }
.bg .g2 { width: 44vw; height: 34vw; bottom: -20vw; right: -6vw; background: radial-gradient(closest-side, var(--bg-2), transparent); opacity: .7; }
.bg .g3 { display: none; }

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

.wrap { width: min(1240px, 100%); margin: 0 auto; padding: 22px 18px 64px; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  /* niski pasek: 8px odstępu w pionie + 36px treści ≈ 53px wysokości
     (wcześniej 81px — wszystko w nagłówku skurczone o ~35%)                  */
  padding: 8px clamp(14px, 3vw, 34px);
  background: var(--topbar-bg);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-ball { filter: drop-shadow(0 3px 7px rgba(35, 33, 30, .18)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 16px; letter-spacing: .2px; }
.brand-text i { font-style: normal; font-size: 12px; color: var(--muted); }

.topnav { display: flex; align-items: center; gap: 8px; }
.topnav a {
  color: var(--text); text-decoration: none; font-size: 14.5px; padding: 6px 12px;
  border-radius: 10px; transition: background .2s var(--ease), color .2s var(--ease);
}
.topnav a:hover { background: var(--surface-2); }
.topnav form { margin: 0; }

/* przełącznik motywu: auto → jasny → ciemny */
.theme-btn {
  appearance: none; cursor: pointer; font: inherit; line-height: 1;
  width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center;
  border-radius: 10px; font-size: 16px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  transition: background .2s var(--ease), transform .18s var(--ease), border-color .2s var(--ease);
}
.theme-btn:hover { background: var(--surface-2); transform: translateY(-1px); }
.theme-btn.floating { box-shadow: var(--shadow); }
.theme-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* na stronie logowania brak nagłówka — przycisk wisi w rogu */
.theme-btn.floating { position: fixed; top: 14px; right: 14px; z-index: 40; }

.foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  width: min(1240px, 100%); margin: 0 auto; padding: 18px;
  color: var(--muted); font-size: 12.5px; border-top: 1px solid var(--line-soft);
}

.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }

/* --------------------------------------------------------------- nagłówek -- */

.page-head {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  flex-wrap: wrap; margin: 8px 0 22px;
}

.month-nav { display: flex; align-items: center; gap: 10px; }
.month-nav h1 { margin: 0; font-size: clamp(22px, 3.4vw, 32px); letter-spacing: -.2px; text-transform: capitalize; }
.month-label { color: var(--muted); font-size: 14px; }

.nav-btn {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  text-decoration: none; font-size: 22px; line-height: 1;
  transition: transform .18s var(--ease), background .18s var(--ease);
}
.nav-btn:hover { background: var(--surface-2); transform: translateY(-2px); }

.legend { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12.5px; }

/* ------------------------------------------------------------- plakietki --
   Wypełnienie na pełnym kolorze + biały tekst: status widać z daleka.      */

.badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 13px; border-radius: 999px; font-size: 13px; font-weight: 650;
  border: 1px solid transparent; white-space: nowrap;
}
.badge .pulse { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1.6s infinite; }

.badge.open      { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.badge.playing   { color: var(--ok-ink);     background: var(--ok);     border-color: var(--ok); }
.badge.cancelled { color: var(--danger-ink); background: var(--danger); border-color: var(--danger); }

@keyframes pulse { 0% { box-shadow: 0 0 0 0 currentColor; opacity: 1; } 70% { box-shadow: 0 0 0 6px transparent; opacity: .75; } 100% { opacity: 1; } }

.tag {
  font-size: 11.5px; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-3); color: var(--muted); border: 1px solid var(--line-soft); white-space: nowrap;
}
.tag.ok     { color: var(--ok);     background: var(--ok-soft);     border-color: var(--ok-line); }
.tag.warn   { color: var(--warn);   background: var(--warn-soft);   border-color: var(--warn-line); }
.tag.admin  { color: var(--warn);   background: var(--warn-soft);   border-color: var(--warn-line); }
.tag.action { color: var(--muted);  background: var(--surface-3);   border-color: var(--line); }
.tag.plain  { color: var(--muted);  background: var(--surface-3); }

/* ------------------------------------------------------------ statystyki -- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 2px;
  box-shadow: var(--shadow-sm); animation: fadeUp .5s var(--ease) both;
}
.stat:nth-child(2) { animation-delay: .06s; }
.stat:nth-child(3) { animation-delay: .12s; }
.stat:nth-child(4) { animation-delay: .18s; }
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: .5px; }
.stat-value i { font-style: normal; font-size: 15px; color: var(--muted); font-weight: 500; }
.stat-sub { font-size: 12px; color: var(--muted); }

/* ----------------------------------------------------------------- karty -- */

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 18px; }

.card {
  position: relative; overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line); border-top: 4px solid var(--line);
  border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
  animation: fadeUp .5s var(--ease) both;
  transition: transform .25s var(--ease), border-color .25s var(--ease), box-shadow .25s var(--ease);
}
.card:nth-child(2) { animation-delay: .04s; }
.card:nth-child(3) { animation-delay: .08s; }
.card:nth-child(4) { animation-delay: .12s; }
.card:nth-child(5) { animation-delay: .16s; }
.card:nth-child(6) { animation-delay: .2s; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow), 0 4px 12px -6px rgba(0, 0, 0, .18); }

.card-glow { position: absolute; inset: 0 0 65% 0; background: linear-gradient(180deg, var(--accent-soft), transparent); pointer-events: none; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* najbliższa środa — delikatnie rozjaśnione tło, żeby od razu było widać,
   na którą środę zbieramy zapisy */
.session.is-next {
  background: var(--next-bg);
  border-color: var(--next-line);
  box-shadow: var(--shadow), 0 0 0 1px var(--next-line);
}

/* status środy — nasycona belka u góry karty to główny nośnik informacji */
.session.status-open      { border-top-color: var(--accent); }
.session.status-playing   { border-top-color: var(--ok); background: linear-gradient(180deg, var(--ok-soft), var(--surface) 55%); }
.session.status-cancelled { border-top-color: var(--danger); background: linear-gradient(180deg, var(--danger-soft), var(--surface) 55%); }
.session.status-cancelled .s-title h3 { text-decoration: line-through; text-decoration-color: var(--danger); text-decoration-thickness: 2px; }

/* miniona środa — domyślnie zwinięta do paska, w którym widać głównie kolor
   statusu: pełna belka z lewej i u góry plus plakietka. Kliknięcie nagłówka
   rozwija pełną kartę (<details>).                                      */
.session.is-past > summary { cursor: pointer; grid-template-columns: auto 1fr auto auto; }
.session.is-past > summary::-webkit-details-marker { display: none; }
.session.is-past > summary::marker { content: ""; }
.session.is-past > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: var(--radius-sm); }

.session.is-past:not([open]) {
  align-self: start;   /* zwinięty pasek nie rozciąga się do wysokości sąsiadów */
  padding: 11px 14px;
  border-left: 6px solid var(--line);
}
.session.is-past.status-open:not([open])      { border-left-color: var(--accent); }
.session.is-past.status-playing:not([open])   { border-left-color: var(--ok);     background: var(--ok-tint); }
.session.is-past.status-cancelled:not([open]) { border-left-color: var(--danger); background: var(--danger-tint); }

.session.is-past:not([open]) .date-chip {
  width: 52px; height: 52px; border-radius: 13px;
  background: var(--surface); border-color: var(--line-soft);
}
.session.is-past:not([open]) .date-chip b { font-size: 24px; }
.session.is-past:not([open]) .date-chip span { font-size: 9.5px; letter-spacing: .6px; }
.session.is-past.status-playing:not([open])   .date-chip b { color: var(--ok); }
.session.is-past.status-cancelled:not([open]) .date-chip b { color: var(--danger); }
.session.is-past:not([open]) .s-title h3 { font-size: 15px; }
.session.is-past:not([open]) .s-title p { display: none; }   /* miejsce i pełna data zbędne */
.session.is-past:not([open]) .badge { padding: 4px 10px; font-size: 12px; }

.session.is-past .pulse { animation: none; }   /* historia nie musi pulsować */

.chev { color: var(--muted); font-size: 14px; line-height: 1; }
.chev::after { content: "⌄"; }
.session.is-past[open] > summary .chev::after { content: "⌃"; }
.session.is-past > summary:hover .chev { color: var(--text); }

.s-head { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; }
.date-chip {
  width: 58px; height: 58px; border-radius: 14px; display: grid; place-items: center; align-content: center;
  background: var(--surface-3); border: 1px solid var(--line);
}
.session.status-playing   .date-chip { background: var(--ok-soft);     border-color: var(--ok-line); }
.session.status-cancelled .date-chip { background: var(--danger-soft); border-color: var(--danger-line); }
.date-chip b { font-size: 22px; line-height: 1; }
.date-chip span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.s-title h3 { margin: 0; font-size: 18px; }
.s-title h3 .hour { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.s-title p { margin: 2px 0 0; font-size: 12.5px; }

.s-meta { display: flex; align-items: flex-end; justify-content: space-between; margin: 16px 0 10px; }
.count { display: flex; align-items: baseline; gap: 6px; }
.count .num { font-size: 34px; font-weight: 800; letter-spacing: -1px; }
.session.status-playing   .count .num { color: var(--ok); }
.session.status-cancelled .count .num { color: var(--danger); }
.count .of { color: var(--muted); font-size: 13px; }
.cost { text-align: right; display: flex; flex-direction: column; }
.cost b { font-size: 20px; color: var(--text); }
.cost span { font-size: 12px; color: var(--muted); }
.cost i { font-style: normal; font-size: 11.5px; color: var(--muted); opacity: .85; }
.cost.cancelled b { color: var(--danger); }

.progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-bottom: 12px; }
.progress span { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width .8s var(--ease); }
.session.status-playing .progress span { background: var(--ok); }

.cancelled-note {
  margin: 14px 0 4px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--danger); border: 1px solid var(--danger);
  display: flex; flex-direction: column; gap: 3px; animation: shake .5s var(--ease);
}
.cancelled-note strong { color: var(--danger-ink); font-size: 14.5px; }
.cancelled-note span { font-size: 12.5px; color: var(--danger-ink); opacity: .88; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.players { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.player {
  /* flex-wrap: gdy imię jest długie albo dochodzą plakietki i dopisek
     „(teraz …)”, prawa grupa przechodzi do drugiej linii — bez tego przyciski
     admina wychodziły poza kartę (były ucinane przy prawej krawędzi).        */
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 9px; row-gap: 7px; padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line-soft);
  animation: fadeUp .4s var(--ease) both;
  transition: background .2s var(--ease), transform .2s var(--ease);
}
.player:hover { background: var(--surface-3); transform: translateX(2px); }
.player .idx { flex: none; width: 20px; text-align: center; color: var(--muted); font-size: 12.5px; }
.player .who { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.player .tag { flex: none; }
.player .amount {
  flex: none; font-variant-numeric: tabular-nums; font-size: 14px;
  color: var(--text); font-weight: 600; white-space: nowrap;
}
.player .amount i { font-style: normal; font-size: 11.5px; color: var(--muted); font-weight: 400; }
.player.is-paid { border-color: var(--ok-line); background: var(--ok-soft); }
.player.is-paid .amount { color: var(--ok); }
.player .empty, .players .empty { color: var(--muted); font-size: 13.5px; padding: 10px; text-align: center; }

/* Koniec wiersza osoby: kwota i przyciski trzymają się razem jako jedna grupa
   i razem przechodzą do drugiej linii, zawsze wyrównane do prawej. Dzięki temu
   „zł” i „×” nie rozjeżdżają się i nie wychodzą poza kartę.                   */
.row-end {
  margin-left: auto; display: flex; flex-wrap: wrap; justify-content: flex-end;
  align-items: center; gap: 12px;
}

/* Przyciski admina przy osobie: „zł” (zapłacone) i „×” (wypisz). Muszą być
   duże i odsunięte od siebie — na telefonie łatwo było kliknąć nie ten.     */
.row-actions { display: flex; gap: 10px; flex: none; }
.mini {
  width: 34px; height: 34px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-3); color: var(--text); border: 1px solid var(--line);
  font: inherit; font-size: 15px; font-weight: 650; line-height: 1;
  transition: background .18s var(--ease), transform .18s var(--ease), border-color .18s var(--ease);
}
.mini:hover { transform: translateY(-1px); background: var(--line-soft); }
.mini:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* ikonka monety wewnątrz przycisku — kwadrat, żeby nie łapała odstępu linii */
.mini svg { width: 18px; height: 18px; display: block; }
.mini.paid { color: var(--ok); border-color: var(--ok-line); }
.mini.paid:hover { background: var(--ok-soft); }
.mini.danger { color: var(--danger); border-color: var(--danger-line); }
.mini.danger:hover { background: var(--danger); border-color: var(--danger); color: var(--danger-ink); }
.mini.on { background: var(--ok); border-color: var(--ok); color: var(--ok-ink); }
.mini.on:hover { background: var(--ok); }

.s-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.deadline { font-size: 12px; color: var(--muted); }
.deadline.ok { color: var(--ok); font-weight: 650; }
.note { margin: 12px 0 0; font-size: 12.5px; color: var(--warn); }

/* ------------------------------------------------------------- przyciski -- */

.btn {
  appearance: none; cursor: pointer; font: inherit; font-size: 14.5px; font-weight: 600;
  padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); text-decoration: none; display: inline-flex;
  align-items: center; gap: 8px; justify-content: center;
  transition: transform .18s var(--ease), background .18s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.btn:hover { transform: translateY(-2px); background: var(--surface-2); border-color: var(--accent-line); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  box-shadow: var(--shadow-sm);
}
.btn.primary:hover { box-shadow: 0 12px 26px -14px rgba(0, 0, 0, .7); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.wide { width: 100%; margin-top: 8px; }
.btn.danger { color: var(--danger); border-color: var(--danger-line); }
.btn.danger:hover { background: var(--danger); border-color: var(--danger); color: var(--danger-ink); }

/* --------------------------------------------------------------- panele -- */

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-top: 22px; box-shadow: var(--shadow);
  animation: fadeUp .5s var(--ease) both;
}
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.panel-head h2 { margin: 0 0 4px; font-size: 19px; }
.panel-head p { margin: 0; font-size: 13px; }
.panel-tools { display: flex; gap: 8px; flex-wrap: wrap; }

.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--line-soft); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  position: sticky; top: 0; background: var(--sticky-bg);
  text-align: left; font-size: 12px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted);
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.ok { color: var(--ok); font-weight: 600; }
td.due { color: var(--text); font-weight: 700; }
td.name { font-weight: 600; }
.cell-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip {
  display: inline-grid; place-items: center; min-width: 30px; padding: 3px 7px; border-radius: 8px;
  font-size: 12px; background: var(--surface-2); border: 1px solid var(--line-soft);
}
.chip i { font-style: normal; font-size: 10px; color: var(--ok); }
.chip.playing   { border-color: var(--ok-line);     background: var(--ok-soft); }
.chip.cancelled { border-color: var(--danger-line); background: var(--danger-soft); text-decoration: line-through; color: var(--muted); }
.chip.is-paid   { box-shadow: inset 0 0 0 2px var(--ok); }

.empty-state { color: var(--muted); text-align: center; padding: 22px; font-size: 14px; }

/* -------------------------------------------------------- tabela admina -- */

.admin-table .sticky-col { position: sticky; left: 0; background: var(--sticky-bg); z-index: 2; }
.admin-table thead th.col a { color: var(--text); text-decoration: none; }
.admin-table thead th.col span { display: block; font-size: 10.5px; text-transform: none; letter-spacing: 0; color: var(--muted); }
.admin-table thead th.col.playing   { box-shadow: inset 0 3px 0 var(--ok); }
.admin-table thead th.col.cancelled { box-shadow: inset 0 3px 0 var(--danger); }
.admin-table td.cell { text-align: center; }
.admin-table td.cell.is-empty { color: var(--muted-2); }
.admin-table td.cell.is-paid { background: var(--ok-soft); }
.admin-table tfoot td { border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }

.paid-btn {
  cursor: pointer; font: inherit; font-size: 13px; font-variant-numeric: tabular-nums;
  padding: 6px 10px; border-radius: 9px; min-width: 64px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  transition: background .18s var(--ease), transform .18s var(--ease), color .18s var(--ease);
}
.paid-btn:hover { transform: translateY(-1px); border-color: var(--accent-line); }
.paid-btn.on { background: var(--ok); border-color: var(--ok); color: var(--ok-ink); font-weight: 650; }

.settings-table th { text-align: left; color: var(--muted); font-weight: 500; width: 42%; }
.settings-table td, .settings-table th { padding: 9px 12px; }

/* -------------------------------------------------------------- zakładki -- */

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 4px; }
.tab {
  cursor: pointer; font: inherit; font-size: 14px; padding: 9px 15px; border-radius: 12px 12px 0 0;
  background: transparent; border: 1px solid transparent; border-bottom: none; color: var(--muted);
  transition: color .2s var(--ease), background .2s var(--ease);
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--text); background: var(--surface); border-color: var(--line); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeUp .4s var(--ease) both; }

/* ----------------------------------------------------------------- alert -- */

.alert { padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; }
.alert.warn { background: var(--warn-soft); border: 1px solid var(--warn-line); color: var(--text); }
.alert.warn strong { color: var(--warn); }
.alert code, .panel code { background: var(--surface-3); padding: 1px 6px; border-radius: 6px; font-size: 12.5px; }

/* ----------------------------------------------------------------- login -- */

.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-wrap { width: min(420px, 100%); padding: 20px; }
.login-card {
  display: flex; flex-direction: column; gap: 12px; padding: 30px 26px;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow);
  animation: fadeUp .5s var(--ease) both; text-align: center;
}
.login-card h1 { margin: 0; font-size: 24px; }
.login-card .muted { margin: -6px 0 8px; font-size: 13.5px; }
.login-ball { margin: 0 auto; filter: drop-shadow(0 10px 22px rgba(35, 33, 30, .22)); }
.login-foot { margin: 6px 0 0; font-size: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.field > span, .field > label { font-size: 12.5px; color: var(--muted); }
input, select, textarea {
  font: inherit; font-size: 15px; color: var(--text);
  background: var(--input-bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 13px; width: 100%; transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
/* pole PIN-u: rozstrzelone cyfry i wąskie — od razu widać, że to nie imię */
input[name="pin"] {
  max-width: 9rem;
  letter-spacing: .4em;
  font-variant-numeric: tabular-nums;
}
.form-error { margin: 4px 0; padding: 9px 12px; border-radius: 10px; font-size: 13.5px;
  background: var(--danger); border: 1px solid var(--danger); color: var(--danger-ink); }
.hint { margin: 0; font-size: 12px; color: var(--muted); min-height: 15px; }

.inline-form { display: flex; gap: 8px; align-items: center; }

/* ----------------------------------------------------------------- modal -- */

.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20, 18, 15, .55); backdrop-filter: blur(4px); animation: fadeIn .2s var(--ease); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  position: relative; width: min(440px, 100%); max-height: 88vh; overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: 20px; padding: 24px; box-shadow: var(--shadow);
  animation: popIn .3s var(--ease) both;
}
@keyframes popIn { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }
.modal-card h3 { margin: 0 0 16px; font-size: 19px; }
.modal-x {
  position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 10px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text); font-size: 18px; line-height: 1;
}
.modal-x:hover { background: var(--surface-3); }
.modal-form { display: flex; flex-direction: column; gap: 14px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.choice-row { display: flex; gap: 8px; flex-wrap: wrap; }
.choice {
  flex: 1 1 120px; cursor: pointer; text-align: center; padding: 11px 12px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 13.5px; transition: all .2s var(--ease);
}
.choice input { display: none; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }

/* ---------------------------------------------------------------- toasty -- */

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 240px; max-width: 360px; padding: 12px 14px; border-radius: 14px; font-size: 14px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  border-left: 4px solid var(--accent);
  box-shadow: var(--shadow); animation: toastIn .3s var(--ease) both;
}
.toast.ok    { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--danger); }
.toast.leaving { animation: toastOut .25s var(--ease) both; }
@keyframes toastIn  { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------------------------------------------------------- błąd / druk -- */

.error-page { text-align: center; padding: 60px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.error-page h1 { font-size: 54px; margin: 0; }

.print-toolbar { display: flex; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--line-soft); }
.print-sheet { width: min(1100px, 100%); margin: 0 auto; padding: 24px 18px 60px; }
.print-head { display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 18px; }
.print-head h1 { margin: 0 0 6px; font-size: 22px; }
.print-head p, .print-stamp span { margin: 0; font-size: 12.5px; color: var(--muted); display: block; }
.print-table th, .print-table td { border: 1px solid var(--line); padding: 8px 10px; font-size: 13px; }
.print-table th.cancelled { color: var(--danger); }
.print-table td.sign { min-width: 90px; }
.print-foot { margin-top: 16px; font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------- responsywność - */

@media (max-width: 720px) {
  .wrap { padding: 16px 12px 48px; }
  .grid { grid-template-columns: 1fr; }
  /* na wąskim ekranie menu wchodzi pod nazwę, zamiast ucinać „Wyloguj” */
  .topbar { flex-wrap: wrap; row-gap: 6px; }
  .topnav { margin-left: auto; }
  .s-head { grid-template-columns: auto 1fr; }
  .s-head .badge { grid-column: 1 / -1; justify-self: start; }
  .page-head { gap: 12px; }
  .brand-text i { display: none; }
  .counter, .s-meta { flex-wrap: wrap; gap: 8px; }
  .modal-card { padding: 20px 16px; }
  .toasts { left: 12px; right: 12px; }
  .toast { max-width: none; }
  .tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  .theme-btn { width: 32px; height: 32px; }

  /* palce zamiast kursora: przyciski admina większe i szerzej rozstawione.
     Gdy wiersz się nie mieści, cała grupa (kwota + przyciski) schodzi do
     drugiej linii — tak samo jak na komputerze.                              */
  .mini { width: 42px; height: 42px; border-radius: 12px; font-size: 17px; }
  .mini svg { width: 22px; height: 22px; }
  .row-actions { gap: 12px; }

  /* zwinięty pasek minionej środy zostaje jednoliniowy (chip, data, status, ⌄) */
  .session.is-past:not([open]) > summary { grid-template-columns: auto 1fr auto auto; }
  .session.is-past:not([open]) > summary .badge { grid-column: auto; }
}

/* ------------------------------------------------------------------ druk -- */

@media print {
  :root { color-scheme: light; --text: #111; --muted: #555; --line: #ccc; --line-soft: #ddd; --surface: #fff; --surface-2: #fff; --bg: #fff; }
  body { background: #fff; color: #111; }
  .bg, .topbar, .no-print, .toasts, .modal, .foot, .theme-btn { display: none !important; }
  .print-sheet { padding: 0; }
  .print-table th, .print-table td { border: 1px solid #999; }
  .print-head h1 { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
