:root {
  --regulator-bg: #10151d;
  --regulator-panel: #171e28;
  --regulator-panel-strong: #1d2632;
  --regulator-border: #2d3745;
  --regulator-text: #eef4ff;
  --regulator-muted: #a9b7c8;
  --regulator-accent: #00b6b8;
  --regulator-accent-2: #ff6384;
  --regulator-warning: #ffbf47;
  --regulator-error: #ff6b6b;
  --regulator-success: #62d394;
  --pico-font-size: 92%;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  background: var(--regulator-bg);
}

body {
  margin: 0;
  color: var(--regulator-text);
}

[x-cloak] {
  display: none !important;
}

.dashboard-shell {
  width: min(1900px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px;
}

.app-header,
.metric-grid,
.dashboard-grid,
.panel,
.notice-stack {
  width: 100%;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  padding: 14px 16px;
  border: 1px solid var(--regulator-border);
  background: var(--regulator-panel);
}

.app-header h1,
.panel h2 {
  margin: 0;
  line-height: 1.1;
  letter-spacing: 0;
}

.app-header h1 {
  font-size: 1.5rem;
}

.panel h2 {
  font-size: 1rem;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--regulator-muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.header-controls {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.header-meta {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.ecosystem-links {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
  margin: 0;
}

.ecosystem-links a {
  display: inline-flex;
  width: 32px;
  min-width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  box-shadow: none;
  color: var(--regulator-muted);
}

.ecosystem-links a:hover,
.ecosystem-links a:focus-visible {
  background: var(--regulator-panel-strong);
  color: var(--regulator-accent);
}

.ecosystem-icon {
  display: block;
  width: 18px;
  height: 18px;
  background-color: currentcolor;
  mask: var(--ecosystem-icon) center / contain no-repeat;
}

.icon-wiki {
  --ecosystem-icon: url("/assets/icons/wiki-icon.svg");
}

.icon-map {
  --ecosystem-icon: url("/assets/icons/map-icon.svg");
}

.icon-chat {
  --ecosystem-icon: url("/assets/icons/chat-icon.svg");
}

.icon-database {
  --ecosystem-icon: url("/assets/icons/database-icon.svg");
}

.icon-web-fcs {
  --ecosystem-icon: url("/assets/icons/web-fcs-icon.svg");
}

.header-meta span,
.status-pill,
.segmented-control button,
.panel header > span {
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid var(--regulator-border);
  background: var(--regulator-panel-strong);
  color: var(--regulator-muted);
  font-size: 0.8rem;
}

.status-pill.is-healthy {
  border-color: rgb(98 211 148 / 50%);
  color: var(--regulator-success);
}

.status-pill.is-unhealthy,
.status-pill.is-unavailable {
  border-color: rgb(255 107 107 / 55%);
  color: var(--regulator-error);
}

.status-pill.is-stale {
  border-color: rgb(255 191 71 / 55%);
  color: var(--regulator-warning);
}

.notice-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.notice {
  display: flex;
  gap: 10px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgb(255 191 71 / 45%);
  background: rgb(255 191 71 / 8%);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.metric-card,
.panel {
  margin: 0;
  border: 1px solid var(--regulator-border);
  border-radius: 8px;
  background: var(--regulator-panel);
}

.metric-card {
  padding: 12px;
}

.metric-card span,
.gear-grid span,
.detail-list dt {
  display: block;
  color: var(--regulator-muted);
  font-size: 0.78rem;
}

.metric-card strong {
  display: block;
  margin-top: 4px;
  font-size: 1.35rem;
}

.dashboard-grid {
  display: grid;
  grid-template-areas:
    "details chart"
    "events events";
  grid-template-columns: minmax(360px, 0.9fr) minmax(560px, 1.4fr);
  gap: 12px;
}

.left-column {
  grid-area: details;
  display: grid;
  gap: 12px;
  align-content: start;
}

.panel {
  padding: 14px;
}

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

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

.gear-grid div {
  padding: 10px;
  background: var(--regulator-panel-strong);
}

.gear-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 1.5rem;
}

.detail-list {
  display: grid;
  gap: 7px;
  margin: 0;
}

.detail-list div {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 10px;
}

.detail-list dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

code {
  padding: 2px 4px;
  white-space: pre-wrap;
}

.reason-list {
  display: grid;
  gap: 6px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.reason-list li {
  padding: 7px 9px;
  border-left: 3px solid var(--regulator-accent);
  background: rgb(0 182 184 / 8%);
  color: var(--regulator-muted);
}

.compact-table {
  margin: 14px 0 0;
  font-size: 0.84rem;
}

.compact-table th:not(:first-child),
.compact-table td:not(:first-child) {
  text-align: right;
}

.chart-panel {
  grid-area: chart;
  display: grid;
  grid-template-rows: auto minmax(340px, 1fr) auto;
  min-height: 470px;
}

.chart-panel h2 {
  white-space: nowrap;
}

.segmented-control {
  display: flex;
  width: auto;
  flex: 0 0 auto;
  gap: 0;
}

.segmented-control button {
  width: 48px;
  flex: 0 0 48px;
  margin: 0;
  border-radius: 0;
}

.segmented-control button[aria-pressed="true"] {
  border-color: var(--regulator-accent);
  color: var(--regulator-text);
}

.chart-wrap {
  position: relative;
  min-height: 340px;
}

.chart-wrap canvas {
  width: 100%;
  height: 100%;
}

.chart-wrap .empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  pointer-events: none;
}

.insight-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.insight-strip span {
  padding: 8px;
  background: var(--regulator-panel-strong);
  color: var(--regulator-muted);
}

.insight-strip strong {
  color: var(--regulator-text);
}

.event-panel {
  grid-area: events;
  min-height: 330px;
}

.event-panel select {
  width: min(230px, 45%);
  height: 36px;
  margin: 0;
  padding: 5px 34px 5px 10px;
  font-size: 0.82rem;
  line-height: 1.2;
}

.event-list {
  display: grid;
  max-height: 420px;
  gap: 8px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.event-list li {
  display: grid;
  grid-template-columns: 82px 190px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 8px;
  background: var(--regulator-panel-strong);
}

.event-list time {
  color: var(--regulator-muted);
  font-size: 0.78rem;
}

.event-list strong {
  color: var(--regulator-accent);
  font-size: 0.82rem;
}

.empty-state {
  margin: 14px 0 0;
  color: var(--regulator-muted);
}

@media (max-width: 980px) {
  .dashboard-shell {
    padding: 10px;
  }

  .app-header,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-areas:
      "details"
      "chart"
      "events";
  }

  .app-header {
    display: grid;
  }

  .header-controls,
  .header-meta {
    justify-content: flex-start;
  }

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

  .event-list li {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .metric-grid,
  .gear-grid,
  .insight-strip {
    grid-template-columns: 1fr;
  }

  .panel header {
    align-items: flex-start;
    flex-direction: column;
  }

  .event-panel select {
    width: 100%;
  }

  .detail-list div {
    grid-template-columns: 1fr;
  }
}
