:root {
  --bg: #070d19;
  --surface: #0f172a;
  --surface-2: #162238;
  --border: #25344f;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --starter: #14b8a6;
  --standard: #f59e0b;
  --showcase: #f43f5e;
  --focus: #38bdf8;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

a {
  color: #38bdf8;
}

.wrap {
  max-width: 1360px;
  margin: 0 auto;
  padding: 20px 16px 56px;
}

.hero {
  background: linear-gradient(135deg, #0d182d 0%, #101f36 60%, #17152e 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
}

.eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #2dd4bf;
  margin: 0 0 6px;
  font-weight: 700;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.6rem, 3vw, 2.35rem);
  line-height: 1.15;
}

.hero-lead {
  margin: 0 0 8px;
  font-size: 1.05rem;
  color: #e2e8f0;
  max-width: 72ch;
}

.hero-credit {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.95rem;
}

.agent-start {
  background: #070d19;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.agent-start-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 6px;
}

.agent-cmd {
  display: block;
  color: #e2e8f0;
  font-size: 0.85rem;
  word-break: break-word;
  margin-bottom: 10px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.btn-primary,
.btn-secondary,
.tier-filter,
.replay-speed,
.band-tab {
  appearance: none;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.btn-primary {
  background: #0f766e;
  border-color: #14b8a6;
  color: #ffffff;
}

.btn-primary:hover {
  background: #115e59;
}

.btn-secondary:hover,
.tier-filter:hover,
.replay-speed:hover,
.band-tab:hover {
  border-color: #64748b;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

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

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: clamp(1.1rem, 2vw, 1.55rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
  word-break: break-word;
}

.analytics-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 20px;
}

.band-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.band-tab {
  flex-direction: column;
  align-items: flex-start;
  padding: 6px 11px;
  gap: 1px;
}

.band-tab span {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
}

.band-tab.active {
  border-color: #38bdf8;
  background: #152847;
}

.band-tab.frontier {
  border-left: 3px solid var(--showcase);
}

.band-tab.complete strong::after {
  content: " · ok";
  color: #2dd4bf;
  font-weight: 600;
  font-size: 0.78rem;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.chart-box h3 {
  margin: 0 0 6px;
  font-size: 0.92rem;
  color: #cbd5e1;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 10px;
  border: 1px solid #1e293b;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr);
  gap: 18px;
  align-items: start;
}

.map-panel,
.inspector-card,
.activity-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}

.map-panel {
  position: relative;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tier-filter.active,
.replay-speed.active {
  background: #1d3557;
  border-color: #38bdf8;
}

.presence-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--muted);
}

.replay-panel {
  background: #0b1324;
  border: 1px solid #38bdf8;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.replay-panel[hidden] {
  display: none;
}

.replay-panel input[type="range"] {
  flex: 1 1 160px;
  min-width: 120px;
}

.frontier-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 14px;
  color: #fb7185;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.frontier-divider::before,
.frontier-divider::after {
  content: "";
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, rgba(244, 63, 94, 0.2), rgba(244, 63, 94, 0.85));
}

.band-group {
  margin-bottom: 16px;
}

.band-group-head h3 {
  margin: 0;
  font-size: 0.98rem;
}

.band-meta {
  margin: 2px 0 10px;
  font-size: 0.82rem;
  color: var(--muted);
}

.unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 5px;
}

.unit-tile {
  position: relative;
  appearance: none;
  border-radius: 6px;
  border: 1px solid #26354d;
  background: #0b1120;
  color: #cbd5e1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  padding: 7px 3px;
  cursor: pointer;
  text-align: center;
}

.unit-tile.tier-starter {
  border-color: rgba(20, 184, 166, 0.45);
}

.unit-tile.tier-standard {
  border-color: rgba(245, 158, 11, 0.45);
}

.unit-tile.tier-showcase {
  border-color: rgba(244, 63, 94, 0.45);
}

.unit-tile.accepted.tier-starter {
  background: rgba(20, 184, 166, 0.28);
  border-color: var(--starter);
  color: #ffffff;
  font-weight: 700;
}

.unit-tile.accepted.tier-standard {
  background: rgba(245, 158, 11, 0.28);
  border-color: var(--standard);
  color: #ffffff;
  font-weight: 700;
}

.unit-tile.accepted.tier-showcase {
  background: rgba(244, 63, 94, 0.28);
  border-color: var(--showcase);
  color: #ffffff;
  font-weight: 700;
}

.unit-tile.live-claimed {
  background: rgba(56, 189, 248, 0.2);
  border-style: dashed;
  border-color: #38bdf8;
}

.unit-tile.live-submitted,
.unit-tile.live-checked,
.unit-tile.live-agreeing {
  border-color: #facc15;
  animation: pulse-slot 1.4s ease-in-out infinite;
}

.unit-tile.fresh {
  box-shadow: 0 0 0 2px #2dd4bf;
}

.unit-tile.selected {
  box-shadow: 0 0 0 2px #ffffff;
}

.tile-badge {
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: 0.6rem;
  color: #facc15;
}

.presence-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  border-radius: 14px;
}

.presence-dot {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #38bdf8;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25);
}

.presence-label {
  position: absolute;
  left: 11px;
  top: -4px;
  background: rgba(15, 23, 42, 0.92);
  color: #e2e8f0;
  font-size: 0.7rem;
  padding: 1px 5px;
  border-radius: 4px;
  white-space: nowrap;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.inspector-head {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.pill {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 999px;
  background: #1e293b;
  color: #e2e8f0;
}

.pill.tier-starter { background: rgba(20, 184, 166, 0.22); color: #5eead4; }
.pill.tier-standard { background: rgba(245, 158, 11, 0.22); color: #fcd34d; }
.pill.tier-showcase { background: rgba(244, 63, 94, 0.22); color: #fda4af; }
.pill-ok { background: rgba(34, 197, 94, 0.22); color: #86efac; }

.inspector-card h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.credit-line,
.slot-summary,
.visual-caption,
.how-it-works,
.muted {
  color: var(--muted);
  font-size: 0.88rem;
}

.live-banner {
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.86rem;
}

.inspector-visual {
  margin: 12px 0;
}

.lattice-svg {
  width: 100%;
  max-width: 280px;
  height: auto;
  display: block;
  margin: 0 auto 8px;
}

.stat-list {
  margin: 12px 0;
  display: grid;
  gap: 8px;
}

.stat-list > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid #1e293b;
  padding-bottom: 6px;
  font-size: 0.86rem;
}

.stat-list dt {
  color: var(--muted);
}

.stat-list dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.needs-list {
  margin: 10px 0 14px;
  padding-left: 18px;
  font-size: 0.86rem;
  color: #cbd5e1;
}

.claim-actions {
  margin: 12px 0 8px;
}

.activity-card h2 {
  margin: 0 0 8px;
  font-size: 0.96rem;
}

.activity-list {
  margin: 0;
  padding-left: 18px;
  font-size: 0.84rem;
  display: grid;
  gap: 6px;
}

.site-footer {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.84rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
}

@keyframes pulse-slot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.45); }
  50% { box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.12); }
}

@media (prefers-reduced-motion: reduce) {
  .unit-tile.live-submitted,
  .unit-tile.live-checked,
  .unit-tile.live-agreeing {
    animation: none;
  }
}

@media (max-width: 980px) {
  .totals-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .charts-grid,
  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .wrap {
    padding: 12px 10px 40px;
  }
  .hero {
    padding: 16px;
  }
  .totals-grid {
    grid-template-columns: 1fr;
  }
  .unit-grid {
    grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  }
}
