/* Reports app styles (tokens from admin.css only: --panel, --line, --ink, --muted, --brand, --accent, --ok, --warn, --danger, --info + -soft, --c1..c8; logical properties for RTL) */
.rep-page { --rep: #7a5aa6; }

/* ------------------------------------------------------------ overview */
.rep-search { max-width: 520px; flex: 1 1 320px; }
.rep-overview { display: grid; gap: 26px; }
.rep-area { display: grid; gap: 12px; }
.rep-area-h { display: flex; align-items: center; gap: 10px; font-size: 17px; }
.rep-area-ico { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; color: #fff; }
.rep-lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.rep-lib { display: flex; align-items: center; gap: 12px; min-height: 76px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-inline-start: 4px solid var(--area, var(--rep)); border-radius: var(--r); color: inherit; text-decoration: none; transition: border-color .15s, background .15s, transform .12s; min-width: 0; }
.rep-lib:hover { border-color: var(--area, var(--rep)); background: var(--panel-2); }
.rep-lib:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rep-lib-ico { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; flex: 0 0 auto; color: var(--area, var(--rep)); background: color-mix(in srgb, var(--area, var(--rep)) 14%, var(--panel)); }
.rep-lib-txt { display: grid; gap: 2px; min-width: 0; flex: 1; }
.rep-lib-txt small { line-height: 1.35; }
.rep-lib-go { color: var(--muted); flex: 0 0 auto; }
[dir="rtl"] .rep-lib-go.ico, [dir="rtl"] .rep-drill-ico { transform: scaleX(-1); }
.rep-pin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.rep-pin { display: grid; gap: 4px; align-content: start; padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); color: inherit; text-decoration: none; min-width: 0; }
.rep-pin:hover { border-color: var(--accent); }
.rep-pin-head { display: flex; align-items: center; gap: 6px; color: var(--warn-ink); min-width: 0; }
.rep-pin-head b { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rep-pin-val { font-size: 24px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.rep-pin-spark { min-height: 38px; direction: ltr; }
.rep-pin-spark .spark { width: 100%; height: 38px; }

/* ------------------------------------------------------------ builder layout */
.rep-layout { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 16px; align-items: start; }
.rep-controls { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow: auto; display: grid; gap: 4px; padding: 6px 16px 16px; align-content: start; }
.rep-sec { display: grid; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--line-2); min-width: 0; }
.rep-sec:last-of-type { border-bottom: 0; }
.rep-sec h4 { font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--brand); }
.rep-field { display: grid; gap: 4px; min-width: 0; }
.rep-label { font-size: 12px; font-weight: 700; color: var(--muted); }
.rep-wide { width: 100%; }
.rep-desc { line-height: 1.4; }
.rep-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rep-chip { display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer; text-align: start; max-width: 100%; }
.rep-chip:hover { border-color: var(--muted); }
.rep-chip:focus-visible, .rep-x:focus-visible, .seg:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rep-chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-d); }
.rep-chip-x { cursor: default; padding-inline-end: 4px; }
.rep-x { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 0; background: transparent; color: inherit; cursor: pointer; }
.rep-x:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.rep-well { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 36px; padding: 4px; border: 1px dashed var(--line); border-radius: var(--r-sm); }
.rep-well.need { border-color: var(--warn); background: var(--warn-soft); }
.rep-add { height: 32px; max-width: 100%; color: var(--muted); }
.rep-custom { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rep-custom .date-in { flex: 1 1 120px; width: auto; min-width: 0; }
.rep-range-note:empty { display: none; }
.rep-addfilter { display: grid; gap: 8px; padding: 10px 0 2px; }
.rep-addfilter .chip-select, .rep-addfilter .search-input { width: 100%; padding-inline-start: 12px; }
.rep-valbox { display: block; }
.rep-details > summary { cursor: pointer; font-weight: 650; color: var(--accent-d); min-height: 32px; display: flex; align-items: center; }
.rep-details[open] > summary { margin-bottom: 4px; }
.rep-sheet-head, .rep-sheet-foot, .rep-scrim, .rep-customize { display: none; }

/* ------------------------------------------------------------ results */
.rep-main { display: grid; gap: 14px; min-width: 0; align-content: start; transition: opacity .15s; }
.rep-main.is-loading { opacity: .6; }
.rep-summary { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rep-kpis:empty { display: none; }
.rep-card { padding: 0; overflow: hidden; }
.rep-viewbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--line-2); }
.rep-views .seg { display: inline-flex; align-items: center; gap: 6px; }
.rep-count { white-space: nowrap; }
.rep-result { padding: 0; min-width: 0; }
.rep-result > .list-body { border: 0; border-radius: 0; box-shadow: none; }
.rep-result > .rep-chartwrap, .rep-result > .rep-pivot { padding: 14px; }
.rep-result > .empty { padding: 44px 18px; }
.rep-result > .skeleton, .rep-result > .error-box { margin: 14px; }
.rep-table td, .rep-table th, .rep-pivot td, .rep-pivot th { white-space: nowrap; }
.rep-cell-drill { display: inline-flex; align-items: center; gap: 4px; }
.rep-drill-ico { color: var(--muted); opacity: 0; transition: opacity .12s; }
tr.clickable:hover .rep-drill-ico, tr.clickable:focus-visible .rep-drill-ico { opacity: 1; }
tr.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.rep-heat { background: color-mix(in srgb, var(--accent) calc(var(--p, 0) * 30%), transparent); }
.rep-note { margin-top: 8px; }
.rep-chart { direction: ltr; }
.rep-hbars { gap: 12px; }
.rep-hbar-val { display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hbar-track.prev { height: 4px; opacity: .65; }
.rep-export { position: relative; }
.rep-menu { inset-inline-end: 0; inset-inline-start: auto; min-width: 190px; }
.rep-save { display: grid; gap: 14px; }
.rep-save .toggle-row { justify-content: flex-start; align-items: flex-start; }
.rep-save .toggle-row span { display: grid; gap: 1px; }
.rep-save input[type=checkbox] { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); }
.rep-name { padding-inline-start: 12px; }
.rep-row-actions { display: inline-flex; gap: 4px; justify-content: flex-end; }
.rep-pinbtn.on { color: var(--warn-ink); border-color: var(--warn); }
.rep-pinbtn.on svg { fill: currentColor; }
.rep-on { color: var(--accent-d); border-color: var(--accent); }
.rep-slug { display: block; }
.rep-group { display: grid; gap: 14px; transition: opacity .15s; }
.rep-group.is-loading { opacity: .6; }

/* ------------------------------------------------------------ print / PDF page: always white paper, so the tokens are pinned to the light palette */
.rep-doc { --ink: #1b1b1b; --muted: #666; --line: #cfcfcf; --line-2: #e5e5e5; --panel: #fff; --c1: #6f4e37; --c2: #168c82; --c3: #c78525; --c4: #7a5aa6; --c5: #c94d49; --c6: #4a7fb5; --c7: #8a9a3b; --c8: #d17b9a; color: var(--ink); background: #fff; }
.rep-doc-meta { margin-bottom: 12px; }
.rep-print-chart { margin-bottom: 12px; max-height: 330px; }
.rep-doc .chart { max-height: 300px; }

/* ------------------------------------------------------------ tablet / phone: controls become a bottom sheet */
@media (max-width: 1100px) {
  .rep-layout { grid-template-columns: minmax(0, 1fr); }
  .rep-customize { display: inline-flex; }
  .rep-controls { position: fixed; inset-inline: 0; bottom: 0; top: auto; z-index: 60; max-height: 86vh; border-radius: 18px 18px 0 0; border-bottom: 0; padding: 0 16px; box-shadow: var(--shadow-lg);
    transform: translateY(105%); visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s; }
  .rep-controls.open { transform: none; visibility: visible; transition: transform .22s ease; }
  .rep-sheet-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 2; background: var(--panel); padding: 14px 0 8px; }
  .rep-sheet-head::before { content: ""; position: absolute; inset-inline: 0; top: 5px; margin-inline: auto; width: 40px; height: 4px; border-radius: 4px; background: var(--line); }
  .rep-sheet-foot { display: block; position: sticky; bottom: 0; background: var(--panel); padding: 10px 0 14px; border-top: 1px solid var(--line-2); }
  .rep-scrim.open { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(20, 12, 8, .5); }
  body.rep-sheet-open { overflow: hidden; }
  .rep-chip { min-height: 40px; }
  .rep-add, .rep-controls .chip-select, .rep-controls .date-in { height: 42px; }
}
@media (max-width: 720px) {
  .rep-seg-label { display: none; }
  .rep-views .seg { min-width: 44px; justify-content: center; padding: 0 10px; min-height: 40px; }
  .rep-viewbar { padding: 10px; }
  .rep-lib-grid, .rep-pin-grid { grid-template-columns: minmax(0, 1fr); }
  .rep-result > .rep-chartwrap, .rep-result > .rep-pivot { padding: 10px; }
  .rep-result .list-body .data-table tr.clickable { cursor: pointer; }
  .rep-drill-ico { display: none; }
  .rep-search { max-width: none; }
}
