/* ============================================================
   Panel szkół Wing Tsun Kung Fu — Design System v2 ("Dojo")
   Estetyka wg mockupu DojoManager: ciepła ciemna paleta
   (brązy/czernie), akcent cynobrowy #C23B22, złoto #C9A227,
   nagłówki Bebas Neue, pieczęcie stopni, pigułki statusów.
   Zachowuje pełne API klas i zmiennych poprzedniej wersji.
   ============================================================ */

:root {
  /* Tła (ciepłe brązy) */
  --bg:            #14110F;
  --bg-2:          #0F0D0B;
  --panel:         #1E1A17;   /* surface   */
  --panel-2:       #25201C;   /* surface-2 */
  --panel-3:       #2B2521;   /* surface-3 */
  --border:        #29231E;   /* miekki podzial */
  --border-strong: #332C26;

  /* Akcenty (cynober + zloto) */
  --red:           #C23B22;
  --red-soft:      #D96A55;
  --red-dim:       rgba(194, 59, 34, 0.16);
  --gold:          #C9A227;
  --gold-soft:     #DDBC55;
  --gold-dim:      rgba(201, 162, 39, 0.16);

  /* Tekst (cieple kosci sloniowej) */
  --text:          #EDE6DC;
  --muted:         #A69B8D;
  --faint:         #6E655B;

  /* Statusy (niezalezne od akcentu — nie zmieniaja sie z typem szkoly) */
  --paid:          #5C8A5A;
  --due:           #C23B22;
  --overdue:       #D0492F;
  --warn:          #C9A227;
  --info:          #5F7A8C;

  /* Ksztalty / cienie */
  --radius:        10px;
  --radius-sm:     6px;
  --radius-lg:     12px;
  --shadow:        0 16px 40px rgba(0,0,0,0.50);
  --shadow-soft:   0 4px 14px rgba(0,0,0,0.25);
  --ring:          0 0 0 3px rgba(194, 59, 34, 0.28);

  --sidebar-w:     252px;
  --topbar-h:      68px;

  --font:         "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --font-display: "Bebas Neue", "Inter", sans-serif;
  --font-mono:    "JetBrains Mono", Consolas, monospace;
}

/* Kontekst szkoly szermierczej: akcent stalowo-blekitny (statusy bez zmian) */
body[data-school-type="sabre_fencing"] {
  --red:      #5F7A8C;
  --red-soft: #7E99AB;
  --red-dim:  rgba(95, 122, 140, 0.18);
  --ring:     0 0 0 3px rgba(95, 122, 140, 0.30);
}

* { box-sizing: border-box; }

html { color-scheme: dark; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
::selection { background: var(--red); color: #fff; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Tekstura tla: siatka kropek (znak firmowy stylu) */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,0.025) 1px, transparent 0);
  background-size: 5px 5px;
  opacity: .6;
}

/* ---------- Logo / godlo (pieczec) ---------- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; flex: 0 0 42px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--red);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute; inset: -5px;
  border-radius: 50%;
  border: 1px dashed var(--red);
  opacity: .40;
}
.brand-mark span {
  position: relative; z-index: 1;
  font-weight: 800; color: var(--gold);
  font-size: 16px; letter-spacing: .5px;
}
/* Emblemat szermierczy (skrzyzowane szable) — wariant dla szkoly szablowej */
.brand-mark .brand-sabre { position: relative; z-index: 1; width: 23px; height: 23px; color: var(--gold); }
.brand-mark--lg .brand-sabre { width: 34px; height: 34px; }

/* Segmentowany wybor statusu obecnosci */
.att-seg { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.att-seg label { position: relative; display: inline-flex; cursor: pointer; }
.att-seg input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.att-seg span {
  display: inline-block; padding: 5px 11px; border-radius: 20px;
  border: 1px solid var(--border-strong); font-size: 11.5px; font-weight: 600;
  color: var(--muted); white-space: nowrap; transition: background .12s, color .12s, border-color .12s;
}
.att-seg label:hover span { color: var(--text); border-color: var(--faint); }
.att-seg input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 1px; }
.att-seg input:checked + span { color: #fff; }
.att-seg .s-present input:checked + span { background: var(--paid);    border-color: var(--paid); }
.att-seg .s-absent  input:checked + span { background: var(--due);     border-color: var(--due); }
.att-seg .s-late    input:checked + span { background: var(--warn);    border-color: var(--warn); color: #171106; }
.att-seg .s-excused input:checked + span { background: var(--info);    border-color: var(--info); }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text b { font-family: var(--font-display); font-weight: 400; font-size: 21px; letter-spacing: .5px; }
.brand-text small { color: var(--faint); font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; margin-top: 2px; }

/* ============================================================
   EKRAN LOGOWANIA (wysrodkowany panel)
   ============================================================ */
.auth-wrap {
  position: relative; z-index: 1;
  min-height: 100vh;
}
.auth-wrap.auth-wrap--center {
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-wrap.auth-wrap--center::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(620px 440px at 50% -12%, rgba(194,59,34,0.16), transparent 62%),
    radial-gradient(520px 380px at 50% 118%, rgba(201,162,39,0.08), transparent 62%);
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 40px 34px 34px;
}
.auth-card h2 { margin: 18px 0 4px; font-size: 23px; font-weight: 700; }
.auth-card .sub { color: var(--muted); font-size: 13.5px; margin: 0 0 24px; }
.auth-emblem { display: flex; justify-content: center; margin-bottom: 6px; }
.brand-mark--lg { width: 62px; height: 62px; flex: 0 0 62px; }
.brand-mark--lg::after { inset: -7px; }
.brand-mark--lg span { font-size: 25px; }
.auth-title {
  text-align: center; margin: 16px 0 26px;
  font-family: var(--font-display); font-weight: 400;
  font-size: 30px; letter-spacing: .8px;
}

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 11px; letter-spacing: .8px; text-transform: uppercase; color: var(--faint); margin-bottom: 7px; font-weight: 700; }
.input-wrap { position: relative; }
.input-wrap > svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.input {
  width: 100%; height: 46px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0 14px 0 40px;
  font-size: 14.5px;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--faint); }
.input:focus { outline: none; border-color: var(--red); box-shadow: var(--ring); }
.input-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--faint); padding: 8px; border-radius: 6px;
}
.input-toggle:hover { color: var(--muted); }

.row-between { display: flex; align-items: center; justify-content: space-between; }
.checkbox { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; cursor: pointer; user-select: none; }
.checkbox input { accent-color: var(--red); width: 15px; height: 15px; }
.link-gold { color: var(--gold); font-size: 13px; }
.link-gold:hover { color: var(--gold-soft); text-decoration: underline; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: 13.5px; letter-spacing: .2px;
  transition: transform .08s, filter .15s, background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-block { width: 100%; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { filter: brightness(1.12); }
.btn-ghost { background: var(--panel-2); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--panel-3); }
.btn-gold { background: var(--gold); color: #171106; }
.btn-gold:hover { filter: brightness(1.08); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 12.5px; }
.btn-icon { width: 40px; height: 40px; padding: 0; }

.auth-error {
  display: flex; align-items: center; gap: 9px;
  background: var(--red-dim); border: 1px solid rgba(194,59,34,0.45);
  color: #E8A79A; border-radius: var(--radius-sm);
  padding: 11px 13px; font-size: 13px; margin-bottom: 18px;
}
.auth-error svg { flex: 0 0 16px; color: var(--red-soft); }

.divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 12px; margin: 22px 0; }
.divider::before, .divider::after { content: ""; height: 1px; flex: 1; background: var(--border-strong); }

.demo-accounts { display: grid; gap: 8px; }
.demo-chip {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 11px; text-align: left; color: var(--text);
  transition: border-color .15s, background .15s;
}
.demo-chip:hover { border-color: var(--border-strong); background: var(--panel); }
.demo-chip .role-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }
.demo-chip .dc-meta { display: flex; flex-direction: column; line-height: 1.25; }
.demo-chip .dc-meta b { font-size: 13px; font-weight: 600; }
.demo-chip .dc-meta small { font-size: 11.5px; color: var(--muted); }
.demo-chip .dc-go { margin-left: auto; color: var(--faint); }
.demo-chip:hover .dc-go { color: var(--gold); }

/* ============================================================
   LAYOUT APLIKACJI
   ============================================================ */
/* UWAGA: .app celowo BEZ z-index. Ustawienie tu z-index tworzyloby wlasny
   stacking context i uwiezilo w nim .sidebar (nawet z wysokim z-index),
   przez co .overlay (sibling .app) zawsze renderowalby sie NAD sidebarem
   na mobile niezaleznie od jego z-index — objawiajac sie jako "nieaktywne"
   menu i przewijanie strony pod spodem zamiast listy. */
.app { position: relative; display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-head { padding: 18px 18px 16px; border-bottom: 1px solid var(--border); }
.sidebar-school-switch { padding: 12px 14px 0; }
.sidebar-school-switch label { display: block; font-size: 10px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--faint); margin-bottom: 6px; font-weight: 700; }
.sidebar-school-switch select {
  width: 100%; padding: 9px 10px; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border-strong); font-size: 13px; font-weight: 600;
}
.sidebar-school-switch select:hover { border-color: var(--gold); }
.nav { padding: 10px 12px 14px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 10px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--faint); margin: 14px 10px 6px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm); color: var(--muted);
  font-size: 14px; font-weight: 500; margin-bottom: 2px;
  position: relative; transition: background .15s, color .15s;
}
.nav-item svg { flex: 0 0 18px; }
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--red-dim); color: var(--text); }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  height: 60%; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--red);
}
.nav-item .badge-count { margin-left: auto; }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); }
.user-mini { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); transition: background .15s; }
.user-mini:hover { background: var(--panel); }
.user-mini .meta { line-height: 1.2; min-width: 0; }
.user-mini .meta b { font-size: 13px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-mini .meta small { font-size: 11px; color: var(--muted); }

/* Awatar: okragla pieczec z inicjalami (Bebas) */
.avatar {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 400; font-size: 15px; letter-spacing: .5px;
  color: var(--text);
  background: var(--panel-3);
  border: 1px solid var(--border-strong);
}
.avatar.gold { background: var(--gold-dim); color: var(--gold); border-color: rgba(201,162,39,0.45); }
.avatar.sm { width: 30px; height: 30px; flex-basis: 30px; font-size: 12px; }
.avatar.xl { width: 120px; height: 120px; flex-basis: 120px; font-size: 44px; }
/* Zdjecie profilowe wypelnia pieczec awatara (fallback = inicjaly) */
.avatar { overflow: hidden; padding: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Karta zdjecia profilowego (profil uzytkownika) */
.avatar-edit { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.avatar-edit .avatar { width: 84px; height: 84px; flex-basis: 84px; font-size: 30px; }
/* Wieksza, wyrazniejsza wersja podgladu (edycja konta uzytkownika) */
.avatar-edit.lg { gap: 22px; }
.avatar-edit.lg .avatar { width: 120px; height: 120px; flex-basis: 120px; font-size: 44px; }
.avatar-edit .ae-actions { display: flex; flex-direction: column; gap: 8px; min-width: 220px; flex: 1; }
.avatar-edit input[type="file"] {
  width: 100%; font-size: 12.5px; color: var(--muted);
  background: var(--bg-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 8px 10px;
}
.avatar-edit input[type="file"]::file-selector-button {
  font: inherit; font-weight: 600; font-size: 12px; cursor: pointer;
  background: var(--panel-3); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 5px 11px; margin-right: 10px;
}
.avatar-edit input[type="file"]::file-selector-button:hover { background: var(--panel-2); }

/* ---- Topbar ---- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-h); position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px;
  background: rgba(20,17,15,0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.school-switch {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 7px 12px; min-width: 230px;
  transition: border-color .15s;
}
.school-switch:hover { border-color: var(--gold); }
.school-switch .sw-ic { width: 30px; height: 30px; border-radius: var(--radius-sm); display: grid; place-items: center; background: var(--red-dim); color: var(--red-soft); flex: 0 0 30px; }
.school-switch .sw-meta { line-height: 1.2; }
.school-switch .sw-meta b { font-size: 13px; display: block; font-weight: 600; }
.school-switch .sw-meta small { font-size: 11px; color: var(--muted); }
.school-switch .sw-caret { margin-left: auto; color: var(--faint); transition: transform .15s; }

/* Rozwijany przelacznik szkoly */
.school-switch-wrap { position: relative; }
.school-switch-wrap > .school-switch { width: 100%; cursor: pointer; font: inherit; color: var(--text); text-align: left; }
.school-switch-wrap.open > .school-switch { border-color: var(--gold); }
.school-switch-wrap.open .sw-caret { transform: rotate(180deg); }
.school-switch-menu {
  position: absolute; top: calc(100% + 8px); left: 0; min-width: 280px; z-index: 60;
  background: var(--panel-2); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 6px; display: none; max-height: 360px; overflow-y: auto;
}
.school-switch-wrap.open .school-switch-menu { display: block; }
.ssm-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--text); }
.ssm-item:hover { background: var(--panel-3); }
.ssm-item.active { background: var(--red-dim); }
.ssm-item .ssm-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.ssm-item b { font-size: 13px; display: block; line-height: 1.2; font-weight: 600; }
.ssm-item small { font-size: 11.5px; color: var(--muted); }
.ssm-empty { padding: 12px; color: var(--faint); font-size: 13px; text-align: center; }

.searchbar { position: relative; flex: 1; max-width: 340px; }
.searchbar svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.searchbar input {
  width: 100%; height: 38px; background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); color: var(--text); padding: 0 12px 0 38px; font-size: 13px;
}
.searchbar input::placeholder { color: var(--faint); }
.searchbar input:focus { outline: none; border-color: var(--red); }
.topbar-spacer { flex: 1; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center; position: relative;
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); color: var(--muted);
  transition: color .15s, border-color .15s, background .15s;
}
.icon-btn:hover { color: var(--text); background: var(--panel-2); }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px var(--bg); }

/* Menu uzytkownika (avatar w topbarze) */
.user-menu-wrap { position: relative; flex-shrink: 0; }
.user-menu-wrap > .avatar { cursor: pointer; transition: box-shadow .15s; }
.user-menu-wrap.open > .avatar,
.user-menu-wrap > .avatar:hover { box-shadow: 0 0 0 2px var(--border-strong); }
.user-menu {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 220px; z-index: 60;
  background: var(--panel-2); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 6px; display: none;
}
.user-menu-wrap.open .user-menu { display: block; }
.user-menu-head { padding: 9px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.user-menu-head b { font-size: 13.5px; display: block; }
.user-menu-head small { font-size: 11.5px; color: var(--muted); display: block; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
  color: var(--text); text-align: left; background: none; border: none;
}
.user-menu-item svg { flex: 0 0 15px; color: var(--faint); }
.user-menu-item:hover { background: var(--panel-3); }
.user-menu-item--danger:hover { color: var(--red-soft); }
.user-menu-item--danger:hover svg { color: var(--red-soft); }

/* ---- Content ---- */
.content { padding: 24px 26px 60px; max-width: 1500px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 {
  margin: 0;
  font-family: var(--font-display); font-weight: 400;
  font-size: 34px; letter-spacing: .5px; line-height: 1;
}
.page-head .crumb {
  color: var(--faint); font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase;
  font-weight: 700; margin: 0 0 8px;
}
.page-head .crumb b { color: var(--red-soft); font-weight: 700; }
.page-head .crumb a { color: var(--muted); }
.page-head .crumb a:hover { color: var(--gold); }
.head-actions { display: flex; gap: 10px; align-items: center; }

/* ---- Karty / siatka ---- */
.grid { display: grid; gap: 16px; }
.cards-4 { grid-template-columns: repeat(4, 1fr); }
.cols-3-1 { grid-template-columns: 2.1fr 1fr; }
.cols-2 { grid-template-columns: 1fr 1fr; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.card-pad { padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.card-head h3 {
  margin: 0;
  font-family: var(--font-display); font-weight: 400;
  font-size: 17px; letter-spacing: .4px;
}
.card-head a { font-size: 12px; font-weight: 600; color: var(--red-soft); }
.card-head a:hover { text-decoration: underline; }

/* ---- Stat cards ---- */
.stat { padding: 16px 18px; position: relative; overflow: hidden; }
.stat .stat-ic { width: 40px; height: 40px; border-radius: var(--radius-sm); display: grid; place-items: center; margin-bottom: 12px; }
.stat .stat-val {
  font-family: var(--font-display); font-weight: 400;
  font-size: 36px; letter-spacing: .5px; line-height: 1;
}
.stat .stat-label { color: var(--faint); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; font-weight: 600; margin-top: 7px; }
.stat .stat-trend { font-size: 11.5px; margin-top: 9px; display: inline-flex; align-items: center; gap: 5px; }
.trend-up { color: var(--paid); }
.trend-down { color: var(--overdue); }
.ic-red { background: var(--red-dim); color: var(--red-soft); }
.ic-gold { background: var(--gold-dim); color: var(--gold); }
.ic-green { background: rgba(92,138,90,0.16); color: var(--paid); }
.ic-blue { background: rgba(95,122,140,0.18); color: #8FA9BA; }

/* ---- Badges (pigulki statusow) ---- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; letter-spacing: .3px;
  border: 1px solid transparent; white-space: nowrap;
}
.badge i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; background: var(--red); color: #fff;
}
.b-paid    { background: rgba(92,138,90,0.16);   color: #7FAF7D; }
.b-due     { background: rgba(194,59,34,0.16);   color: #E07B60; }
.b-overdue { background: rgba(208,73,47,0.20);   color: #ED9077; }
.b-warn    { background: var(--gold-dim);        color: var(--gold-soft); }
.b-info    { background: rgba(95,122,140,0.18);  color: #8FA9BA; }
.b-muted   { background: rgba(255,255,255,0.05); color: var(--muted); }

/* Pieczec stopnia */
.rank-pill {
  display: inline-flex; align-items: center; gap: 7px;
  background: transparent;
  border: 1.5px solid rgba(201,162,39,0.55);
  color: var(--gold);
  padding: 3px 11px;
  border-radius: 10px 13px 11px 14px;
  font-family: var(--font-display); font-weight: 400;
  font-size: 13px; letter-spacing: .8px;
}

/* ---- Tabele ---- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th {
  text-align: left; font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--faint); font-weight: 700; padding: 12px 16px; border-bottom: 1px solid var(--border);
}
table.tbl td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr { transition: background .12s; }
table.tbl tbody tr:hover { background: var(--panel-2); }
.cell-user { display: flex; align-items: center; gap: 10px; }
.cell-user .meta b { font-size: 13px; display: block; font-weight: 700; }
.cell-user .meta small { font-size: 11.5px; color: var(--muted); }
.t-actions { display: flex; gap: 6px; }
.t-act { width: 30px; height: 30px; border-radius: var(--radius-sm); display: grid; place-items: center; background: var(--panel-3); border: 1px solid var(--border-strong); color: var(--muted); }
.t-act:hover { color: var(--text); border-color: var(--red); }

/* ---- Listy aktywnosci / komunikatow ---- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.list-item:last-child { border-bottom: none; }
.list-item .li-ic { width: 34px; height: 34px; border-radius: var(--radius-sm); display: grid; place-items: center; flex: 0 0 34px; }
.list-item .li-body { min-width: 0; flex: 1; }
.list-item .li-body b { font-size: 13.5px; font-weight: 700; }
.list-item .li-body p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.list-item .li-time { font-size: 10.5px; color: var(--faint); white-space: nowrap; letter-spacing: .5px; text-transform: uppercase; }

/* ---- Grafik tygodniowy ---- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; padding: 16px; }
.week-day { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; min-height: 150px; }
.week-day .wd-name { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--faint); font-weight: 700; margin-bottom: 8px; text-align: center; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.week-day.today { border-color: var(--red); }
.week-day.today .wd-name { color: var(--red-soft); }
.session {
  background: var(--panel-2); border: 1px solid var(--border-strong); border-left: 3px solid var(--gold);
  border-radius: var(--radius-sm); padding: 7px 8px; margin-bottom: 7px;
  transition: transform .12s;
}
.session:hover { transform: translateY(-2px); }
.session.wt { border-left-color: var(--red); }
.session b { font-size: 11.5px; display: block; }
.session small { font-size: 10.5px; color: var(--muted); font-family: var(--font-mono); }

/* ---- Progres / paski ---- */
.progress { height: 8px; background: var(--bg-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--red), var(--gold)); }
.kv { display: flex; align-items: center; justify-content: space-between; font-size: 13px; padding: 7px 0; }
.kv + .kv { border-top: 1px solid var(--border); }
.kv .k { color: var(--muted); }

/* ---- Hero ucznia ---- */
.hero-card {
  background: linear-gradient(180deg, var(--red-dim), transparent 55%), var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 22px; display: flex; align-items: center; gap: 20px;
}
.hero-card .avatar { width: 64px; height: 64px; flex-basis: 64px; font-size: 24px; }
/* Szczegoly konta uzytkownika: duze, wyrazne zdjecie (2x standardu hero) */
.hero-card .avatar.xl { width: 128px; height: 128px; flex-basis: 128px; font-size: 46px; }
.hero-card h1 { font-family: var(--font-display); font-weight: 400; letter-spacing: .5px; }

/* ---- Quick actions ---- */
.qa-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 16px; }
.qa {
  display: flex; align-items: center; gap: 11px; padding: 12px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 12.5px; font-weight: 600; transition: border-color .15s, background .15s;
}
.qa:hover { border-color: var(--red); background: var(--panel-3); }
.qa .qa-ic { width: 32px; height: 32px; border-radius: var(--radius-sm); display: grid; place-items: center; flex: 0 0 32px; }

/* ---- Utilities ---- */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.mt-18 { margin-top: 18px; }
.text-muted { color: var(--muted); }
.text-gold { color: var(--gold); }
.big-num { font-family: var(--font-display); font-weight: 400; font-size: 34px; letter-spacing: .5px; }

/* ---- Responsywnosc ---- */
@media (max-width: 1100px) {
  .cards-4 { grid-template-columns: repeat(2, 1fr); }
  .cols-3-1, .cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  /* z-index 75 = NAD overlayem (70), pod drawerem (80) — inaczej overlay blokuje klikniecia w menu */
  .sidebar { position: fixed; left: 0; top: 0; width: var(--sidebar-w); z-index: 75; transform: translateX(-100%); transition: transform .25s ease; box-shadow: 20px 0 60px rgba(0,0,0,0.5); }
  .sidebar.open { transform: translateX(0); }
  .week { grid-template-columns: repeat(2, 1fr); }
  .searchbar { display: none; }
  .cards-4 { grid-template-columns: 1fr; }
  .content { padding: 18px 14px 50px; }
  .page-head h1 { font-size: 27px; }
}

.menu-toggle { display: none; }
@media (max-width: 820px) { .menu-toggle { display: grid; } }

/* ============================================================
   FORMULARZE, FLASH, PAGINACJA
   ============================================================ */
.flash {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 15px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 13.5px;
  border: 1px solid transparent;
}
.flash svg { flex: 0 0 18px; }
.flash-success { background: rgba(92,138,90,0.14);  color: #8FBF8D; border-color: rgba(92,138,90,0.40); }
.flash-error   { background: rgba(194,59,34,0.14);  color: #E8A79A; border-color: rgba(194,59,34,0.45); }

.form-grid { display: grid; gap: 16px; padding: 20px; }
.form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.form-section-title { font-size: 10.5px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--faint); font-weight: 700; margin: 6px 0 -4px; grid-column: 1 / -1; }
.form-field { display: flex; flex-direction: column; }
.form-field.col-span-2 { grid-column: 1 / -1; }
.form-field label { font-size: 11px; letter-spacing: .6px; text-transform: uppercase; color: var(--faint); margin-bottom: 7px; font-weight: 700; }
.form-field .hint { font-size: 11.5px; color: var(--faint); margin-top: 5px; }
.form-control {
  height: 42px; background: var(--bg-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); color: var(--text); padding: 0 13px; font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s;
}
textarea.form-control { height: auto; padding: 11px 13px; resize: vertical; min-height: 90px; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23A69B8D' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; padding-right: 36px; }
.form-control:focus { outline: none; border-color: var(--red); box-shadow: var(--ring); }
.form-control.is-invalid { border-color: var(--due); }
.field-error { color: #E8A79A; font-size: 12px; margin-top: 6px; }

.form-check { display: flex; align-items: center; gap: 9px; color: var(--text); font-size: 13.5px; cursor: pointer; user-select: none; }
.form-check input { accent-color: var(--red); width: 16px; height: 16px; }

.form-actions { display: flex; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--border); justify-content: flex-end; }

.btn-danger { background: var(--red-dim); color: #E8A79A; border-color: rgba(194,59,34,0.45); }
.btn-danger:hover { background: rgba(194,59,34,0.26); }
.btn-link { background: none; color: var(--muted); }
.btn-link:hover { color: var(--text); }

/* Pasek filtrow */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.chip-filter {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; border-radius: 20px;
  background: var(--panel); border: 1px solid var(--border-strong); color: var(--muted); font-size: 12px; font-weight: 600;
  transition: background .15s, color .15s, border-color .15s;
}
.chip-filter.active { background: var(--red); border-color: var(--red); color: #fff; }
.chip-filter:hover:not(.active) { color: var(--text); }

/* Nawigacja daty (obecnosci itp.): zawsze JEDNA linia */
.week-nav { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; white-space: nowrap; }
.week-nav .form-control { min-width: 0; }

/* Kalendarz miesiaca w obecnosciach */
.att-cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; max-width: 560px; }
.att-cal .ac-dow { text-align: center; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--faint); font-weight: 700; padding-bottom: 2px; }
.att-cal .ac-day {
  position: relative; display: flex; align-items: center; justify-content: center;
  aspect-ratio: 1; border-radius: var(--radius-sm); border: 1px solid var(--border);
  color: var(--muted); font-size: 13px; transition: border-color .15s, color .15s;
}
.att-cal .ac-day:hover { border-color: var(--red); color: var(--text); }
.att-cal .ac-empty { border: none; pointer-events: none; }
.att-cal .ac-has { color: var(--text); border-color: var(--border-strong); }
.att-cal .ac-has i {
  position: absolute; right: 4px; bottom: 4px; font-style: normal;
  min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px;
  background: var(--red); color: #fff; font-size: 9.5px; font-weight: 700;
  display: grid; place-items: center; line-height: 1;
}
.att-cal .ac-today { border-color: var(--gold); }

/* Kalendarz ROCZNY obecnosci ucznia (12 mini-miesiecy) */
.year-cal { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 18px 22px; }
.year-cal .ym h4 { margin: 0 0 7px; font-family: var(--font-display); font-weight: 400; font-size: 15px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.ym-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.ym-grid u { text-decoration: none; text-align: center; font-size: 9px; color: var(--faint); font-weight: 700; }
.ym-grid i { aspect-ratio: 1; }
.ym-day {
  aspect-ratio: 1; display: grid; place-items: center;
  font-size: 10px; border-radius: 4px; color: var(--faint);
  background: var(--panel); border: 1px solid var(--border);
}
.ym-day.st-present { background: var(--paid); border-color: var(--paid); color: #fff; font-weight: 700; }
.ym-day.st-absent  { background: var(--due); border-color: var(--due); color: #fff; font-weight: 700; }
.ym-day.st-late    { background: var(--warn); border-color: var(--warn); color: #1a1408; font-weight: 700; }
.ym-day.st-excused { background: var(--info); border-color: var(--info); color: #fff; font-weight: 700; }
/* Typ zajec: zlota obwodka = zajecia dodatkowe (zaawansowane/prywatne) */
.ym-day.ev { box-shadow: inset 0 0 0 2px var(--gold); }
.ym-day.today { outline: 2px solid var(--gold); outline-offset: 1px; }
.year-legend { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin-top: 16px; font-size: 12px; color: var(--muted); }
.year-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg-box { width: 13px; height: 13px; border-radius: 3px; display: inline-block; background: var(--panel); border: 1px solid var(--border); }
.lg-box.st-present { background: var(--paid); }
.lg-box.st-absent  { background: var(--due); }
.lg-box.st-late    { background: var(--warn); }
.lg-box.st-excused { background: var(--info); }
.lg-box.ev { box-shadow: inset 0 0 0 2px var(--gold); }
.att-cal .ac-sel { background: var(--red); border-color: var(--red); color: #fff; }
.att-cal .ac-sel i { background: #fff; color: var(--red); }

/* Kolumna liczby porzadkowej na listach */
.tbl th.c-num, .tbl td.c-num { width: 44px; text-align: center; color: var(--faint); font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* Paginacja Laravela */
.pagination-wrap { padding: 14px 18px; border-top: 1px solid var(--border); }
.pagination-wrap nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pagination-wrap .pagination { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0; align-items: center; }
.pagination-wrap .pagination a, .pagination-wrap .pagination span {
  display: grid; place-items: center; min-width: 34px; height: 34px; padding: 0 9px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); color: var(--muted); font-size: 13px;
}
.pagination-wrap .pagination a:hover { border-color: var(--red); color: var(--text); }
.pagination-wrap .pagination .active span { background: var(--red); border-color: var(--red); color: #fff; }
.pagination-wrap .pagination .disabled span { opacity: .38; }
.pagination-wrap p { color: var(--faint); font-size: 12.5px; margin: 0; }

/* Kolory wydarzen w grafiku */
.session.ev-regular    { border-left-color: var(--red); }
.session.ev-advanced   { border-left-color: #5F7A8C; }
.session.ev-private    { border-left-color: var(--gold); }
.session.ev-seminar    { border-left-color: #8e5fd6; }
.session.ev-camp       { border-left-color: #5C8A5A; }
.session.ev-instructor { border-left-color: #2bb0a8; }
.session.ev-other      { border-left-color: #8a8f98; }
.session a, a.session { color: var(--text); }

.legend-item { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.legend-dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend-dot.ev-regular    { background: var(--red); }
.legend-dot.ev-advanced   { background: #5F7A8C; }
.legend-dot.ev-private    { background: var(--gold); }
.legend-dot.ev-seminar    { background: #8e5fd6; }
.legend-dot.ev-camp       { background: #5C8A5A; }
.legend-dot.ev-instructor { background: #2bb0a8; }
.legend-dot.ev-other      { background: #8a8f98; }

.badge.b-kind { background: rgba(142,95,214,0.16); color: #C0A3EE; }

/* Przelacznik widoku (miesiac/rok) */
.view-switch { display: inline-flex; background: var(--panel); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 3px; }
.view-switch .vs-opt { padding: 6px 14px; border-radius: 4px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.view-switch .vs-opt:hover { color: var(--text); }
.view-switch .vs-opt.active { background: var(--red); color: #fff; }

/* Kalendarz miesieczny */
.cal { padding: 0; overflow: hidden; }
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--border); }
.cal-hd { padding: 10px 12px; font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--faint); font-weight: 700; text-align: left; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-cell { min-height: 116px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 7px 8px; display: flex; flex-direction: column; gap: 4px; }
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell.out { background: rgba(0,0,0,0.22); }
.cal-cell.out .cal-day-num { color: var(--faint); }
.cal-cell.today { background: var(--red-dim); }
.cal-day-num { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 2px; font-family: var(--font-mono); }
.cal-cell.today .cal-day-num { color: #fff; background: var(--red); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; }
.cal-chip { display: flex; align-items: center; gap: 4px; font-size: 11px; line-height: 1.25; padding: 3px 6px; border-radius: 4px; background: var(--panel-2); border-left: 3px solid var(--gold); color: var(--text); }
.cal-chip .cc-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-chip b { font-weight: 700; }
.cal-chip.cancelled { opacity: .6; }
.cal-chip.cancelled .cc-text { text-decoration: line-through; }
.cc-tag { color: var(--red-soft); font-weight: 600; text-decoration: none; }
.cal-chip.cancelled .cc-tag { text-decoration: none; }
.cc-act { display: inline; }
.cc-act button { background: none; border: none; color: var(--faint); cursor: pointer; padding: 0 2px; font-size: 12px; line-height: 1; border-radius: 4px; }
.cc-act button:hover { color: var(--text); background: rgba(255,255,255,0.08); }
.cal-chip.ev-regular    { border-left-color: var(--red); }
.cal-chip.ev-advanced   { border-left-color: #5F7A8C; }
.cal-chip.ev-private    { border-left-color: var(--gold); }
.cal-chip.ev-seminar    { border-left-color: #8e5fd6; }
.cal-chip.ev-camp       { border-left-color: #5C8A5A; }
.cal-chip.ev-instructor { border-left-color: #2bb0a8; }
.cal-chip.ev-other      { border-left-color: #8a8f98; }
.cal-more { font-size: 10.5px; color: var(--gold); padding: 1px 6px; }
.cal-mob-head { display: none; } /* nagłówek dnia — tylko w agendzie mobilnej */

/* Kalendarz roczny — 12 mini-miesiecy */
.year-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.mini-month { padding: 12px; }
.mini-title { display: block; font-family: var(--font-display); font-weight: 400; font-size: 16px; letter-spacing: .5px; text-transform: capitalize; margin-bottom: 9px; color: var(--text); }
.mini-title:hover { color: var(--gold); }
.mini-head, .mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.mini-head span { font-size: 9.5px; color: var(--faint); text-align: center; padding-bottom: 4px; }
.mini-day { font-size: 10.5px; text-align: center; padding: 4px 0; border-radius: 4px; color: var(--muted); position: relative; font-family: var(--font-mono); }
.mini-day.out { color: #453D35; }
.mini-day.today { outline: 1px solid var(--red); color: #fff; }
.mini-day.has-ev { background: var(--gold-dim); color: var(--gold-soft); font-weight: 700; }
.mini-day.has-ev.today { background: var(--red); color: #fff; }

@media (max-width: 1100px) { .year-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 820px) {
  .year-grid { grid-template-columns: repeat(2, 1fr); }
  .cal-cell { min-height: 84px; }
  .cal-chip { font-size: 10px; }
}

/* Kalendarz miesieczny na telefonie: pionowa AGENDA (dzien = wiersz).
   Sztywna siatka 7 kolumn rozpychala sie i nie dalo sie przewijac w bok. */
@media (max-width: 640px) {
  .cal { overflow: visible; }
  .cal-head { display: none; }                 /* naglowki Pon–Ndz zbedne w agendzie */
  .cal-grid { display: block; }
  .cal-cell {
    min-height: 0; flex-direction: column; align-items: stretch;
    border-right: none; padding: 10px 12px; gap: 5px;
  }
  .cal-cell.out { display: none; }             /* dni sasiednich miesiecy */
  .cal-cell.cal-empty:not(.today) { display: none; } /* puste dni pomijamy */
  .cal-day-num { display: none; }
  .cal-mob-head {
    display: block; font-size: 12.5px; font-weight: 700; letter-spacing: .3px;
    text-transform: capitalize; color: var(--gold-soft); margin-bottom: 2px;
  }
  .cal-cell.today { background: var(--red-dim); border-left: 3px solid var(--red); }
  .cal-cell.today .cal-mob-head { color: #fff; }
  /* Chipy pelnej szerokosci, tekst moze sie zawijac (nazwy widoczne w calosci) */
  .cal-chip { font-size: 12.5px; padding: 6px 8px; }
  .cal-chip .cc-text { white-space: normal; overflow: visible; }
  .cal-more { font-size: 12px; padding: 4px 6px; }
}

/* Definicje (show) */
.dl { display: grid; grid-template-columns: 180px 1fr; }
.dl > dt { color: var(--muted); font-size: 13px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.dl > dd { margin: 0; font-size: 13.5px; padding: 10px 0; border-bottom: 1px solid var(--border); }
@media (max-width: 700px) { .dl { grid-template-columns: 1fr; } .dl > dt { padding-bottom: 0; border: none; } }

/* ============================================================
   ZWIJANY SIDEBAR (desktop; na mobile pozostaje off-canvas)
   ============================================================ */
.sb-toggle {
  position: absolute; right: -13px; top: 72px; z-index: 5;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--panel-2); border: 1px solid var(--border-strong); color: var(--muted);
  transition: color .15s, border-color .15s, transform .25s ease;
}
.sb-toggle:hover { color: var(--text); border-color: var(--red); }
.sidebar { overflow: visible; }

@media (min-width: 821px) {
  html.sb-collapsed .app { grid-template-columns: 76px 1fr; }
  html.sb-collapsed .sb-toggle svg { transform: rotate(180deg); }
  html.sb-collapsed .brand-text,
  html.sb-collapsed .nav-txt,
  html.sb-collapsed .nav-label,
  html.sb-collapsed .sidebar-school-switch,
  html.sb-collapsed .user-mini .meta,
  html.sb-collapsed .user-mini > svg { display: none; }
  html.sb-collapsed .sidebar-head { display: flex; justify-content: center; padding: 18px 8px 16px; }
  html.sb-collapsed .brand { gap: 0; }
  html.sb-collapsed .brand-mark { width: 38px; height: 38px; flex-basis: 38px; }
  html.sb-collapsed .nav { padding: 10px 8px 14px; }
  html.sb-collapsed .nav-item { justify-content: center; padding: 11px 0; gap: 0; }
  html.sb-collapsed .nav-item.active::before { left: -8px; }
  html.sb-collapsed .nav-item .badge-count {
    position: absolute; top: 3px; right: 6px; margin: 0;
    min-width: 16px; height: 16px; font-size: 9px; padding: 0 4px;
  }
  html.sb-collapsed .sidebar-foot { padding: 10px 8px; }
  html.sb-collapsed .user-mini { justify-content: center; padding: 8px 0; }
}
@media (max-width: 820px) { .sb-toggle { display: none; } }

/* ============================================================
   OVERLAY / DRAWER (szybki podglad profilu)
   ============================================================ */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 70; display: none; }
.overlay.open { display: block; }

/* Blokada przewijania tla, gdy mobilny sidebar lub drawer sa otwarte */
html.no-scroll, html.no-scroll body { overflow: hidden; height: 100%; overscroll-behavior: none; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 400px; max-width: 94vw;
  background: var(--bg-2); border-left: 1px solid var(--border-strong); z-index: 80;
  transform: translateX(100%); transition: transform .28s ease;
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.drawer-head > span { font-size: 10.5px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--faint); font-weight: 700; }
.drawer-close { width: 30px; height: 30px; display: grid; place-items: center; border-radius: var(--radius-sm); background: none; border: none; color: var(--muted); }
.drawer-close:hover { background: var(--panel); color: var(--text); }
.drawer-body { flex: 1; overflow-y: auto; padding: 22px 20px; }
.drawer-body .dw-loading { padding: 40px 0; text-align: center; color: var(--faint); font-size: 13px; }
.drawer-profile { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.drawer-profile .avatar { width: 88px; height: 88px; flex-basis: 88px; font-size: 32px; }
.drawer-profile .n { font-family: var(--font-display); font-weight: 400; font-size: 23px; letter-spacing: .4px; line-height: 1.1; }
.drawer-profile .s { font-size: 12px; color: var(--faint); margin-top: 3px; }
.drawer-section { margin-bottom: 20px; }
.drawer-section h5 { font-size: 10.5px; letter-spacing: 1.1px; text-transform: uppercase; color: var(--faint); font-weight: 700; margin: 0 0 9px; }
.info-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 13px; }
.info-row:first-of-type { border-top: none; }
.info-row span:first-child { color: var(--faint); flex-shrink: 0; }
.info-row span:last-child { font-weight: 600; text-align: right; }
.drawer-actions { display: flex; flex-direction: column; gap: 8px; }

/* ============================================================
   PIECZEC STOPNIA (rank seal)
   ============================================================ */
.rank-seal {
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: 48% 52% 51% 49% / 52% 48% 53% 47%;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 400;
  font-size: 12px; letter-spacing: .3px;
  border: 2px solid currentColor; position: relative;
  transform: rotate(-6deg);
  box-shadow: inset 0 0 0 3px rgba(0,0,0,0.15);
}
.rank-seal::after { content: ""; position: absolute; inset: -4px; border: 1px dashed currentColor; border-radius: inherit; opacity: .35; }
.rank-seal.tier-sg { color: var(--muted); background: transparent; }
.rank-seal.tier-tg { color: #fff; background: var(--red); border-color: var(--red); }
.rank-seal.tier-master { color: var(--gold); background: transparent; border-color: var(--gold); }
.rank-seal.sm { width: 30px; height: 30px; flex-basis: 30px; font-size: 10px; }
.rank-seal.lg { width: 64px; height: 64px; flex-basis: 64px; font-size: 18px; transform: rotate(-4deg); }
/* Graficzny symbol stopnia (kwiat sliwy Kung Fu / godlo szermiercze) — te same rozmiary co pieczec */
.rank-seal-img { width: 38px; height: 38px; flex: 0 0 38px; object-fit: contain; display: inline-block; vertical-align: middle; }
.rank-seal-img.sm { width: 30px; height: 30px; flex-basis: 30px; }
.rank-seal-img.lg { width: 64px; height: 64px; flex-basis: 64px; }
.rank-seal-img.xl { width: 128px; height: 128px; flex-basis: 128px; }
/* Klikalna pieczec w konfiguracji stopni (wgranie symbolu) */
.rank-symbol-pick { cursor: pointer; display: inline-flex; border-radius: 8px; transition: box-shadow .15s; }
.rank-symbol-pick:hover { box-shadow: 0 0 0 2px var(--gold); }
.rank-cell { display: flex; align-items: center; gap: 10px; }
.rank-cell .label { font-size: 12.5px; color: var(--muted); }

/* ============================================================
   WYSZUKIWARKA / TOOLBAR (listy)
   ============================================================ */
.search-box {
  display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); height: 38px;
  flex: 1; min-width: 200px; max-width: 320px;
}
.search-box svg { width: 15px; height: 15px; color: var(--faint); flex-shrink: 0; }
.search-box input { background: none; border: none; outline: none; font-size: 13px; width: 100%; color: var(--text); font-family: inherit; }
.search-box input::placeholder { color: var(--faint); }
.search-box:focus-within { border-color: var(--red); }
.search-box .clear-q {
  display: grid; place-items: center; width: 18px; height: 18px; flex-shrink: 0;
  border-radius: 50%; background: var(--border-strong); color: var(--muted);
  font-size: 13px; line-height: 1; transition: background .15s, color .15s;
}
.search-box .clear-q:hover { background: var(--red); color: #fff; }
.result-count { font-size: 12px; color: var(--faint); white-space: nowrap; }

/* ============================================================
   POPOVER ZAJEC (kalendarz)
   ============================================================ */
.class-popover {
  position: fixed; background: var(--panel-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 16px; width: 264px;
  box-shadow: var(--shadow); z-index: 90; display: none;
}
.class-popover.open { display: block; }
.class-popover h4 { font-family: var(--font-display); font-weight: 400; font-size: 19px; letter-spacing: .4px; margin: 0 0 8px; padding-right: 24px; }
.class-popover .row { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; padding: 6px 0; border-top: 1px solid var(--border); }
.class-popover .row span:first-child { color: var(--faint); }
.class-popover .row span:last-child { font-weight: 600; text-align: right; }
.class-popover .row .mono { font-family: var(--font-mono); }
.class-popover .close-pop { position: absolute; top: 10px; right: 10px; width: 22px; height: 22px; display: grid; place-items: center; color: var(--faint); background: none; border: none; }
.class-popover .close-pop:hover { color: var(--text); }
.cal-chip[data-pop] { cursor: pointer; }

/* ============================================================
   TOASTY
   ============================================================ */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--panel-3); border: 1px solid var(--paid); color: var(--text);
  padding: 12px 18px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; z-index: 100;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  display: flex; align-items: center; gap: 9px;
  max-width: min(92vw, 480px);
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast svg { flex: 0 0 15px; }
.toast-success { border-color: rgba(92,138,90,0.65); }
.toast-success svg { color: var(--paid); }
.toast-error { border-color: rgba(194,59,34,0.65); }
.toast-error svg { color: var(--red-soft); }

/* ============================================================
   MOBILE — dopieszczenie
   ============================================================ */
@media (max-width: 760px) {
  .form-grid { grid-template-columns: 1fr !important; }
  .form-field.col-span-2 { grid-column: auto; }
  .head-actions { flex-wrap: wrap; }
  .topbar { padding: 0 14px; gap: 10px; }
  .school-switch { min-width: 0; }
  .school-switch .sw-meta small { display: none; }
  .search-box { max-width: none; }
  .drawer { width: 100%; max-width: 100%; border-left: none; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .toolbar { align-items: stretch; }
  .toolbar .search-box { order: -1; }
  .stat .stat-val { font-size: 30px; }
  .hero-card { flex-direction: column; align-items: flex-start; gap: 12px; }
  .qa-grid { grid-template-columns: 1fr; }
  .week { grid-template-columns: 1fr; }
  .fulfill-summary { flex-direction: column; }
}

/* ---------- Modal wysylki (edytowalna tresc SMS) ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(0, 0, 0, .55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: modalIn .15s ease;
}
@keyframes modalIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 520px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
  max-height: 90vh; display: flex; flex-direction: column;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-family: var(--font-display); font-size: 18px; margin: 0; letter-spacing: .5px; }
.modal-x {
  background: none; border: none; color: var(--faint); font-size: 26px;
  line-height: 1; cursor: pointer; padding: 0 4px;
}
.modal-x:hover { color: var(--text); }
.modal-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; overflow: auto; }
.modal-body textarea { width: 100%; resize: vertical; min-height: 120px; }
.modal-hint { font-size: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; align-items: center; }

/* ---------- Kalendarz: chip zapisu na trening probny ---------- */
.cal-chip.cc-trial {
  border: 1px dashed rgba(201, 162, 39, .55);
  border-left: 3px solid var(--gold);
  background: rgba(201, 162, 39, .14);
  color: var(--gold);
}
.legend-dot.cc-trial-dot { background: rgba(201, 162, 39, .35); border: 1px dashed var(--gold); }

/* ---------- Miniatury produktow ---------- */
.prod-thumb {
  width: 40px; height: 40px; border-radius: 8px; object-fit: cover;
  border: 1px solid var(--border); background: rgba(255, 255, 255, .03);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; vertical-align: middle;
}
.prod-thumb-empty { color: var(--faint); }
.prod-thumb-sm { width: 32px; height: 32px; border-radius: 6px; font-size: 15px; }
.prod-thumb-lg { width: 64px; height: 64px; border-radius: 10px; font-size: 26px; }

/* ---------- Szybkie wprowadzanie pozycji zamowienia ---------- */
.draft-items .li-prod { display: inline-flex; align-items: center; gap: 8px; }
.draft-summary-label { margin: 0 0 6px; font-size: 11px; letter-spacing: .5px; text-transform: uppercase; color: var(--faint); }
.draft-summary-line { padding: 4px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.draft-summary-line:last-child { border-bottom: none; }

/* Stepper ilosci: [− N +] */
.qty-stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: rgba(255, 255, 255, .03); }
.qty-stepper .qty-btn {
  width: 34px; min-height: 34px; border: none; background: transparent; color: var(--text);
  font-size: 20px; line-height: 1; cursor: pointer; user-select: none; touch-action: manipulation;
}
.qty-stepper .qty-btn:hover { background: rgba(255, 255, 255, .07); color: var(--gold); }
.qty-stepper .qty-btn:active { background: rgba(201, 162, 39, .18); }
.qty-stepper .qty-val {
  width: 46px; border: none; border-left: 1px solid var(--border); border-right: 1px solid var(--border);
  background: transparent; color: var(--text); text-align: center; font-size: 14px; font-weight: 600; padding: 0;
}
.qty-stepper .qty-val:focus { outline: none; background: rgba(201, 162, 39, .08); }

/* Picker produktow */
.picker { border-top: 1px solid var(--border); }
.picker-search { display: flex; align-items: center; gap: 8px; padding: 12px 16px; position: sticky; top: 0; z-index: 2;
  background: var(--panel); border-bottom: 1px solid var(--border); color: var(--faint); }
.picker-search input { flex: 1; background: transparent; border: none; color: var(--text); font-size: 14px; outline: none; }
.picker-grid { max-height: 420px; overflow-y: auto; padding: 8px; display: grid; gap: 6px; }
.picker-card { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: rgba(255, 255, 255, .02); }
.picker-card.open { border-color: rgba(201, 162, 39, .5); }
.pc-head {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 12px; text-align: left;
  background: transparent; border: none; color: var(--text); cursor: pointer;
}
.pc-head:hover { background: rgba(255, 255, 255, .04); }
.pc-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pc-name { font-size: 14px; }
.pc-meta { font-size: 12px; color: var(--faint); }
.pc-caret { font-size: 20px; color: var(--faint); transition: transform .15s ease; }
.picker-card.open .pc-caret { transform: rotate(45deg); color: var(--gold); }
.pc-add { padding: 4px 12px 12px; border-top: 1px dashed var(--border); }
.pc-variants { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.pc-qtyrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pc-qtyrow .pc-submit { margin-left: auto; }

/* Chip-radio: wybor wariantu (rozmiar / stopien) */
.chip-radio { position: relative; cursor: pointer; }
.chip-radio input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip-radio {
  display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 34px;
  padding: 0 10px; border: 1px solid var(--border); border-radius: 9px; font-size: 13px; font-weight: 600;
  color: var(--text); background: rgba(255, 255, 255, .03); user-select: none;
}
.chip-radio:has(input:checked) { border-color: var(--gold); background: rgba(201, 162, 39, .16); color: var(--gold); }

@media (max-width: 640px) {
  .picker-grid { grid-template-columns: 1fr; max-height: none; }
  .pc-qtyrow .pc-submit { margin-left: 0; flex: 1; min-height: 40px; }
  .qty-stepper .qty-btn { width: 42px; min-height: 40px; }
}

/* Przypisanie pozycji do ucznia (opcjonalne) */
.li-assign { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.li-assign-btn {
  background: none; border: 1px dashed var(--border-strong); border-radius: 8px;
  color: var(--faint); font-size: 11.5px; padding: 2px 8px; cursor: pointer;
}
.li-assign-btn:hover { color: var(--gold); border-color: var(--gold); }

/* Modal przypisania: duza, filtrowana, dotykowa lista uczniow */
.learner-list {
  max-height: 42vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 4px;
  border: 1px solid var(--border); border-radius: 10px; padding: 6px;
}
.learner-row {
  text-align: left; width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid transparent; border-radius: 8px; background: rgba(255, 255, 255, .02);
  color: var(--text); font-size: 14px; cursor: pointer;
}
.learner-row:hover { background: rgba(255, 255, 255, .06); }
.learner-row.selected { border-color: var(--gold); background: rgba(201, 162, 39, .16); color: var(--gold); font-weight: 600; }
@media (max-width: 640px) { .learner-list { max-height: 50vh; } .learner-row { min-height: 48px; font-size: 15px; } }

/* ---------- Zamowienia: wybor rodzaju + magazyn ---------- */
.order-type-choice { display: grid; gap: 8px; }
.otc-opt { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 10px; cursor: pointer; }
.otc-opt:has(input:checked) { border-color: var(--gold); background: rgba(201, 162, 39, .10); }
.otc-opt input { margin-top: 3px; accent-color: var(--red); }
.otc-opt span { display: flex; flex-direction: column; }
.otc-opt small { color: var(--faint); font-size: 12px; }
.stock-adjust { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.handout-form { display: flex; gap: 14px; flex-wrap: wrap; }
.hchk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.hchk input { accent-color: var(--gold); width: 18px; height: 18px; }
.handout-student { font-size: 18px; font-weight: 700; letter-spacing: .2px; }
.handout-student a { text-decoration: none; }
.handout-student a:hover { text-decoration: underline; }
tr.row-muted { opacity: .6; }
