/* Paneli i Klubit — header band in pitch green, amber accent, one working panel per section.
   Every text colour pair below is chosen for at least 4.5:1 contrast in both themes. */
:root {
  --bg: #f3f5f1;
  --surface: #ffffff;
  --surface-2: #eef1ec;
  --fg: #17211b;
  --muted: #56645b;
  --line: #d3dbd1;
  --pitch: #9a4310;
  --pitch-2: #7f360c;
  --pitch-ink: #ffffff;
  --primary: #9a4310;
  --primary-hover: #7f360c;
  --accent: #e0a21b;
  --accent-ink: #1b1404;
  --accent-soft: #fbf0d3;
  --ok: #1d6e40;
  --ok-soft: #e1f2e7;
  --warn: #8a5a12;
  --warn-soft: #fbf0d9;
  --bad: #a8321f;
  --bad-soft: #fbe3df;
  --focus: #1a5fb4;
  --paper: #ffffff;
  --paper-ink: #17211b;
  --paper-muted: #4f5c54;
  --paper-line: #d6dcd5;
  --shadow: 0 1px 2px rgba(15, 30, 20, .06), 0 4px 14px rgba(15, 30, 20, .06);

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --radius: 10px;
  --radius-sm: 8px;
  --tap: 44px;

  --f-display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --f-body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
/* Light is the default for everyone, whatever the device setting. Dark only when chosen in the account menu. */
:root[data-theme="dark"] {
  --bg: #0f1512; --surface: #18211c; --surface-2: #1f2a24; --fg: #e7ede8; --muted: #a3b2a8; --line: #2f3c34;
  --pitch: #5e2a0b; --pitch-2: #482008; --pitch-ink: #eef6f0; --accent: #f0b73a; --accent-ink: #1b1404; --accent-soft: #3a2f14;
  --ok: #6fd39a; --ok-soft: #173323; --warn: #f0b45a; --warn-soft: #382a12; --bad: #ff8a7a; --bad-soft: #3d1c18;
  --primary: #b4561d; --primary-hover: #9a4918;
  --focus: #8ab8ff; --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--f-body); font-size: 16px; line-height: 1.5; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
header.band :focus-visible { outline-color: var(--accent); }

.skip { position: absolute; left: var(--s4); top: -100px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: var(--s3) var(--s4); border-radius: var(--radius-sm); font-weight: 700; text-decoration: none; }
.skip:focus { top: var(--s3); }

.wrap { max-width: 1200px; margin: 0 auto; padding-left: max(var(--s4), env(safe-area-inset-left, 0px)); padding-right: max(var(--s4), env(safe-area-inset-right, 0px)); }

/* ---------- Header ---------- */
header.band { background: var(--pitch); color: var(--pitch-ink); position: sticky; top: 0; z-index: 30; padding-top: env(safe-area-inset-top, 0px); }
/* A light goal net on the right of the band, fading out towards the club name; works on every club colour. */
header.band {
  background:
    linear-gradient(90deg, var(--pitch) 30%, transparent 85%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Cpath d='M0 0L22 22M22 0L0 22' stroke='%23fff' stroke-opacity='.16' stroke-width='1.2' fill='none'/%3E%3C/svg%3E") repeat,
    var(--pitch);
}
.top { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding-block: var(--s3); }
.brand { display: flex; align-items: center; gap: var(--s3); color: inherit; text-decoration: none; min-width: 0; }
.brand-mark { width: 40px; height: 40px; flex: none; }
.brand small { display: block; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; opacity: .85; }
.brand b { display: block; font-family: var(--f-display); font-weight: 700; font-size: clamp(22px, 4vw, 32px); line-height: 1; text-transform: uppercase; letter-spacing: .01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-r { display: flex; align-items: center; gap: var(--s3); }

.clubpick select { min-height: var(--tap); width: auto; max-width: 220px; background: rgba(255, 255, 255, .12); color: var(--pitch-ink); border: 1px solid rgba(255, 255, 255, .35); font-weight: 600; }
.clubpick select option { color: var(--fg); background: var(--surface); }
/* Language picker next to the name: short codes only (SQ, TUR, BOS…). */
.langpick select { min-height: var(--tap); width: auto; padding-left: 10px; padding-right: 28px; background-color: rgba(255, 255, 255, .12); color: var(--pitch-ink);
  border: 1px solid rgba(255, 255, 255, .35); font-weight: 700; letter-spacing: .03em; }
.langpick select option { color: var(--fg); background: var(--surface); }
.langpick[hidden] { display: none; }
/* On phones the centre picker gets its own full-width row under the club name. */
@media (max-width: 680px) {
  .top { flex-wrap: wrap; row-gap: var(--s2); }
  .top-r { display: contents; }
  .clubpick { order: 10; flex: 1 1 100%; }
  .clubpick select { max-width: none; width: 100%; }
}
.usermenu { position: relative; }
.userbtn { display: flex; align-items: center; gap: var(--s2); min-height: var(--tap); padding: var(--s1) var(--s3) var(--s1) var(--s1); border-radius: 999px; border: 1px solid rgba(255, 255, 255, .28); background: rgba(255, 255, 255, .1); color: inherit; font: inherit; cursor: pointer; text-align: left; }
.userbtn b { display: block; font-size: 14px; line-height: 1.15; }
.userbtn small { display: block; font-size: 12px; opacity: .85; line-height: 1.15; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.userpanel { position: absolute; right: 0; top: calc(100% + var(--s2)); background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 230px; padding: var(--s2); display: flex; flex-direction: column; z-index: 40; }
.userpanel button { min-height: var(--tap); text-align: left; padding: var(--s2) var(--s3); background: none; border: 0; border-radius: var(--radius-sm); font: inherit; color: inherit; cursor: pointer; }
.userpanel button:hover { background: var(--surface-2); }
.userpanel :focus-visible { outline-color: var(--focus); }

.menubtn { display: none; align-items: center; gap: var(--s2); min-height: var(--tap); min-width: var(--tap); padding: 0 var(--s3); border-radius: var(--radius-sm); border: 1px solid rgba(255, 255, 255, .28); background: rgba(255, 255, 255, .1); color: inherit; font-family: var(--f-display); font-size: 17px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; cursor: pointer; }
.burger { display: inline-flex; flex-direction: column; gap: 4px; }
.burger i { display: block; width: 20px; height: 2px; background: currentColor; border-radius: 2px; transition: transform .2s, opacity .2s; }
.menubtn[aria-expanded="true"] .burger i:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menubtn[aria-expanded="true"] .burger i:nth-child(2) { opacity: 0; }
.menubtn[aria-expanded="true"] .burger i:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* All sections fit on one line without scrolling: the text shrinks a little on narrower screens,
   and if a centre ever has more sections than fit, they wrap to a second line instead of scrolling. */
.nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: flex-start; column-gap: 2px; }
.nav a { display: flex; align-items: center; min-height: var(--tap); padding: var(--s2) clamp(3px, .42vw, 8px) var(--s3); color: var(--pitch-ink); text-decoration: none; font-family: var(--f-display); font-weight: 600; font-size: clamp(13px, 1.25vw, 15px); letter-spacing: .01em; text-transform: uppercase; white-space: nowrap; border-bottom: 3px solid transparent; opacity: .88; }
.nav a:hover { opacity: 1; }
.nav a[aria-current="page"] { opacity: 1; border-bottom-color: var(--accent); }
/* A small basketball marks the section you are in. */
.nav a[aria-current="page"]::before {
  content: ""; width: 13px; height: 13px; margin-right: 6px; flex: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-14 -14 28 28'%3E%3Ccircle r='13' fill='%23f08a24'/%3E%3Cpath d='M0-13V13M-13 0H13M-9.2-9.2C-3-5-3 5-9.2 9.2M9.2-9.2C3-5 3 5 9.2 9.2' fill='none' stroke='%2317211b' stroke-width='1.8'/%3E%3Ccircle r='13' fill='none' stroke='%23fff' stroke-width='1.4'/%3E%3C/svg%3E") center / contain no-repeat;
}

@media (max-width: 1000px) {
  .menubtn { display: inline-flex; }
  .nav { display: none; padding-bottom: var(--s3); }
  .nav.open { display: block; }
  .nav ul { flex-direction: column; flex-wrap: nowrap; background: var(--pitch-2); border-radius: var(--radius); }
  .nav li + li a { border-top: 1px solid rgba(255, 255, 255, .1); }
  .nav a { border-bottom: 0; border-left: 4px solid transparent; padding: var(--s3) var(--s4); font-size: 18px; }
  .nav a[aria-current="page"] { border-left-color: var(--accent); background: rgba(255, 255, 255, .08); }
}
.brand { flex: 1 1 auto; }
.top-r { flex: none; }
.menubtn, .userbtn { flex: none; height: var(--tap); }
@media (max-width: 560px) {
  .top { gap: var(--s2); }
  .userbtn > span:last-child { display: none; }
  .userbtn { padding: var(--s1); }
  .brand small { display: none; }
  .brand-mark { width: 32px; height: 32px; }
  .brand b { font-size: 21px; }
  /* Only the icon shows; the section name stays available to screen readers. */
  .menubtn { padding: 0; width: var(--tap); justify-content: center; }
  .menubtn #menuLbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* ---------- Page ---------- */
main { outline: none; }
main .wrap { padding-block: var(--s5) var(--s6); display: flex; flex-direction: column; gap: var(--s5); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.page-head p { margin: var(--s1) 0 0; color: var(--muted); max-width: 70ch; }
h1, h2, h3 { font-family: var(--f-display); text-transform: uppercase; letter-spacing: .02em; margin: 0; text-wrap: balance; line-height: 1.1; }
h1 { font-size: clamp(26px, 4vw, 34px); font-weight: 700; outline: none; }
h2 { font-size: 21px; font-weight: 600; letter-spacing: .03em; }
.actions { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }

.notice { display: flex; gap: var(--s3); align-items: center; justify-content: space-between; flex-wrap: wrap; padding: var(--s3) var(--s4); border-radius: var(--radius-sm); border: 1px solid var(--accent); background: var(--accent-soft); }
.notice.bad { border-color: var(--bad); background: var(--bad-soft); }

/* ---------- Filters ---------- */
.filters { display: flex; gap: var(--s3); flex-wrap: wrap; align-items: flex-end; padding: var(--s4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.filters .field { flex: 1 1 170px; min-width: 0; }
.filters .field.grow { flex: 2 1 240px; }
/* Report type and month stay side by side, even on a phone. */
.filters .field.pair { flex: 1 1 130px; }
.field { display: flex; flex-direction: column; gap: var(--s1); }
.field > label, .field > .flabel { font-size: 14px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 13px; color: var(--muted); }
.field .err { font-size: 14px; color: var(--bad); font-weight: 600; margin: 0; }
.req { color: var(--bad); }

input, select, textarea {
  font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--muted); border-radius: var(--radius-sm);
  padding: var(--s2) var(--s3); min-height: var(--tap); min-width: 0; width: 100%;
}
textarea { min-height: 80px; resize: vertical; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--bad); border-width: 2px; }
input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--pitch); flex: none; }
.check { display: flex; align-items: flex-start; gap: var(--s3); min-height: var(--tap); padding-top: var(--s2); font-weight: 500; color: var(--fg); cursor: pointer; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: var(--tap); padding: var(--s2) var(--s4); border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--fg); font: inherit; font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-ink, #fff); border-color: var(--primary); }
input[type="color"] { padding: 4px; min-height: var(--tap); cursor: pointer; }
.presets { display: flex; flex-wrap: wrap; gap: var(--s2); }
/* Date fields: text dd-mm-yyyy + calendar button; the browser's own date input stays hidden behind it. */
.date-in { position: relative; display: flex; }
.date-in input[data-date] { flex: 1; min-width: 0; padding-right: 44px; font-variant-numeric: tabular-nums; }
.date-cal { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; display: grid; place-items: center; border: 0; background: none; color: var(--muted); border-radius: var(--radius-sm); cursor: pointer; }
.date-cal:hover { color: var(--fg); background: var(--surface-2); }
.date-cal:disabled { opacity: .4; cursor: default; }
.date-native { position: absolute; right: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; }
button.chip { font: inherit; font-size: inherit; cursor: pointer; }
.logo-row { display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap; }
.logo-prev { width: 88px; height: 88px; border: 1px dashed var(--line); border-radius: var(--radius-sm); display: grid; place-items: center; background: var(--surface-2); text-align: center; font-size: 12px; padding: 4px; }
.logo-prev img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-field .lbl { font-weight: 600; }
.club-logo-sm { width: 22px; height: 22px; object-fit: contain; vertical-align: middle; margin-right: var(--s2); }
/* Team logo: larger than the standard ball so it reads well; a soft shadow keeps it visible on any band colour. */
.brand-mark.brand-logo { width: 64px; height: 64px; margin-block: -8px; object-fit: contain; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .3)); }
@media (max-width: 1000px) { .brand-mark.brand-logo { width: 56px; height: 56px; margin-block: -6px; } }
@media (max-width: 560px) { .brand-mark.brand-logo { width: 46px; height: 46px; margin-block: -4px; } }
.swatch { display: inline-flex; gap: 2px; vertical-align: middle; margin-right: var(--s1); }
.swatch i { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, .2); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-danger { color: var(--bad); border-color: var(--bad); background: var(--surface); }
.btn-danger.solid { background: var(--bad); color: #fff; }
.btn-sm { padding: var(--s1) var(--s3); font-size: 14px; }
.btn .ico { width: 18px; height: 18px; flex: none; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after { content: ""; position: absolute; width: 18px; height: 18px; border: 2px solid currentColor; border-color: var(--muted) transparent var(--muted) transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s3); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4); display: flex; flex-direction: column; gap: var(--s1); min-width: 0; }
.kpi .lbl { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.kpi .val { font-family: var(--f-display); font-weight: 700; font-size: 32px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 14px; color: var(--muted); }
.kpi.main { background: var(--pitch); color: var(--pitch-ink); border-color: var(--pitch); }
.kpi.main .lbl, .kpi.main .sub { color: var(--pitch-ink); opacity: .9; }
.pos { color: var(--ok); }
.neg { color: var(--bad); }
.warn-t { color: var(--warn); }

/* ---------- Panels & tables ---------- */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: var(--s4); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4); min-width: 0; display: flex; flex-direction: column; gap: var(--s3); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.panel-head p { margin: 0; color: var(--muted); font-size: 14px; }
.tbl { overflow-x: auto; position: relative; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
caption { text-align: left; font-size: 14px; color: var(--muted); padding-bottom: var(--s2); }
th { text-align: left; font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
.name { font-weight: 600; }
.muted { color: var(--muted); }
.rowlink { background: none; border: 0; padding: 0; font: inherit; color: inherit; font-weight: 600; text-align: left; cursor: pointer; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; min-height: 32px; }
.rowlink:hover { text-decoration-color: currentColor; }

.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 999px; white-space: nowrap; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.chip.ex { background: var(--accent-soft); color: var(--warn); border-color: transparent; }
.chips { display: flex; gap: var(--s1); flex-wrap: wrap; }

.empty { padding: var(--s6) var(--s4); text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: var(--s3); align-items: center; }
.empty strong { color: var(--fg); font-size: 17px; }
.loading { padding: var(--s6); display: flex; justify-content: center; align-items: center; gap: var(--s3); color: var(--muted); }
.loading::before { content: ""; width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--pitch); animation: spin .8s linear infinite; }
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.pager { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); flex-wrap: wrap; padding-top: var(--s2); }

/* attendance status buttons */
.seg { display: inline-flex; border: 1px solid var(--muted); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { font: inherit; font-size: 14px; font-weight: 600; border: 0; background: var(--surface); color: var(--fg); min-height: var(--tap); padding: 0 var(--s3); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--muted); }
.seg button[aria-pressed="true"].p { background: var(--ok); color: var(--surface); }
.seg button[aria-pressed="true"].v { background: var(--warn); color: var(--surface); }
.seg button[aria-pressed="true"].m { background: var(--bad); color: var(--surface); }
.seg button:disabled { cursor: not-allowed; opacity: .7; }
input[type="time"] { width: 130px; }

/* chart */
.bars { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--s3); align-items: end; height: 170px; padding-top: var(--s2); }
.bcol { display: flex; flex-direction: column; align-items: center; gap: var(--s2); height: 100%; justify-content: flex-end; min-width: 0; }
.bpair { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.b { width: 42%; max-width: 24px; border-radius: 4px 4px 0 0; min-height: 2px; }
.b.in { background: var(--pitch); }
.b.out { background: var(--accent); }
:root[data-theme="dark"] .b.in { background: var(--ok); }
.bcol span { font-size: 13px; color: var(--muted); }
.legend { display: flex; gap: var(--s4); font-size: 14px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- Dialog ---------- */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--surface); color: var(--fg); width: min(600px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(10, 20, 14, .55); }
dialog form { display: flex; flex-direction: column; gap: var(--s4); padding: var(--s5); }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s3); }
.dlg-head p { margin: var(--s1) 0 0; font-size: 14px; color: var(--muted); }
.iconbtn { min-width: var(--tap); min-height: var(--tap); border: 0; background: none; color: var(--muted); border-radius: var(--radius-sm); cursor: pointer; display: grid; place-items: center; font-size: 26px; line-height: 1; }
.iconbtn:hover { background: var(--surface-2); color: var(--fg); }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
.fields .full { grid-column: 1 / -1; }
.dlg-actions { display: flex; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: var(--s4); }
.form-err { margin: 0; padding: var(--s3); border-radius: var(--radius-sm); background: var(--bad-soft); color: var(--bad); font-weight: 600; }

/* signature */
.sig { grid-column: 1 / -1; display: flex; flex-direction: column; gap: var(--s2); padding: var(--s3); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.sig legend { font-weight: 600; font-size: 14px; color: var(--muted); padding: 0 var(--s1); }
.sigpad { width: 100%; max-width: 480px; aspect-ratio: 3 / 1; background: var(--paper); border: 2px dashed var(--paper-muted); border-radius: var(--radius-sm); touch-action: none; cursor: crosshair; display: block; }
.sigrow { display: flex; gap: var(--s2); align-items: center; justify-content: space-between; flex-wrap: wrap; max-width: 480px; }
.sigrow small { color: var(--muted); font-size: 13px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--s5) + env(safe-area-inset-bottom, 0px)); z-index: 60; display: flex; flex-direction: column; gap: var(--s2); align-items: center; width: min(520px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; background: var(--fg); color: var(--bg); padding: var(--s3) var(--s4); border-radius: var(--radius-sm); font-weight: 600; box-shadow: var(--shadow); border-left: 6px solid var(--ok); width: 100%; }
.toast.err { border-left-color: var(--bad); }
.import-errors { margin: 0 0 var(--s3); padding-left: 1.2em; max-height: 40vh; overflow-y: auto; }
.import-errors li { margin-bottom: var(--s2); overflow-wrap: anywhere; }

/* ---------- Report sheet ---------- */
.paper { background: var(--paper); color: var(--paper-ink); border: 1px solid var(--line); border-radius: 6px; padding: clamp(var(--s4), 4vw, var(--s6)); display: flex; flex-direction: column; gap: var(--s4); max-width: 900px; width: 100%; box-shadow: var(--shadow); }
.paper .rhead { display: flex; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; border-bottom: 2px solid var(--paper-ink); padding-bottom: var(--s3); }
.paper .rclub { font-family: var(--f-display); font-weight: 700; font-size: 26px; text-transform: uppercase; line-height: 1; }
.paper .rtitle { font-family: var(--f-display); font-size: 22px; font-weight: 600; margin-top: var(--s1); }
.paper .meta { font-size: 14px; color: var(--paper-muted); margin-top: var(--s2); max-width: 56ch; }
.paper .qr { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; color: var(--paper-muted); }
.paper .qr img { width: 124px; height: 124px; image-rendering: pixelated; }
.paper th { color: var(--paper-muted); border-color: var(--paper-line); }
.paper td { border-color: var(--paper-line); }
.paper tfoot td { font-weight: 700; border-top: 2px solid var(--paper-ink); }
.paper h3 { font-size: 18px; letter-spacing: .04em; margin-bottom: var(--s2); }
.paper input, .paper select { background: var(--paper); color: var(--paper-ink); border-color: var(--paper-muted); }
.paper .check { color: var(--paper-ink); }
.paper .sig { background: var(--paper); border-color: var(--paper-line); }
.paper .sig legend, .paper .sigrow small { color: var(--paper-muted); }
.rinfo { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s1) var(--s5); font-size: 15px; }
.rinfo span { color: var(--paper-muted); }
.rsum { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s3); }
.rsum div { border: 1px solid var(--paper-line); border-radius: 6px; padding: var(--s2) var(--s3); }
.rsum span { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--paper-muted); }
.rsum b { font-family: var(--f-display); font-size: 23px; font-variant-numeric: tabular-nums; }
.signs { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--s5); }
.sign { display: flex; flex-direction: column; gap: var(--s2); }
.sign .simg { height: 84px; display: flex; align-items: flex-end; }
.sign .simg img { max-height: 84px; max-width: 100%; }
.sign .line { border-top: 1px solid var(--paper-ink); padding-top: var(--s1); font-size: 14px; }
.sign .line span { color: var(--paper-muted); }

/* ---------- Phones: tables become cards ---------- */
@media (max-width: 680px) {
  main .wrap { padding-block: var(--s4) var(--s6); gap: var(--s4); }
  .fields { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; gap: var(--s2); }
  .kpi { padding: var(--s3); }
  .kpi .val { font-size: 25px; }
  .kpi.main { grid-column: 1 / -1; }
  .panel, .filters { padding: var(--s3); }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1 1 auto; }
  dialog form { padding: var(--s4); }
  .tbl.cards table, .tbl.cards tbody, .tbl.cards tr, .tbl.cards td { display: block; width: 100%; }
  .tbl.cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tbl.cards tr { border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s2) var(--s3); margin-bottom: var(--s3); background: var(--surface); }
  .tbl.cards td { border: 0; padding: 6px 0; display: flex; justify-content: space-between; align-items: center; gap: var(--s3); text-align: right; }
  .tbl.cards td::before { content: attr(data-label); font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; text-align: left; flex: none; max-width: 45%; }
  .tbl.cards td[data-label=""]::before { display: none; }
  .tbl.cards td[data-label=""] { justify-content: flex-end; }
  .tbl.cards td:first-child { font-size: 17px; }
  .paper .tbl table { font-size: 14px; }
  .signs { grid-template-columns: 1fr; }
}

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