.cw-root {
  --cw-bg: #f4f6f8;
  --cw-surface: #ffffff;
  --cw-text: #17202a;
  --cw-muted: #3e4c59;
  --cw-border: #d5dde6;
  --cw-accent: #0b4fad;
  --cw-accent-soft: #e7f0fb;
  --cw-positive: #0d6b42;
  --cw-warning: #7a4e00;
  --cw-danger: #8d1d1a;
  --cw-radius: 12px;
  --cw-shadow: 0 1px 2px rgba(23, 32, 42, 0.06);
  --cw-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --cw-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  container-type: inline-size;
  color: var(--cw-text);
  background: var(--cw-bg);
  font-family: var(--cw-font);
  font-size: 15px;
  line-height: 1.45;
  padding: 16px;
  border-radius: var(--cw-radius);
  min-width: 0;
  max-width: 100%;
}

.cw-root[data-theme="dark"] {
  --cw-bg: #10161d;
  --cw-surface: #1a232e;
  --cw-text: #eef3f8;
  --cw-muted: #c5d0dc;
  --cw-border: #314050;
  --cw-accent: #8eb6f5;
  --cw-accent-soft: #24344a;
  --cw-positive: #8fd6b0;
  --cw-warning: #f0c36a;
  --cw-danger: #f0a8a4;
  --cw-shadow: none;
}

@media (prefers-color-scheme: dark) {
  .cw-root[data-theme="system"] {
    --cw-bg: #10161d;
    --cw-surface: #1a232e;
    --cw-text: #eef3f8;
    --cw-muted: #c5d0dc;
    --cw-border: #314050;
    --cw-accent: #8eb6f5;
    --cw-accent-soft: #24344a;
    --cw-positive: #8fd6b0;
    --cw-warning: #f0c36a;
    --cw-danger: #f0a8a4;
    --cw-shadow: none;
  }
}

.cw-section {
  position: relative;
  background: var(--cw-surface);
  border: 1px solid var(--cw-border);
  border-radius: var(--cw-radius);
  box-shadow: var(--cw-shadow);
  padding: 16px;
  margin: 0;
}

.cw-root.cw-section {
  margin: 0;
}

.cw-dashboard {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.cw-stack,
.cw-panel-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cw-dashboard-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.cw-dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.cw-dashboard-ranges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.cw-dashboard-ranges button {
  font: inherit;
  color: inherit;
  background: var(--cw-surface);
  border: 1px solid var(--cw-border);
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
}

.cw-dashboard-ranges button[aria-pressed="true"] {
  background: var(--cw-accent);
  border-color: var(--cw-accent);
  color: var(--cw-bg);
}

.cw-dashboard-ranges button:focus-visible,
.cw-dashboard-nav a:focus-visible,
.cw-dashboard-advanced:focus-visible {
  outline: 2px solid var(--cw-accent);
  outline-offset: 2px;
}

.cw-dashboard-advanced {
  color: var(--cw-accent);
  font-weight: 650;
  text-decoration: none;
}

.cw-dashboard-advanced:hover {
  text-decoration: underline;
}

.cw-dashboard-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cw-dashboard-nav a {
  color: var(--cw-accent);
  font-size: 0.85rem;
  font-weight: 650;
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 999px;
}

.cw-dashboard-nav a:hover {
  text-decoration: underline;
}

.cw-dashboard-nav a[aria-current="location"] {
  color: var(--cw-text);
  background: var(--cw-accent-soft);
  text-decoration: none;
}

.cw-dashboard-nav a[aria-current="location"]:hover {
  color: var(--cw-text);
  background: var(--cw-accent-soft);
  text-decoration: none;
}

.cw-layout {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.cw-panel {
  min-width: 0;
  scroll-margin-top: 12px;
  grid-column: var(--cw-col-start) / span var(--cw-col-span);
  grid-row: var(--cw-row-start) / span var(--cw-row-span);
}

.cw-layout-tools,
.cw-hidden-panels,
.cw-restore {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-width: 0;
  max-width: 100%;
}

.cw-hidden-panels {
  margin: 0;
  padding: 0;
  list-style: none;
}

.cw-layout-tools button,
.cw-hidden-panels button,
.cw-restore > button {
  font: inherit;
  color: inherit;
  background: var(--cw-surface);
  border: 1px solid var(--cw-border);
  border-radius: 999px;
  padding: 4px 8px;
  max-width: 100%;
}

.cw-layout-hint {
  margin: 0 0 8px;
  color: var(--cw-muted);
  font-size: 0.85rem;
}

.cw-grid {
  position: relative;
  transition: height 200ms ease;
}

.cw-grid .react-grid-item {
  transition: transform 200ms ease, width 200ms ease, height 200ms ease;
  outline: 1px solid var(--cw-border);
  border-radius: 12px;
  background: var(--cw-surface);
}

.cw-grid .react-grid-item.resizing {
  transition: none;
  z-index: 1;
}

.cw-grid .react-grid-item.react-draggable-dragging {
  transition: none;
  z-index: 3;
  outline: 2px solid var(--cw-accent);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}

.cw-grid .react-grid-item.react-grid-placeholder {
  background: var(--cw-accent);
  opacity: 0.18;
  border-radius: 12px;
  outline: none;
  z-index: 2;
}

.cw-grid .cw-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: auto;
  grid-column: auto;
  grid-row: auto;
}

.cw-panel-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px 0;
}

.cw-grip,
.cw-hide {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--cw-muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
}

.cw-grip {
  cursor: grab;
  touch-action: none;
}

.cw-grip:hover,
.cw-grip:focus-visible,
.cw-hide:hover,
.cw-hide:focus-visible {
  color: var(--cw-text);
  background: var(--cw-accent-soft);
}

.cw-grip:active {
  cursor: grabbing;
}

.cw-grip-icon {
  fill: currentColor;
}

.cw-hide {
  font-size: 1.1rem;
  line-height: 1;
}

.cw-panel-body {
  min-width: 0;
  padding: 0 14px 8px;
}

.cw-grid .react-grid-item > .react-resizable-handle {
  position: absolute;
  opacity: 1;
  background: transparent;
}

.cw-grid .react-grid-item > .react-resizable-handle-e,
.cw-grid .react-grid-item > .react-resizable-handle-w {
  top: 16px;
  width: 14px;
  height: calc(100% - 32px);
  margin: 0;
  transform: none;
  cursor: ew-resize;
}

.cw-grid .react-grid-item > .react-resizable-handle-e {
  right: 2px;
}

.cw-grid .react-grid-item > .react-resizable-handle-w {
  left: 2px;
}

.cw-grid .react-grid-item > .react-resizable-handle-e::after,
.cw-grid .react-grid-item > .react-resizable-handle-w::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 5px;
  width: 4px;
  height: 28px;
  margin-top: -14px;
  border: 0;
  border-radius: 999px;
  background: var(--cw-accent);
}

.cw-layout-status {
  margin: 0;
  color: var(--cw-muted);
  font-size: 0.85rem;
}

.cw-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.cw-title {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.cw-dashboard-head .cw-title {
  font-size: 1.35rem;
}

.cw-note,
.cw-period,
.cw-status,
.cw-meta {
  color: var(--cw-muted);
  margin: 0 0 12px;
}

.cw-status-error {
  color: var(--cw-danger);
  font-weight: 600;
}

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

.cw-stats > div,
.cw-inline-metrics > div {
  border: 1px solid var(--cw-border);
  border-radius: 10px;
  padding: 12px;
  min-width: 0;
}

.cw-stats dt,
.cw-inline-metrics dt {
  color: var(--cw-muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cw-stats dd,
.cw-inline-metrics dd {
  margin: 4px 0 0;
  font-size: 1.6rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.cw-inline-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 12px;
}

.cw-inline-metrics dd {
  font-size: 1.25rem;
}

.cw-table-wrap {
  max-width: 100%;
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  table-layout: fixed;
}

th,
td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--cw-border);
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  font-weight: 650;
}

thead th {
  color: var(--cw-muted);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cw-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 8px 0 0;
  min-height: 180px;
  max-width: 100%;
  overflow: hidden;
}

.cw-chart > li {
  flex: 1 1 0;
  min-width: 0;
}

.cw-bar-button {
  appearance: none;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 8px;
  cursor: pointer;
  position: relative;
}

.cw-bar-button:hover,
.cw-bar-button:focus-visible {
  background: var(--cw-accent-soft);
  outline: 2px solid var(--cw-accent);
  outline-offset: 2px;
}

.cw-bar-track {
  display: flex;
  align-items: flex-end;
  width: 100%;
  height: 140px;
}

.cw-bar {
  display: block;
  width: 100%;
  background: var(--cw-accent);
  border-radius: 6px 6px 2px 2px;
  min-height: 4px;
}

.cw-bar-label {
  font-size: 0.72rem;
  color: var(--cw-muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cw-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% - 8px);
  z-index: 1;
  background: var(--cw-text);
  color: var(--cw-bg);
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  white-space: nowrap;
}

.cw-bar-button:hover .cw-tooltip,
.cw-bar-button:focus-visible .cw-tooltip {
  display: block;
}

.cw-sr-table {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.cw-pill {
  display: inline-block;
  border: 1px solid var(--cw-border);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.78rem;
  font-weight: 600;
}

.cw-pill-receiving_events {
  color: var(--cw-positive);
}

.cw-pill-no_matching_events,
.cw-pill-tracking_not_installed,
.cw-pill-inactive {
  color: var(--cw-warning);
}

.cw-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 0;
  list-style: none;
}

.cw-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cw-step-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.92rem;
}

.cw-step-track {
  height: 8px;
  background: var(--cw-accent-soft);
  border-radius: 999px;
  overflow: hidden;
}

.cw-step-fill {
  display: block;
  height: 100%;
  background: var(--cw-accent);
}

code,
.cw-path {
  font-family: var(--cw-mono);
}

.cw-path {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow-wrap: normal;
}

/* Viewport fallback for browsers without container queries. Container rules follow so a narrow column wins on a wide screen. */
@media (max-width: 960px) {
  .cw-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .cw-stats {
    grid-template-columns: 1fr;
  }

  .cw-layout .cw-panel {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .cw-dashboard-toolbar {
    flex-direction: column;
  }

  .cw-dashboard-nav {
    flex-wrap: wrap;
  }
}

@container (max-width: 960px) {
  .cw-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@container (max-width: 640px) {
  .cw-stats {
    grid-template-columns: 1fr;
  }

  .cw-step-head,
  .cw-inline-metrics {
    flex-direction: column;
  }

  .cw-layout .cw-panel {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .cw-dashboard-toolbar {
    flex-direction: column;
  }

  .cw-dashboard-nav {
    flex-wrap: wrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cw-root *,
  .cw-root *::before,
  .cw-root *::after {
    transition: none !important;
    animation: none !important;
  }
}
