:root {
  --orange: #e8641b;
  --orange-dark: #c94f0e;
  --ink: #1f2430;
  --muted: #6b7280;
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #e5e7eb;
  --green: #15803d;
  --green-bg: #dcfce7;
  --red: #b91c1c;
  --red-bg: #fee2e2;
  --amber: #92600a;
  --amber-bg: #fef3c7;
  --radius: 12px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
}

.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }

/* ---------- górny pasek ---------- */
.topbar {
  background: linear-gradient(135deg, #23262f, #363b47);
  color: #fff;
  border-bottom: 4px solid var(--orange);
}
.topbar-in {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px; padding-top: 12px; padding-bottom: 12px;
}
.brand {
  color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem;
  display: flex; align-items: center; gap: 10px;
}
.brand-logo { height: 44px; width: auto; }
.nav { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 14px; }
.nav a { color: #d9dce3; text-decoration: none; font-size: .95rem; }
.nav a:hover { color: #fff; }
.inline { display: inline; }
.linklike {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--orange); font: inherit; font-size: .95rem;
}
.linklike:hover { text-decoration: underline; }

main { padding: 24px 16px 40px; }

h1 { font-size: 1.5rem; margin: 0 0 16px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 0 0 8px; }
.sub { color: var(--muted); font-size: .9rem; }

/* ---------- karty ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin-bottom: 20px;
}
.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 720px) { .grid-3 { grid-template-columns: 1fr; } }

.stat { text-align: center; padding: 16px; }
.stat .num { font-size: 1.7rem; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: .85rem; }
.stat.bad .num { color: var(--red); }
.stat.good .num { color: var(--green); }

/* ---------- alerty / plakietki ---------- */
.alert { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; }
.alert-ok   { background: var(--green-bg); color: var(--green); }
.alert-err  { background: var(--red-bg); color: var(--red); }
.alert-info { background: #e0ecff; color: #1d4ed8; }
.alert-warn { background: var(--amber-bg); color: var(--amber); }

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 99px;
  font-size: .8rem; font-weight: 600; white-space: nowrap;
}
.badge-paid    { background: var(--green-bg); color: var(--green); }
.badge-due     { background: var(--amber-bg); color: var(--amber); }
.badge-overdue { background: var(--red-bg); color: var(--red); }
.badge-part    { background: #e0ecff; color: #1d4ed8; }
.badge-muted   { background: var(--line); color: var(--muted); }

/* ---------- tabele ---------- */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }

/* ---------- formularze ---------- */
label { display: block; font-weight: 600; font-size: .9rem; margin: 12px 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=number], input[type=date], input[type=month], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #cbd0d8; border-radius: 8px;
  font: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--orange); outline-offset: 0; border-color: var(--orange);
}
.hint { color: var(--muted); font-size: .85rem; margin-top: 4px; }

.btn {
  display: inline-block; background: var(--orange); color: #fff; border: 0;
  padding: 10px 18px; border-radius: 8px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--orange-dark); }
.btn-sm { padding: 5px 12px; font-size: .85rem; }
.btn-ghost { background: transparent; color: var(--orange); border: 1px solid var(--orange); }
.btn-ghost:hover { background: #fdf0e7; }
.btn-danger { background: transparent; color: var(--red); border: 1px solid #f3b4b4; }
.btn-danger:hover { background: var(--red-bg); }
.btn-green { background: var(--green); }
.btn-green:hover { background: #116232; }

.form-narrow { max-width: 420px; margin: 0 auto; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-row > div { flex: 1; min-width: 130px; }
.mt { margin-top: 16px; }

.footer { color: var(--muted); font-size: .85rem; padding: 20px 16px 40px; text-align: center; }

.pay-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pay-form input[type=number] { width: 100px; }
.pay-form select { width: auto; }

.bank-box {
  background: #fdf0e7; border: 1px dashed var(--orange); border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 20px; font-size: .95rem;
}
.bank-box .acct { font-weight: 700; font-size: 1.05rem; letter-spacing: .5px; }

details.child-card { margin-bottom: 8px; }
details.child-card summary { cursor: pointer; font-weight: 600; padding: 6px 0; }

/* ---------- zgody / dokument ---------- */
.doc-wrap { max-width: 760px; margin: 0 auto; }
.doc-intro { text-align: center; margin-bottom: 20px; }

.doc-paper {
  background: #fffdf9;
  border: 1px solid var(--line);
  border-top: 6px solid var(--orange);
  border-radius: var(--radius);
  padding: 32px clamp(18px, 5vw, 48px);
  box-shadow: 0 10px 30px rgba(31, 36, 48, .08);
}
.doc-head { text-align: center; margin-bottom: 24px; }
.doc-logo { height: 90px; margin-bottom: 8px; }
.doc-org { font-weight: 700; letter-spacing: .04em; color: var(--orange-dark); font-size: .9rem; text-transform: uppercase; }
.doc-title { font-size: 1.25rem; margin: 10px 0 4px; letter-spacing: .02em; }
.doc-subtitle { color: var(--muted); font-size: .9rem; margin: 0; }

.doc-fields {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px;
  background: #f8f4ec; border-radius: 10px; padding: 18px; margin-bottom: 24px;
}
@media (max-width: 620px) { .doc-fields { grid-template-columns: 1fr; } }
.doc-field-label { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.doc-field-value { font-weight: 700; font-size: 1.05rem; }
.doc-fill { border-bottom: 2px solid var(--orange); padding: 0 2px; }

.doc-sec { margin: 26px 0; }
.doc-sec h3 { display: flex; align-items: center; gap: 10px; font-size: 1.02rem; }
.doc-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  background: var(--orange); color: #fff; font-size: .9rem;
}
.doc-sec p { color: #3c4250; font-size: .93rem; }
.doc-accepted-line { color: var(--green); font-weight: 600; }

.check-row {
  display: flex; align-items: center; gap: 12px;
  border: 2px solid var(--line); border-radius: 10px;
  padding: 13px 15px; cursor: pointer; font-weight: 600; font-size: .95rem;
  transition: border-color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.check-row:hover { border-color: var(--orange); }
.check-row:has(input:checked) { border-color: var(--green); background: var(--green-bg); }
.check-row input { width: 24px; height: 24px; flex: none; accent-color: var(--green); margin: 0; }

.stickybar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 18px; margin-top: 16px;
  box-shadow: 0 -6px 24px rgba(31, 36, 48, .12);
}
.progress-dots { display: flex; gap: 8px; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--line); transition: background .2s, transform .2s; }
.dot.on { background: var(--green); transform: scale(1.15); }
.btn-sign { font-size: 1.02rem; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.doc-signature {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  margin-top: 34px; padding-top: 22px; border-top: 1px dashed #cbd0d8;
}
.stamp {
  border: 3px solid var(--green); color: var(--green);
  border-radius: 8px; padding: 8px 14px; font-weight: 800; font-size: .8rem;
  letter-spacing: .08em; text-align: center; transform: rotate(-6deg);
  opacity: .85; flex: none;
}
.doc-sig-meta { font-size: .92rem; line-height: 1.55; }

/* ekran sukcesu */
.success-box { text-align: center; }
.success-check { width: 84px; height: 84px; margin: 10px auto 4px; display: block; }
.success-check circle, .success-check path {
  stroke: var(--green); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 160; stroke-dashoffset: 160;
  animation: draw .7s ease forwards;
}
.success-check path { stroke-dasharray: 50; stroke-dashoffset: 50; animation-delay: .55s; animation-duration: .45s; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* wydruk dokumentu */
@media print {
  .topbar, .footer, .no-print, .alert { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
  .doc-paper { border: 0; box-shadow: none; padding: 0; }
}
