:root {
  --background: #f4f6fa;
  --foreground: #172033;
  --card: #ffffff;
  --muted: #64708a;
  --border: #dce3ed;
  --primary: #2859d6;
  --primary-soft: #e6edff;
  --good: #177a59;
  --good-soft: #e0f4eb;
  --bad: #bd3948;
  --bad-soft: #fde7ea;
  --pending: #a4680b;
  --shadow: 0 12px 34px rgba(39, 54, 83, .07);
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #0f1420;
    --foreground: #e8edf7;
    --card: #171e2d;
    --muted: #a7b2c7;
    --border: #303a4e;
    --primary: #9ab7ff;
    --primary-soft: #273b6a;
    --good: #7adbb6;
    --good-soft: #193f35;
    --bad: #ff929c;
    --bad-soft: #51272d;
    --pending: #f0bb64;
    --shadow: 0 16px 40px rgba(0, 0, 0, .2);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

button { font: inherit; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 44px 0 48px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

h1 {
  font-size: clamp(30px, 4vw, 44px);
  font-weight: 560;
  letter-spacing: -.04em;
}

h2 { font-size: 19px; font-weight: 600; letter-spacing: -.015em; }

.subtitle { max-width: 610px; margin-top: 7px; color: var(--muted); }

.header-actions { display: flex; align-items: center; gap: 14px; }
.live-status { display: flex; align-items: center; min-width: 220px; gap: 10px; }
.live-status strong, .live-status small { display: block; }
.live-status strong { font-size: 14px; font-weight: 600; }
.live-status small { margin-top: 1px; color: var(--muted); font-size: 12px; }

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--pending);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--pending) 15%, transparent);
}

.status-dot.ok { background: var(--good); box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 15%, transparent); }
.status-dot.bad { background: var(--bad); box-shadow: 0 0 0 4px color-mix(in srgb, var(--bad) 15%, transparent); }

.button, .command button {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  color: var(--foreground);
  cursor: pointer;
  font-weight: 600;
}

.button { min-height: 40px; padding: 8px 14px; }
.button:hover, .command button:hover { border-color: var(--primary); color: var(--primary); }
.button:focus-visible, .command button:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 30%, transparent); outline-offset: 2px; }
.button:disabled { cursor: wait; opacity: .65; }

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

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

.stat { padding: 19px 21px; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .045em; text-transform: uppercase; }
.stat-value { margin-top: 6px; font-size: clamp(26px, 3vw, 34px); font-weight: 600; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat-context { margin-top: 1px; color: var(--muted); font-size: 12px; }

.activity-card { overflow: hidden; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding: 21px 22px 18px; }
.section-heading p { margin-top: 3px; color: var(--muted); font-size: 13px; }
.refresh-note { color: var(--muted); font-size: 12px; white-space: nowrap; }

.table-wrap { width: 100%; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 14px 14px; border-top: 1px solid var(--border); text-align: right; white-space: nowrap; }
th { color: var(--muted); font-size: 10px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; }
th:first-child, td:first-child { padding-left: 22px; text-align: left; }
th:last-child, td:last-child { padding-right: 22px; }
tbody tr:hover { background: color-mix(in srgb, var(--primary-soft) 28%, transparent); }
.registry-cell strong, .registry-cell small { display: block; }
.registry-cell strong { font-weight: 600; }
.registry-cell small { color: var(--muted); font-size: 11px; }
.metric-unavailable { color: var(--muted); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 99px;
  color: var(--good);
  background: var(--good-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .025em;
  text-transform: uppercase;
}

.badge::before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; content: ""; }
.badge.bad { color: var(--bad); background: var(--bad-soft); }

.table-note { padding: 14px 22px 17px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }

.usage { margin-top: 30px; }
.usage-heading { padding: 0 2px 14px; }
.mirror-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.daemon-card { grid-column: 1 / -1; padding: 22px; }
.daemon-layout { display: grid; grid-template-columns: minmax(0, .85fr) minmax(360px, 1.15fr); gap: 28px; align-items: start; }
.daemon-copy h3 { font-size: 18px; font-weight: 650; letter-spacing: -.015em; }
.daemon-copy > p { margin-top: 8px; color: var(--muted); font-size: 13px; }
.daemon-copy code { color: var(--foreground); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.scope-note { padding-left: 11px; border-left: 3px solid var(--primary); }
.config-block { border: 1px solid var(--border); border-radius: 10px; background: var(--background); overflow: hidden; }
.config-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 38px; padding-left: 12px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 11px; }
.copy-button { align-self: stretch; padding: 5px 11px; border: 0; border-left: 1px solid var(--border); background: var(--card); color: var(--foreground); cursor: pointer; font-size: 11px; font-weight: 650; }
.copy-button:hover { color: var(--primary); }
.copy-button:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 30%, transparent); outline-offset: -3px; }
.config-block pre { margin: 0; padding: 13px; overflow-wrap: anywhere; color: var(--foreground); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; line-height: 1.55; white-space: pre-wrap; }
.command-label { margin: 12px 0 6px; color: var(--muted); font-size: 12px; }
.daemon-command code { white-space: pre-wrap; }
.restart-note { margin-top: 8px; color: var(--muted); font-size: 11px; }
.mirror-card { min-width: 0; padding: 16px; }
.mirror-card:last-child { grid-column: 1 / -1; }
.mapping { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-bottom: 11px; }
.mapping span { color: var(--muted); }
.mapping strong { font-weight: 600; }

.command {
  display: flex;
  align-items: center;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--background);
  overflow: hidden;
}

.command code { min-width: 0; flex: 1; padding: 10px 12px; color: var(--foreground); overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; }
.command button { align-self: stretch; padding: 6px 11px; border-width: 0 0 0 1px; border-radius: 0; background: var(--card); font-size: 11px; }

footer { max-width: 850px; margin: 24px 2px 0; color: var(--muted); font-size: 12px; }
.noscript { margin-top: 18px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); }

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

@media (max-width: 860px) {
  main { width: min(100% - 24px, 700px); padding-top: 28px; }
  .page-header { align-items: flex-start; flex-direction: column; gap: 16px; }
  .header-actions { width: 100%; justify-content: space-between; }
  .stats { grid-template-columns: 1fr; }
  .mirror-grid { grid-template-columns: 1fr; }
  .daemon-card { grid-column: auto; }
  .daemon-layout { grid-template-columns: 1fr; gap: 18px; }
  .mirror-card:last-child { grid-column: auto; }
}

@media (max-width: 720px) {
  .section-heading { align-items: flex-start; flex-direction: column; gap: 5px; }
  .refresh-note { white-space: normal; }
  .table-wrap { padding: 0 12px 12px; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  tbody { display: grid; gap: 10px; }
  tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 16px; padding: 15px; border: 1px solid var(--border); border-radius: 12px; }
  tbody tr:hover { background: transparent; }
  td, th:first-child, td:first-child, th:last-child, td:last-child { padding: 0; border: 0; text-align: left; white-space: normal; }
  td::before { display: block; margin-bottom: 2px; color: var(--muted); content: attr(data-label); font-size: 9px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; }
  .registry-cell { grid-column: 1 / -1; padding-bottom: 8px !important; border-bottom: 1px solid var(--border) !important; }
  .registry-cell::before { display: none; }
  .loading-row { display: block; }
  .loading-row td { padding: 6px; }
  .loading-row td::before { display: none; }
  .table-note { border-top: 0; padding-top: 3px; }
}

@media (max-width: 470px) {
  main { width: calc(100% - 20px); padding-top: 22px; }
  .header-actions { align-items: flex-start; }
  .live-status { min-width: 0; }
  .button { min-height: 38px; }
  .stat { padding: 17px; }
  .section-heading { padding: 18px 16px 15px; }
  .mirror-card { padding: 14px; }
  .daemon-card { padding: 16px; }
  .mapping { align-items: flex-start; flex-direction: column; gap: 2px; }
  .mapping span:nth-child(2) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
