:root {
  --bg: #07111f;
  --bg2: #0a1830;
  --panel: rgba(10, 22, 45, 0.94);
  --panel-2: rgba(11, 27, 54, 0.96);
  --panel-3: rgba(13, 33, 66, 0.96);
  --text: #edf4ff;
  --muted: #95a7c8;
  --line: rgba(163, 191, 255, 0.12);
  --line-strong: rgba(163, 191, 255, 0.2);
  --good: #52d69a;
  --warn: #ffbf47;
  --bad: #ff6a7f;
  --accent: #7fb3ff;
  --accent-2: #8ec5ff;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(33, 77, 164, 0.42), transparent 33%),
    radial-gradient(circle at 86% 12%, rgba(26, 134, 150, 0.22), transparent 22%),
    linear-gradient(180deg, #08111f 0%, #0a1529 46%, #08101d 100%);
  font: 14px/1.5 "IBM Plex Sans", system-ui, sans-serif;
}

body.dashboard-locked {
  overflow: hidden;
}

a {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
}

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-gate[hidden],
.app-shell[hidden] {
  display: none !important;
}

.auth-shell {
  width: min(560px, 100%);
}

.auth-panel {
  padding: 28px;
}

.auth-panel h1 {
  margin: 0;
  font: 700 34px/1.04 "Space Grotesk", "IBM Plex Sans", sans-serif;
}

.auth-copy {
  margin: 14px 0 18px;
  color: #d7e3fb;
  font-size: 15px;
}

.auth-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.auth-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.auth-runtime-panel {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.auth-runtime-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.auth-runtime-item {
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  gap: 4px;
}

.auth-runtime-item span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-runtime-item strong {
  font: 700 16px/1.1 "Space Grotesk", "IBM Plex Sans", sans-serif;
}

.auth-runtime-note {
  margin: 12px 0 0;
}

.content {
  width: min(1540px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

.card {
  background: linear-gradient(180deg, rgba(15, 28, 56, 0.96), rgba(9, 20, 41, 0.94));
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.runtime-bar {
  display: grid;
  grid-template-columns: minmax(300px, 1.1fr) minmax(320px, 1fr);
  gap: 18px 20px;
  padding: 24px;
  margin-bottom: 16px;
}

.runtime-copy h1,
.stage-card h2,
.detail-panel h2 {
  margin: 0;
  font: 700 28px/1.05 "Space Grotesk", "IBM Plex Sans", sans-serif;
  letter-spacing: -0.02em;
}

.runtime-summary {
  margin: 12px 0 8px;
  max-width: 62ch;
  color: #d6e4ff;
  font-size: 15px;
}

.runtime-target {
  margin: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: #8fb0ff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.runtime-pill-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-content: start;
}

.runtime-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  grid-column: 1 / -1;
}

.runtime-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill,
.tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  white-space: normal;
  line-height: 1.25;
}

.pill b,
.tag {
  color: var(--text);
}

.pill.emphasis {
  border-color: rgba(127, 179, 255, 0.38);
  background: linear-gradient(180deg, rgba(127, 179, 255, 0.16), rgba(127, 179, 255, 0.08));
}

.pill.good {
  border-color: rgba(82, 214, 154, 0.34);
  color: #d1ffe8;
}

.pill.warn {
  border-color: rgba(255, 191, 71, 0.34);
  color: #ffe7b3;
}

.pill.bad {
  border-color: rgba(255, 106, 127, 0.34);
  color: #ffd0d8;
}

.runtime-wallet {
  max-width: 100%;
  flex-basis: 100%;
}

.context-pill {
  border-color: rgba(127, 179, 255, 0.2);
  background: rgba(127, 179, 255, 0.07);
  align-items: flex-start;
  border-radius: 18px;
  min-height: 0;
}

.context-pill b {
  display: inline;
  font-weight: 600;
}

.context-pill-muted {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 14px;
  cursor: pointer;
  font: inherit;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.btn.primary {
  border-color: rgba(127, 179, 255, 0.46);
  background: rgba(127, 179, 255, 0.16);
}

.btn.warn {
  border-color: rgba(255, 191, 71, 0.35);
  background: rgba(255, 191, 71, 0.12);
}

.btn.bad {
  border-color: rgba(255, 106, 127, 0.38);
  background: rgba(255, 106, 127, 0.14);
}

.btn.subtle {
  background: rgba(255, 255, 255, 0.025);
}

.health-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.health-card,
.metric-mini,
.decision-tile,
.position-metric,
.rule-chip,
.mini-panel,
.detail-panel,
.alert-card,
.stream-item,
.position-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(16, 31, 61, 0.92), rgba(8, 17, 33, 0.96));
}

.health-card {
  padding: 14px 16px;
  display: grid;
  gap: 4px;
}

.health-label,
.metric-label,
.decision-label,
.position-metric span,
.rule-chip span,
.small,
.table th,
.logline {
  color: var(--muted);
}

.health-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.health-value {
  font: 700 18px/1.1 "Space Grotesk", "IBM Plex Sans", sans-serif;
}

.operator-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.stage-card {
  padding: 22px;
}

.card-header,
.stream-header,
.position-header,
.panel-header {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
}

.stage-meta,
.decision-bar,
.position-summary {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-mini,
.decision-tile {
  padding: 13px 14px;
}

.metric-mini strong,
.decision-tile strong {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font-size: 16px;
}

.featured-candidate {
  margin: 18px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(13, 29, 58, 0.9), rgba(9, 19, 36, 0.96));
}

.candidate-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.candidate-head h3 {
  margin: 0;
  font: 700 24px/1.05 "Space Grotesk", "IBM Plex Sans", sans-serif;
}

.candidate-mint {
  margin: 6px 0 0;
  color: var(--muted);
}

.candidate-health,
.scan-status-rail,
.inline-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scan-status-rail {
  margin-top: 14px;
}

.expando-card {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.02);
}

.expando-card summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 16px;
  font-weight: 600;
}

.expando-card summary::-webkit-details-marker {
  display: none;
}

.expando-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 0 16px 16px;
}

.mini-panel,
.detail-panel {
  padding: 16px;
}

.mini-panel h3,
.detail-panel h2,
.position-card h3 {
  margin: 0 0 10px;
  font: 700 17px/1.15 "Space Grotesk", "IBM Plex Sans", sans-serif;
}

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

.table th,
.table td {
  padding: 8px 4px;
  border-bottom: 1px solid rgba(163, 191, 255, 0.08);
  text-align: left;
  vertical-align: top;
}

.table th {
  font-size: 12px;
  font-weight: 600;
}

.compact-table td:last-child,
.compact-table th:last-child {
  padding-right: 0;
}

.checklist {
  display: grid;
  gap: 10px;
}

.item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.024);
}

.item.good {
  border-color: rgba(82, 214, 154, 0.25);
  background: rgba(82, 214, 154, 0.07);
}

.item.warn {
  border-color: rgba(255, 191, 71, 0.22);
  background: rgba(255, 191, 71, 0.06);
}

.item.bad {
  border-color: rgba(255, 106, 127, 0.24);
  background: rgba(255, 106, 127, 0.07);
}

.icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  flex: 0 0 auto;
  margin-top: 2px;
}

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

.tag.good {
  border-color: rgba(82, 214, 154, 0.34);
  color: #d1ffe8;
}

.tag.warn {
  border-color: rgba(255, 191, 71, 0.34);
  color: #ffe7b3;
}

.tag.bad {
  border-color: rgba(255, 106, 127, 0.34);
  color: #ffd0d8;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted);
}

.tag.good .dot {
  background: var(--good);
}

.tag.warn .dot {
  background: var(--warn);
}

.tag.bad .dot {
  background: var(--bad);
}

.stream-header,
.position-header {
  margin: 18px 0 12px;
}

.checked-stream-shell {
  margin: 18px 0 0;
  padding: 16px 18px;
  border: 1px solid rgba(163, 191, 255, 0.1);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(13, 23, 49, 0.78), rgba(8, 16, 34, 0.92)),
    radial-gradient(circle at top right, rgba(94, 202, 255, 0.1), transparent 52%);
}

.checked-stream-head {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.checked-stream-list {
  display: grid;
  gap: 10px;
  max-height: 240px;
  overflow: auto;
  padding-right: 4px;
}

.checked-token {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 11px 12px;
  border: 1px solid rgba(163, 191, 255, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
}

.checked-token.accepted {
  border-color: rgba(82, 214, 154, 0.2);
  background: rgba(82, 214, 154, 0.07);
}

.checked-token.rejected {
  border-color: rgba(255, 106, 127, 0.18);
  background: rgba(255, 106, 127, 0.06);
}

.checked-token.featured {
  box-shadow: 0 0 0 1px rgba(127, 179, 255, 0.26) inset;
}

.checked-token.empty {
  grid-template-columns: 1fr;
  color: var(--muted);
  padding: 16px;
}

.checked-order {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid rgba(163, 191, 255, 0.14);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.checked-token-main {
  min-width: 0;
}

.checked-token-name {
  display: block;
  font: 700 15px/1.15 "Space Grotesk", "IBM Plex Sans", sans-serif;
  color: var(--text);
}

.checked-token-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.checked-token-reason {
  min-width: 0;
  text-align: right;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.checked-token-reason strong {
  display: block;
  color: var(--text);
  font-size: 12px;
}

@media (max-width: 860px) {
  .checked-token {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .checked-token-reason {
    grid-column: 1 / -1;
    text-align: left;
    padding-left: 42px;
  }
}

.stream-list,
.position-deck,
.alert-stack,
.pending-list,
.panel-stack {
  display: grid;
  gap: 12px;
}

.stream-item {
  overflow: hidden;
}

.stream-item summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 18px;
}

.stream-item summary::-webkit-details-marker {
  display: none;
}

.stream-item.accepted {
  border-color: rgba(82, 214, 154, 0.28);
}

.stream-item.rejected {
  border-color: rgba(255, 106, 127, 0.22);
}

.stream-item.empty,
.position-card.empty {
  padding: 20px;
  color: var(--muted);
}

.stream-item-head,
.position-head {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
}

.stream-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.stream-token {
  display: block;
  font: 700 17px/1.15 "Space Grotesk", "IBM Plex Sans", sans-serif;
  color: var(--text);
}

.stream-address {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.stream-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stream-chip.source {
  background: rgba(127, 179, 255, 0.12);
  color: #d6e8ff;
}

.stream-chip.good {
  background: rgba(82, 214, 154, 0.14);
  color: #d1ffe8;
}

.stream-chip.bad {
  background: rgba(255, 106, 127, 0.14);
  color: #ffd4dc;
}

.stream-item-body {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.stream-detail-grid,
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0 18px 18px;
}

.detail-stack {
  display: grid;
  gap: 8px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(163, 191, 255, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.024);
}

.detail-row.good strong {
  color: #d1ffe8;
}

.detail-row.warn strong {
  color: #ffe7b3;
}

.detail-row.bad strong {
  color: #ffd0d8;
}

.position-card {
  padding: 18px;
}

.position-status-copy {
  margin: 14px 0 0;
}

.position-metrics-grid,
.position-rule-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.position-metric,
.rule-chip {
  padding: 12px 13px;
}

.position-metric strong,
.rule-chip strong {
  display: block;
  margin-top: 5px;
  color: var(--text);
}

.rule-chip.good {
  border-color: rgba(82, 214, 154, 0.28);
}

.rule-chip.warn {
  border-color: rgba(255, 191, 71, 0.22);
}

.position-rationale {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(163, 191, 255, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.024);
}

.position-rationale-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.position-rationale p {
  margin: 0;
  color: #dbe7ff;
}

.lower-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 18px;
  margin-top: 18px;
}

.lower-grid .full-span {
  grid-column: 1 / -1;
}

.alert-card {
  padding: 16px;
  display: grid;
  gap: 5px;
}

.alert-card.good {
  border-color: rgba(82, 214, 154, 0.28);
}

.alert-card.warn {
  border-color: rgba(255, 191, 71, 0.26);
}

.alert-card.bad {
  border-color: rgba(255, 106, 127, 0.28);
}

.log {
  max-height: 360px;
  overflow: auto;
}

.logline {
  padding: 9px 0;
  border-bottom: 1px solid rgba(163, 191, 255, 0.08);
}

.logline b {
  color: var(--text);
}

.logline.info {
  color: #dce7ff;
}

.logline.warn {
  color: #ffe2a0;
}

.logline.error {
  color: #ffcad4;
}

.chart {
  width: 100%;
  height: 300px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.16);
}

.pending-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.024);
}

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

.pending-meta {
  margin-top: 7px;
  display: grid;
  gap: 4px;
  color: var(--muted);
}

.pending-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

.pending-actions button {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 7px 10px;
  cursor: pointer;
}

.pending-actions .approve {
  border-color: rgba(82, 214, 154, 0.28);
}

.pending-actions .reject {
  border-color: rgba(255, 106, 127, 0.28);
}

.target-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px 12px;
  align-items: center;
}

input[type="text"],
input[type="password"],
select {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  width: 100%;
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
  outline: 1px solid rgba(127, 179, 255, 0.52);
}

.admin-inline-label {
  align-self: center;
  color: var(--muted);
}

.admin-inline-select {
  min-width: 190px;
}

.admin-inline-status {
  margin-top: 10px;
  color: var(--muted);
}

.pnl-pos {
  color: #7bf1bc;
}

.pnl-neg {
  color: #ffb2bf;
}

details.admin-panel > summary {
  cursor: pointer;
  list-style: none;
}

details.admin-panel > summary::-webkit-details-marker {
  display: none;
}

@media (max-width: 1380px) {
  .health-strip,
  .stage-meta,
  .decision-bar,
  .position-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .expando-grid,
  .lower-grid,
  .operator-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .content {
    width: min(100vw - 24px, 100%);
    padding-top: 16px;
  }

  .runtime-bar,
  .runtime-pill-grid,
  .runtime-status-row,
  .position-metrics-grid,
  .position-rule-grid,
  .stream-detail-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .health-strip {
    grid-template-columns: 1fr;
  }

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

  .auth-runtime-grid {
    grid-template-columns: 1fr;
  }

  .auth-panel {
    padding: 22px;
  }
}
