/* detectaicheck.com: the /stats dashboard. Loaded after app.css
   and built on its tokens, so it follows the light and the dark theme. The
   charts are inline SVG styled from here. CSP: no inline styles. */

.dst-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

/* ------------------------------------------------------------- filters */

.dst-filters {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.dst-seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--track);
}

.dst-seg-item {
  padding: 5px 12px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}

.dst-seg-item:hover,
.dst-seg-item:focus-visible {
  color: var(--ink);
}

.dst-seg-item.dst-on {
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.dst-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
  text-decoration: none;
}

.dst-switch {
  position: relative;
  width: 30px;
  height: 18px;
  border-radius: 9px;
  background: var(--line);
  transition: background 0.15s;
}

.dst-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s;
}

.dst-toggle.dst-on .dst-switch {
  background: var(--ai1);
}

.dst-toggle.dst-on .dst-switch::after {
  transform: translateX(12px);
}

.dst-seg-item:focus-visible,
.dst-toggle:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- KPIs */

.dst-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dst-kpi {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.dst-kpi p {
  margin: 0;
}

.dst-kpi-label {
  color: var(--muted);
  font-size: 13px;
}

.dst-kpi-value {
  margin-top: 4px;
  font-size: 26px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.dst-kpi-note {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12.5px;
}

/* --------------------------------------------------------------- cards */

.dst-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  gap: 18px;
}

.dst-card {
  min-width: 0;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.dst-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  margin-bottom: 10px;
}

.dst-card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.dst-card-sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.dst-empty,
.dst-note {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

.dst-note a {
  color: inherit;
}

/* -------------------------------------------------------------- charts */

.dst-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
}

.dst-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dst-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.dst-chart-wrap {
  overflow-x: auto;
}

.dst-chart {
  display: block;
  width: 100%;
  min-width: 560px;
  height: auto;
}

.dst-chart .dst-gridline {
  stroke: var(--line);
  stroke-width: 1;
}

.dst-chart .dst-base {
  stroke: var(--muted);
  stroke-width: 1;
}

.dst-chart .dst-axis {
  fill: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
}

.dst-chart .dst-hit {
  fill: transparent;
}

.dst-chart .dst-bar:hover .dst-hit {
  fill: var(--track);
}

.dst-bar-visits,
.dst-sw-visits {
  fill: var(--ai1);
  background: var(--ai1);
}

.dst-bar-ips,
.dst-sw-ips {
  fill: var(--ai2);
  background: var(--ai2);
}

.dst-bar-ips {
  fill: color-mix(in srgb, var(--ink) 55%, var(--surface));
}

.dst-sw-ips {
  background: color-mix(in srgb, var(--ink) 55%, var(--surface));
}

.dst-bar-ok,
.dst-sw-ok {
  fill: var(--capture);
  background: var(--capture);
}

.dst-bar-failed,
.dst-sw-failed {
  fill: var(--alert);
  background: var(--alert);
}

.dst-bar-refused,
.dst-sw-refused {
  fill: var(--warn);
  background: var(--warn);
}

/* -------------------------------------------------------------- tables */

.dst-scroll {
  overflow-x: auto;
}

.dst-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.dst-table th,
.dst-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.dst-table th {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
}

.dst-table tbody tr:last-child td {
  border-bottom: 0;
}

.dst-table .dst-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dst-mono {
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-all;
}

.dst-time {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dst-code {
  margin-left: 6px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.dst-muted {
  color: var(--muted);
}

.dst-tag {
  margin-left: 6px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}

.dst-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 560px) {
  .dst-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dst-kpi-value {
    font-size: 22px;
  }

  .dst-card {
    padding: 14px;
  }
}

/* ------------------------------------------------- filters and the form */

.dst-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  min-width: 0;
}

.dst-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  min-width: 0;
}

.dst-filter-label {
  min-width: 72px;
  color: var(--muted);
  font-size: 13px;
}

.dst-seg {
  max-width: 100%;
}

.dst-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 14px;
  margin: 0;
}

.dst-field {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.dst-input {
  box-sizing: border-box;
  max-width: 100%;
  height: 34px;
  padding: 4px 10px;
  border: 1px solid var(--line2);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface2);
  color-scheme: light dark;
  font: inherit;
  font-size: 14px;
}

.dst-button {
  height: 34px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  color: var(--on-accent);
  background: var(--ai1);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.dst-button:hover {
  background: var(--ai2);
}

.dst-input:focus-visible,
.dst-button:focus-visible,
.dst-filter:focus-visible,
.dst-chip-remove:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.dst-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dst-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 3px 4px 3px 10px;
  border: 1px solid var(--line2);
  border-radius: 999px;
  background: var(--track);
  font-size: 13px;
}

.dst-chip-text {
  overflow-wrap: anywhere;
}

.dst-chip-remove {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: var(--muted);
}

.dst-chip-remove:hover {
  color: var(--ink);
  background: var(--surface3);
}

.dst-chip-icon {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* ------------------------------------------------- links, tags, accounts */

.dst-filter {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--line2);
  text-underline-offset: 3px;
}

.dst-filter:hover {
  color: var(--ai1);
  text-decoration-color: currentColor;
}

.dst-fmt {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
}

.dst-table td > .dst-tag:first-child {
  margin-left: 0;
}

.dst-tag-ok {
  color: var(--capture);
  border-color: currentColor;
}

.dst-tag-failed {
  color: var(--alert);
  border-color: currentColor;
}

.dst-tag-refused {
  color: var(--warn);
  border-color: currentColor;
}

.dst-kpis-small .dst-kpi {
  background: var(--surface2);
  box-shadow: none;
}

.dst-kpis-small .dst-kpi-value {
  font-size: 22px;
}

.dst-message {
  display: grid;
  gap: 6px;
}

@media (max-width: 560px) {
  .dst-filters {
    padding: 12px;
  }

  .dst-filter-row > .dst-filter-label {
    flex-basis: 100%;
  }

  .dst-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dst-input {
    width: 100%;
  }

  .dst-button {
    grid-column: 1 / -1;
  }
}
