/* ═══════════════════════════════════════════════════════════
   Reports
   Markup: modules/features/reports.js and modules/features/reports/*.js
   A filter band across the top, the report library down the left, the open
   report on the right. Runs edge to edge on --page-gutter (styles.css).
   ═══════════════════════════════════════════════════════════ */

.rpt-page {
  --rpt-surface: var(--bg-secondary, #ffffff);
  --rpt-line: var(--border-color, rgba(0, 0, 0, 0.08));
  --rpt-good: #11803d;
  --rpt-bad: #c22d2d;
  --rpt-warn: #a35a00;
  --rpt-good-bg: rgba(17, 128, 61, 0.09);
  --rpt-bad-bg: rgba(194, 45, 45, 0.08);
  --rpt-warn-bg: rgba(214, 133, 0, 0.12);
  --rpt-series-1: #2f5fd0;
  --rpt-nav-width: 224px;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--header-height, 52px));
  color: var(--text-primary);
}

[data-theme="dark"] .rpt-page {
  --rpt-good: #4ade80;
  --rpt-bad: #f87171;
  --rpt-warn: #fbbf24;
  --rpt-good-bg: rgba(74, 222, 128, 0.12);
  --rpt-bad-bg: rgba(248, 113, 113, 0.12);
  --rpt-warn-bg: rgba(251, 191, 36, 0.12);
  --rpt-series-1: #3987e5;
}

/* ── Top band ───────────────────────────────────────────── */

.rpt-top {
  padding: var(--space-3) var(--page-gutter);
  border-bottom: 1px solid var(--rpt-line);
  background: var(--bg-primary);
}

.rpt-toolbar {
  width: 100%;
}

.rpt-updated {
  font-size: var(--type-xs, 12px);
  color: var(--text-muted);
  white-space: nowrap;
}

.rpt-icon-btn {
  width: var(--control-height-sm, 32px);
  min-width: var(--control-height-sm, 32px);
  height: var(--control-height-sm, 32px);
  padding: 0;
  justify-content: center;
}

.rpt-icon-btn svg {
  width: 15px;
  height: 15px;
}

.rpt-icon-btn.is-spinning svg {
  animation: rpt-spin 0.8s linear infinite;
}

/* ── Layout ─────────────────────────────────────────────── */

.rpt-layout {
  display: grid;
  grid-template-columns: var(--rpt-nav-width) minmax(0, 1fr);
  flex: 1;
}

.rpt-nav {
  padding: var(--space-4) var(--space-3) var(--space-6) var(--page-gutter);
  border-right: 1px solid var(--rpt-line);
}

.rpt-nav-group + .rpt-nav-group {
  margin-top: var(--space-4);
}

.rpt-nav-heading {
  margin: 0 0 var(--space-1);
  padding: 0 var(--space-2);
  font-size: var(--type-xxs, 11px);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.rpt-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: var(--control-height-sm, 32px);
  padding: 0 var(--space-2);
  border: 0;
  border-radius: var(--btn-radius, 6px);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: var(--type-sm, 13px);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast, 100ms ease), color var(--transition-fast, 100ms ease);
}

.rpt-nav-item svg {
  flex-shrink: 0;
  color: var(--text-muted);
}

.rpt-nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.rpt-nav-item.is-active {
  background: var(--bg-active);
  color: var(--text-primary);
  font-weight: 600;
}

.rpt-nav-item.is-active svg {
  color: var(--color-primary);
}

.rpt-nav-item:focus-visible,
.rpt-link:focus-visible,
.rpt-kpi.is-link:focus-visible,
.rpt-barlist-row.is-link:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

.rpt-main {
  min-width: 0;
  padding: var(--space-5) var(--page-gutter) var(--space-8);
}

.rpt-picker {
  display: none;
  margin-bottom: var(--space-4);
}

/* ── Report header ──────────────────────────────────────── */

.rpt-report-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3) var(--space-5);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}

.rpt-report-title {
  margin: 0;
  font-size: var(--type-xl, 18px);
  font-weight: 650;
  letter-spacing: -0.01em;
}

.rpt-report-desc {
  margin: var(--space-1) 0 0;
  max-width: 64ch;
  font-size: var(--type-sm, 13px);
  color: var(--text-secondary);
}

.rpt-report-period {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  font-size: var(--type-xs, 12px);
  color: var(--text-muted);
}

.rpt-report-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* ── Number tiles ───────────────────────────────────────── */

/* One even row of tiles when there's room (--cols is the tile count), then
   three, then two a row as the report narrows */
.rpt-report-body {
  container-type: inline-size;
}

.rpt-kpis {
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr));
  gap: var(--space-3);
}

@container (max-width: 820px) {
  .rpt-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rpt-kpis[data-n="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@container (max-width: 520px) {
  .rpt-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.rpt-kpi {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: var(--space-3) var(--space-4) 14px;
  border: 1px solid var(--rpt-line);
  border-radius: var(--radius-md, 8px);
  background: var(--rpt-surface);
  color: inherit;
  font: inherit;
  text-align: left;
}

.rpt-kpi.is-link {
  cursor: pointer;
  transition: border-color var(--transition-fast, 100ms ease), background var(--transition-fast, 100ms ease);
}

.rpt-kpi.is-link:hover {
  border-color: color-mix(in srgb, var(--color-primary) 35%, var(--rpt-line));
}

.rpt-kpi-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--type-xs, 12px);
  font-weight: 500;
  color: var(--text-secondary);
}

.rpt-kpi-value {
  font-size: 1.375rem;
  font-weight: 650;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rpt-kpi-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  min-height: 18px;
  font-size: var(--type-xs, 12px);
  color: var(--text-muted);
}

.rpt-kpi-sub {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rpt-delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 6px 1px 4px;
  border-radius: var(--radius-xs, 4px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rpt-delta.is-good { color: var(--rpt-good); background: var(--rpt-good-bg); }
.rpt-delta.is-bad { color: var(--rpt-bad); background: var(--rpt-bad-bg); }
.rpt-delta.is-neutral { color: var(--text-secondary); background: var(--bg-tertiary); padding-left: 6px; }

/* A small "how is this worked out" mark with its explanation on hover / focus */
.rpt-hint {
  position: relative;
  display: inline-flex;
  color: var(--text-muted);
  cursor: help;
}

.rpt-hint::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  z-index: 30;
  width: max-content;
  max-width: 240px;
  padding: 7px 9px;
  border-radius: 6px;
  background: #1a1d21;
  color: #ffffff;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  white-space: normal;
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast, 100ms ease);
}

.rpt-hint:hover::after,
.rpt-hint:focus-visible::after {
  opacity: 1;
}

/* ── Cards and grids ────────────────────────────────────── */

.rpt-grid {
  display: grid;
  gap: var(--space-4);
}

.rpt-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rpt-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rpt-span-2 { grid-column: span 2; }

.rpt-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--rpt-line);
  border-radius: var(--radius-lg, 10px);
  background: var(--rpt-surface);
}

.rpt-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) 0;
}

.rpt-card-title {
  margin: 0;
  font-size: var(--type-md, 14px);
  font-weight: 600;
}

.rpt-card-sub {
  margin: 2px 0 0;
  font-size: var(--type-xs, 12px);
  color: var(--text-muted);
}

.rpt-card-actions {
  flex-shrink: 0;
}

.rpt-card-body {
  flex: 1;
  min-width: 0;
  padding: var(--space-4);
}

.rpt-card.is-flush .rpt-card-body {
  padding: var(--space-3) 0 0;
}

.rpt-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--color-primary);
  font: inherit;
  font-size: var(--type-xs, 12px);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.rpt-link:hover {
  text-decoration: underline;
}

.rpt-chart {
  position: relative;
  width: 100%;
}

.rpt-chart-missing,
.rpt-muted {
  color: var(--text-muted);
  font-size: var(--type-sm, 13px);
}

.rpt-empty {
  padding: var(--space-6) var(--space-4);
  text-align: center;
}

.rpt-empty-title {
  margin: 0;
  font-weight: 600;
  font-size: var(--type-sm, 13px);
}

.rpt-empty-text {
  margin: var(--space-1) 0 0;
  color: var(--text-muted);
  font-size: var(--type-sm, 13px);
}

/* ── Bar lists ──────────────────────────────────────────── */

.rpt-barlist {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rpt-barlist-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px var(--space-3);
  padding: 7px 8px;
  margin: 0 -8px;
  width: calc(100% + 16px);
  border: 0;
  border-radius: var(--radius-sm, 6px);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
}

.rpt-barlist-row.is-link {
  cursor: pointer;
}

.rpt-barlist-row.is-link:hover {
  background: var(--bg-hover);
}

.rpt-barlist-label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: var(--type-sm, 13px);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rpt-barlist-value {
  font-size: var(--type-sm, 13px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.rpt-barlist-note {
  margin-left: 6px;
  font-weight: 400;
  color: var(--text-muted);
  font-size: var(--type-xs, 12px);
}

.rpt-barlist-track {
  grid-column: 1 / -1;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  overflow: hidden;
}

.rpt-barlist-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
}

.rpt-dot {
  display: inline-block;
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

/* ── Segmented bar ──────────────────────────────────────── */

.rpt-seg {
  display: flex;
  gap: 2px;
  height: 14px;
  border-radius: 4px;
  overflow: hidden;
}

.rpt-seg-part {
  min-width: 3px;
}

.rpt-seg-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-6);
  margin: var(--space-4) 0 0;
  padding: 0;
  list-style: none;
}

.rpt-seg-legend li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--type-sm, 13px);
  min-width: 0;
}

.rpt-seg-label {
  color: var(--text-secondary);
}

.rpt-seg-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.rpt-seg-pct {
  color: var(--text-muted);
  font-size: var(--type-xs, 12px);
  font-variant-numeric: tabular-nums;
}

/* ── Ranked list (Overview) ─────────────────────────────── */

.rpt-ranked {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rpt-ranked li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 9px 0;
  border-bottom: 1px solid var(--rpt-line);
}

.rpt-ranked li:last-child {
  border-bottom: 0;
}

.rpt-rank {
  width: 16px;
  color: var(--text-muted);
  font-size: var(--type-xs, 12px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.rpt-ranked-who {
  flex: 1;
  min-width: 0;
}

.rpt-ranked-who .rpt-person {
  max-width: 100%;
}

.rpt-ranked-who .rpt-cell-sub {
  padding-left: 30px;
}

.rpt-ranked-value {
  font-size: var(--type-sm, 13px);
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Tables ─────────────────────────────────────────────── */

.rpt-table-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  flex-wrap: wrap;
  padding: 0 var(--space-4) var(--space-3);
}

.rpt-table-search {
  width: 240px;
  max-width: 100%;
}

.rpt-table-count {
  margin-left: auto;
  font-size: var(--type-xs, 12px);
  color: var(--text-muted);
  white-space: nowrap;
}

.rpt-table-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 4px 0 10px;
  border-radius: var(--radius-full, 999px);
  background: color-mix(in srgb, var(--color-primary) 10%, transparent);
  color: var(--color-primary);
  font-size: var(--type-xs, 12px);
  font-weight: 600;
}

.rpt-table-chip[hidden] {
  display: none;
}

.rpt-table-chip button {
  display: inline-flex;
  padding: 3px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: inherit;
  cursor: pointer;
}

.rpt-table-chip button:hover {
  background: color-mix(in srgb, var(--color-primary) 16%, transparent);
}

.rpt-table-export {
  position: relative;
}

.rpt-table-export .btn {
  gap: 6px;
}

.rpt-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 25;
  display: flex;
  flex-direction: column;
  min-width: 150px;
  padding: 4px;
  border: 1px solid var(--rpt-line);
  border-radius: var(--radius-md, 8px);
  background: var(--bg-elevated, var(--rpt-surface));
  box-shadow: var(--shadow-lg);
}

.rpt-menu[hidden] {
  display: none;
}

.rpt-menu button {
  padding: 7px 10px;
  border: 0;
  border-radius: var(--radius-sm, 6px);
  background: none;
  color: var(--text-primary);
  font: inherit;
  font-size: var(--type-sm, 13px);
  text-align: left;
  cursor: pointer;
}

.rpt-menu button:hover {
  background: var(--bg-hover);
}

.rpt-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.rpt-table table,
.rpt-mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--type-sm, 13px);
}

.rpt-table th,
.rpt-mini-table th {
  padding: 0;
  border-top: 1px solid var(--rpt-line);
  border-bottom: 1px solid var(--rpt-line);
  background: var(--bg-tertiary);
  font-size: var(--type-xs, 12px);
  font-weight: 600;
  color: var(--text-secondary);
  text-align: left;
  white-space: nowrap;
}

.rpt-mini-table th {
  padding: 8px 12px;
}

.rpt-table th button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: inherit;
  cursor: pointer;
}

.rpt-table th.is-num button {
  justify-content: flex-end;
}

.rpt-sort-icon {
  display: inline-flex;
  color: var(--text-muted);
  opacity: 0.5;
}

.rpt-table th.is-sorted .rpt-sort-icon,
.rpt-table th button:hover .rpt-sort-icon {
  opacity: 1;
}

.rpt-table th.is-sorted {
  color: var(--text-primary);
}

.rpt-table td,
.rpt-mini-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--rpt-line);
  background: var(--rpt-surface);
  vertical-align: top;
  white-space: nowrap;
}

/* Long text gets room to wrap; everything else stays on one line */
.rpt-table td.is-wrap {
  min-width: 180px;
  max-width: 340px;
  white-space: normal;
}

/* The first column stays put while a wide table scrolls sideways */
.rpt-table th:first-child,
.rpt-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
}

.rpt-table th:first-child {
  background: var(--bg-tertiary);
}

.rpt-table-scroll.is-scrolled td:first-child,
.rpt-table-scroll.is-scrolled th:first-child {
  box-shadow: 1px 0 0 var(--rpt-line);
}

.rpt-table th:first-child button,
.rpt-table td:first-child,
.rpt-mini-table th:first-child,
.rpt-mini-table td:first-child {
  padding-left: var(--space-4);
}

.rpt-table th:last-child button,
.rpt-table td:last-child,
.rpt-mini-table th:last-child,
.rpt-mini-table td:last-child {
  padding-right: var(--space-4);
}

.rpt-table tbody tr:last-child td,
.rpt-mini-table tbody tr:last-child td {
  border-bottom: 0;
}

.rpt-table .is-num,
.rpt-mini-table .is-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rpt-table tr.is-link,
.rpt-mini-table tr.is-link {
  cursor: pointer;
}

.rpt-table tr.is-link:hover td,
.rpt-mini-table tr.is-link:hover td {
  background: color-mix(in srgb, var(--text-primary) 3%, var(--rpt-surface));
}

.rpt-table tr.is-link:focus-visible,
.rpt-mini-table tr.is-link:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

.rpt-table tr.is-empty td {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--text-muted);
}

.rpt-table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--rpt-line);
  font-size: var(--type-xs, 12px);
  color: var(--text-muted);
}

.rpt-table-foot:empty {
  display: none;
}

.rpt-pager {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.rpt-pager .btn {
  width: 30px;
  padding: 0;
  justify-content: center;
}

.rpt-strong {
  font-weight: 600;
  color: var(--text-primary);
}

.rpt-cell-sub {
  display: block;
  margin-top: 1px;
  font-size: var(--type-xs, 12px);
  font-weight: 400;
  color: var(--text-muted);
}

.rpt-cell-delta {
  margin-left: 6px;
  font-size: var(--type-xs, 12px);
  font-weight: 600;
}

.rpt-cell-delta.is-good { color: var(--rpt-good); }
.rpt-cell-delta.is-bad { color: var(--rpt-bad); }

.rpt-notes {
  display: block;
  max-width: 320px;
  color: var(--text-secondary);
}

.rpt-warn { color: var(--rpt-warn); font-weight: 600; }
.rpt-bad { color: var(--rpt-bad); font-weight: 600; }

.rpt-person {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  white-space: nowrap;
}

.rpt-person > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.rpt-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
}

.rpt-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-xs, 4px);
  font-size: var(--type-xs, 12px);
  font-weight: 600;
  white-space: nowrap;
}

.rpt-badge.is-neutral { background: var(--bg-tertiary); color: var(--text-secondary); }
.rpt-badge.is-good { background: var(--rpt-good-bg); color: var(--rpt-good); }
.rpt-badge.is-bad { background: var(--rpt-bad-bg); color: var(--rpt-bad); }
.rpt-badge.is-warn { background: var(--rpt-warn-bg); color: var(--rpt-warn); }

.rpt-stage {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* ── Report builder ─────────────────────────────────────── */

.rpt-builder-bar {
  width: 100%;
}

.rpt-builder-bar .fb-actions .btn {
  gap: 6px;
}

.rpt-saved {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--rpt-line);
}

.rpt-saved-label {
  font-size: var(--type-xs, 12px);
  font-weight: 600;
  color: var(--text-muted);
}

.rpt-saved-chip {
  display: inline-flex;
  align-items: center;
  height: 28px;
  border: 1px solid var(--rpt-line);
  border-radius: var(--radius-full, 999px);
  overflow: hidden;
}

.rpt-saved-chip.is-active {
  border-color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 8%, transparent);
}

.rpt-saved-chip button {
  height: 100%;
  padding: 0 4px 0 12px;
  border: 0;
  background: none;
  color: var(--text-primary);
  font: inherit;
  font-size: var(--type-xs, 12px);
  font-weight: 500;
  cursor: pointer;
}

.rpt-saved-chip .rpt-saved-remove {
  display: inline-flex;
  align-items: center;
  padding: 0 8px 0 4px;
  color: var(--text-muted);
}

.rpt-saved-chip .rpt-saved-remove:hover {
  color: var(--rpt-bad);
}

/* ── Dialog, loading ────────────────────────────────────── */

.rpt-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: var(--space-5);
  border: 1px solid var(--rpt-line, var(--border-color));
  border-radius: var(--radius-lg, 10px);
  background: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: var(--shadow-xl);
}

.rpt-dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.rpt-dialog h2 {
  margin: 0;
  font-size: var(--type-lg, 16px);
  font-weight: 600;
}

.rpt-dialog p {
  margin: var(--space-1) 0 var(--space-4);
  font-size: var(--type-sm, 13px);
  color: var(--text-secondary);
}

.rpt-dialog input {
  width: 100%;
  height: var(--control-height-md, 36px);
  padding: 0 var(--space-3);
  border: 1px solid var(--border-color);
  border-radius: var(--btn-radius, 6px);
  background: var(--bg-primary);
  color: var(--text-primary);
  font: inherit;
  box-sizing: border-box;
}

.rpt-dialog input:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: -1px;
}

.rpt-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.rpt-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  min-height: 50vh;
  color: var(--text-muted);
  font-size: var(--type-sm, 13px);
}

.rpt-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--rpt-line, var(--border-color));
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: rpt-spin 0.8s linear infinite;
}

@keyframes rpt-spin {
  to { transform: rotate(360deg); }
}

/* ── Smaller screens ────────────────────────────────────── */

@media (max-width: 1279px) {
  .rpt-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rpt-grid-3 > .rpt-span-2 { grid-column: 1 / -1; }
}

@media (max-width: 1023px) {
  .rpt-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .rpt-nav {
    display: none;
  }

  .rpt-picker {
    display: block;
  }
}

@media (max-width: 768px) {
  .rpt-grid-2,
  .rpt-grid-3 {
    grid-template-columns: minmax(0, 1fr);
  }

  .rpt-span-2,
  .rpt-grid-3 > .rpt-span-2 {
    grid-column: auto;
  }

  .rpt-main {
    padding-top: var(--space-4);
  }

  .rpt-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
  }

  .rpt-kpi {
    padding: var(--space-3);
  }

  .rpt-kpi-value {
    font-size: 1.25rem;
  }

  .rpt-report-head {
    margin-bottom: var(--space-4);
  }

  .rpt-updated,
  #rpt-print {
    display: none;
  }

  .rpt-table-search {
    width: 100%;
  }

  .rpt-table-count {
    margin-left: 0;
  }

  .rpt-table-export {
    margin-left: auto;
  }

  .rpt-hint::after {
    left: auto;
    right: -8px;
    transform: none;
  }
}

/* ── Print / PDF ────────────────────────────────────────── */

@media print {
  .sidebar,
  .app-header,
  .bottom-nav,
  .rpt-top,
  .rpt-nav,
  .rpt-picker,
  .rpt-table-bar .fb-search,
  .rpt-table-export,
  .rpt-pager {
    display: none !important;
  }

  .rpt-layout {
    display: block;
  }

  .rpt-main {
    padding: 0 !important;
  }

  .main-content {
    margin: 0 !important;
    padding: 0 !important;
  }

  .rpt-card,
  .rpt-kpi {
    break-inside: avoid;
    box-shadow: none !important;
  }

  .rpt-grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .rpt-table-scroll {
    overflow: visible;
  }
}
