/* Buitendienst — app-specific styles, loaded after nexus.css.
   Built only from --nx-* and --bs-* variables (Nexus design system rule):
   no hex values here. Brand colours, buttons, the app shell, cards, tables
   and the rest live in nexus.css; don't fork that file. */

/* ---- Shell: keep the offcanvas sidebar on the Nexus surface ------------ */
@media (max-width: 991.98px) {
  .admin-sidebar {
    --bs-offcanvas-width: var(--nx-sidebar-width);
    background: var(--bs-tertiary-bg);
  }
}

/* ---- Filter pills above lists (status filters) ------------------------- */
.filter-pills {
  --bs-nav-pills-border-radius: var(--nx-radius-nav);
  --bs-nav-link-padding-y: 0.375rem;
  --bs-nav-link-padding-x: 0.75rem;
  --bs-nav-link-color: var(--bs-secondary-color);
  --bs-nav-link-hover-color: var(--bs-body-color);
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.filter-pills .nav-link {
  font-size: 0.875rem;
  font-weight: 500;
}

.filter-pills .nav-link:not(.active):hover {
  background: var(--bs-secondary-bg);
}

/* ---- Clickable table rows --------------------------------------------- */
.admin-table tr[data-id] {
  cursor: pointer;
}

/* ---- Detail pages: label/value list inside a card ---------------------- */
.detail-list {
  margin: 0;
}

.detail-list dt {
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--bs-secondary-color);
}

.detail-list dd {
  margin-bottom: 0.75rem;
}

.detail-list dd:last-child {
  margin-bottom: 0;
}

/* Attention state for a stat card whose number needs action */
.stat-card--alert .icon-bubble {
  background: var(--bs-danger-bg-subtle);
  color: var(--bs-danger-text-emphasis);
}

/* ---- Day planning board (drag & drop columns) -------------------------- */
.plan-board {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  min-height: 200px;
  padding-bottom: 1rem;
  overflow-x: auto;
}

.plan-column {
  flex: 0 0 320px;
  width: 320px;
}

.plan-column--unassigned {
  flex-basis: 300px;
  width: 300px;
  background: var(--bs-tertiary-bg);
}

.plan-column .admin-card__header {
  flex-wrap: wrap;
}

.plan-column .list-group-item {
  padding: 0.625rem var(--nx-card-pad);
  background: transparent;
  border-color: var(--bs-border-color);
}

.plan-column .drop-zone {
  min-height: 90px;
  border-radius: 0 0 var(--nx-radius-card) var(--nx-radius-card);
}

/* Concept mode: cards, swap selection, unsaved-changes bar */
.plan-card {
  cursor: grab;
  border-left: 3px solid transparent;
}

.plan-card .min-w-0 {
  min-width: 0;
}

.plan-card.is-changed {
  border-left-color: var(--nx-primary);
  background: var(--nx-primary-subtle);
}

.plan-card.is-locked {
  cursor: not-allowed;
  background: var(--bs-tertiary-bg);
  color: var(--bs-secondary-color);
}

.plan-card--ghost {
  opacity: 0.4;
  outline: 1px dashed var(--nx-primary);
  outline-offset: -4px;
}

.plan-board.is-swap-mode .plan-card:not(.is-locked) {
  cursor: pointer;
}

.plan-board.is-swap-mode .plan-card:not(.is-locked):hover {
  background: var(--bs-secondary-bg);
}

.plan-card.is-selected,
.plan-board.is-swap-mode .plan-card.is-selected:hover {
  outline: 2px solid var(--nx-primary);
  outline-offset: -2px;
  background: var(--nx-primary-subtle);
}

.concept-bar {
  position: sticky;
  bottom: 1rem;
  z-index: 1020;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 0.75rem var(--nx-card-pad);
  border: 1px solid var(--nx-primary);
  border-radius: var(--nx-radius-card);
  background: var(--bs-body-bg);
  box-shadow: var(--bs-box-shadow);
}

.concept-bar > .bi {
  font-size: 1.25rem;
  color: var(--nx-primary);
}

.concept-bar__text {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}

.concept-bar__sub {
  font-size: 0.875rem;
  color: var(--bs-secondary-color);
}

@media (max-width: 575.98px) {
  .concept-bar {
    flex-wrap: wrap;
  }

  .concept-bar__text {
    flex-basis: calc(100% - 2rem);
  }
}

/* ---- Week board ---------------------------------------------------------- */
.week-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.week-sidebar {
  position: sticky;
  top: calc(var(--nx-navbar-height) + 1rem);
  max-height: calc(100vh - var(--nx-navbar-height) - 2rem);
  display: flex;
  flex-direction: column;
  background: var(--bs-tertiary-bg);
}

.week-sidebar__filters {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem var(--nx-card-pad);
  border-bottom: 1px solid var(--bs-border-color);
}

.week-sidebar__list {
  flex: 1 1 auto;
  min-height: 120px;
  overflow-y: auto;
}

.week-sidebar__list .list-group-item {
  padding: 0.5rem var(--nx-card-pad);
  background: transparent;
}

.week-board-wrap {
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.week-grid {
  display: grid;
  grid-template-columns: 150px repeat(7, minmax(150px, 1fr));
  gap: 1px;
  min-width: calc(150px + 7 * 150px);
  border: 1px solid var(--bs-border-color);
  border-radius: var(--nx-radius-card);
  background: var(--bs-border-color);
  overflow: hidden;
}

.week-grid > .empty-state {
  grid-column: 1 / -1;
  background: var(--bs-body-bg);
}

.week-grid__corner,
.week-grid__day,
.week-grid__tech {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bs-body-bg);
  font-size: 0.875rem;
}

.week-grid__corner,
.week-grid__day {
  font-weight: 600;
  background: var(--bs-tertiary-bg);
}

.week-grid__day {
  justify-content: space-between;
  color: inherit;
  text-decoration: none;
  text-transform: capitalize;
}

.week-grid__day-link {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.week-grid__day-link:hover {
  color: var(--nx-primary);
}

.week-grid__day.is-today {
  color: var(--nx-primary);
  box-shadow: inset 0 -2px 0 var(--nx-primary);
}

.week-grid__tech {
  position: sticky;
  left: 0;
  z-index: 1;
  font-weight: 600;
}

.week-cell {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  min-height: 110px;
  padding: 0.5rem;
  background: var(--bs-body-bg);
}

.week-cell.is-today {
  background: var(--nx-surface-muted);
}

.week-cell.is-changed {
  box-shadow: inset 0 0 0 2px var(--nx-primary);
}

.week-cell__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
}

.week-cell__hours {
  color: var(--bs-secondary-color);
  white-space: nowrap;
}

.week-cell__stops {
  flex: 1 1 auto;
  min-height: 48px;
  border-radius: var(--nx-radius-control);
}

.week-chip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.375rem;
  margin-bottom: 2px;
  border: 1px solid var(--bs-border-color);
  border-left-width: 3px;
  border-radius: var(--nx-radius-control);
  font-size: 0.75rem;
  background: var(--bs-body-bg);
}

.week-chip.is-changed {
  border-left-color: var(--nx-primary);
}

.week-chip__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.week-grid.is-swap-mode .plan-card:not(.is-locked),
.week-sidebar__list.is-swap-mode .plan-card {
  cursor: pointer;
}

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

  .week-sidebar {
    position: static;
    max-height: 360px;
  }
}

/* ---- Route map --------------------------------------------------------- */
.route-map {
  height: 420px;
  border-radius: var(--nx-radius-card);
  overflow: hidden;
}

.map-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 2px solid var(--nx-on-primary);
  border-radius: 50%;
  background: var(--nx-primary);
  color: var(--nx-on-primary);
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--bs-box-shadow-sm);
}

.map-pin--depot {
  border-radius: var(--nx-radius-control);
  background: var(--nx-ink);
  color: var(--nx-surface);
  border-color: var(--nx-surface);
}

/* Map tiles are always light: these pins use fixed colours, not theme tokens. */
.map-pin--unassigned {
  background: #ffffff;
  color: #475569;
  border: 2px dashed #64748b;
}

.map-pin.is-muted {
  opacity: 0.45;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  border-top: 1px solid var(--bs-border-color);
}

.map-legend:empty {
  display: none;
}

.map-legend__swatch {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  margin-right: 0.35rem;
  border-radius: 50%;
  vertical-align: -1px;
}

/* ---- Live tracking ------------------------------------------------------- */
.live-map {
  height: 320px;
}

/* Tracking: Live / Geschiedenis switch in the page header. */
.tracking-tabs .nav-link {
  padding: 0.3rem 0.8rem;
}

/* ---- Location history ---------------------------------------------------- */
.history-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  padding: 0.875rem 1rem;
  margin-bottom: 1rem;
}

.history-filters__field {
  flex: 1 1 220px;
  max-width: 360px;
}

.history-filters__hint {
  flex: 1 1 100%;
}

.history-scrub {
  border-top: 1px solid var(--bs-border-color);
  font-variant-numeric: tabular-nums;
}

.map-legend__swatch--dashed {
  width: 1.1rem;
  height: 0;
  border-radius: 0;
  border-top: 3px dashed #64748b;
  vertical-align: 3px;
}

.history-pin {
  width: 24px;
  height: 24px;
  font-size: 12px;
  border-color: #ffffff;
}

/* Map tiles are always light: fixed colours, not theme tokens. */
.history-pin--start { background: #1baf7a; color: #1a1a19; }
.history-pin--end { background: #1a1a19; color: #ffffff; }
.history-pin--stop { background: #2a78d6; color: #ffffff; }
.history-pin--speeding { background: #e34948; color: #ffffff; }

.history-events {
  max-height: min(60vh, 560px);
  overflow-y: auto;
}

.history-event {
  cursor: pointer;
}

.history-event:hover,
.history-event:focus-visible {
  background: var(--bs-secondary-bg);
  outline: none;
}

.history-event__icon {
  width: 1.25rem;
  flex: none;
  text-align: center;
}

/* ---- Werkbon on the task page ------------------------------------------ */
.workorder-text {
  white-space: pre-wrap;
}

.workorder-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem;
}

.workorder-photo img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid var(--bs-border-color);
  border-radius: var(--nx-radius-control);
}

.workorder-signature {
  display: block;
  width: 100%;
  max-width: 320px;
  height: auto;
  padding: 0.25rem;
  border: 1px solid var(--bs-border-color);
  border-radius: var(--nx-radius-control);
  background: #fff;
  color: #111;
}

/* "Monteurs live": map and list side by side, stacked on narrow screens. */
.live-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

@media (min-width: 992px) {
  .live-layout {
    grid-template-columns: minmax(0, 3fr) minmax(320px, 2fr);
    align-items: start;
  }
}

.live-layout__map {
  overflow: hidden;
}

.live-map--tall {
  height: min(70vh, 640px);
  min-height: 320px;
}

.live-row {
  cursor: pointer;
}

.live-row:hover,
.live-row:focus-visible {
  background: var(--bs-secondary-bg);
  outline: none;
}

/* Live tech position: truck + initial, larger than stop pins, on top. */
.live-pin {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: #0284c7;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.live-pin .bi {
  font-size: 13px;
}

.live-pin.is-stale {
  background: #64748b;
  opacity: 0.8;
}

/* ---- Tracking dashboard -------------------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.kpi-tile {
  padding: 0.875rem 1rem;
}

.kpi-tile__label {
  font-size: 0.8125rem;
  color: var(--bs-secondary-color);
}

.kpi-tile__value {
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.kpi-tile__sub {
  font-size: 0.8125rem;
  color: var(--bs-secondary-color);
}

.route-progress {
  height: 6px;
  border-radius: 3px;
  background: var(--bs-secondary-bg);
  overflow: hidden;
  min-width: 80px;
}

.route-progress__bar {
  height: 100%;
  border-radius: 3px;
}

.tech-swatch {
  display: inline-block;
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  flex: none;
}

.live-seen {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--bs-info-text-emphasis);
}

.live-seen.is-stale {
  color: var(--bs-secondary-color);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bs-info);
}

.live-seen.is-stale .live-dot {
  background: var(--bs-secondary);
}

@media (prefers-reduced-motion: no-preference) {
  .live-seen:not(.is-stale) .live-dot {
    animation: live-pulse 2s ease-in-out infinite;
  }
}

@keyframes live-pulse {
  50% {
    opacity: 0.35;
  }
}

/* ---- Email template editor -------------------------------------------- */
.preview-box {
  padding: 0.75rem;
  border: 1px solid var(--bs-border-color);
  border-radius: var(--nx-radius-nav);
  background: var(--bs-tertiary-bg);
  font-size: 0.875rem;
}

.preview-box pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
}

/* ---- Error pages ------------------------------------------------------- */
.error-code {
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1;
  color: var(--bs-secondary-color);
}

.error-trace {
  max-width: 640px;
  overflow: auto;
  text-align: left;
}

/* Whole row is a link (via .stretched-link in a cell) */
.admin-table tr.row-link {
  position: relative;
}

/* ---- Modals: same shape as cards; footer is a Nexus form footer -------- */
.modal {
  --bs-modal-border-radius: var(--nx-radius-card);
  --bs-modal-inner-border-radius: calc(var(--nx-radius-card) - 1px);
  --bs-modal-border-color: var(--bs-border-color);
  --bs-modal-header-border-color: var(--bs-border-color);
}

.modal-header .modal-title {
  font-size: 1rem;
  font-weight: 600;
}

.modal-footer.form-footer {
  justify-content: flex-start;
  border-radius: 0 0 var(--bs-modal-inner-border-radius) var(--bs-modal-inner-border-radius);
}

.modal-footer.form-footer > * {
  margin: 0;
}

/* ---- Settings page (/admin/settings) ----------------------------------- */
.settings-layout {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.settings-nav {
  position: sticky;
  top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.5rem;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: var(--nx-radius-card);
}

.settings-nav__group {
  margin: 0.75rem 0.5rem 0.25rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bs-secondary-color);
}

.settings-nav__group:first-child {
  margin-top: 0.25rem;
}

.settings-nav__link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border-radius: var(--nx-radius-nav);
  color: var(--bs-body-color);
  font-size: 0.9rem;
  text-decoration: none;
}

.settings-nav__link:hover {
  background: var(--bs-secondary-bg);
  color: var(--bs-body-color);
}

.settings-nav__link.active {
  background: var(--nx-primary-subtle);
  color: var(--nx-primary-text);
  font-weight: 600;
}

.settings-nav__link .bi {
  width: 1.1rem;
  text-align: center;
  opacity: 0.8;
}

.settings-nav__label {
  flex: 1;
  min-width: 0;
}

/* Unsaved marker + status dot, filled in by admin-settings.js */
.settings-nav__state {
  display: contents;
}

/* Buttons beside the title of a Beheer page (Taaktypes, Rollen, …) */
.settings-section__actions {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
}

/* Status dot per section: configured / incomplete / off / error */
.settings-dot {
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--bs-border-color);
}

.settings-dot--ok { background: var(--bs-success); }
.settings-dot--warn { background: var(--bs-warning); }
.settings-dot--error { background: var(--bs-danger); }

.settings-dirty {
  flex: none;
  font-size: 0.7rem;
  color: var(--nx-primary);
}

.settings-section__head {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.settings-section__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.settings-section__lead {
  margin: 0.15rem 0 0;
  color: var(--bs-secondary-color);
}

.settings-section__status {
  margin-left: auto;
  white-space: nowrap;
}

.settings-fields {
  padding: var(--nx-card-pad);
  display: grid;
  gap: 1.25rem;
}

.settings-field__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.settings-field__top .form-label {
  margin: 0;
  font-weight: 500;
}

.settings-field__meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  white-space: nowrap;
}

.settings-field__help {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--bs-secondary-color);
}

.settings-source {
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--bs-border-color);
  color: var(--bs-secondary-color);
}

.settings-source--env {
  border-color: var(--bs-warning-border-subtle);
  background: var(--bs-warning-bg-subtle);
  color: var(--bs-warning-text-emphasis);
}

.settings-secret {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: calc(1.5em + 0.75rem + 2px);
}

.settings-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem var(--nx-card-pad);
  border-top: 1px solid var(--bs-border-color);
  background: var(--bs-tertiary-bg);
  border-radius: 0 0 var(--nx-radius-card) var(--nx-radius-card);
}

.settings-result {
  flex-basis: 100%;
  font-size: 0.875rem;
}

.settings-result:empty {
  display: none;
}

.settings-block {
  padding: var(--nx-card-pad);
  border-top: 1px solid var(--bs-border-color);
}

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

  /* The section menu becomes a scrollable strip above the content. */
  .settings-nav {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .settings-nav__group {
    display: none;
  }

  .settings-nav__link {
    flex: none;
    white-space: nowrap;
  }

  .settings-section__head {
    flex-wrap: wrap;
  }

  .settings-section__status,
  .settings-section__actions {
    margin-left: 0;
  }
}

/* ---- Overview (dashboard.ejs) ------------------------------------------- */
.dash-eyebrow {
  margin-bottom: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--nx-primary-text);
}

/* Work pipeline: one card, stages side by side, chevrons on the dividers. */
.dash-flow {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
}

.dash-flow__stage {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: var(--nx-card-pad);
  border-left: 1px solid var(--bs-border-color);
  color: inherit;
  text-decoration: none;
  transition: background-color 0.12s ease;
}

.dash-flow__stage:first-child {
  border-left: 0;
  border-bottom-left-radius: var(--nx-radius-card);
}

.dash-flow__stage:last-child {
  border-bottom-right-radius: var(--nx-radius-card);
}

.dash-flow__stage:hover {
  background: var(--bs-tertiary-bg);
  color: inherit;
}

/* Bottom edge in the brand colour when a stage has work waiting. */
.dash-flow__stage.is-busy::after {
  content: "";
  position: absolute;
  right: var(--nx-card-pad);
  bottom: 0;
  left: var(--nx-card-pad);
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--nx-primary);
}

.dash-flow__step {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--bs-secondary-color);
}

.dash-flow__stage.is-busy .dash-flow__step {
  color: var(--nx-primary-text);
}

.dash-flow__value {
  font-size: 2.25rem;
  font-variant-numeric: tabular-nums;
}

.dash-flow__stage:not(.is-busy) .dash-flow__value {
  color: var(--bs-secondary-color);
}

.dash-flow__arrow {
  position: absolute;
  top: 50%;
  left: 0;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 50%;
  background: var(--bs-body-bg);
  color: var(--bs-secondary-color);
  font-size: 0.7rem;
  transform: translate(-50%, -50%);
}

@media (max-width: 767.98px) {
  .dash-flow {
    grid-auto-flow: row;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dash-flow__stage {
    border-top: 1px solid var(--bs-border-color);
    border-radius: 0 !important;
  }

  .dash-flow__stage:nth-child(odd) {
    border-left: 0;
  }

  .dash-flow__stage:nth-child(-n + 2) {
    border-top: 0;
  }

  .dash-flow__arrow {
    display: none;
  }
}

.dash-alert:hover {
  filter: brightness(0.97);
}

/* Feed rows that link somewhere */
.dash-feed li {
  position: relative;
}

.dash-feed li:hover {
  background: var(--bs-tertiary-bg);
}

.dash-feed li:last-child {
  border-radius: 0 0 var(--nx-radius-card) var(--nx-radius-card);
}

.dash-feed__note {
  overflow-wrap: anywhere;
}

.dash-progress {
  --bs-progress-height: 0.5rem;
  --bs-progress-bg: var(--bs-secondary-bg);
  --bs-progress-bar-bg: var(--nx-primary);
  --bs-progress-border-radius: 999px;
}

.dash-progress--sm {
  --bs-progress-height: 0.3125rem;
}

/* Shortcuts: Nexus app tiles in a two-column grid */
.dash-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.dash-tile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  padding: 0.875rem 1rem;
  color: inherit;
  text-decoration: none;
}

.dash-tile:hover {
  color: inherit;
}

.dash-tile .stat-card__label {
  font-size: 0.8125rem;
  line-height: 1.35;
}

.dash-tile .app-tile__icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  border-radius: var(--nx-radius-icon);
  font-size: 1.15rem;
}

@media (max-width: 575.98px) {
  .dash-tiles {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-tile:hover {
    transform: none;
  }
}

/* ---- Nieuwe servicetaak (task-new.ejs): steps, week tiles, summary ------- */
.min-w-0 {
  min-width: 0;
}

.wizard-steps {
  display: flex;
  gap: 0.5rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
  counter-reset: none;
}

.wizard-steps li {
  position: relative;
  display: flex;
  flex: 1 1 0;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--bs-border-color);
  border-radius: var(--nx-radius-nav);
  background: var(--bs-body-bg);
  color: var(--bs-secondary-color);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
}

.wizard-steps li:hover {
  background: var(--bs-tertiary-bg);
}

.wizard-steps__num {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--bs-secondary-bg);
  font-size: 0.8rem;
  font-weight: 700;
}

.wizard-steps__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wizard-steps li.is-active {
  border-color: var(--nx-primary);
  color: var(--bs-emphasis-color);
  box-shadow: inset 0 -2px 0 var(--nx-primary);
}

.wizard-steps li.is-active .wizard-steps__num {
  background: var(--nx-primary);
  color: var(--nx-on-primary);
}

.wizard-steps li.is-done {
  color: var(--bs-body-color);
}

.wizard-steps li.is-done .wizard-steps__num {
  background: var(--nx-primary-subtle);
  color: var(--nx-primary-text);
}

@media (max-width: 575.98px) {
  .wizard-steps li {
    justify-content: center;
    padding: 0.5rem 0.25rem;
  }

  .wizard-steps li:not(.is-active) .wizard-steps__label {
    display: none;
  }
}

.wizard .form-footer {
  flex-wrap: wrap;
}

/* Week tiles: the coming weeks as one-click choices */
.week-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.5rem;
}

.week-tile {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.week-tile:has(input:focus-visible) {
  outline: 2px solid var(--nx-primary);
  outline-offset: 2px;
}

.week-tile__when {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bs-secondary-color);
}

.week-tile__num {
  font-size: 1.1rem;
  font-weight: 700;
}

.week-tile__range {
  font-size: 0.85rem;
  color: var(--bs-secondary-color);
}

.week-tile:has(input:checked) .week-tile__when {
  color: var(--nx-primary-text);
}

/* Summary before sending */
.summary {
  margin: 0 0 1rem;
}

.summary-row {
  display: grid;
  grid-template-columns: 8rem minmax(0, 1fr) auto;
  gap: 0.25rem 1rem;
  align-items: start;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--bs-border-color);
}

.summary-row:first-child {
  padding-top: 0;
}

.summary-row dt {
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--bs-secondary-color);
}

.summary-row dd {
  margin: 0;
}

@media (max-width: 575.98px) {
  .summary-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .summary-row dd {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}


/* ---- Servicetaken workspace (tasks.ejs) -------------------------------- */
/* KPI tiles double as quick filters. */
.task-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.task-kpi {
  width: 100%;
  padding: 0.875rem 1rem;
  text-align: left;
  cursor: pointer;
}

.task-kpi > span:last-child {
  display: flex;
  flex-direction: column;
}

.task-kpi .stat-card__value {
  font-variant-numeric: tabular-nums;
}

.task-kpi:hover {
  border-color: var(--nx-primary-border-subtle);
  transform: translateY(-1px);
}

.task-kpi:focus-visible {
  outline: 2px solid var(--nx-primary);
  outline-offset: 2px;
}

.task-kpi.is-active {
  border-color: var(--nx-primary);
  box-shadow: inset 0 0 0 1px var(--nx-primary);
}

.task-kpi--alert:not(.is-quiet) .icon-bubble {
  background: var(--bs-danger-bg-subtle);
  color: var(--bs-danger-text-emphasis);
}

.task-kpi--alert:not(.is-quiet) .stat-card__value {
  color: var(--bs-danger-text-emphasis);
}

/* Toolbar */
.task-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.task-search {
  position: relative;
  flex: 1 1 320px;
  min-width: 0;
}

.task-search > .bi {
  position: absolute;
  top: 50%;
  left: 0.75rem;
  transform: translateY(-50%);
  color: var(--bs-secondary-color);
  pointer-events: none;
}

.task-search .form-control {
  padding-left: 2.25rem;
  padding-right: 2.25rem;
}

.task-search__kbd {
  position: absolute;
  top: 50%;
  right: 0.625rem;
  transform: translateY(-50%);
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--bs-border-color);
  border-radius: var(--nx-radius-control);
  background: var(--bs-tertiary-bg);
  color: var(--bs-secondary-color);
  font-size: 0.75rem;
  pointer-events: none;
}

.task-search .form-control:focus ~ .task-search__kbd,
.task-search .form-control:not(:placeholder-shown) ~ .task-search__kbd {
  display: none;
}

.task-toolbar__select {
  flex: 0 1 190px;
  width: auto;
}

.task-view-switch .btn.active {
  background: var(--bs-secondary-bg);
  color: var(--bs-emphasis-color);
  border-color: var(--bs-border-color);
}

.filter-count {
  margin-left: 0.25rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--bs-secondary-bg);
  color: var(--bs-secondary-color);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.filter-count:empty {
  display: none;
}

.filter-pills .nav-link.active .filter-count {
  background: rgba(255, 255, 255, 0.22);
  color: var(--nx-on-primary);
}

/* Split layout: list and map share the viewport height. */
.task-workspace {
  display: grid;
  grid-template-columns: minmax(360px, 5fr) minmax(0, 7fr);
  gap: 1rem;
  height: max(520px, calc(100vh - var(--nx-navbar-height) - 2rem));
}

.task-workspace[data-view="list"] {
  grid-template-columns: minmax(0, 1fr);
  height: auto;
}

.task-workspace[data-view="list"] .task-map-card {
  display: none;
}

.task-workspace[data-view="list"] .task-list {
  overflow: visible;
}

.task-workspace[data-view="map"] {
  grid-template-columns: minmax(0, 1fr);
}

.task-workspace[data-view="map"] .task-list-card {
  display: none;
}

.task-list-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.task-list-card__header {
  font-weight: 500;
  font-size: 0.9rem;
}

.task-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  outline: none;
}

.task-group__header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem var(--nx-card-pad);
  background: var(--bs-tertiary-bg);
  border-bottom: 1px solid var(--bs-border-color);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bs-secondary-color);
}

.task-group__count {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.task-group--attention .task-group__header,
.task-group--overdue .task-group__header {
  color: var(--bs-danger-text-emphasis);
}

.task-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 2.25rem 0.75rem var(--nx-card-pad);
  border-bottom: 1px solid var(--bs-border-color);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background-color 0.1s ease;
}

.task-item:hover,
.task-item.is-hover {
  background: var(--bs-tertiary-bg);
}

.task-item.is-selected {
  border-left-color: var(--nx-primary);
  background: var(--nx-primary-subtle);
}

.task-item__dot {
  flex: none;
  width: 0.625rem;
  height: 0.625rem;
  margin-top: 0.4rem;
  border-radius: 50%;
}

.task-item__main {
  flex: 1 1 auto;
  min-width: 0;
}

.task-item__title {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  min-width: 0;
  font-weight: 600;
}

.task-item__meta {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  min-width: 0;
  margin-top: 0.125rem;
  font-size: 0.8125rem;
  color: var(--bs-secondary-color);
}

.task-item__meta .bi-geo-alt {
  margin-right: 0.25rem;
}

.task-item__desc {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 0.125rem;
  font-size: 0.8125rem;
  color: var(--bs-secondary-color);
}

.task-item__side {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  font-size: 0.8125rem;
  text-align: right;
}

.task-item__when,
.task-item__tech {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  white-space: nowrap;
}

.task-item__when {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.task-item__when .bi,
.task-item__tech {
  color: var(--bs-secondary-color);
}

.task-item__open {
  position: absolute;
  top: 50%;
  right: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--nx-radius-control);
  transform: translateY(-50%);
  color: var(--bs-secondary-color);
}

.task-item__open:hover,
.task-item__open:focus-visible {
  background: var(--nx-primary);
  color: var(--nx-on-primary);
}

/* List-only view on wider screens: side column becomes a row. */
@media (min-width: 768px) {
  .task-workspace[data-view="list"] .task-item {
    align-items: center;
  }

  .task-workspace[data-view="list"] .task-item__side {
    flex-direction: row;
    align-items: center;
    gap: 1.25rem;
  }

  .task-workspace[data-view="list"] .task-item__desc {
    -webkit-line-clamp: 2;
  }
}

/* Map card with floating controls */
.task-map-card {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.task-map {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.task-map__overlay {
  position: absolute;
  z-index: 500;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  pointer-events: none;
}

.task-map__overlay > * {
  pointer-events: auto;
}

.task-map__overlay--top {
  top: 0.75rem;
  left: 0.75rem;
  right: 3.75rem;
}

.task-map__overlay--right {
  top: 5.75rem;
  right: 10px;
  flex-direction: column;
  gap: 0.375rem;
}

.task-map__overlay--bottom {
  left: 0.75rem;
  right: 0.75rem;
  bottom: 1.5rem;
  align-items: flex-end;
}

.task-map__chip,
.task-map__btn,
.task-map__legend {
  border: 1px solid var(--bs-border-color);
  border-radius: var(--nx-radius-nav);
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  box-shadow: var(--bs-box-shadow-sm);
  font-size: 0.8125rem;
}

.task-map__chip.form-switch {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem 0.375rem 2.75rem;
}

.task-map__chip .btn {
  --bs-btn-padding-y: 0.3rem;
  --bs-btn-padding-x: 0.65rem;
  --bs-btn-font-size: 0.8125rem;
  border: 0;
  color: var(--bs-secondary-color);
}

.task-map__chip .btn.active {
  background: var(--nx-primary);
  color: var(--nx-on-primary);
}

.task-map__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
}

.task-map__btn:hover {
  background: var(--bs-secondary-bg);
}

.task-map__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.125rem;
  max-width: 100%;
  padding: 0.25rem;
}

.task-map__legend:empty {
  display: none;
}

.task-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.2rem 0.5rem;
  border: 0;
  border-radius: var(--nx-radius-control);
  background: transparent;
  color: inherit;
  font-size: 0.8125rem;
}

.task-legend__item:hover {
  background: var(--bs-secondary-bg);
}

.task-legend__item.is-active {
  background: var(--nx-primary-subtle);
  color: var(--nx-primary-text);
}

.task-legend__swatch {
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
}

.task-legend__swatch.is-unassigned {
  border: 1.5px dashed var(--bs-secondary-color);
}

.task-legend__n {
  color: var(--bs-secondary-color);
  font-variant-numeric: tabular-nums;
}

.task-map__nogeo {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-left: auto;
  padding: 0.3rem 0.65rem;
  color: var(--bs-warning-text-emphasis);
}

.task-map__nogeo.is-active {
  border-color: var(--bs-warning-border-subtle);
  background: var(--bs-warning-bg-subtle);
}

/* Pins and clusters. Map tiles are always light: fixed white ring/centre. */
.task-pin {
  width: 28px;
  height: 28px;
  font-size: 13px;
  transition: transform 0.12s ease;
}

.task-pin.has-flag {
  box-shadow: 0 0 0 3px rgba(227, 73, 72, 0.45), var(--bs-box-shadow-sm);
}

.leaflet-marker-icon.is-hover .task-pin,
.task-pin.is-selected {
  transform: scale(1.3);
}

.task-pin.is-selected {
  box-shadow: 0 0 0 3px var(--nx-primary), 0 2px 8px rgba(0, 0, 0, 0.35);
}

.task-cluster {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: transform 0.12s ease;
}

.task-cluster > span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(100% - 10px);
  height: calc(100% - 10px);
  border-radius: 50%;
  background: #ffffff;
  color: #1a1a19;
  font-size: 13px;
  font-weight: 700;
}

.task-cluster:hover,
.leaflet-marker-icon.is-hover .task-cluster,
.task-cluster.is-selected {
  transform: scale(1.12);
}

.task-cluster.is-selected {
  box-shadow: 0 0 0 3px var(--nx-primary), 0 1px 4px rgba(0, 0, 0, 0.35);
}

/* Popup and tooltips follow the page theme. */
.task-map-card .leaflet-popup-content-wrapper,
.task-map-card .leaflet-popup-tip,
.task-map-card .leaflet-tooltip {
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  border-color: var(--bs-border-color);
}

.task-map-card .leaflet-popup-content-wrapper {
  border-radius: var(--nx-radius-card);
}

.task-map-card .leaflet-popup-content {
  margin: 0.875rem 1rem;
  font-size: 0.875rem;
  line-height: 1.4;
}

.task-popup__head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.375rem;
}

.task-popup__title {
  margin-bottom: 0.375rem;
  font-size: 1rem;
  font-weight: 600;
}

.task-popup__row {
  display: flex;
  gap: 0.5rem;
  color: var(--bs-secondary-color);
}

.task-popup__desc {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--bs-border-color);
}

.task-popup__actions {
  display: flex;
  gap: 0.375rem;
  margin-top: 0.75rem;
}

.task-popup__actions .btn-primary {
  color: var(--nx-on-primary);
}

/* Narrow screens: list stacked under a shorter map. */
@media (max-width: 991.98px) {
  .task-workspace,
  .task-workspace[data-view="map"] {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
  }

  .task-workspace[data-view="split"] .task-map-card {
    order: -1;
    height: 320px;
  }

  .task-workspace[data-view="map"] .task-map-card {
    height: calc(100vh - var(--nx-navbar-height) - 2rem);
  }

  .task-list {
    overflow: visible;
  }

  .task-list-card {
    overflow: visible;
  }

  .task-group__header {
    top: var(--nx-navbar-height);
  }

  .task-toolbar__select {
    flex: 1 1 140px;
  }
}

@media (max-width: 575.98px) {
  .task-item {
    flex-wrap: wrap;
  }

  .task-item__side {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
    padding-left: 1.375rem;
  }

  .task-map__overlay--top {
    right: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .task-pin,
  .task-cluster,
  .task-item {
    transition: none;
  }
}

/* ---- Task types: chips, pickers, admin --------------------------------- */
/* Type colours come from a fixed palette (src/models/taskType.js) and only
   ever colour a mark (dot, icon tile, bar) — text stays in text tokens. */
.type-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 999px;
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}

.type-chip .bi {
  color: var(--bs-secondary-color);
}

.type-chip--none {
  border-style: dashed;
  color: var(--bs-secondary-color);
}

.type-chip--button {
  cursor: pointer;
  font-size: 0.8125rem;
  padding: 0.2rem 0.65rem;
}

.type-chip--button:hover,
.type-chip--button[aria-expanded="true"] {
  border-color: var(--nx-primary-border-subtle);
  background: var(--bs-tertiary-bg);
}

.type-chip__dot {
  display: inline-block;
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: 0.15rem;
  border-radius: 50%;
}

.type-chip__icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--nx-radius-control);
  color: #ffffff;
  font-size: 0.9rem;
}

.task-item__type {
  margin-top: 0.25rem;
}

/* Approve dialog: pick a type from tiles */
.type-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.5rem;
}

.type-choice {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--bs-border-color);
  border-radius: var(--nx-radius-nav);
  cursor: pointer;
  font-size: 0.875rem;
}

.type-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.type-choice:hover {
  border-color: var(--nx-primary-border-subtle);
}

.type-choice:has(input:checked) {
  border-color: var(--nx-primary);
  background: var(--nx-primary-subtle);
}

.type-choice:has(input:focus-visible) {
  outline: 2px solid var(--nx-primary);
  outline-offset: 2px;
}

/* Admin: colour picker and archived rows */
.type-swatch {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
}

.type-color-grid {
  display: grid;
  grid-template-columns: repeat(5, 28px);
  gap: 0.375rem;
}

.type-color {
  width: 28px;
  height: 28px;
  border: 2px solid var(--bs-body-bg);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--bs-border-color);
}

.type-color.is-active,
.type-color:hover {
  box-shadow: 0 0 0 2px var(--nx-primary);
}

.type-name-input {
  min-width: 180px;
}

.admin-table tr.is-archived td {
  color: var(--bs-secondary-color);
  background: var(--bs-tertiary-bg);
}

.admin-table tr.is-archived .type-chip__icon {
  opacity: 0.5;
}

/* ---- Statistieken ------------------------------------------------------ */
.stats-filters {
  position: sticky;
  top: var(--nx-navbar-height);
  z-index: 1010;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: -0.5rem 0 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg);
}

.stats-filters__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.stats-period .btn {
  --bs-btn-padding-y: 0.25rem;
  --bs-btn-padding-x: 0.65rem;
  --bs-btn-font-size: 0.8125rem;
}

.stats-period .btn.active {
  background: var(--nx-primary);
  border-color: var(--nx-primary);
  color: var(--nx-on-primary);
}

.stats-custom {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.stats-custom .form-control {
  width: 150px;
}

.stats-filters__select {
  width: auto;
  min-width: 170px;
}

.stats-type-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.stats-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.65rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 999px;
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  font-size: 0.8125rem;
}

.stats-chip .bi {
  color: var(--bs-secondary-color);
}

.stats-chip:hover {
  background: var(--bs-tertiary-bg);
}

.stats-chip.is-active {
  border-color: var(--nx-primary);
  background: var(--nx-primary-subtle);
  color: var(--nx-primary-text);
}

.stats-range:empty {
  display: none;
}

.stats-body {
  transition: opacity 0.15s ease;
}

.stats-body.is-loading {
  opacity: 0.55;
  pointer-events: none;
}

.stats-kpis {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.stats-kpi {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  color: inherit;
  text-decoration: none;
}

a.stats-kpi:hover {
  border-color: var(--nx-primary);
}

.stats-delta {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--bs-secondary-color);
}

.stats-delta.is-good {
  color: var(--bs-success-text-emphasis);
}

.stats-delta.is-bad {
  color: var(--bs-danger-text-emphasis);
}

.stats-delta.is-good .text-body-secondary,
.stats-delta.is-bad .text-body-secondary {
  font-weight: 400;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1rem;
}

.stats-span-4 { grid-column: span 4; }
.stats-span-6 { grid-column: span 6; }
.stats-span-8 { grid-column: span 8; }
.stats-span-12 { grid-column: span 12; }

@media (max-width: 1199.98px) {
  .stats-span-4,
  .stats-span-8 {
    grid-column: span 12;
  }
}

@media (max-width: 767.98px) {
  .stats-span-6 {
    grid-column: span 12;
  }

  .stats-filters {
    position: static;
  }
}

.stats-grid > .admin-card {
  min-width: 0;
}

/* Legend: rect swatches for bars, a line for the comparison line. */
.stats-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  margin-bottom: 0.5rem;
}

.stats-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.125rem 0.25rem;
  border: 0;
  border-radius: var(--nx-radius-control);
  background: none;
  color: var(--bs-body-color);
  font-size: 0.8125rem;
}

button.stats-legend__item:hover {
  background: var(--bs-secondary-bg);
}

.stats-legend__item.is-static {
  color: var(--bs-secondary-color);
}

.stats-legend__swatch {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 3px;
}

.stats-legend__line {
  width: 1rem;
  border-top: 2px dashed var(--bs-secondary-color);
}

.stats-chart {
  min-height: 260px;
}

.stats-svg {
  display: block;
  overflow: visible;
}

.stats-grid-line {
  stroke: var(--bs-border-color);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.stats-axis {
  fill: var(--bs-secondary-color);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.stats-seg {
  transition: opacity 0.12s ease;
}

.stats-seg.is-dim {
  opacity: 0.35;
}

.stats-prev-line {
  fill: none;
  stroke: var(--bs-secondary-color);
  stroke-width: 2;
  stroke-dasharray: 5 4;
  stroke-linejoin: round;
  stroke-linecap: round;
  pointer-events: none;
}

.stats-hit {
  fill: transparent;
  outline: none;
}

.stats-hit:hover,
.stats-hit:focus-visible {
  fill: var(--bs-body-color);
  fill-opacity: 0.04;
}

/* Tooltip: value leads, label follows, line keys. */
.stats-tooltip {
  position: fixed;
  z-index: 1080;
  min-width: 160px;
  max-width: 280px;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--bs-border-color);
  border-radius: var(--nx-radius-nav);
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  box-shadow: var(--bs-box-shadow);
  font-size: 0.8125rem;
  pointer-events: none;
}

.stats-tooltip__title {
  margin-bottom: 0.25rem;
  color: var(--bs-secondary-color);
  font-size: 0.75rem;
}

.stats-tooltip__row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.stats-tooltip__row strong {
  font-variant-numeric: tabular-nums;
}

.stats-tooltip__row span:last-child {
  color: var(--bs-secondary-color);
}

.stats-tooltip__key {
  flex: none;
  width: 0.75rem;
  height: 2px;
  border-radius: 1px;
}

.stats-tooltip__key:not([style]) {
  visibility: hidden;
}

.stats-tooltip__key.is-dashed {
  background: none !important;
  border-top: 2px dashed var(--bs-secondary-color);
}

/* Insights */
.stats-insights {
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
}

.stats-insights li {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem var(--nx-card-pad);
  border-top: 1px solid var(--bs-border-color);
  font-size: 0.875rem;
}

.stats-insights li:first-child {
  border-top: 0;
}

.stats-insights li[data-type] {
  cursor: pointer;
}

.stats-insights li[data-type]:hover,
.stats-insights li[data-type]:focus-visible {
  background: var(--bs-tertiary-bg);
  outline: none;
}

/* Per-type table */
.stats-table th[data-sort] {
  cursor: pointer;
  user-select: none;
}

.stats-table th[data-sort]:hover,
.stats-table th.is-sorted {
  color: var(--bs-body-color);
}

.stats-table th.is-sorted::after {
  content: "";
  display: inline-block;
  margin-left: 0.3rem;
  border: 4px solid transparent;
  vertical-align: middle;
}

.stats-table th[aria-sort="descending"]::after {
  border-top-color: currentColor;
  margin-top: 4px;
}

.stats-table th[aria-sort="ascending"]::after {
  border-bottom-color: currentColor;
  margin-top: -4px;
}

.stats-table tbody tr {
  cursor: pointer;
}

.stats-table tbody tr:focus-visible {
  outline: 2px solid var(--nx-primary);
  outline-offset: -2px;
}

.stats-open {
  color: var(--bs-secondary-color);
  font-size: 0.8rem;
}

.stats-open:hover {
  color: var(--nx-primary);
}

.stats-share {
  height: 8px;
  border-radius: 4px;
  background: var(--bs-secondary-bg);
  overflow: hidden;
}

.stats-share span {
  display: block;
  height: 100%;
  border-radius: 0 4px 4px 0;
}

/* Horizontal bar lists */
.stats-bars {
  margin: 0 0 0.5rem;
  padding: 0;
  list-style: none;
}

.stats-bars__row {
  display: grid;
  grid-template-columns: minmax(90px, 38%) 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.3rem 0.25rem;
  border-radius: var(--nx-radius-control);
  font-size: 0.875rem;
  outline: none;
}

.stats-bars__row:hover,
.stats-bars__row:focus-visible {
  background: var(--bs-tertiary-bg);
}

.stats-bars__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-bars__track {
  height: 12px;
}

.stats-bars__bar {
  display: block;
  min-width: 2px;
  height: 100%;
  border-radius: 0 4px 4px 0;
}

.stats-bars__value {
  min-width: 2.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stats-corr {
  margin: 0;
  padding: 0;
  list-style: none;
}

.stats-corr li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-top: 1px solid var(--bs-border-color);
}

.stats-corr li:first-child {
  border-top: 0;
}

/* Heatmap: one hue, light → dark */
.stats-matrix td,
.stats-matrix th {
  white-space: nowrap;
}

.stats-heat {
  min-width: 92px;
  text-align: center;
  border-left: 2px solid var(--bs-body-bg);
  font-variant-numeric: tabular-nums;
}

.stats-heat.is-dark {
  color: #ffffff;
}

.stats-heat.is-empty {
  color: var(--bs-tertiary-color);
}

.stats-heat__sub {
  display: block;
  font-size: 0.7rem;
  opacity: 0.8;
}

.stats-scale {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stats-scale__ramp {
  width: 120px;
  height: 8px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .stats-body,
  .stats-seg {
    transition: none;
  }
}
