/* Odstępy nagłówków we wpisach – mniejsze */
.entry-content :is(h2, h3, h4, h5, h6),
.post-content :is(h2, h3, h4, h5, h6),
.single-post article :is(h2, h3, h4, h5, h6),
.td-post-content :is(h2, h3, h4, h5, h6) {
  margin-top: 1.2em !important;     /* było 1.6em */
  margin-bottom: 0.35em !important; /* było 0.6em */
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  line-height: 1.3;
}

@media (max-width: 767px) {
  .entry-content :is(h2, h3, h4, h5, h6),
  .post-content :is(h2, h3, h4, h5, h6),
  .single-post article :is(h2, h3, h4, h5, h6),
  .td-post-content :is(h2, h3, h4, h5, h6) {
    margin-top: 1em !important;      /* było 1.4em */
    margin-bottom: 0.3em !important; /* było 0.5em */
  }
}

/* Odstęp pod listami we wpisach */
:is(.entry-content, .post-content, .single-post article, .td-post-content) :is(ul, ol) {
  margin-bottom: 1.2em !important;
}

/* Tekst po liście zawsze z odstępem */
:is(.entry-content, .post-content, .single-post article, .td-post-content) :is(ul, ol) + :is(p, h2, h3, h4, table, figure) {
  margin-top: 1.2em !important;
}

/* Listy zagnieżdżone bez dodatkowego odstępu */
:is(.entry-content, .post-content, .single-post article, .td-post-content) li > :is(ul, ol) {
  margin-top: 0.3em !important;
  margin-bottom: 0.3em !important;
}

@media (max-width: 767px) {
  :is(.entry-content, .post-content, .single-post article, .td-post-content) :is(ul, ol) {
    margin-bottom: 1em !important;
  }
  :is(.entry-content, .post-content, .single-post article, .td-post-content) :is(ul, ol) + :is(p, h2, h3, h4, table, figure) {
    margin-top: 1em !important;
  }
}

/* ===== Tabele – wersja uniwersalna ===== */
:root {
  --tbl-accent: #2f6f4f;
  --tbl-accent-text: #ffffff;
  --tbl-border: #e3e6ea;
  --tbl-stripe: #f6f8f9;
  --tbl-hover: #eef4f1;
}

body .wp-block-table {
  margin: 2em 0 !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
}

body table:not(#wp-calendar) {
  width: 100% !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  margin: 2em 0 !important;
  font-size: 0.95em !important;
  line-height: 1.5 !important;
  border: 1px solid var(--tbl-border) !important;
  border-radius: 10px !important;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05) !important;
  background: #fff !important;
}

body .wp-block-table table {
  margin: 0 !important;
}

body table:not(#wp-calendar) :is(th, td) {
  padding: 14px 18px !important;
  vertical-align: top !important;
  border: 0 !important;
  border-bottom: 1px solid var(--tbl-border) !important;
  background: transparent;
  text-align: left;
}

body table:not(#wp-calendar) tr:last-child td {
  border-bottom: 0 !important;
}

/* Nagłówek: thead albo pierwszy wiersz z komórkami th */
body table:not(#wp-calendar) thead :is(th, td),
body table:not(#wp-calendar) tr:first-child th {
  background: var(--tbl-accent) !important;
  color: var(--tbl-accent-text) !important;
  font-weight: 600 !important;
}

body table:not(#wp-calendar) tbody tr:nth-child(even) {
  background: var(--tbl-stripe) !important;
}
body table:not(#wp-calendar) tbody tr:hover {
  background: var(--tbl-hover) !important;
}

/* ===== Mobile ===== */
@media (max-width: 767px) {
  body table:not(#wp-calendar) {
    display: block !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    font-size: 0.875em !important;
  }

  body table:not(#wp-calendar) :is(th, td) {
    padding: 10px 12px !important;
    min-width: 130px;
  }

  body table:not(#wp-calendar) :is(th, td):first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.06);
  }
  body table:not(#wp-calendar) tbody td:first-child {
    background: #fff !important;
  }
  body table:not(#wp-calendar) tbody tr:nth-child(even) td:first-child {
    background: var(--tbl-stripe) !important;
  }
  body table:not(#wp-calendar) thead :is(th, td):first-child {
    background: var(--tbl-accent) !important;
  }
}

/* Tabele: proste rogi */
body table:not(#wp-calendar) {
  border-radius: 0 !important;
}

/* =========================================================
   SEKCJA FAQ
   ========================================================= */
body :is(.faq, .schema-faq, .rank-math-block) {
  background: var(--tbl-stripe) !important;
  border: 1px solid var(--tbl-border) !important;
  border-radius: 14px !important;
  padding: 28px 32px !important;
  margin: 2.5em 0 !important;
}

body .faq > :is(h2, h3):first-child {
  margin: 0 0 1em !important;
  padding-bottom: 0.5em !important;
  border-bottom: 2px solid var(--tbl-accent) !important;
}

/* Pytania */
body .faq :is(h3, h4):not(:first-child),
body .schema-faq-question,
body .rank-math-question {
  position: relative;
  display: block;
  margin: 1.4em 0 0.4em !important;
  padding: 0 0 0 40px !important;
  font-size: 1.1em !important;
  font-weight: 700 !important;
  line-height: 1.4 !important;
  color: inherit;
}

body .faq :is(h3, h4):not(:first-child)::before,
body .schema-faq-question::before,
body .rank-math-question::before {
  content: "?";
  position: absolute;
  left: 0;
  top: 0.05em;
  width: 28px;
  height: 28px;
  line-height: 28px;
  text-align: center;
  border-radius: 50%;
  background: var(--tbl-accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}

/* Odpowiedzi */
body .faq :is(h3, h4) ~ :is(p, ul, ol),
body .schema-faq-answer,
body .rank-math-answer {
  margin: 0 0 0.6em !important;
  padding-left: 40px !important;
  color: #4b5563;
}

/* Linia między pytaniami */
body .faq :is(p, ul, ol) + :is(h3, h4),
body .schema-faq-section + .schema-faq-section,
body .rank-math-list-item + .rank-math-list-item {
  margin-top: 1.6em !important;
  padding-top: 1.8em !important;
  border-top: 1px solid var(--tbl-border);
}

body .faq :is(p, ul, ol) + :is(h3, h4)::before {
  top: calc(1.8em + 0.05em);
}

body .faq > :last-child {
  margin-bottom: 0 !important;
}

/* =========================================================
   MOBILE
   ========================================================= */
@media (max-width: 767px) {

  /* Nagłówki */
  .entry-content :is(h2, h3, h4, h5, h6),
  .post-content :is(h2, h3, h4, h5, h6),
  .single-post article :is(h2, h3, h4, h5, h6),
  .td-post-content :is(h2, h3, h4, h5, h6) {
    margin-top: 1em !important;
    margin-bottom: 0.3em !important;
  }

  /* Listy */
  :is(.entry-content, .post-content, .single-post article, .td-post-content) :is(ul, ol) {
    margin-bottom: 1em !important;
  }
  :is(.entry-content, .post-content, .single-post article, .td-post-content) :is(ul, ol) + :is(p, h2, h3, h4, table, figure) {
    margin-top: 1em !important;
  }

  /* Tabele */
  body table:not(#wp-calendar) {
    display: block !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    font-size: 0.875em !important;
  }
  body table:not(#wp-calendar) :is(th, td) {
    padding: 10px 12px !important;
    min-width: 130px;
  }
  body table:not(#wp-calendar) :is(th, td):first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.06);
  }
  body table:not(#wp-calendar) tbody td:first-child {
    background: #fff !important;
  }
  body table:not(#wp-calendar) tbody tr:nth-child(even) td:first-child {
    background: var(--tbl-stripe) !important;
  }
  body table:not(#wp-calendar) thead :is(th, td):first-child {
    background: var(--tbl-accent) !important;
  }

  /* FAQ */
  body :is(.faq, .schema-faq, .rank-math-block) {
    padding: 20px 18px !important;
    border-radius: 10px !important;
  }
  body .faq :is(h3, h4):not(:first-child),
  body .schema-faq-question,
  body .rank-math-question {
    padding-left: 34px !important;
    font-size: 1em !important;
  }
  body .faq :is(h3, h4):not(:first-child)::before,
  body .schema-faq-question::before,
  body .rank-math-question::before {
    width: 24px;
    height: 24px;
    line-height: 24px;
    font-size: 13px;
  }
  body .faq :is(h3, h4) ~ :is(p, ul, ol),
  body .schema-faq-answer,
  body .rank-math-answer {
    padding-left: 34px !important;
  }
}

/* =========================================================
   LISTY PUNKTOWANE – PTASZKI
   ========================================================= */
body :is(:is(p, h2, h3, h4, h5, h6) + ul, ul.wp-block-list):not(aside ul, nav ul, header ul, footer ul, .sidebar ul) {
  list-style: none !important;
  padding-left: 0 !important;
  margin-left: 0 !important;
}

body :is(:is(p, h2, h3, h4, h5, h6) + ul, ul.wp-block-list):not(aside ul, nav ul, header ul, footer ul, .sidebar ul) > li {
  position: relative !important;
  padding-left: 32px !important;
  margin-bottom: 0.45em !important;
  list-style: none !important;
  background: none !important;
}

body :is(:is(p, h2, h3, h4, h5, h6) + ul, ul.wp-block-list):not(aside ul, nav ul, header ul, footer ul, .sidebar ul) > li::before {
  content: "" !important;
  display: block !important;
  position: absolute !important;
  left: 7px !important;
  top: 0.25em !important;
  width: 7px !important;
  height: 13px !important;
  margin: 0 !important;
  border: 0 !important;
  border-right: 3px solid var(--tbl-accent, #2f6f4f) !important;
  border-bottom: 3px solid var(--tbl-accent, #2f6f4f) !important;
  border-radius: 0 !important;
  background: none !important;
  transform: rotate(45deg) !important;
}

body :is(:is(p, h2, h3, h4, h5, h6) + ul, ul.wp-block-list):not(aside ul, nav ul, header ul, footer ul, .sidebar ul) li > ul {
  list-style: none !important;
  padding-left: 0 !important;
  margin: 0.3em 0 !important;
}
body :is(:is(p, h2, h3, h4, h5, h6) + ul, ul.wp-block-list):not(aside ul, nav ul, header ul, footer ul, .sidebar ul) li > ul > li {
  position: relative !important;
  padding-left: 22px !important;
  list-style: none !important;
}
body :is(:is(p, h2, h3, h4, h5, h6) + ul, ul.wp-block-list):not(aside ul, nav ul, header ul, footer ul, .sidebar ul) li > ul > li::before {
  content: "" !important;
  position: absolute !important;
  left: 4px !important;
  top: 0.6em !important;
  width: 8px !important;
  height: 8px !important;
  border: 0 !important;
  border-radius: 50% !important;
  background: var(--tbl-accent, #2f6f4f) !important;
  transform: none !important;
}

/* Odstęp między górnym opisem kategorii a listą wpisów */
.custom-box + .blog-onecolumn {
  margin-top: 40px;
}

/* Zabezpieczenie: to samo od strony górnego opisu */
.custom-box:first-child {
  margin-bottom: 40px;
}

@media (max-width: 768px) {
  .custom-box + .blog-onecolumn {
    margin-top: 24px;
  }

  .custom-box:first-child {
    margin-bottom: 24px;
  }
}
