/*
  Rapporten — KPI's, omzetgrafiek, tabellen en export.
  Alleen rapportgerichte regels; gedeelde componenten komen uit components.css.
*/

.reports-view {
  --reports-chart-height: 220px;
  --reports-axis-width: 56px;
}

.reports-head__titles {
  min-width: 0;
}

.reports-head .page__subtitle {
  max-width: 56ch;
}

.reports-export {
  gap: var(--space-2);
}

.reports-export .ph {
  font-size: 18px;
}

/* ---------------------------------------------------------- Periodekeuze */

.reports-toolbar {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
  padding: var(--space-3);
}

.reports-toolbar__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-width: 0;
}

.reports-toolbar__period {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
}

.reports-toolbar__period .segmented {
  width: max-content;
  max-width: none;
}

.reports-toolbar__meta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-width: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

.reports-toolbar__meta .ph {
  flex: 0 0 auto;
  color: var(--accent);
}

.reports-toolbar__range {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reports-custom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: var(--line-thin) solid var(--line);
}

.reports-custom .field {
  min-width: 0;
}

.reports-custom__submit {
  min-width: 88px;
}

/* ----------------------------------------------------------------- KPI's */

.reports-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

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

.reports-kpi {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
  padding: var(--space-3);
}

.reports-kpi__label {
  display: flex;
  align-items: flex-start;
  gap: var(--space-1);
  min-height: 2.6em;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
}

.reports-kpi__label .ph {
  flex: 0 0 auto;
  margin-top: 1px;
  color: var(--accent);
  font-size: 16px;
}

.reports-kpi__value {
  color: var(--ink);
  font-size: clamp(17px, 4.8vw, 24px);
  font-weight: var(--weight-semibold);
  line-height: 1.15;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.reports-kpi__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px var(--space-2);
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
}

.reports-kpi__prev {
  min-width: 0;
}

.reports-kpi__delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}

.reports-kpi__delta .ph {
  font-size: 14px;
}

.reports-kpi__delta.is-up {
  color: var(--ok);
}

.reports-kpi__delta.is-down {
  color: var(--danger);
}

.reports-kpi__delta.is-muted {
  color: var(--muted);
}

/* ---------------------------------------------------------- Omzetgrafiek */

.reports-chart {
  min-width: 0;
  margin: 0;
  padding: var(--space-4);
}

.reports-chart__caption {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.reports-chart__heading {
  min-width: 0;
}

.reports-chart__title {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
}

.reports-chart__sub {
  margin: var(--space-1) 0 0;
  color: var(--muted);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

.reports-chart__legend {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--muted);
  font-size: var(--text-xs);
}

.reports-chart__legend .ph {
  color: var(--accent);
  font-size: 16px;
}

.reports-chart__frame {
  display: grid;
  grid-template-columns: var(--reports-axis-width) minmax(0, 1fr);
  gap: var(--space-2);
  min-width: 0;
}

.reports-chart__y {
  position: relative;
  height: var(--reports-chart-height);
  min-width: 0;
}

.reports-chart__y-label {
  position: absolute;
  right: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.reports-chart__y-label.is-top {
  top: 0;
}

.reports-chart__y-label.is-mid {
  top: 50%;
  transform: translateY(-50%);
}

.reports-chart__y-label.is-base {
  bottom: 0;
}

.reports-chart__area {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.reports-chart__plot {
  position: relative;
  height: var(--reports-chart-height);
  min-width: 0;
}

.reports-chart__grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.reports-chart__line {
  position: absolute;
  right: 0;
  left: 0;
  border-top: var(--line-thin) dashed var(--line);
}

.reports-chart__line.is-top {
  top: 0;
}

.reports-chart__line.is-mid {
  top: 50%;
}

.reports-chart__line.is-base {
  bottom: 0;
  border-top-style: solid;
}

.reports-chart__bars {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 100%;
  min-width: 0;
}

.reports-chart__col {
  display: flex;
  flex: 1 1 0;
  align-items: flex-end;
  min-width: 0;
  height: 100%;
}

.reports-chart__bar {
  position: relative;
  display: flex;
  align-items: flex-end;
  width: 100%;
  height: 100%;
  border-radius: 4px 4px 2px 2px;
  outline-offset: 2px;
}

.reports-chart__fill {
  display: block;
  width: 100%;
  height: var(--bar-height, 0%);
  min-height: 0;
  border-radius: 4px 4px 2px 2px;
  background: var(--accent);
  transition: opacity var(--dur-fast) linear;
}

.reports-chart__bar:hover .reports-chart__fill {
  opacity: 0.82;
}

.reports-chart__bar:focus-visible {
  outline: var(--focus-width) solid var(--focus-color);
}

.reports-chart__tip {
  position: absolute;
  bottom: calc(var(--bar-height, 0%) + 6px);
  left: 50%;
  z-index: var(--z-tooltip);
  padding: 4px 8px;
  border: var(--line-thin) solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-md);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition:
    opacity var(--dur-fast) linear,
    transform var(--dur-fast) var(--ease-out);
}

.reports-chart__col:first-child .reports-chart__tip {
  left: 0;
  transform: translate(0, 4px);
}

.reports-chart__col:last-child .reports-chart__tip {
  right: 0;
  left: auto;
  transform: translate(0, 4px);
}

.reports-chart__bar:hover .reports-chart__tip,
.reports-chart__bar:focus-visible .reports-chart__tip {
  opacity: 1;
}

.reports-chart__bar:hover .reports-chart__tip {
  transform: translate(-50%, 0);
}

.reports-chart__col:first-child .reports-chart__bar:hover .reports-chart__tip,
.reports-chart__col:last-child .reports-chart__bar:hover .reports-chart__tip {
  transform: translate(0, 0);
}

.reports-chart__bar:focus-visible .reports-chart__tip {
  transform: translate(-50%, 0);
}

.reports-chart__col:first-child .reports-chart__bar:focus-visible .reports-chart__tip,
.reports-chart__col:last-child .reports-chart__bar:focus-visible .reports-chart__tip {
  transform: translate(0, 0);
}

.reports-chart__xaxis {
  display: flex;
  gap: 2px;
  min-width: 0;
  padding-top: var(--space-1);
}

.reports-chart__x {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------- Tabellen */

.reports-tables {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-3);
  min-width: 0;
}

.reports-table-card {
  min-width: 0;
}

.reports-table-card .card__head {
  align-items: center;
  margin-bottom: var(--space-2);
}

.reports-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

.reports-table-wrap:focus-visible {
  outline: var(--focus-width) solid var(--focus-color);
  outline-offset: var(--focus-offset);
}

.reports-table {
  min-width: 400px;
}

.reports-table--services {
  min-width: 320px;
}

.reports-table th,
.reports-table td {
  white-space: nowrap;
}

.reports-table th:first-child,
.reports-table td:first-child {
  padding-left: 0;
}

.reports-table th:last-child,
.reports-table td:last-child {
  padding-right: 0;
}

.reports-table th.num,
.reports-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

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

.reports-table__name {
  color: var(--ink);
  font-weight: var(--weight-medium);
  text-align: left;
}

.reports-table__none {
  padding: var(--space-5) var(--space-3);
  color: var(--muted);
  text-align: center;
}

.reports-occ {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 132px;
}

.reports-occ__pct {
  min-width: 40px;
  color: var(--ink);
  text-align: right;
}

.reports-occ__bar {
  position: relative;
  flex: 1 1 auto;
  height: 6px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
}

.reports-occ__fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--ok);
}

/* ---------------------------------------------- Leeg, laden en fouten */

.reports-view .empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-7) var(--space-5);
  border: var(--line-thin) solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.reports-view .empty-state__icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--accent);
  font-size: 28px;
}

.reports-view .empty-state__title {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
}

.reports-view .empty-state__text {
  max-width: 40ch;
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.reports-view .error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-7) var(--space-5);
  border: var(--line-thin) solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.reports-view .error-state__icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--danger);
  font-size: 28px;
}

.reports-view .error-state__title {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

.reports-view .error-state__text {
  max-width: 40ch;
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.reports-view .loading {
  display: block;
  padding: var(--space-4);
  border: var(--line-thin) solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

/* -------------------------------------------------------- Responsief */

@media (max-width: 560px) {
  .reports-export {
    width: 100%;
  }

  .reports-custom {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .reports-custom__submit {
    grid-column: 1 / -1;
    width: 100%;
  }
}

@media (min-width: 640px) {
  .reports-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-3);
  }

  .reports-kpi {
    padding: var(--space-4);
  }

  .reports-kpi__label {
    min-height: auto;
  }
}

@media (min-width: 960px) {
  .reports-view {
    --reports-chart-height: 260px;
  }
}

@media (min-width: 1280px) {
  .reports-kpis {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .reports-tables {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .reports-chart__fill,
  .reports-chart__tip {
    transition: none;
  }
}
