/* ===== Układanka: aplikacja zespołu =====
   Kolorystyka jak strona www: błękit z logo #049fe4, grafit jak napis w logo, jasne tła. */
:root {
  --blue: #049fe4;
  --blue-d: #0380b8;
  --blue-dd: #035a82;
  --blue-l: #e8f6fd;
  --navy: #1c2630;
  --yellow: #ffc93c;

  --bg: #f4f9fc;
  --surface: #ffffff;
  --text: #26313c;
  --muted: #5d6b78;
  --line: #e3edf3;

  --ok-bg: #e5f6ec; --ok-ink: #1d6b40;
  --err-bg: #fdecec; --err-ink: #b3261e;
  --warn-bg: #fff6d6; --warn-ink: #7a5d00;

  --r: 18px;
  --shadow: 0 6px 24px rgba(4, 80, 120, .08);
  --shadow-s: 0 2px 8px rgba(4, 80, 120, .07);
  --font: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-h: "Baloo 2", "Nunito", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 var(--font);
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--blue-d); }
h1, h2, h3 { font-family: var(--font-h); color: var(--navy); line-height: 1.15; }
h1 { font-size: 1.8rem; margin: .2em 0 .5em; }
h2 { font-size: 1.2rem; margin: 0 0 .7em; }
code { background: var(--blue-l); padding: .1em .35em; border-radius: 6px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.center { text-align: center; }
.accent { color: var(--blue-d); }
.danger { color: var(--err-ink); }
.eyebrow { font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--blue-d); font-size: .78rem; margin: 0; }
[hidden] { display: none !important; }

/* ---------- Pasek górny ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px);
  border-bottom: 3px solid var(--blue); box-shadow: 0 2px 10px rgba(31, 42, 68, .05);
  padding-top: env(safe-area-inset-top);
}
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1180px; margin: 0 auto; padding: 8px 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--navy); text-decoration: none; min-width: 0; }
.brand-logo { width: 40px; height: 40px; flex: none; border-radius: 12px; object-fit: contain; background: #fff; }
.brand-logo.big { width: 150px; height: 150px; border-radius: 50%; box-shadow: var(--shadow); display: inline-block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-family: var(--font-h); font-weight: 800; font-size: 1.2rem; letter-spacing: .02em; }
.brand-sub { font-size: .8rem; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 2px; }
.icon-btn { position: relative; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: none; border: 0; color: var(--navy); cursor: pointer; text-decoration: none; }
.icon-btn:hover, .icon-btn.on { background: var(--blue-l); color: var(--blue-d); }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .badge { top: 3px; right: 3px; left: auto; }
.bell.on { color: var(--blue); }
.bell.on svg { fill: color-mix(in srgb, var(--blue) 22%, transparent); }

/* ---------- Układ ---------- */
.wrap { max-width: 760px; margin: 0 auto; padding: 20px 16px 48px; }
body.wide .wrap { max-width: 1180px; }
.wrap.narrow { max-width: 480px; }
.card { background: var(--surface); border-radius: var(--r); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-links { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 0; }
.h-inline { margin: 0; }
.span2 { grid-column: 1 / -1; }

/* ---------- Formularze ---------- */
.form { display: grid; gap: 14px; }
.form.grid2 { grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .form.grid2 { grid-template-columns: 1fr 1fr; }
  .form.grid2 > .btn { grid-column: 1 / -1; justify-self: start; }
}
.form.row { grid-template-columns: 1fr auto; margin-top: 10px; align-items: center; }
label { display: grid; gap: 6px; font-size: .9rem; font-weight: 700; color: var(--navy); }
label.check { display: flex; align-items: center; gap: 10px; font-weight: 600; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 2px solid var(--line); border-radius: 12px; padding: 10px 14px; min-height: 48px;
}
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--blue); flex: none; }
input[type=color] { padding: 3px; width: 48px; min-height: 42px; height: 42px; cursor: pointer; background: #fff; flex: none; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); background: #fff; }
textarea { resize: vertical; min-height: 120px; line-height: 1.45; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-size: .9rem; font-weight: 700; color: var(--navy); margin-bottom: 6px; padding: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 22px; border: 2px solid transparent; border-radius: 999px; cursor: pointer;
  background: var(--blue); color: #fff; font: inherit; font-weight: 800; text-decoration: none; white-space: nowrap;
  box-shadow: 0 6px 16px rgba(4, 159, 228, .28); transition: transform .15s, background .2s;
}
.btn:hover { background: var(--blue-d); }
.btn:active { transform: translateY(1px); }
.btn-wide { width: 100%; }
.btn-ghost { background: #fff; color: var(--blue-d); border-color: var(--blue); box-shadow: none; }
.btn-ghost:hover { background: var(--blue-l); }
.btn-danger { background: var(--err-bg); color: var(--err-ink); box-shadow: none; }
.btn-danger:hover { background: #f9d9d9; }
.btn-sm { min-height: 38px; padding: 0 16px; font-size: .9rem; }
.btn-sq { width: 46px; padding: 0; font-size: 1.5rem; line-height: 1; }
.btn .ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.linklike { background: none; border: 0; padding: 6px 8px; cursor: pointer; font: inherit; font-weight: 700; color: var(--blue-d); }
.inline { display: inline; margin: 0; }
.linklike.danger { color: var(--err-ink); }

.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 14px; font-size: .95rem; font-weight: 600; }
.flash-ok { background: var(--ok-bg); color: var(--ok-ink); }
.flash-err { background: var(--err-bg); color: var(--err-ink); }
.flash-warn { background: var(--warn-bg); color: var(--warn-ink); border: 1px dashed #e7c34a; }

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--blue-l); color: var(--blue-dd); font-size: .8rem; font-weight: 700; white-space: nowrap; }
.tag { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--blue-d); }
.tag-off { color: var(--err-ink); }
.tag-new { color: #1d8a4f; }
.role { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 800; white-space: nowrap; }
.role-master { background: var(--navy); color: #fff; }
.role-admin { background: var(--blue); color: #fff; }
.role-user { background: var(--blue-l); color: var(--blue-dd); }
.badge {
  position: absolute; top: 2px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: #e5487d; color: #fff; font-size: .68rem; font-weight: 800; line-height: 18px; text-align: center;
}
.badge-inline { display: inline-block; min-width: 20px; padding: 1px 7px; margin-left: 4px; border-radius: 999px; background: #e5487d; color: #fff; font-size: .78rem; font-weight: 800; vertical-align: middle; text-align: center; }

/* ---------- Logowanie ---------- */
body.auth { background: linear-gradient(160deg, var(--blue-l) 0%, #fbfdff 60%) fixed; }
.login { max-width: 420px; margin: 2vh auto 0; }
.login-hero { text-align: center; margin-bottom: 18px; }
.login-hero h1 { margin: 14px 0 2px; font-size: 1.7rem; }
.login-hero p { margin: 0; }

/* ---------- Start ---------- */
.notice { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--navy); border-left: 5px solid #e5487d; flex-wrap: wrap; }
.notice strong { flex: 1 1 auto; }
.admin-link-arrow { color: var(--muted); font-size: 1.5rem; flex: none; }
.today-card { border-top: 5px solid var(--blue); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.tile { display: grid; gap: 4px; padding: 16px; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); border-top: 5px solid var(--c, var(--blue)); color: var(--text); text-decoration: none; transition: transform .15s; }
.tile:hover { transform: translateY(-3px); }
.tile-head { display: flex; align-items: center; gap: 10px; }
.tile-head strong { font-family: var(--font-h); font-size: 1.1rem; color: var(--navy); }
.tile-ico { width: 34px; height: 34px; padding: 6px; border-radius: 10px; flex: none; color: var(--c, var(--blue)); background: color-mix(in srgb, var(--c, var(--blue)) 15%, white); fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.mini-post { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); color: var(--text); text-decoration: none; }
.mini-post strong { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-post span { flex: none; }
.mini-post.important strong { color: var(--err-ink); }

/* ---------- Ogłoszenia ---------- */
.compose summary { list-style: none; cursor: pointer; font-weight: 800; color: var(--navy); display: flex; align-items: center; gap: 10px; }
.compose summary::-webkit-details-marker { display: none; }
.compose[open] summary { margin-bottom: 14px; }
.plus { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--blue); color: #fff; font-size: 1.25rem; line-height: 1; }
.sub-compose { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.feed { display: grid; }
.post h2 { font-size: 1.2rem; margin: 2px 0 8px; }
.post-meta { display: flex; gap: 10px; flex-wrap: wrap; }
.post-meta:empty { display: none; }
.post-body { overflow-wrap: anywhere; }
.post-photo { display: block; margin: 12px 0 2px; border-radius: 14px; overflow: hidden; }
.post-photo img { display: block; width: 100%; height: auto; max-height: 460px; object-fit: cover; }
.post-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.post-actions { display: flex; gap: 6px; }
.post.important { border-left: 5px solid #e5487d; }
.post.pinned { border-top: 5px solid var(--yellow); }

/* ---------- Wiadomości ---------- */
.conv-list { display: grid; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.conv { display: grid; gap: 2px; padding: 14px 18px; border-top: 1px solid var(--line); text-decoration: none; color: var(--text); }
.conv:first-child { border-top: 0; }
.conv:hover { background: var(--blue-l); }
.conv-top { display: flex; justify-content: space-between; gap: 10px; }
.conv-top strong { color: var(--navy); }
.conv-prev { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.conv-prev .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv.unread strong { font-weight: 800; }
.conv.unread .conv-prev .muted { color: var(--text); font-weight: 700; }

.chat-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.chat-head .back { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-s); font-size: 1.6rem; line-height: 1; text-decoration: none; color: var(--blue-d); flex: none; }
.chat-head strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-h); font-size: 1.2rem; color: var(--navy); }
.chat { display: grid; gap: 8px; margin-bottom: 150px; }
.bubble { max-width: 82%; padding: 8px 13px; border-radius: 18px; box-shadow: var(--shadow-s); font-size: .96rem; }
.bubble-text { overflow-wrap: anywhere; }
.bubble img { max-width: 100%; border-radius: 12px; display: block; margin-bottom: 4px; }
.bubble-time { display: block; font-size: .68rem; color: var(--muted); margin-top: 3px; }
.bubble.mine { margin-left: auto; background: var(--blue); color: #fff; border-bottom-right-radius: 5px; }
.bubble.mine .bubble-time { color: rgba(255, 255, 255, .8); }
.bubble.mine a { color: #fff; }
.bubble.theirs { background: var(--surface); border-bottom-left-radius: 5px; }
.chat-compose {
  position: fixed; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 15;
  display: flex; align-items: flex-end; gap: 8px; max-width: 760px; margin: 0 auto;
  padding: 8px 12px; background: color-mix(in srgb, var(--surface) 95%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
}
.chat-compose textarea { flex: 1; min-height: 44px; max-height: 120px; border-radius: 22px; padding: 10px 16px; resize: none; }
.chat-compose .attach { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border: 2px solid var(--line); border-radius: 50%; cursor: pointer; color: var(--muted); background: var(--bg); }
.chat-compose .attach svg, .chat-compose .send svg { width: 22px; height: 22px; }
.chat-compose .send { width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 50%; flex: none; }

/* ---------- Panel ---------- */
.jump { display: flex; gap: 8px; flex-wrap: wrap; margin: -4px 0 16px; }
.jump a { padding: 7px 14px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow-s); font-weight: 700; font-size: .9rem; text-decoration: none; color: var(--navy); }
.jump a:hover { background: var(--blue-l); color: var(--blue-d); }
.users { display: grid; gap: 8px; }
.user { border: 2px solid var(--line); border-radius: 14px; background: var(--bg); }
.user.off { opacity: .6; }
.user summary { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; list-style: none; }
.user summary::-webkit-details-marker { display: none; }
.user-name { font-weight: 800; color: var(--navy); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-body { padding: 0 14px 14px; display: grid; gap: 8px; }
.user-body form, .user-body p { margin: 0; }
.user.req { padding: 12px 14px; display: grid; gap: 6px; }
.user.req p { margin: 0; }
.req-head { display: flex; align-items: center; gap: 10px; }
.req-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sms-card { border: 2px solid var(--blue); }
.sms-card .btn { margin-top: 6px; }
.dict { display: grid; gap: 8px; }
.dict-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px; border-radius: 14px; background: var(--bg); }
.dict-row input[name=name] { flex: 1 1 200px; min-height: 42px; }
.dict-row select { flex: 0 1 200px; min-height: 42px; }
.dict-row.off { opacity: .6; }
.dict-row.add { border: 2px dashed var(--line); background: #fff; }
.dict-use { min-width: 80px; }
.policy h2 { font-size: 1.05rem; margin: 18px 0 6px; }
.policy h2:first-child { margin-top: 0; }
.policy ul { margin: 0 0 6px; padding-left: 20px; }
.policy p { margin: 6px 0; }
.info { border-left: 5px solid var(--blue); }

/* ---------- Grafik: nagłówek i filtry ---------- */
.plan-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.plan-title h1 { margin: 0; font-size: clamp(1.4rem, 3.4vw, 2rem); }
.plan-title p { margin: 0; }
.plan-nav { display: flex; gap: 6px; }
.plan-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.seg { display: inline-flex; background: var(--surface); border-radius: 999px; padding: 4px; box-shadow: var(--shadow-s); }
.seg a { padding: 8px 16px; border-radius: 999px; text-decoration: none; font-weight: 800; color: var(--navy); font-size: .92rem; }
.seg a.on { background: var(--blue); color: #fff; }
.plan-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; flex: 1 1 320px; }
.plan-filters select { width: auto; flex: 1 1 160px; min-height: 42px; padding: 6px 12px; background: #fff; }
.chip { padding: 8px 14px; border-radius: 999px; background: #fff; border: 2px solid var(--line); min-height: 42px; cursor: pointer; white-space: nowrap; }
.plan-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.legend { list-style: none; display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; padding: 0; }
.legend a { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; background: color-mix(in srgb, var(--c) 14%, white); color: var(--navy); font-size: .82rem; font-weight: 700; text-decoration: none; border: 2px solid transparent; }
.legend a::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.legend a.on { border-color: var(--c); }
.empty { padding: 32px 20px; }

.only-narrow { display: none; }
@media (max-width: 759px) {
  .only-wide { display: none; }
  .only-narrow { display: block; }
  .hide-sm { display: none; }
  .plan-actions { width: 100%; }
  .plan-actions .btn { flex: 1; }
}

/* ---------- Lista zajęć (telefon, Start) ---------- */
.agenda { display: grid; gap: 10px; }
.agenda.compact { gap: 6px; }
.ag-day { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 12px; display: grid; gap: 6px; }
.ag-day.today { outline: 3px solid var(--blue); }
.ag-day-h { font-family: var(--font-h); font-weight: 800; font-size: 1.1rem; color: var(--navy); text-decoration: none; padding: 0 4px; }
.ag-empty { margin: 0 4px; }
.ag-item { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--c) 12%, white); border-left: 5px solid var(--c); color: var(--text); text-decoration: none; }
a.ag-item:hover { background: color-mix(in srgb, var(--c) 20%, white); }
.ag-item.past { opacity: .55; }
.ag-item.now { box-shadow: 0 0 0 2px var(--c); }
.ag-time { display: grid; font-weight: 800; color: var(--navy); min-width: 48px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.ag-time small { font-weight: 600; color: var(--muted); }
.ag-date { min-width: 78px; }
.ag-body { display: grid; min-width: 0; line-height: 1.3; }
.ag-body strong { color: var(--navy); }
.ag-body .muted { overflow: hidden; text-overflow: ellipsis; }

/* ---------- Siatka godzinowa (dzień, tydzień) ---------- */
.card-flush:has(.tgrid) { overflow-x: auto; }
.tgrid { --ppm: 1.1px; --tw: 54px; min-width: calc(var(--tw) + var(--cols) * 104px); }
.tg-head, .tg-body { display: grid; grid-template-columns: var(--tw) repeat(var(--cols), minmax(104px, 1fr)); }
.tg-head { border-bottom: 2px solid var(--line); background: #fff; position: sticky; top: 0; z-index: 2; }
.tg-col-h { display: grid; justify-items: center; padding: 10px 4px 8px; text-decoration: none; color: var(--navy); border-left: 1px solid var(--line); line-height: 1.2; text-align: center; }
a.tg-col-h:hover { background: var(--blue-l); }
.tg-h1 { font-family: var(--font-h); font-weight: 800; font-size: 1rem; text-transform: capitalize; }
.tg-h2 { font-size: .8rem; color: var(--muted); font-weight: 700; }
.tg-col-h.today { background: var(--blue); color: #fff; }
.tg-col-h.today .tg-h2 { color: rgba(255, 255, 255, .85); }
.tg-body { height: calc(var(--hours) * 60 * var(--ppm)); position: relative;
  background-image: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px calc(60 * var(--ppm))); }
.tg-times { display: grid; grid-auto-rows: calc(60 * var(--ppm)); font-size: .75rem; color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.tg-times span { padding: 2px 6px 0 0; text-align: right; }
.tg-col { position: relative; border-left: 1px solid var(--line); }
.tg-col.today { background: color-mix(in srgb, var(--blue) 5%, transparent); }
.tg-now { position: absolute; left: 0; right: 0; top: calc(var(--s) * var(--ppm)); height: 2px; background: #e5487d; z-index: 3; }
.tg-now::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: #e5487d; }
.lb {
  position: absolute; z-index: 1;
  top: calc(var(--s) * var(--ppm) + 1px); height: calc(var(--len) * var(--ppm) - 2px);
  left: calc(var(--lane) * 100% / var(--lanes) + 2px); width: calc(100% / var(--lanes) - 4px);
  display: flex; flex-direction: column; gap: 0; overflow: hidden;
  padding: 4px 6px; border-radius: 8px; border-left: 4px solid var(--c);
  background: color-mix(in srgb, var(--c) 16%, white); color: var(--navy); text-decoration: none;
  font-size: .76rem; line-height: 1.25; transition: box-shadow .15s;
}
a.lb:hover { z-index: 4; box-shadow: 0 4px 14px rgba(4, 80, 120, .22); background: color-mix(in srgb, var(--c) 24%, white); }
.lb > span, .lb > strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-subj { font-weight: 800; font-size: .8rem; }
.lb-time { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.lb-room { color: var(--muted); }
.lb-short { flex-direction: row; gap: 6px; align-items: center; padding-top: 1px; padding-bottom: 1px; }
.lb-short .lb-who, .lb-short .lb-room { display: none; }

/* ---------- Miesiąc ---------- */
.m-head, .m-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.m-head span { padding: 8px 6px; text-align: center; font-weight: 800; font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; border-bottom: 2px solid var(--line); }
.m-cell { display: flex; flex-direction: column; gap: 3px; min-height: 118px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text); min-width: 0; }
.m-cell:nth-child(7n) { border-right: 0; }
.m-cell:hover { background: var(--blue-l); }
.m-cell.we { background: #fafcfd; }
.m-cell.out { background: #f6f8fa; }
.m-cell.out .m-num { color: #b3bec8; }
.m-num { font-weight: 800; font-size: .9rem; color: var(--navy); width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; }
.m-cell.today .m-num { background: var(--blue); color: #fff; }
.m-chip { display: block; padding: 1px 6px; border-radius: 6px; font-size: .72rem; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: color-mix(in srgb, var(--c) 16%, white); border-left: 3px solid var(--c); color: var(--navy); }
.m-chip b { font-variant-numeric: tabular-nums; }
.m-more { font-size: .72rem; font-weight: 800; color: var(--blue-d); padding-left: 4px; }
.m-dots { display: none; }
@media (max-width: 759px) {
  .m-cell { min-height: 64px; padding: 4px; align-items: center; }
  .m-chip, .m-more { display: none; }
  .m-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; align-items: center; }
  .m-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
  .m-dots em { font-style: normal; font-size: .66rem; font-weight: 800; color: var(--muted); }
}

/* ---------- Formularz zajęć ---------- */
.time-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick-len { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: -4px; }
.chip-btn { border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 12px; font: inherit; font-size: .85rem; font-weight: 700; color: var(--navy); cursor: pointer; }
.chip-btn:hover { border-color: var(--blue); color: var(--blue-d); }
.repeat-box { border: 2px dashed var(--line); border-radius: 14px; padding: 12px 14px; }
.repeat-box summary { cursor: pointer; font-weight: 800; color: var(--blue-d); }
.repeat-box[open] summary { margin-bottom: 12px; }
.weekdays { display: flex; gap: 6px; flex-wrap: wrap; }
.weekdays legend { width: 100%; }
.wd { display: block; cursor: pointer; }
.wd input { position: absolute; opacity: 0; pointer-events: none; }
.wd span { display: grid; place-items: center; width: 46px; height: 42px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font-weight: 800; color: var(--navy); }
.wd input:checked + span { background: var(--blue); border-color: var(--blue); color: #fff; }
.wd input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--blue) 40%, transparent); }

/* ---------- Statystyki ---------- */
.stats-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.stats-form label { flex: 1 1 170px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 640px) { .kpis { grid-template-columns: 1fr 1fr; } }
.kpi { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 16px; display: grid; }
.kpi-v { font-family: var(--font-h); font-weight: 800; font-size: 1.7rem; color: var(--navy); line-height: 1.1; }
.kpi-l { font-size: .82rem; color: var(--muted); font-weight: 700; }
.stats-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .stats-cols { grid-template-columns: 1fr; gap: 0; } }
.bars { display: grid; gap: 4px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 10px; border-radius: 12px; text-decoration: none; color: var(--text); }
.bar-row:hover { background: var(--blue-l); }
.bar-label { font-weight: 700; color: var(--navy); display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar-val { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bar { grid-column: 1 / -1; height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 999px; background: var(--c, var(--blue)); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--c, var(--blue)); flex: none; margin-right: 6px; vertical-align: baseline; }
.bar-label .dot { margin-right: 0; }
.table-scroll { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.stat-table { border-collapse: collapse; width: 100%; font-size: .9rem; font-variant-numeric: tabular-nums; }
.stat-table th, .stat-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.stat-table thead th { font-size: .78rem; color: var(--muted); font-weight: 800; border-bottom: 2px solid var(--line); }
.stat-table th:first-child { text-align: left; color: var(--navy); font-weight: 800; position: sticky; left: 0; background: #fff; }
.stat-table thead th:first-child { color: var(--muted); }
.stat-table td.zero { color: #c3ccd4; }
.stat-table .sum { font-weight: 800; color: var(--navy); background: var(--blue-l); }
.stat-table tfoot th, .stat-table tfoot td { border-bottom: 0; border-top: 2px solid var(--line); }

/* ---------- Dolny pasek ---------- */
body.has-tabbar { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center; gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  backdrop-filter: blur(12px); border-top: 1px solid var(--line); box-shadow: 0 -4px 18px rgba(4, 80, 120, .06);
}
.tabbar a {
  position: relative; flex: 1; max-width: 120px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 4px; border-radius: 14px; color: var(--muted); text-decoration: none; font-size: .74rem; font-weight: 800;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.on { color: var(--blue-d); background: var(--blue-l); }
.tab-fab {
  flex: none; align-self: center; width: 56px; height: 56px; margin: -22px 8px 0;
  border: 4px solid #fff; border-radius: 50%; cursor: pointer; display: grid; place-items: center;
  background: var(--blue); color: #fff; box-shadow: 0 8px 20px rgba(4, 159, 228, .4);
}
.tab-fab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.tab-fab:active { transform: scale(.94); }
.install-hint {
  position: fixed; left: 12px; right: 12px; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 30;
  max-width: 700px; margin: 0 auto; padding: 12px 16px; border-radius: 14px;
  background: var(--navy); color: #fff; box-shadow: var(--shadow); font-size: .92rem; text-align: center; cursor: pointer;
}

.app-version { text-align: center; color: var(--muted); font-size: .72rem; opacity: .6; margin: 30px 0 6px; }

/* ---------- Wydruk grafiku ---------- */
@media print {
  .topbar, .tabbar, .plan-bar, .plan-nav, .install-hint, .app-version, .flash, .info { display: none !important; }
  body, body.has-tabbar { background: #fff; padding: 0; font-size: 12px; }
  .wrap, body.wide .wrap { max-width: none; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccd; }
  .only-wide { display: block !important; }
  .only-narrow { display: none !important; }
  .card-flush:has(.tgrid) { overflow: visible; }
  .tgrid { --ppm: .9px; min-width: 0; }
  .lb, .ag-item, .m-chip, .legend a { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
