:root {
  color-scheme: dark;
  --bg: #10110f;
  --panel: #1a1d19;
  --panel-2: #22261f;
  --panel-solid: #1a1d19;
  --panel-glass: rgba(26, 29, 25, 0.88);
  --control-bg: #121410;
  --text: #f3f4ef;
  --muted: #a7ad9f;
  --line: #343b31;
  --green: #7fd77e;
  --amber: #f2bd67;
  --red: #ef6f6c;
  --cyan: #72c7d9;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.3);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f7f1;
  --panel: #ffffff;
  --panel-2: #edf1e8;
  --panel-solid: #ffffff;
  --panel-glass: rgba(255, 255, 255, 0.88);
  --control-bg: #f7f9f4;
  --text: #191d17;
  --muted: #66705f;
  --line: #d6ddcf;
  --green: #2f8b4f;
  --amber: #a56b18;
  --red: #ba3d3a;
  --cyan: #247f93;
  --shadow: 0 18px 50px rgba(39, 54, 31, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background:
    linear-gradient(145deg, rgba(127, 215, 126, 0.13), transparent 34rem),
    radial-gradient(circle at 92% 8%, rgba(242, 189, 103, 0.12), transparent 22rem),
    var(--bg);
}

button {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar,
.section-head,
.metric-head,
.proof-row,
.topbar-actions,
.runner-actions {
  display: flex;
  align-items: center;
}

.topbar-actions {
  gap: 10px;
}

.topbar {
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--amber);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 6vw, 4.75rem);
  line-height: 0.96;
}

h2 {
  font-size: 1.25rem;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 138px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(26, 29, 25, 0.82);
  color: var(--muted);
}

:root[data-theme="light"] .status {
  background: rgba(255, 255, 255, 0.82);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--amber);
}

.status[data-status="live"] .status-dot {
  background: var(--green);
}

.status[data-status="offline"] .status-dot {
  background: var(--red);
}

.metrics {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: stretch;
}

.metric-primary,
.runner,
.programs {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-glass);
  box-shadow: var(--shadow);
}

.metric-primary {
  min-width: 0;
  padding: 22px;
}

.metric-head {
  justify-content: space-between;
  gap: 16px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  width: min(100%, 300px);
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control-bg);
}

.segment {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.segment.active {
  color: #10110f;
  background: var(--green);
}

.total {
  font-variant-numeric: tabular-nums;
  font-size: clamp(2.8rem, 13vw, 8.4rem);
  font-weight: 800;
  line-height: 0.92;
}

.total-wrap {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-height: clamp(3.1rem, 14vw, 8.8rem);
  margin-top: 26px;
}

.counter-delta {
  min-width: 4ch;
  margin-top: 0.4em;
  color: var(--green);
  font-size: clamp(1.2rem, 3vw, 2rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  transform: translateY(8px);
}

.counter-delta.flash {
  animation: delta-flash 900ms ease-out;
}

.proof-row {
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

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

.runner {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
  padding: 22px;
}

dl {
  display: grid;
  gap: 12px;
  margin: 0;
}

dl > div {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  align-items: baseline;
}

dt {
  color: var(--muted);
  font-size: 0.82rem;
}

dd {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.runner-actions {
  gap: 10px;
}

.command {
  min-height: 42px;
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-2);
  cursor: pointer;
}

.icon-command,
.close-command {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-2);
  cursor: pointer;
}

.icon-command {
  padding: 0 14px;
}

.close-command {
  padding: 0 12px;
}

.command.primary {
  border-color: transparent;
  color: #10110f;
  background: var(--amber);
}

.command:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.programs {
  margin-top: 18px;
  overflow: hidden;
}

.section-head {
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.program-list {
  display: grid;
}

.program-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px 128px;
  gap: 16px;
  align-items: center;
  min-height: 72px;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(52, 59, 49, 0.72);
}

:root[data-theme="light"] .program-row {
  border-bottom-color: rgba(214, 221, 207, 0.9);
}

.program-row:last-child {
  border-bottom: 0;
}

.program-main {
  min-width: 0;
}

.program-title,
.program-meta {
  display: flex;
  min-width: 0;
  gap: 10px;
  align-items: baseline;
}

.program-title {
  font-weight: 700;
}

.program-title > span:first-child,
.program-meta > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.program-version {
  flex: 0 0 auto;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.program-meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.84rem;
}

.hash {
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.program-stat {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.empty {
  padding: 24px 20px;
  color: var(--muted);
}

.settings-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-solid);
  box-shadow: var(--shadow);
}

.settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.52);
}

.settings-dialog form {
  display: grid;
  gap: 20px;
  padding: 20px;
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.toggle-row span {
  display: grid;
  gap: 3px;
}

.toggle-row small {
  color: var(--muted);
}

.toggle-row input {
  width: 46px;
  height: 26px;
  accent-color: var(--green);
}

@keyframes delta-flash {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  20% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-14px);
  }
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    align-items: stretch;
    width: 100%;
  }

  .status {
    flex: 1;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .metric-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .program-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .program-stat {
    text-align: left;
  }

  .program-title,
  .program-meta,
  .proof-row {
    align-items: flex-start;
    flex-direction: column;
  }
}
