/* =========================================================================
   Sobotnia: app.css
   Direction A, "Ink and paper", with a Polish flag accent.
   One file, no build step, no inline styles (strict CSP). Mobile-first.
   Sections:
     1. Tokens          5. Navigation          9. Tables and lists
     2. Base            6. Page furniture     10. Feedback (alerts, empty, confirm)
     3. Typography      7. Buttons            11. Register (phone)
     4. App shell       8. Forms              12. Feature screens, utilities, print
   Breakpoints (custom properties can't be used in media queries, so they are
   written out literally): 600px small tablet, 900px sidebar, 1200px wide.
   ========================================================================= */

/* 1. Tokens ---------------------------------------------------------------- */

:root {
  /* Neutrals */
  --paper: #faf7f2;          /* page background */
  --surface: #ffffff;        /* cards, inputs, rows */
  --surface-sunk: #f2eee6;   /* table headers, quiet panels */
  --ink: #1f2433;            /* body text: 14.5:1 on paper, 15.5:1 on white */
  --ink-muted: #585d6b;      /* secondary text: 6.2:1 on paper, 6.6:1 on white */
  --line: #ddd6ca;           /* decorative dividers only (not for controls) */
  --line-strong: #858072;    /* input and control borders: 3.9:1 on white */

  /* Brand */
  --navy: #1f3a5f;           /* primary: white on navy 11.5:1 */
  --navy-dark: #152a46;      /* hover/pressed */
  --navy-tint: #e9eef5;
  --flag-white: #ffffff;     /* decoration only */
  --flag-red: #dc143c;       /* decoration only: never text, never meaning */

  /* Meaning. Always paired with an icon and a word. */
  --present: #1e6b3a;        --present-tint: #e5f1e9;   /* = paid, success */
  --absent: #a3271f;         --absent-tint: #f8e6e3;    /* = in arrears, error, danger */
  --late: #8a5300;           --late-tint: #f8eddb;      /* = part-paid, warning */
  --info: var(--navy);       --info-tint: var(--navy-tint);

  --focus: #1f3a5f;          /* 3px outline, offset 2px, with a white halo */
  --focus-on-dark: #ffffff;

  /* Type */
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --font-head: "Iowan Old Style", Charter, "Bitstream Charter", Georgia, "Noto Serif", "DejaVu Serif", serif;
  --font-mono: ui-monospace, "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;

  --fs-xs: 0.8125rem;   /* 13px: meta only, never the only place a fact appears */
  --fs-sm: 0.875rem;    /* 14px */
  --fs-md: 1rem;        /* 16px: body, inputs (keeps iOS from zooming) */
  --fs-lg: 1.125rem;    /* 18px */
  --fs-xl: 1.375rem;    /* 22px: h2 */
  --fs-2xl: 1.75rem;    /* 28px: h1 on phone */
  --fs-3xl: 2.125rem;   /* 34px: h1 on desktop, big numbers */

  --lh-tight: 1.2;
  --lh-body: 1.5;
  --fw-regular: 400;
  --fw-semibold: 600;
  --fw-bold: 700;

  /* Space: 4px steps */
  --sp-1: 0.25rem;  --sp-2: 0.5rem;  --sp-3: 0.75rem; --sp-4: 1rem;
  --sp-5: 1.5rem;   --sp-6: 2rem;    --sp-7: 3rem;    --sp-8: 4rem;
  --gutter: 1rem;   /* page side padding on phones */

  /* Sizes */
  --tap: 2.75rem;        /* 44px minimum target */
  --tap-lg: 3.5rem;      /* 56px register buttons */
  --control-h: 3rem;     /* 48px inputs and buttons */
  --measure: 66ch;       /* readable line length */
  --content-max: 72rem;
  --sidebar-w: 15rem;
  --topbar-h: 3.5rem;
  --tabbar-h: 4rem;
  --stripe-h: 6px;       /* the biało-czerwona band: 3px + 3px */

  /* Shape */
  --r-sm: 6px;  --r-md: 8px;  --r-lg: 12px;  --r-pill: 999px;
  --border: 1px solid var(--line);

  /* Elevation: used sparingly; most separation is borders */
  --sh-1: 0 1px 2px rgb(31 36 51 / 0.08);
  --sh-2: 0 4px 14px rgb(31 36 51 / 0.12);
  --sh-3: 0 12px 32px rgb(31 36 51 / 0.18);

  --z-tabbar: 20;  --z-topbar: 30;  --z-menu: 40;
}

/* 2. Base ------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: var(--lh-body);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }
svg.icon { width: 1.25rem; height: 1.25rem; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.icon--sm { width: 1rem; height: 1rem; }
svg.icon--lg { width: 1.5rem; height: 1.5rem; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

a { color: var(--navy); text-decoration-thickness: 1px; text-underline-offset: 0.15em; }
a:hover { color: var(--navy-dark); text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--surface);
}

::selection { background: var(--navy-tint); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: var(--sp-2); top: -10rem; z-index: 100;
  background: var(--surface); color: var(--navy); padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-sm); box-shadow: var(--sh-2); font-weight: var(--fw-bold);
}
.skip-link:focus { top: var(--sp-2); }

/* 3. Typography ------------------------------------------------------------ */

h1, h2, h3 { font-family: var(--font-head); font-weight: var(--fw-semibold); line-height: var(--lh-tight); margin: 0 0 var(--sp-3); text-wrap: balance; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); font-weight: var(--fw-bold); margin: 0 0 var(--sp-2); }
@media (min-width: 900px) { h1 { font-size: var(--fs-3xl); } }

p { margin: 0 0 var(--sp-4); max-width: var(--measure); }
small, .text-sm { font-size: var(--fs-sm); }
.text-muted { color: var(--ink-muted); }
.lead { font-size: var(--fs-lg); color: var(--ink-muted); }
.num, .money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.money--neg { color: var(--absent); }
.code { font-family: var(--font-mono); letter-spacing: 0.05em; }
.overline { font-size: var(--fs-xs); font-weight: var(--fw-bold); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-muted); margin: 0 0 var(--sp-1); }
.draft-note { font-size: var(--fs-xs); color: var(--late); font-weight: var(--fw-semibold); }
hr { border: 0; border-top: var(--border); margin: var(--sp-5) 0; }

/* 4. App shell ------------------------------------------------------------- */
/* Phone: topbar, content, fixed bottom tab bar.
   900px+: topbar, sidebar + content. */

.topbar {
  position: sticky; top: 0; z-index: var(--z-topbar);
  background: var(--navy); color: #fff;
}
/* The flag band: white over red, under the navy bar. */
.topbar::after, .flag-band {
  content: "";
  display: block;
  height: var(--stripe-h);
  background: linear-gradient(var(--flag-white) 0 50%, var(--flag-red) 50% 100%);
}
.topbar__inner {
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: var(--topbar-h);
  padding: 0 var(--sp-2) 0 var(--gutter);
  max-width: none;
}
.topbar :focus-visible { outline-color: var(--focus-on-dark); box-shadow: none; }

.wordmark {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  min-height: var(--tap);
  color: #fff; text-decoration: none;
  font-family: var(--font-head); font-size: var(--fs-lg); font-weight: var(--fw-bold); letter-spacing: 0.01em;
}
.wordmark:hover { color: #fff; }
/* Small flag mark: CSS only, no image */
.wordmark__flag {
  width: 1.25rem; height: 0.875rem; flex: none;
  border-radius: 2px;
  background: linear-gradient(var(--flag-white) 0 50%, var(--flag-red) 50% 100%);
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.5);
}
.wordmark__text { display: none; }
.topbar__school {
  flex: 1; min-width: 0;
  font-size: var(--fs-sm); color: #dfe6f0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (min-width: 600px) {
  .wordmark__text { display: inline; }
  .topbar__school { padding-left: var(--sp-3); border-left: 1px solid rgb(255 255 255 / 0.3); }
}

/* Account menu: <details>, so it works without JavaScript */
.menu { position: relative; }
.menu > summary {
  list-style: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: var(--sp-2);
  min-height: var(--tap); min-width: var(--tap); padding: 0 var(--sp-3);
  border-radius: var(--r-sm); color: #fff;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover { background: rgb(255 255 255 / 0.1); }
.menu__name { display: none; font-size: var(--fs-sm); font-weight: var(--fw-semibold); }
@media (min-width: 600px) { .menu__name { display: inline; } }
.menu__panel {
  position: absolute; right: 0; top: calc(100% + var(--sp-2)); z-index: var(--z-menu);
  width: min(18rem, calc(100vw - 2 * var(--sp-2)));
  background: var(--surface); color: var(--ink);
  border: var(--border); border-radius: var(--r-md); box-shadow: var(--sh-3);
  padding: var(--sp-2);
}
.menu__who { padding: var(--sp-2) var(--sp-3) var(--sp-3); border-bottom: var(--border); margin-bottom: var(--sp-2); }
.menu__who strong { display: block; }
.menu__who span { font-size: var(--fs-sm); color: var(--ink-muted); }
.menu__panel ul { list-style: none; margin: 0; padding: 0; }
.menu__panel a, .menu__panel button {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%;
  min-height: var(--tap); padding: 0 var(--sp-3);
  border: 0; border-radius: var(--r-sm); background: none;
  font: inherit; color: var(--ink); text-decoration: none; text-align: left; cursor: pointer;
}
.menu__panel a:hover, .menu__panel button:hover { background: var(--surface-sunk); }
.menu__panel form { margin: 0; }
.menu__panel :focus-visible { outline-color: var(--focus); }

.shell { display: block; }
.main {
  padding: var(--sp-5) var(--gutter) calc(var(--tabbar-h) + var(--sp-7));
  max-width: var(--content-max);
}
.main--narrow { max-width: 40rem; margin-inline: auto; }
@media (min-width: 900px) {
  :root { --gutter: 2rem; }
  .shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: calc(100vh - var(--topbar-h) - var(--stripe-h)); }
  .main { padding: var(--sp-6) var(--gutter) var(--sp-8); }
}
/* Focused task pages (register, login) hide the tab bar and sidebar */
.is-focused .main { padding-bottom: var(--sp-7); }
.is-focused .shell { display: block; }

/* 5. Navigation ------------------------------------------------------------ */

.sidenav { display: none; }
@media (min-width: 900px) {
  .sidenav {
    display: block;
    background: var(--surface); border-right: var(--border);
    padding: var(--sp-4) var(--sp-3);
  }
  .is-focused .sidenav { display: none; }
}
.sidenav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.sidenav a {
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: var(--tap); padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  color: var(--ink); text-decoration: none; font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
}
.sidenav a:hover { background: var(--surface-sunk); }
.sidenav a[aria-current="page"] { background: var(--navy-tint); color: var(--navy); box-shadow: inset 4px 0 0 var(--navy); }
.sidenav .icon { color: var(--ink-muted); }
.sidenav a[aria-current="page"] .icon { color: var(--navy); }
.sidenav__section { font-size: var(--fs-xs); font-weight: var(--fw-bold); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-muted); padding: var(--sp-4) var(--sp-3) var(--sp-1); }

/* Phone tab bar: at most 4 destinations + More */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-tabbar);
  background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: 0 -2px 8px rgb(31 36 51 / 0.06);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
@media (min-width: 900px) { .tabbar { display: none; } }
.is-focused .tabbar { display: none; }
.tabbar > ul { list-style: none; margin: 0; padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.tabbar a, .tabbar summary {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--tabbar-h); padding: var(--sp-1) 2px;
  color: var(--ink-muted); text-decoration: none; cursor: pointer; list-style: none;
  font-size: 0.75rem; font-weight: var(--fw-semibold); line-height: 1.1; text-align: center;
  overflow-wrap: anywhere; hyphens: auto;
}
.tabbar summary::-webkit-details-marker { display: none; }
.tabbar a[aria-current="page"] { color: var(--navy); box-shadow: inset 0 3px 0 var(--navy); }
.tabbar .menu__panel { bottom: calc(100% + var(--sp-2)); top: auto; right: var(--sp-2); }
.tabbar details { position: static; }

/* Back link for sub-pages */
.backlink {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  min-height: var(--tap); margin: calc(-1 * var(--sp-3)) 0 var(--sp-2) calc(-1 * var(--sp-2)); padding: 0 var(--sp-2);
  font-weight: var(--fw-semibold); text-decoration: none;
}
.backlink:hover { text-decoration: underline; }

/* 6. Page furniture -------------------------------------------------------- */

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--sp-3) var(--sp-5); margin-bottom: var(--sp-5); }
.page-head > div:first-child { min-width: 0; flex: 1 1 18rem; }
.page-head h1 { margin-bottom: var(--sp-1); }
.page-head p { margin: 0; color: var(--ink-muted); }
.page-head__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

.section { margin-top: var(--sp-6); }
.section__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--sp-2) var(--sp-4); margin-bottom: var(--sp-3); }
.section__head h2 { margin: 0; }

.panel {
  background: var(--surface);
  border: var(--border); border-radius: var(--r-md);
  padding: var(--sp-4);
}
@media (min-width: 600px) { .panel { padding: var(--sp-5); } }
.panel--sunk { background: var(--surface-sunk); border-color: transparent; }
.panel > :last-child { margin-bottom: 0; }

.grid { display: grid; gap: var(--sp-4); }
@media (min-width: 900px) {
  .grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--main-side { grid-template-columns: minmax(0, 2fr) minmax(16rem, 1fr); align-items: start; }
}

/* Key figures */
.stats { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); }
.stat { background: var(--surface); border: var(--border); border-radius: var(--r-md); padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-1); }
.stat__label { font-size: var(--fs-sm); color: var(--ink-muted); font-weight: var(--fw-semibold); }
.stat__value { font-family: var(--font-head); font-size: var(--fs-3xl); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat__note { font-size: var(--fs-sm); color: var(--ink-muted); display: flex; align-items: center; gap: var(--sp-1); flex-wrap: wrap; }
.stat a { margin-top: auto; padding-top: var(--sp-2); font-weight: var(--fw-semibold); }

.meter { height: 8px; background: var(--surface-sunk); border-radius: var(--r-pill); overflow: hidden; margin: var(--sp-1) 0; }
.meter > span { display: block; height: 100%; background: var(--navy); border-radius: inherit; }
/* Widths are classes, not inline styles. Add steps as needed. */
.w-10 { width: 10%; } .w-20 { width: 20%; } .w-25 { width: 25%; } .w-30 { width: 30%; } .w-40 { width: 40%; }
.w-50 { width: 50%; } .w-60 { width: 60%; } .w-70 { width: 70%; } .w-75 { width: 75%; } .w-80 { width: 80%; }
.w-90 { width: 90%; } .w-100 { width: 100%; }

/* Description lists for key/value facts */
.kv { display: grid; grid-template-columns: minmax(7rem, max-content) 1fr; gap: var(--sp-2) var(--sp-4); margin: 0; }
.kv dt { color: var(--ink-muted); font-size: var(--fs-sm); padding-top: 0.1em; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 359px) { .kv { grid-template-columns: 1fr; gap: 0; } .kv dd { margin-bottom: var(--sp-2); } }

/* Status badges: icon + word, never colour alone */
.badge {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: 0.125rem var(--sp-2) 0.125rem 0.375rem;
  border-radius: var(--r-pill); border: 1px solid currentColor;
  font-size: var(--fs-sm); font-weight: var(--fw-semibold); line-height: 1.3;
  white-space: nowrap;
  color: var(--ink-muted); background: var(--surface);
}
.badge .icon { width: 0.875rem; height: 0.875rem; stroke-width: 2.6; }
.badge--present, .badge--paid, .badge--success { color: var(--present); background: var(--present-tint); }
.badge--absent, .badge--arrears, .badge--danger { color: var(--absent); background: var(--absent-tint); }
.badge--late, .badge--part-paid, .badge--warning { color: var(--late); background: var(--late-tint); }
.badge--info { color: var(--navy); background: var(--navy-tint); }
.badge--neutral { color: var(--ink-muted); background: var(--surface-sunk); border-color: var(--line-strong); }

/* 7. Buttons --------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--control-h); padding: var(--sp-2) var(--sp-5);
  border: 2px solid transparent; border-radius: var(--r-sm);
  font: inherit; font-weight: var(--fw-bold); line-height: 1.2; text-align: center; text-decoration: none;
  cursor: pointer;
}
.btn--primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn--primary:hover { background: var(--navy-dark); border-color: var(--navy-dark); color: #fff; }
.btn--secondary { background: var(--surface); border-color: var(--navy); color: var(--navy); }
.btn--secondary:hover { background: var(--navy-tint); color: var(--navy-dark); }
.btn--danger { background: var(--absent); border-color: var(--absent); color: #fff; }
.btn--danger:hover { background: #82201a; border-color: #82201a; color: #fff; }
.btn--quiet { background: transparent; color: var(--navy); text-decoration: underline; text-underline-offset: 0.15em; padding-inline: var(--sp-3); }
.btn--quiet:hover { background: var(--navy-tint); }
.btn--sm { min-height: var(--tap); padding: var(--sp-1) var(--sp-4); font-size: var(--fs-sm); }
.btn--block { display: flex; width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; margin-top: var(--sp-5); }
/* On phones, primary actions stack full width with the main action first */
@media (max-width: 599px) {
  .btn-row--stack { flex-direction: column; align-items: stretch; }
  .btn-row--stack .btn { width: 100%; }
}

/* 8. Forms ----------------------------------------------------------------- */

form { margin: 0; }
.field { margin: 0 0 var(--sp-5); max-width: 36rem; }
.field--wide { max-width: none; }
.label, .field > label, legend.label {
  display: block; font-weight: var(--fw-bold); margin-bottom: var(--sp-1); padding: 0;
}
.label .optional { font-weight: var(--fw-regular); color: var(--ink-muted); }
.hint { display: block; color: var(--ink-muted); font-size: var(--fs-sm); margin: 0 0 var(--sp-2); }
.error-msg {
  display: flex; align-items: flex-start; gap: var(--sp-1);
  color: var(--absent); font-weight: var(--fw-bold); margin: 0 0 var(--sp-2);
}
.error-msg .icon { margin-top: 0.15em; width: 1.1rem; height: 1.1rem; }

.input, .select, .textarea {
  display: block; width: 100%;
  min-height: var(--control-h); padding: var(--sp-2) var(--sp-3);
  font: inherit; font-size: var(--fs-md); color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line-strong); border-radius: var(--r-sm);
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { border-color: var(--focus); }
.textarea { min-height: 10rem; resize: vertical; line-height: var(--lh-body); }
.textarea--tall { min-height: 16rem; }
.select { appearance: none; padding-right: 2.5rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 1.2rem) 55%, calc(100% - 0.8rem) 55%;
  background-size: 0.4rem 0.4rem; background-repeat: no-repeat; }
.input--code { max-width: 9ch; font-family: var(--font-mono); font-size: var(--fs-xl); letter-spacing: 0.15em; text-align: center; }
.input--short { max-width: 12rem; }
.input--money { max-width: 10rem; }
.field--error .input, .field--error .select, .field--error .textarea { border: 2px solid var(--absent); }
.field--error { border-left: 4px solid var(--absent); padding-left: var(--sp-3); }

.input-prefix { display: flex; max-width: 12rem; }
.input-prefix > span {
  display: inline-flex; align-items: center; padding: 0 var(--sp-3);
  background: var(--surface-sunk); border: 1.5px solid var(--line-strong); border-right: 0;
  border-radius: var(--r-sm) 0 0 var(--r-sm); font-weight: var(--fw-bold);
}
.input-prefix > .input { border-radius: 0 var(--r-sm) var(--r-sm) 0; }

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.choices { display: grid; gap: var(--sp-1); }
.choice { display: flex; align-items: flex-start; gap: var(--sp-3); min-height: var(--tap); padding: var(--sp-2) 0; cursor: pointer; }
.choice input { width: 1.5rem; height: 1.5rem; margin: 0.05rem 0 0; flex: none; accent-color: var(--navy); }
.choice span small { display: block; color: var(--ink-muted); }

.error-summary {
  border: 3px solid var(--absent); border-radius: var(--r-md);
  background: var(--surface); padding: var(--sp-4) var(--sp-4) var(--sp-3);
  margin-bottom: var(--sp-5);
}
.error-summary h2 { font-family: var(--font-body); font-size: var(--fs-lg); font-weight: var(--fw-bold); display: flex; gap: var(--sp-2); align-items: center; color: var(--absent); }
.error-summary ul { margin: 0; padding-left: 1.25rem; }
.error-summary a { color: var(--absent); font-weight: var(--fw-bold); }

/* 9. Tables and lists ------------------------------------------------------ */

.table-wrap { background: var(--surface); border: var(--border); border-radius: var(--r-md); overflow: hidden; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
.table caption { text-align: left; padding: var(--sp-3) var(--sp-4); font-weight: var(--fw-bold); }
.table th, .table td { padding: var(--sp-3) var(--sp-4); text-align: left; vertical-align: middle; border-bottom: var(--border); }
.table thead th { background: var(--surface-sunk); font-size: var(--fs-sm); color: var(--ink-muted); font-weight: var(--fw-bold); white-space: nowrap; }
.table tbody tr:last-child > * { border-bottom: 0; }
.table tbody tr:hover { background: #fcfbf8; }
.table .is-num { text-align: right; }
.table td a.rowlink { font-weight: var(--fw-bold); }
.table tfoot td, .table tfoot th { border-top: 2px solid var(--line-strong); font-weight: var(--fw-bold); }

/* Stacked table: under 600px each row becomes a card. Every <td> carries
   data-label="..." (translated in the template); CSS reads it with attr(). */
@media (max-width: 599px) {
  .table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack td, .table--stack th[scope="row"] { display: block; }
  .table--stack tr { padding: var(--sp-3) var(--sp-4); border-bottom: var(--border); }
  .table--stack tbody tr:last-child { border-bottom: 0; }
  .table--stack td, .table--stack th[scope="row"] { border: 0; padding: var(--sp-1) 0; display: grid; grid-template-columns: 8rem 1fr; gap: var(--sp-3); }
  .table--stack td::before { content: attr(data-label); color: var(--ink-muted); font-size: var(--fs-sm); font-weight: var(--fw-semibold); }
  .table--stack th[scope="row"], .table--stack td.is-title { display: block; font-size: var(--fs-lg); padding-bottom: var(--sp-2); }
  .table--stack td.is-title::before { content: none; }
  .table--stack .is-num { text-align: left; }
  .table--stack tfoot { display: block; }
  .table--stack tfoot tr { display: grid; grid-template-columns: 1fr auto; background: var(--surface-sunk); }
  .table--stack tfoot td, .table--stack tfoot th { display: block; border: 0; padding: 0; }
  .table--stack tfoot td::before { content: none; }
}

/* List rows: whole row is the link, 56px minimum */
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: var(--border); border-radius: var(--r-md); overflow: hidden; }
.list > li + li { border-top: var(--border); }
.list-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--sp-1) var(--sp-3);
  min-height: var(--tap-lg); padding: var(--sp-3) var(--sp-4);
  color: inherit; text-decoration: none;
}
a.list-row:hover { background: #fcfbf8; color: inherit; }
a.list-row:hover .list-row__title { text-decoration: underline; }
.list-row__title { font-weight: var(--fw-bold); color: var(--navy); overflow-wrap: anywhere; }
div.list-row .list-row__title { color: var(--ink); }
.list-row__meta { grid-column: 1; font-size: var(--fs-sm); color: var(--ink-muted); }
.list-row__end { grid-column: 2; grid-row: 1 / span 2; display: flex; align-items: center; gap: var(--sp-2); }
.list-row__end .icon { color: var(--ink-muted); }

/* Toolbar above lists: search and filters (a GET form, works without JS) */
.toolbar { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: flex-end; margin-bottom: var(--sp-4); }
.toolbar .field { margin: 0; flex: 1 1 14rem; }
.toolbar .field--filter { flex: 0 1 14rem; }

.pager { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); margin-top: var(--sp-4); font-size: var(--fs-sm); color: var(--ink-muted); }

/* 10. Feedback ------------------------------------------------------------- */

.alert {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--sp-1) var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid; border-left-width: 6px; border-radius: var(--r-sm);
  margin-bottom: var(--sp-4);
  color: var(--ink);
}
.alert > .icon { grid-row: 1 / span 2; margin-top: 0.15em; }
.alert__title { font-weight: var(--fw-bold); margin: 0; }
.alert p { margin: 0; }
.alert p + p { margin-top: var(--sp-2); }
.alert--info { background: var(--info-tint); border-color: var(--navy); }
.alert--info > .icon { color: var(--navy); }
.alert--success { background: var(--present-tint); border-color: var(--present); }
.alert--success > .icon { color: var(--present); }
.alert--warning { background: var(--late-tint); border-color: var(--late); }
.alert--warning > .icon { color: var(--late); }
.alert--error { background: var(--absent-tint); border-color: var(--absent); }
.alert--error > .icon { color: var(--absent); }

.empty {
  text-align: center; padding: var(--sp-7) var(--sp-4);
  background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--r-md);
}
.empty__icon { display: inline-grid; place-items: center; width: 3.5rem; height: 3.5rem; border-radius: 50%; background: var(--navy-tint); color: var(--navy); margin-bottom: var(--sp-3); }
.empty__icon .icon { width: 1.75rem; height: 1.75rem; }
.empty h2 { font-size: var(--fs-lg); margin-bottom: var(--sp-2); }
.empty p { margin: 0 auto var(--sp-4); color: var(--ink-muted); }

/* Confirm step for destructive actions: a real page (works without JS) */
.confirm {
  background: var(--surface); border: var(--border); border-top: 6px solid var(--absent);
  border-radius: var(--r-md); padding: var(--sp-5) var(--sp-4); max-width: 36rem;
}
@media (min-width: 600px) { .confirm { padding: var(--sp-6); } }
.confirm h1, .confirm h2 { display: flex; gap: var(--sp-3); align-items: flex-start; }
.confirm h1 .icon, .confirm h2 .icon { color: var(--absent); width: 1.75rem; height: 1.75rem; margin-top: 0.1em; }
.confirm ul { padding-left: 1.25rem; margin: 0 0 var(--sp-4); }
.confirm li { margin-bottom: var(--sp-1); }

/* 11. Register (phone) ----------------------------------------------------- */

.reg-head { margin: calc(-1 * var(--sp-5)) calc(-1 * var(--gutter)) 0; padding: var(--sp-2) var(--gutter) var(--sp-3); background: var(--paper); border-bottom: var(--border); position: sticky; top: calc(var(--topbar-h) + var(--stripe-h)); z-index: 5; }
.reg-head h1 { font-size: var(--fs-xl); margin: 0; }
.reg-head__meta { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0 var(--sp-3); font-size: var(--fs-sm); color: var(--ink-muted); margin: var(--sp-1) 0 var(--sp-2); }
.reg-head__meta strong { color: var(--ink); }
.reg-head .meter { margin: 0; height: 6px; }

.reg { list-style: none; margin: var(--sp-3) 0 0; padding: 0; display: grid; gap: var(--sp-2); }
.reg-row {
  background: var(--surface);
  border: 1px solid var(--line); border-left: 6px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--sp-1) var(--sp-3) var(--sp-3);
}
.reg-row.is-present { border-left-color: var(--present); }
.reg-row.is-absent { border-left-color: var(--absent); }
.reg-row.is-late { border-left-color: var(--late); }
.reg-row__head { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); min-height: var(--tap); }
.reg-row__name { font-weight: var(--fw-semibold); font-size: var(--fs-lg); line-height: 1.25; min-width: 0; overflow-wrap: anywhere; }
.reg-row__name b { font-weight: var(--fw-bold); }

/* Save state: a fixed slot so nothing moves when it changes */
.save {
  display: inline-flex; align-items: center; justify-content: flex-end; gap: var(--sp-1);
  min-width: 7.5rem; min-height: var(--tap); flex: none;
  font-size: var(--fs-sm); color: var(--ink-muted); white-space: nowrap;
}
.save--saved { color: var(--present); }
.save--failed { color: var(--absent); font-weight: var(--fw-bold); }
.save__retry {
  min-height: var(--tap); padding: 0 var(--sp-2); margin-right: calc(-1 * var(--sp-2));
  border: 0; background: none; cursor: pointer;
  font: inherit; font-weight: var(--fw-bold); color: var(--absent); text-decoration: underline;
}
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-2); }
.seg__btn {
  min-height: var(--tap-lg); padding: var(--sp-1) 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font: inherit; font-size: 0.9375rem; font-weight: var(--fw-semibold); line-height: 1.15;
  color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--line-strong); border-radius: var(--r-sm);
  cursor: pointer; touch-action: manipulation;
}
:lang(pl) .seg__btn { font-size: var(--fs-sm); }
.seg__btn .icon { color: var(--ink-muted); stroke-width: 2.6; }
.seg__btn[aria-pressed="true"] { color: #fff; }
.seg__btn[aria-pressed="true"] .icon { color: #fff; }
.seg__btn--present[aria-pressed="true"] { background: var(--present); border-color: var(--present); }
.seg__btn--absent[aria-pressed="true"] { background: var(--absent); border-color: var(--absent); }
.seg__btn--late[aria-pressed="true"] { background: var(--late); border-color: var(--late); }

.reg-foot {
  position: sticky; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--sp-2);
  margin: var(--sp-4) calc(-1 * var(--gutter)) 0; padding: var(--sp-3) var(--gutter) calc(var(--sp-3) + env(safe-area-inset-bottom, 0));
  background: var(--surface); border-top: var(--border); box-shadow: 0 -2px 8px rgb(31 36 51 / 0.06);
}
.reg-foot .btn { padding-inline: var(--sp-4); }
.is-focused .main.main--register { padding-bottom: 0; max-width: 34rem; margin-inline: auto; }

/* 12. Feature screens ------------------------------------------------------ */

/* Auth (login, two-step) */
.auth { min-height: 100vh; display: flex; flex-direction: column; }
.auth__brand { background: var(--navy); color: #fff; padding: var(--sp-4) var(--gutter); }
.auth__brand .wordmark__text { display: inline; }
.auth__body { flex: 1; padding: var(--sp-6) var(--gutter) var(--sp-7); }
.auth__card { max-width: 28rem; margin: 0 auto; }
@media (min-width: 600px) {
  .auth__card { background: var(--surface); border: var(--border); border-radius: var(--r-lg); padding: var(--sp-6); box-shadow: var(--sh-1); }
}
.auth__card--wide { max-width: 36rem; }
.auth__foot { text-align: center; font-size: var(--fs-sm); color: var(--ink-muted); padding: var(--sp-4) var(--gutter) var(--sp-5); }
.lang-switch { display: flex; justify-content: center; gap: var(--sp-1); }
.lang-switch a, .lang-switch span { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--sp-3); }
.lang-switch [aria-current="true"] { font-weight: var(--fw-bold); color: var(--ink); }

.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; }
.steps > li { counter-increment: step; position: relative; padding: 0 0 var(--sp-5) 3rem; }
.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--navy); color: #fff; font-weight: var(--fw-bold);
}
.steps h2 { font-family: var(--font-body); font-size: var(--fs-lg); font-weight: var(--fw-bold); padding-top: 0.2rem; }
.qr { width: 11rem; height: 11rem; padding: var(--sp-2); background: #fff; border: var(--border); border-radius: var(--r-sm); }
.secret { display: inline-block; font-family: var(--font-mono); font-size: var(--fs-lg); letter-spacing: 0.08em; background: var(--surface-sunk); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); overflow-wrap: anywhere; }

/* Teacher's "today" card */
.today-card { background: var(--surface); border: var(--border); border-left: 6px solid var(--navy); border-radius: var(--r-md); padding: var(--sp-4); }
.today-card h2 { margin-bottom: var(--sp-1); }
.today-card .kv { margin: var(--sp-3) 0 var(--sp-4); }

/* Bank matching */
.match { display: grid; gap: var(--sp-3); }
@media (min-width: 900px) { .match { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: stretch; } }
.match__side { background: var(--surface); border: var(--border); border-radius: var(--r-md); padding: var(--sp-4); }
.match__side--bank { background: var(--surface-sunk); border-color: transparent; }
.match__side h2 { font-family: var(--font-body); font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-muted); font-weight: var(--fw-bold); margin-bottom: var(--sp-3); }
.match__amount { font-family: var(--font-head); font-size: var(--fs-3xl); line-height: 1.1; margin-bottom: var(--sp-3); font-variant-numeric: tabular-nums; }
.match__arrow { display: grid; place-items: center; color: var(--ink-muted); }
.match__arrow .icon { transform: rotate(90deg); width: 2rem; height: 2rem; }
@media (min-width: 900px) { .match__arrow .icon { transform: none; } }
.match__ref { font-family: var(--font-mono); font-size: var(--fs-sm); background: var(--surface); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); border: var(--border); overflow-wrap: anywhere; margin: 0; }
.match__why { margin: var(--sp-3) 0 0; padding: 0; list-style: none; display: grid; gap: var(--sp-1); font-size: var(--fs-sm); }
.match__why li { display: flex; gap: var(--sp-2); align-items: flex-start; }
.match__why .icon { color: var(--present); width: 1rem; height: 1rem; margin-top: 0.2em; }
.match__actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-4); }
@media (max-width: 599px) {
  .match__actions { flex-direction: column; }
  .match__actions .btn { width: 100%; }
}
.queue-pos { font-size: var(--fs-sm); color: var(--ink-muted); }

/* Two-language message composer */
.lang-pair { display: grid; gap: var(--sp-4); }
@media (min-width: 900px) { .lang-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.lang-col { background: var(--surface); border: var(--border); border-radius: var(--r-md); padding: var(--sp-4); }
.lang-col__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-3); padding-bottom: var(--sp-3); border-bottom: var(--border); }
.lang-col__head h2 { font-family: var(--font-body); font-size: var(--fs-lg); font-weight: var(--fw-bold); margin: 0; }
.lang-col .field { max-width: none; }
.lang-col .field:last-child { margin-bottom: 0; }
.lang-col.field--error { border: 2px solid var(--absent); padding-left: var(--sp-4); }

/* Family page: people */
.people { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); }
.person { background: var(--surface); border: var(--border); border-radius: var(--r-md); padding: var(--sp-4); }
.person h3 { font-family: var(--font-body); font-size: var(--fs-lg); font-weight: var(--fw-bold); margin: 0 0 var(--sp-1); }
.person .badges { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin-bottom: var(--sp-3); }

/* Mockup index and component sheet (not needed in the app) */
.swatch-grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr)); }
.swatch { background: var(--surface); border: var(--border); border-radius: var(--r-md); overflow: hidden; font-size: var(--fs-sm); }
.swatch__chip { height: 3.5rem; border-bottom: var(--border); }
.swatch__body { padding: var(--sp-2) var(--sp-3); }
.swatch__body code { font-size: var(--fs-xs); }
.chip-paper { background: var(--paper); } .chip-surface { background: var(--surface); } .chip-sunk { background: var(--surface-sunk); }
.chip-ink { background: var(--ink); } .chip-muted { background: var(--ink-muted); } .chip-line { background: var(--line); } .chip-line-strong { background: var(--line-strong); }
.chip-navy { background: var(--navy); } .chip-navy-tint { background: var(--navy-tint); } .chip-flag { background: linear-gradient(var(--flag-white) 0 50%, var(--flag-red) 50% 100%); }
.chip-present { background: var(--present); } .chip-absent { background: var(--absent); } .chip-late { background: var(--late); }
.chip-present-tint { background: var(--present-tint); } .chip-absent-tint { background: var(--absent-tint); } .chip-late-tint { background: var(--late-tint); }
.type-scale > * { margin: 0 0 var(--sp-2); }
.fs-xs { font-size: var(--fs-xs); } .fs-sm { font-size: var(--fs-sm); } .fs-md { font-size: var(--fs-md); } .fs-lg { font-size: var(--fs-lg); }
.fs-xl { font-size: var(--fs-xl); } .fs-2xl { font-size: var(--fs-2xl); } .fs-3xl { font-size: var(--fs-3xl); }
.serif { font-family: var(--font-head); }
.demo-row { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; margin-bottom: var(--sp-4); }
.demo-phone { max-width: 22.5rem; }
.space-chip { height: 1rem; background: var(--navy); border-radius: 2px; }
.sp-1w { width: var(--sp-1); } .sp-2w { width: var(--sp-2); } .sp-3w { width: var(--sp-3); } .sp-4w { width: var(--sp-4); }
.sp-5w { width: var(--sp-5); } .sp-6w { width: var(--sp-6); } .sp-7w { width: var(--sp-7); } .sp-8w { width: var(--sp-8); }
.radius-chip { width: 3rem; height: 3rem; background: var(--navy-tint); border: 2px solid var(--navy); }
.r-sm { border-radius: var(--r-sm); } .r-md { border-radius: var(--r-md); } .r-lg { border-radius: var(--r-lg); } .r-pill { border-radius: var(--r-pill); }
.shadow-chip { width: 6rem; height: 3rem; background: var(--surface); border-radius: var(--r-md); }
.sh-1 { box-shadow: var(--sh-1); } .sh-2 { box-shadow: var(--sh-2); } .sh-3 { box-shadow: var(--sh-3); }

/* Utilities (keep this list short) */
.stack > * + * { margin-top: var(--sp-4); }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; } .mt-4 { margin-top: var(--sp-4); } .mt-6 { margin-top: var(--sp-6); }
.flex-gap { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.nowrap { white-space: nowrap; }

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

@media print {
  .topbar, .sidenav, .tabbar, .skip-link, .page-head__actions, .btn, .reg-foot { display: none !important; }
  body { background: #fff; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  .panel, .table-wrap, .list { border-color: #999; }
  a { color: inherit; text-decoration: none; }
}
.tabbar--demo { position: static; box-shadow: none; border: var(--border); border-radius: var(--r-md); }
.qr rect { shape-rendering: crispEdges; }

/* Secondary links that stand alone get a full touch target */
.section__head a, .stat a, .panel > details > summary, details.panel > summary {
  display: inline-flex; align-items: center; min-height: var(--tap);
}
details.panel > summary { cursor: pointer; }
@media (max-width: 599px) {
  .table--stack td > * { justify-self: start; }
  .toolbar .field--filter { flex: 1 1 calc(50% - var(--sp-3)); min-width: 0; }
  .toolbar > .btn { flex: 1 1 100%; }
}
.input--code { max-width: 11ch; }
.person .kv { grid-template-columns: max-content minmax(0, 1fr); }
