:root {
  --bg: #f4f6f3; --panel: #ffffff; --panel-2: #eef2ec; --fg: #14201a; --muted: #5d6b63; --line: #dde3dc;
  --ok: #1f8a4c; --bad: #c8372d; --warn: #b7791f; --accent: #2a7a4b; --accent-fg: #ffffff;
  --pitch: rgba(42, 122, 75, .08);
  --radius: 12px; --gap: 14px; --pad: 16px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --num: "SF Pro Display", -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1a14; --panel: #16241c; --panel-2: #1c2e24; --fg: #e8efe9; --muted: #93a49a; --line: #263a2f;
    --ok: #4cc47e; --bad: #f06a5f; --warn: #e3a948; --accent: #4cc47e; --accent-fg: #0f1a14; --pitch: rgba(76, 196, 126, .07); }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 15px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.app { max-width: 1180px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 8px) max(16px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 24px) max(16px, env(safe-area-inset-left)); display: grid; gap: var(--gap); }

/* logo: piłka/boisko */
.logo { width: 56px; height: 56px; border-radius: 16px; background: var(--accent); position: relative; margin: 0 auto 8px; }
.logo::before { content: ""; position: absolute; inset: 22% ; border: 2px solid var(--accent-fg); border-radius: 50%; }
.logo::after { content: ""; position: absolute; left: 50%; top: 12%; bottom: 12%; width: 2px; background: var(--accent-fg); transform: translateX(-50%); }
.logo.sm { width: 26px; height: 26px; border-radius: 8px; margin: 0; display: inline-block; vertical-align: middle; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-box { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px 22px; text-align: center; display: grid; gap: 12px; }
.login-box h1 { margin: 0; font-size: 26px; }
.login-box p { margin: 0; }
.login-box .f { text-align: left; }

/* topbar */
.topbar { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.topbar-actions { position: relative; display: flex; gap: 6px; }
.menu { position: absolute; right: 0; top: 110%; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 4px; display: grid; min-width: 160px; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.menu button { background: none; border: 0; text-align: left; padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.menu button:hover { background: var(--panel-2); }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--pad); min-width: 0; }
.card h2 { margin: 0; font-size: 17px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.note { margin: 4px 0 12px; font-size: 13px; color: var(--muted); }
.grid2 { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.head-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.badge { font-size: 12px; background: var(--warn); color: var(--panel); border-radius: 999px; padding: 0 8px; font-weight: 600; }
.badge:empty { display: none; }

/* form */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 12px; max-width: 100%; }
.segb { border: 0; background: var(--panel-2); color: var(--muted); padding: 9px 14px; cursor: pointer; }
.segb[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 10px 12px; }
.f { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.f.wide { grid-column: 1 / -1; }
.f input, .f select { font-size: 16px; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; min-height: 44px; width: 100%; -webkit-appearance: none; appearance: none; }
.f select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 14px; }
.btn-primary { background: var(--accent); color: var(--accent-fg); border: 0; border-radius: 10px; padding: 12px 20px; font-weight: 650; cursor: pointer; min-height: 44px; }
.btn-primary:disabled { opacity: .55; cursor: progress; }
.btn-ghost { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; cursor: pointer; color: var(--fg); text-decoration: none; font-size: 14px; display: inline-block; }
.btn-mini { background: none; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; font-size: 13px; color: var(--muted); cursor: pointer; }
.btn-mini:hover { color: var(--fg); }
.status { font-size: 13px; color: var(--muted); }
.status.err { color: var(--bad); }

/* kupony w grze */
.slip-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 420px; overflow: auto; }
.slip { border: 1px dashed var(--line); border-left: 4px solid var(--warn); border-radius: 10px; padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; background: var(--bg); }
.slip .s-main { font-weight: 600; }
.slip .s-sub { font-size: 12.5px; color: var(--muted); }
.slip .s-amt { font-family: var(--num); font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.slip .s-act { grid-column: 2; justify-self: end; }
.empty { color: var(--muted); font-size: 14px; margin: 8px 0 0; }

/* tablica */
.board { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px var(--pad); position: relative; overflow: hidden; }
.board::before { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 50%, transparent 0 62px, var(--pitch) 63px 65px, transparent 66px),
              linear-gradient(90deg, transparent calc(50% - 1px), var(--pitch) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)); }
.board > * { position: relative; }
.kicker { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.years { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.year { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-variant-numeric: tabular-nums; }
.year[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.take { margin: 0 0 14px; max-width: 62rem; }
.take b { font-weight: 650; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); gap: 8px; }
.tile { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.tile .lbl { font-size: 12px; color: var(--muted); display: block; }
.tile .num { font-family: var(--num); font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; display: block; margin: 2px 0; letter-spacing: -.01em; }
.tile .sub { font-size: 12px; color: var(--muted); }
.neg { color: var(--bad); } .pos { color: var(--ok); }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; position: sticky; top: 50px; z-index: 4; background: var(--bg); }
.tabs::-webkit-scrollbar { display: none; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; color: var(--muted); cursor: pointer; white-space: nowrap; margin-bottom: -1px; }
.tab[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); font-weight: 650; }
.page { display: grid; gap: var(--gap); }

/* tables */
.scroll { overflow: auto; max-height: 34rem; -webkit-overflow-scrolling: touch; }
.scroll.tall { max-height: 44rem; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.tbl th { position: sticky; top: 0; background: var(--panel); text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; z-index: 1; }
.tbl td { padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl .r { text-align: right; }
.tbl td.wrap { white-space: normal; min-width: 10rem; }
.tbl tr.sel td { background: var(--panel-2); }
.tbl tr.total td { font-weight: 650; border-top: 2px solid var(--line); }
.league tbody { counter-reset: poz; }
.league tbody td:first-child::before { counter-increment: poz; content: counter(poz) "."; display: inline-block; width: 1.7em; color: var(--muted); }
.form { display: inline-flex; gap: 3px; }
.form span { display: inline-grid; place-items: center; width: 1.45em; height: 1.45em; border-radius: 4px; font-size: 11px; font-weight: 700; color: #fff; }
.form .W { background: var(--ok); } .form .P { background: var(--bad); } .form .R { background: var(--muted); }
.dot { display: inline-block; width: .8em; height: .8em; border-radius: 3px; margin-right: .45em; vertical-align: -0.05em; border: 1px solid var(--line); }
.share { display: inline-block; height: .5em; border-radius: 999px; background: var(--accent); opacity: .55; vertical-align: middle; margin-right: .4em; }
.pill { display: inline-block; padding: 0 .55em; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); }
.pill.otwarty { color: var(--warn); border-color: currentColor; }
.pill.przegrany { color: var(--bad); border-color: currentColor; }
.pill.rozliczony { color: var(--ok); border-color: currentColor; }
.flag { color: var(--warn); font-weight: 600; }

/* charts */
.chart { position: relative; min-height: 280px; }
.chart.short { min-height: 240px; }
.chart svg { display: block; }
.chart text { fill: var(--muted); font-size: 11.5px; font-family: var(--font); }
.tip { position: fixed; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: 8px 10px; font-size: 12.5px; z-index: 20; white-space: nowrap; }
.tip b { display: block; color: var(--muted); font-weight: 500; }
.foot { text-align: center; font-size: 12px; padding-top: 8px; }
