:root {
  --bg: #080c14;
  --bg-elevated: #0f1623;
  --bg-card: #121b2b;
  --bg-card-hover: #162236;
  --border: #1e2d45;
  --border-strong: #2d4365;
  --text: #e6eefb;
  --text-muted: #93a7c6;
  --text-dim: #6c80a0;
  --emerald: #10b981;
  --emerald-soft: rgba(16, 185, 129, 0.14);
  --cyan: #38bdf8;
  --cyan-soft: rgba(56, 189, 248, 0.14);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.14);
  --purple: #a78bfa;
  --purple-soft: rgba(167, 139, 250, 0.14);
  --radius: 14px;
  --radius-sm: 8px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 18% 0%, rgba(245, 158, 11, 0.10), transparent 40%),
    radial-gradient(circle at 82% 8%, rgba(16, 185, 129, 0.09), transparent 40%),
    linear-gradient(to right, rgba(30, 45, 69, 0.28) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(30, 45, 69, 0.28) 1px, transparent 1px);
  background-size: auto, auto, 48px 48px, 48px 48px;
  pointer-events: none;
  z-index: -1;
}

.container {
  max-width: 1220px;
  margin: 0 auto;
  padding: 0 22px;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(8, 12, 20, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 0.95rem;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--amber), var(--emerald));
  box-shadow: 0 0 12px var(--emerald);
}

.badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.badge-version {
  background: var(--amber-soft);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.45);
}

.topnav {
  display: flex;
  align-items: center;
  gap: 22px;
}

.topnav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.15s;
}

.topnav a:hover {
  color: var(--text);
}

.host-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--emerald);
  background: var(--emerald-soft);
  border: 1px solid rgba(16, 185, 129, 0.35);
  padding: 5px 12px;
  border-radius: 999px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

/* Hero */
.hero {
  padding: 50px 0 26px;
}

.hero-kicker {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.1em;
  color: var(--cyan);
  margin-bottom: 12px;
  font-weight: 600;
}

.hero h1 {
  font-size: clamp(2rem, 4.2vw, 3.05rem);
  line-height: 1.18;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}

.accent {
  background: linear-gradient(120deg, var(--emerald), var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.amber-text {
  color: var(--amber);
}

.hero-desc {
  max-width: 860px;
  color: var(--text-muted);
  font-size: 1.02rem;
  margin-bottom: 28px;
}

.hero-desc strong {
  color: var(--text);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.kpi-bounty {
  border-color: rgba(245, 158, 11, 0.45);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.09), var(--bg-card));
}

.kpi-highlight {
  border-color: rgba(16, 185, 129, 0.45);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.08), var(--bg-card));
}

.kpi-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 4px;
}

.kpi-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* Sections */
.section {
  padding: 34px 0 18px;
}

.section-head {
  margin-bottom: 18px;
}

.section-head h2 {
  font-size: 1.45rem;
  margin-bottom: 6px;
}

.section-sub {
  color: var(--text-muted);
  font-size: 0.94rem;
}

/* Horizon Switcher */
.horizon-switcher {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.horizon-btn {
  text-align: left;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: all 0.16s;
}

.horizon-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-card);
}

.horizon-btn .h-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.horizon-btn .h-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.horizon-btn.active[data-horizon="short"] {
  border-color: rgba(245, 158, 11, 0.7);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.14), var(--bg-card));
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.25);
}

.horizon-btn.active[data-horizon="long"] {
  border-color: rgba(56, 189, 248, 0.7);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.13), var(--bg-card));
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.22);
}

.horizon-btn.active[data-horizon="all"] {
  border-color: rgba(16, 185, 129, 0.7);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.13), var(--bg-card));
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.22);
}

/* Controls */
.controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
  padding: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.tab:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.tab.active {
  background: var(--cyan-soft);
  color: var(--cyan);
  border-color: rgba(56, 189, 248, 0.5);
  font-weight: 600;
}

.controls-right {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.search-input,
.sort-select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.86rem;
  outline: none;
}

.search-input {
  width: 245px;
}

.search-input:focus,
.sort-select:focus {
  border-color: var(--cyan);
}

/* Playbook Grid */
.playbook-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: border-color 0.18s, background 0.18s;
}

.card:hover {
  border-color: var(--border-strong);
  background: var(--bg-card-hover);
}

.card.card-short {
  border-top: 2px solid rgba(245, 158, 11, 0.55);
}

.card.selected {
  border-color: rgba(16, 185, 129, 0.7);
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.25);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.card-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-bottom: 8px;
}

.rank-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 700;
}

.horizon-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
}

.horizon-short {
  background: var(--amber-soft);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.45);
}

.horizon-long {
  background: var(--cyan-soft);
  color: var(--cyan);
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.tier-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
}

.tier-S {
  background: var(--emerald-soft);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.45);
}

.tier-A {
  background: var(--cyan-soft);
  color: var(--cyan);
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.tier-Bplus,
.tier-B {
  background: rgba(148, 163, 184, 0.14);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.cat-badge {
  font-size: 0.74rem;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.card h3 {
  font-size: 1.14rem;
  line-height: 1.3;
  margin-bottom: 3px;
}

.card-subtitle {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}

.score-pill {
  flex-shrink: 0;
  text-align: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  min-width: 72px;
}

.score-num {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--emerald);
  line-height: 1.1;
}

.score-label {
  font-size: 0.68rem;
  color: var(--text-dim);
}

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

.bar-item {
  background: rgba(8, 12, 20, 0.55);
  border: 1px solid rgba(30, 45, 69, 0.7);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.bar-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.bar-track {
  height: 5px;
  border-radius: 999px;
  background: #1b273c;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--emerald), var(--cyan));
}

.card-short .bar-fill {
  background: linear-gradient(90deg, var(--amber), var(--emerald));
}

.quick-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 0.83rem;
  color: var(--text-muted);
  background: rgba(8, 12, 20, 0.45);
  border: 1px solid rgba(30, 45, 69, 0.6);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
}

.quick-facts strong {
  color: var(--text);
}

.hil-low {
  color: var(--emerald) !important;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.pill {
  font-size: 0.77rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--purple-soft);
  color: #d6c8ff;
  border: 1px solid rgba(167, 139, 250, 0.3);
}

.block {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.block-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}

.pitfall-list {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.subagent-box {
  background: rgba(56, 189, 248, 0.07);
  border: 1px dashed rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.84rem;
  color: #cbeaff;
}

.subagent-box strong {
  color: var(--cyan);
}

.card-footer {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.select-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  user-select: none;
}

.select-toggle input {
  width: 17px;
  height: 17px;
  accent-color: var(--emerald);
  cursor: pointer;
}

/* Matrix Table */
.table-wrap {
  overflow-x: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 880px;
  font-size: 0.85rem;
}

.matrix-table th,
.matrix-table td {
  text-align: left;
  padding: 12px 13px;
  border-bottom: 1px solid var(--border);
}

.matrix-table th {
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.79rem;
}

.matrix-table tr:last-child td {
  border-bottom: none;
}

.matrix-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* Combo */
.strategy-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

.combo-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: stretch;
  gap: 14px;
}

.combo-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.combo-card-bounty {
  border-color: rgba(245, 158, 11, 0.35);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.06), var(--bg-card));
}

.combo-step {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--emerald);
  font-weight: 700;
  margin-bottom: 8px;
}

.combo-card h3 {
  font-size: 1.02rem;
  margin-bottom: 8px;
}

.combo-card p {
  font-size: 0.87rem;
  color: var(--text-muted);
}

.combo-card strong {
  color: var(--text);
}

.combo-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--cyan);
  font-weight: 700;
}

/* Dispatch Panel */
.dispatch-section {
  padding-bottom: 56px;
}

.dispatch-card {
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.08), var(--bg-card));
  border: 1px solid rgba(16, 185, 129, 0.45);
  border-radius: var(--radius);
  padding: 26px;
}

.dispatch-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}

.dispatch-header p {
  max-width: 720px;
}

.dispatch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 15px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s, opacity 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(120deg, var(--emerald), #0ea5e9);
  color: #04131c;
}

.btn-primary:hover {
  opacity: 0.92;
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover {
  border-color: var(--cyan);
}

.selected-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.sel-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--emerald-soft);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: var(--emerald);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}

.sel-chip.sel-short {
  background: var(--amber-soft);
  border-color: rgba(245, 158, 11, 0.45);
  color: var(--amber);
}

.sel-chip button {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.brief-preview-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.brief-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: #d6e4f7;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 24px 0 36px;
  color: var(--text-dim);
  font-size: 0.84rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
}

.footer code {
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.footer a {
  color: var(--cyan);
  text-decoration: none;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: var(--emerald);
  color: #031510;
  font-weight: 700;
  font-size: 0.88rem;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 60;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

@media (max-width: 980px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .horizon-switcher {
    grid-template-columns: 1fr;
  }
  .playbook-grid {
    grid-template-columns: 1fr;
  }
  .combo-grid {
    grid-template-columns: 1fr;
  }
  .combo-arrow {
    transform: rotate(90deg);
    padding: 2px 0;
  }
  .topnav {
    display: none;
  }
}

@media (max-width: 560px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .bars-grid {
    grid-template-columns: 1fr;
  }
  .search-input {
    width: 100%;
  }
}
