/* ==========================================================================
   Primjer dinamičnog dokumenta (izvjestaj.php) — izvještaj kao „list papira" na sivoj podlozi.
   Tokeni (boje, fontovi) i kartice grafova dolaze iz style.css.
   ========================================================================== */
.rep-body { background: #e9eef4; font-size: 16px; }
html:has(.rep-body) { scroll-padding-top: 150px; }

/* ---------- Traka iznad dokumenta (nije dio izvještaja) ---------- */
.rep-bar { background: var(--navy); color: var(--muted-dark); font-size: 13.5px; }
.rep-bar__in { max-width: 1000px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; }
.rep-bar__back { display: inline-flex; align-items: center; gap: 6px; color: #fff; font-weight: 700; }
.rep-bar__back .ico { transform: rotate(180deg); }
.rep-bar__note { flex: 1 1 auto; min-width: 0; }
.rep-bar__note b { color: var(--sky); }
.rep-bar__print { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; color: #fff; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .2); border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.rep-bar__print:hover { background: rgba(255, 255, 255, .18); }

/* ---------- Napomena iznad dokumenta (nije dio izvještaja) ---------- */
.rep-intro { max-width: 960px; margin: 0 auto 24px; display: flex; gap: 14px; align-items: flex-start; padding: 16px 20px; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 10px; font-size: 15px; line-height: 1.6; }
.rep-intro__ico { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--blue-soft); color: var(--blue); }
.rep-intro b { color: var(--ink); }

/* ---------- List dokumenta ---------- */
.rep-page { padding: 32px 16px 56px; }
.rep-doc { max-width: 960px; margin: 0 auto; background: #fff; border-radius: 4px; box-shadow: 0 1px 2px rgba(13, 39, 66, .08), 0 18px 50px rgba(13, 39, 66, .12); }
.rep-doc > * { padding-left: clamp(20px, 6vw, 72px); padding-right: clamp(20px, 6vw, 72px); }
.rep-label { font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

.rep-head { padding-top: 40px; padding-bottom: 30px; border-top: 6px solid var(--blue); border-radius: 4px 4px 0 0; }
.rep-head__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-bottom: 26px; border-bottom: 1px solid var(--line); }
.rep-head__brand { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; font-weight: 800; color: var(--ink); font-size: 16px; }
.rep-head__brand small { flex-basis: 100%; padding-left: 52px; margin-top: -6px; font-weight: 500; font-size: 13px; color: var(--muted); }
.rep-head__mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; background: var(--ink); color: #fff; font-size: 14px; letter-spacing: .04em; }
.rep-head__class { flex: none; font-size: 12px; font-weight: 700; color: var(--danger); border: 1px solid currentColor; border-radius: 4px; padding: 2px 8px; }
.rep-head__kind { margin-top: 34px; font-size: 13px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: var(--blue); }
.rep-head h1 { margin-top: 10px; font-size: clamp(32px, 5vw, 50px); }
.rep-head__sub { margin-top: 12px; max-width: 680px; font-size: 18px; color: var(--text); }
.rep-meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 30px 0 0; padding: 18px 0 0; border-top: 1px solid var(--line-soft); }
.rep-meta dt { font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.rep-meta dd { margin: 4px 0 0; font-size: 14px; color: var(--ink); line-height: 1.45; }

.rep-toc { padding-top: 24px; padding-bottom: 26px; background: var(--ice); }
.rep-toc ol { margin-top: 10px; columns: 2; column-gap: 40px; counter-reset: toc; }
.rep-toc li { counter-increment: toc; break-inside: avoid; padding: 3px 0; }
.rep-toc a { display: flex; gap: 10px; color: var(--ink); font-weight: 600; }
.rep-toc a::before { content: counter(toc); min-width: 18px; color: var(--blue); font-variant-numeric: tabular-nums; }
.rep-toc a:hover { color: var(--blue); }

/* ---------- Poglavlja ---------- */
.rep-sec { padding-top: 40px; padding-bottom: 8px; }
.rep-sec + .rep-sec, .rep-filters + .rep-sec { border-top: 1px solid var(--line-soft); margin-top: 28px; }
.rep-sec h2 { display: flex; align-items: baseline; gap: 14px; font-size: clamp(25px, 3vw, 31px); }
.rep-sec h2 span { font-family: var(--font); font-size: 15px; font-weight: 800; color: var(--blue); min-width: 22px; }
.rep-sec h3 { margin: 30px 0 10px; font-size: 17px; }
.rep-sec > p { margin-top: 14px; max-width: 760px; line-height: 1.7; }
.rep-lead { font-size: 18px; color: var(--ink); }

.rep-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 26px; }
.rep-kpi { padding: 16px; border: 1px solid var(--line); border-radius: 10px; }
.rep-kpi__v { margin-top: 8px; font-family: var(--font-display); font-size: 25px; font-weight: 600; color: var(--ink); line-height: 1.1; font-variant-numeric: tabular-nums; }
.rep-kpi__n { margin-top: 6px; font-size: 13px; color: var(--muted); }
.rep-up { color: #10794f; font-weight: 700; }
.rep-down { color: var(--danger); font-weight: 700; }

.rep-findings { counter-reset: f; display: grid; gap: 10px; max-width: 800px; }
.rep-findings li { counter-increment: f; position: relative; padding: 10px 0 10px 44px; line-height: 1.6; border-bottom: 1px solid var(--line-soft); }
.rep-findings li::before { content: counter(f); position: absolute; left: 0; top: 10px; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--blue-soft); color: var(--blue); font-weight: 800; font-size: 13px; }
.rep-findings b { color: var(--ink); }

/* ---------- Filtri (lijepe se uz vrh dok se čitaju poglavlja 2–6) ---------- */
.rep-filters { position: sticky; top: 0; z-index: 20; margin-top: 36px; padding-top: 0; padding-bottom: 0; background: rgba(255, 255, 255, .94); backdrop-filter: blur(6px); }
.rep-filters__in { padding: 14px 0 12px; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line); }
.rep-filters__title { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font-size: 13px; font-weight: 800; color: var(--ink); }
.rep-filters__title .ico { color: var(--blue); }
.rep-filters__title small { font-weight: 500; color: var(--muted); }
.rep-filters__row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-top: 10px; }
.rep-filters label { display: grid; gap: 3px; font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.rep-filters select { font: inherit; font-size: 14px; font-weight: 500; letter-spacing: 0; color: var(--ink); padding: 6px 28px 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; max-width: 220px; }
.rep-filters select.is-set { border-color: var(--blue); background: var(--blue-soft); }
.rep-filters__reset { font: inherit; font-size: 13px; font-weight: 700; color: var(--blue); background: none; border: 0; padding: 8px 4px; cursor: pointer; }
.rep-filters__kpis { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 10px; font-size: 13px; }
.rep-filters__kpis div { display: flex; align-items: baseline; gap: 6px; }
.rep-filters__kpis span { color: var(--muted); }
.rep-filters__kpis b { color: var(--ink); font-variant-numeric: tabular-nums; }
.rep-filters__kpis .rep-up, .rep-filters__kpis .rep-down { font-size: 12px; }

/* ---------- Slike (grafovi) ---------- */
.rep-fig { margin: 22px 0 0; }
.rep-fig .ai-chart { margin: 0; padding: 14px 14px 10px; border-color: var(--line); }
.rep-fig .ai-chart__plot { height: 320px; }
.rep-fig figcaption { margin-top: 8px; font-size: 13.5px; color: var(--muted); }
.rep-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.rep-two .ai-chart__plot { height: 300px; }
.rep-switch { display: inline-flex; margin-top: 18px; padding: 3px; border-radius: 999px; background: var(--ice-2); }
.rep-switch button { font: inherit; font-size: 13px; font-weight: 600; color: var(--text); background: none; border: 0; border-radius: 999px; padding: 6px 14px; cursor: pointer; }
.rep-switch button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(13, 39, 66, .15); }

/* ---------- Tablice ---------- */
.rep-tbl-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 20px; }
.rep-search { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-width: min(340px, 100%); }
.rep-search__toggle { display: grid; place-items: center; width: 36px; height: 36px; border: 0; background: none; color: var(--muted-dark); cursor: pointer; }
.rep-search.is-on { border-color: var(--blue); }
.rep-search.is-on .rep-search__toggle { color: var(--blue); }
.rep-search input { flex: 1 1 auto; min-width: 0; font: inherit; font-size: 14px; border: 0; padding: 8px 10px 8px 0; background: none; outline: none; }
.rep-tbl-count { font-size: 13px; color: var(--muted); }
.rep-tbl-wrap { margin-top: 12px; overflow-x: auto; }
.rep-tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.rep-tbl th { text-align: left; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 9px 10px; border-bottom: 2px solid var(--ink); white-space: nowrap; }
.rep-tbl th[data-sort] { cursor: pointer; user-select: none; }
.rep-tbl th[data-sort]:hover { color: var(--blue); }
.rep-tbl th[aria-sort="descending"]::after { content: " ↓"; color: var(--blue); }
.rep-tbl th[aria-sort="ascending"]::after { content: " ↑"; color: var(--blue); }
.rep-tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.rep-tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rep-tbl tbody tr:hover td { background: var(--ice); }
.rep-tbl__name { font-weight: 700; color: var(--ink); }
.rep-tbl__empty { text-align: center; color: var(--muted); padding: 24px !important; }
.rep-share { position: relative; min-width: 96px; }
.rep-share i { position: absolute; right: 10px; bottom: 5px; height: 3px; border-radius: 2px; background: var(--blue); opacity: .45; }
.rep-more { margin-top: 12px; font: inherit; font-size: 14px; font-weight: 700; color: var(--blue); background: none; border: 1px solid var(--line); border-radius: 999px; padding: 6px 16px; cursor: pointer; }
.rep-more:hover { border-color: var(--blue); background: var(--blue-soft); }
.rep-tbl--plan td:first-child { color: var(--blue); font-weight: 800; }
.rep-tbl--plan td:last-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
.rep-sign { font-size: 14px; color: var(--muted); font-style: italic; }

/* ---------- Podnožje dokumenta ---------- */
.rep-foot { margin-top: 44px; padding-top: 22px; padding-bottom: 30px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); display: grid; gap: 14px; }
.rep-foot b { color: var(--ink); }
.rep-foot__demo { padding-top: 12px; border-top: 1px dashed var(--line); }

@media (max-width: 760px) {
  .rep-page { padding: 0 0 32px; }
  .rep-intro { margin: 0; border-radius: 0; border-width: 0 0 1px 4px; padding: 14px 16px; font-size: 14.5px; }
  .rep-doc { border-radius: 0; }
  .rep-meta, .rep-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rep-two { grid-template-columns: minmax(0, 1fr); }
  .rep-toc ol { columns: 1; }
  .rep-bar__note { display: none; }
  .rep-bar__in { justify-content: space-between; }
  .rep-filters { position: static; }   /* na mobitelu bi ljepljiva traka pokrila pola ekrana */
  .rep-filters select { max-width: none; }
  .rep-filters__row label { flex: 1 1 140px; }
  .rep-filters__kpis div:nth-child(n+4) { display: none; }
  .rep-fig .ai-chart__plot, .rep-two .ai-chart__plot { height: 270px; }
  .rep-head__class { display: none; }
}

@media print {
  .rep-body { background: #fff; font-size: 11pt; }
  .rep-bar, .rep-intro, .rep-switch, .rep-tbl-tools, .rep-more, .rep-filters__row, .ai-chart__tools { display: none !important; }
  .rep-page { padding: 0; }
  .rep-doc { box-shadow: none; max-width: none; }
  .rep-filters { position: static; }
  .rep-sec, .rep-fig { break-inside: avoid-page; }
}
