:root {
  color-scheme: light;
  --page: #f6f6f3;
  --surface: #fcfcfb;
  --surface-raised: #ffffff;
  --surface-sunken: #f0efec;
  --border: rgba(11, 11, 11, 0.09);
  --border-strong: rgba(11, 11, 11, 0.16);
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e8e7e1;
  --axis: #c3c2b7;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-1-wash: rgba(42, 120, 214, 0.1);
  --accent: #2a78d6;
  --accent-soft: rgba(42, 120, 214, 0.1);
  --status-good: #0ca30c;
  --status-good-text: #006300;
  --status-good-wash: rgba(12, 163, 12, 0.1);
  --status-warning: #c98500;
  --status-warning-wash: rgba(201, 133, 0, 0.12);
  --status-critical: #d03b3b;
  --syntax-key: #52514e;
  --syntax-string: #1c5cab;
  --syntax-number: #c4441c;
  --syntax-literal: #6250d6;
  --new-row-flash: rgba(42, 120, 214, 0.16);
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 8px 24px -12px rgba(11, 11, 11, 0.12);
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-raised: #1f1f1e;
    --surface-sunken: #141413;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-1-wash: rgba(57, 135, 229, 0.12);
    --accent: #6da7ec;
    --accent-soft: rgba(57, 135, 229, 0.14);
    --status-good: #0ca30c;
    --status-good-text: #3fcf3f;
    --status-good-wash: rgba(12, 163, 12, 0.16);
    --status-warning: #fab219;
    --status-warning-wash: rgba(250, 178, 25, 0.14);
    --status-critical: #e66767;
    --syntax-key: #c3c2b7;
    --syntax-string: #86b6ef;
    --syntax-number: #f09a6e;
    --syntax-literal: #a9a0f0;
    --new-row-flash: rgba(57, 135, 229, 0.22);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px -16px rgba(0, 0, 0, 0.6);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  background:
    radial-gradient(1200px 400px at 10% -10%, var(--accent-soft), transparent 70%),
    var(--page);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 28px;
  background: color-mix(in srgb, var(--page) 78%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  color: var(--text-muted);
}

.breadcrumbs a {
  color: var(--text-secondary);
}

.top-bar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.live-dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-good);
}

.live-dot::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--status-good);
  opacity: 0;
  animation: live-pulse 2.4s ease-out infinite;
}

.live-indicator.is-stale .live-dot {
  background: var(--status-warning);
}

.live-indicator.is-stale .live-dot::after {
  animation: none;
}

@keyframes live-pulse {
  0% {
    transform: scale(0.6);
    opacity: 0.6;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot::after {
    animation: none;
  }
}

.page {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 28px 64px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.section {
  margin-bottom: 28px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-secondary);
}

.section-spacer {
  height: 12px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(260px, 1.1fr) minmax(0, 2.4fr);
  gap: 0;
  margin-bottom: 28px;
  overflow: hidden;
}

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

.hero-figure {
  padding: 24px 26px;
  border-right: 1px solid var(--border);
  background: linear-gradient(160deg, var(--accent-soft), transparent 65%);
}

.hero-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.hero-value {
  margin-top: 6px;
  font-size: 56px;
  font-weight: 650;
  line-height: 1;
  letter-spacing: -0.03em;
}

.hero-unit {
  margin-left: 6px;
  font-size: 18px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0;
}

.hero-caption {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 640px) {
  .hero-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.stat {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  min-width: 0;
}

.stat:nth-child(3n) {
  border-right: 0;
}

.stat:nth-last-child(-n + 3) {
  border-bottom: 0;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

.stat-value {
  margin-top: 4px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-detail {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--status-good) 45%, transparent);
  background: var(--status-good-wash);
  font-size: 11px;
  font-weight: 600;
  color: var(--status-good-text);
  vertical-align: middle;
}

.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge::before {
  box-shadow: 0 0 0 3px var(--status-good-wash);
}

.status-badge.is-warning {
  color: var(--status-warning);
  border-color: color-mix(in srgb, var(--status-warning) 45%, transparent);
  background: var(--status-warning-wash);
}

.status-badge.is-critical {
  color: var(--status-critical);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 9px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
}

.segmented button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  padding: 4px 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.segmented button:hover {
  color: var(--text-primary);
}

.segmented button.is-selected {
  background: var(--surface-raised);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

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

.chart-card {
  position: relative;
  padding: 16px 18px 12px;
  min-width: 0;
}

.chart-card.is-refreshing {
  opacity: 0.7;
}

.chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.chart-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.chart-current {
  margin-top: 2px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.chart-current-unit {
  margin-left: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

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

.legend-line {
  width: 14px;
  height: 2px;
  border-radius: 2px;
}

.view-toggle {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  padding: 2px 8px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.view-toggle:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.chart-plot {
  position: relative;
  margin-top: 10px;
}

.chart-svg {
  display: block;
  width: 100%;
  overflow: visible;
}

.chart-svg text {
  fill: var(--text-muted);
  font-family: var(--sans);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart-hit-area {
  outline: none;
  cursor: crosshair;
}

.chart-hit-area:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chart-empty {
  display: grid;
  place-items: center;
  height: 196px;
  color: var(--text-muted);
  font-size: 12px;
}

.chart-tooltip {
  position: absolute;
  top: 0;
  z-index: 5;
  min-width: 150px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  pointer-events: none;
  font-size: 12px;
}

.tooltip-time {
  margin-bottom: 6px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.tooltip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.tooltip-value {
  font-weight: 650;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

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

.chart-table-wrapper {
  margin-top: 10px;
  max-height: 196px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.table-wrapper {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface);
}

.data-table td {
  font-variant-numeric: tabular-nums;
}

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

.data-table td.is-number,
.data-table th.is-number {
  text-align: right;
}

.data-table.is-compact th,
.data-table.is-compact td {
  padding: 6px 10px;
  font-size: 12px;
}

.data-table tbody tr.is-clickable {
  cursor: pointer;
}

.data-table tbody tr.is-clickable:hover {
  background: var(--surface-sunken);
}

.data-table tbody tr.is-selected,
.data-table tbody tr.is-selected:hover {
  background: var(--accent-soft);
}

.row-label {
  font-weight: 600;
}

.share-bar {
  display: inline-block;
  width: 72px;
  height: 6px;
  margin-right: 10px;
  border-radius: 3px;
  background: var(--surface-sunken);
  vertical-align: middle;
  overflow: hidden;
}

.share-bar-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--series-1);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}

.metric {
  padding: 14px 16px;
  min-width: 0;
}

.metric-label {
  font-size: 12px;
  color: var(--text-muted);
}

.metric-value {
  margin-top: 4px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-detail {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.stretch-card {
  display: flex;
  flex-direction: column;
}

.stretch-card .table-wrapper {
  flex: 1;
  display: flex;
}

.stretch-card .data-table {
  height: 100%;
}

@media (max-width: 1000px) {
  .two-column {
    grid-template-columns: minmax(0, 1fr);
  }
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
}

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

.attribute-preview {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-secondary);
}

.empty-state {
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
}

.error-banner {
  margin-bottom: 16px;
  padding: 10px 14px;
  border: 1px solid var(--status-critical);
  border-radius: 10px;
  color: var(--status-critical);
  background: var(--surface);
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 16px;
  align-items: start;
}

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

.detail-panel {
  position: sticky;
  top: 72px;
  padding: 16px;
  max-height: calc(100vh - 96px);
  overflow: auto;
}

.detail-title {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-all;
}

.detail-heading {
  margin: 16px 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.json-block {
  margin: 0;
  padding: 10px 12px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.controls select {
  font: inherit;
  padding: 3px 6px;
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
}

.quiet-button {
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 5px 12px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.quiet-button:hover {
  color: var(--text-primary);
  background: var(--surface-sunken);
}

.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 16px;
}

.login-panel {
  width: 100%;
  max-width: 360px;
  padding: 32px;
}

.login-panel .brand {
  font-size: 20px;
}

.login-subtitle {
  margin: 6px 0 22px;
  color: var(--text-muted);
}

.login-form {
  display: grid;
  gap: 6px;
}

.login-form label {
  font-size: 12px;
  color: var(--text-secondary);
}

.login-form input {
  font: inherit;
  padding: 9px 11px;
  margin-bottom: 8px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-sunken);
  color: var(--text-primary);
}

.login-form input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.login-form button {
  margin-top: 4px;
  font: inherit;
  font-weight: 600;
  padding: 10px;
  border: 0;
  border-radius: 8px;
  background: var(--series-1);
  color: #ffffff;
  cursor: pointer;
}

.login-form button:hover {
  filter: brightness(1.08);
}

.login-error {
  min-height: 18px;
  margin: 0;
  color: var(--status-critical);
  font-size: 12px;
}

.chart-svg .chart-line,
.chart-svg .chart-area {
  will-change: d;
}

.event-id {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}

.event-id-tail {
  color: var(--text-primary);
  font-weight: 600;
}

.fresh-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--axis);
  vertical-align: middle;
}

.fresh-dot.is-fresh {
  background: var(--status-good);
  box-shadow: 0 0 0 3px var(--status-good-wash);
}

.recent-table {
  table-layout: fixed;
}

.recent-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}

.attribute-chips {
  display: flex;
  gap: 6px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to right, #000 80%, transparent);
  mask-image: linear-gradient(to right, #000 80%, transparent);
}

.attribute-chip {
  flex-shrink: 0;
}

.attribute-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  max-width: 200px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attribute-chip-key {
  color: var(--text-muted);
}

.attribute-chip-value {
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
}

.attribute-chip-more {
  align-self: center;
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}

.recent-table td {
  padding-top: 9px;
  padding-bottom: 9px;
}

@keyframes new-row-flash {
  from {
    background: var(--new-row-flash);
  }
  to {
    background: transparent;
  }
}

.recent-table tbody tr.is-new {
  animation: new-row-flash 1.6s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .recent-table tbody tr.is-new {
    animation: none;
  }
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.detail-header .detail-title {
  margin: 0;
}

.copy-button {
  flex-shrink: 0;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 3px 9px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.copy-button:hover {
  color: var(--text-primary);
  background: var(--surface-sunken);
}

.key-value-list {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 16px;
  margin: 0;
  font-size: 12px;
}

.key-value-list dt {
  font-family: var(--mono);
  color: var(--text-muted);
}

.key-value-list dd {
  margin: 0;
  font-family: var(--mono);
  color: var(--text-primary);
  word-break: break-all;
}

.payload-block {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.payload-block summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  background: var(--surface-sunken);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  list-style: none;
}

.payload-block summary::-webkit-details-marker {
  display: none;
}

.payload-block summary::before {
  content: "▸";
  margin-right: 6px;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.payload-block[open] summary::before {
  transform: rotate(90deg);
}

.payload-name {
  flex: 1;
  font-family: var(--mono);
}

.payload-size {
  font-weight: 400;
  color: var(--text-muted);
}

.payload-block .json-block {
  border: 0;
  border-radius: 0;
  max-height: 420px;
  overflow: auto;
  background: var(--surface);
}

.json-key {
  color: var(--syntax-key);
}

.json-string {
  color: var(--syntax-string);
}

.json-number {
  color: var(--syntax-number);
}

.json-literal {
  color: var(--syntax-literal);
}
