:root {
  color-scheme: dark;
  --bg: #080d0b;
  --surface: #111713;
  --surface-2: #171d18;
  --line: #2a352f;
  --text: #e7ece4;
  --muted: #8f988e;
  --green: #8fdbad;
  --green-2: #244c39;
  --amber: #d8a64f;
  --blue: #73b7d7;
  --red: #d06a67;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 8% 4%, rgba(143, 219, 173, 0.18), transparent 24rem),
    radial-gradient(circle at 96% 0%, rgba(216, 166, 79, 0.12), transparent 20rem),
    linear-gradient(135deg, #a9c8ca, #d1b7ae 58%, #ebe1d7);
  color: var(--text);
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

code,
pre {
  font-family: "SFMono-Regular", Consolas, monospace;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121913;
  color: var(--text);
  font: inherit;
  min-height: 38px;
  padding: 0 16px;
  cursor: pointer;
  white-space: nowrap;
}

.setup-error {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 28px;
}

.setup-error section {
  width: min(880px, 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent),
    #080d0b;
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.48);
  padding: 34px;
}

.setup-error h1 {
  margin: 12px 0;
  font-size: 30px;
}

.setup-error p {
  color: var(--muted);
  line-height: 1.75;
}

.setup-error-card {
  margin-top: 18px;
  border: 1px solid rgba(143, 219, 173, 0.22);
  border-radius: 10px;
  background: rgba(143, 219, 173, 0.06);
  padding: 16px;
}

.setup-error-card h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.setup-error-card pre {
  overflow: auto;
  margin: 0;
  color: #cfe8d6;
  line-height: 1.7;
  white-space: pre-wrap;
}

.setup-error-muted {
  margin-top: 18px;
  color: var(--amber);
}

button:hover,
button.selected {
  border-color: #47745b;
  background: #1c3428;
  color: var(--green);
}

button.primary {
  background: linear-gradient(180deg, #9ae1b6, #72c593);
  color: #092013;
  border-color: #9ae1b6;
  font-weight: 700;
}

.shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  width: calc(100vw - 40px);
  min-height: calc(100vh - 40px);
  margin: 20px;
  overflow: hidden;
  border-radius: 34px;
  background: #070c09;
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.48);
}

.sidebar {
  padding: 28px 24px;
  border-right: 1px solid var(--line);
  background: #07100c;
}

.brand {
  padding: 10px 4px 26px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  display: block;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 4px;
}

.brand strong {
  display: block;
  margin-top: 10px;
  font-size: 22px;
}

.brand small,
.topbar p,
.briefing p,
.keyword-row p,
.keyword-row small,
.opportunity-card p,
.opportunity-card small,
.source-row p {
  color: var(--muted);
}

.nav {
  display: grid;
  gap: 8px;
  margin: 18px 0 28px;
}

.nav button {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  color: #cbd4cc;
  text-decoration: none;
  text-align: left;
  width: 100%;
}

.nav button.active {
  background: #1a2b22;
  color: #f2f8f1;
  box-shadow: inset 3px 0 0 var(--green);
}

.nav em {
  color: var(--green);
  background: rgba(143, 219, 173, 0.12);
  border: 1px solid rgba(143, 219, 173, 0.25);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-style: normal;
}

.side-block {
  margin-top: 26px;
}

.side-block h2 {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 4px;
}

.config-row,
.segment {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  min-height: 31px;
  color: #b8c2b8;
  gap: 8px;
}

.segment {
  grid-template-columns: 1fr auto;
}

.filter-chip {
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  width: 100%;
}

.config-row b,
.segment b {
  color: var(--muted);
  font-size: 13px;
}

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

.dot.ok {
  background: var(--green);
}

.workspace {
  padding: 32px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 10px 0 6px;
  font-size: 28px;
}

.topbar p {
  margin: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.notice {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid #315f49;
  border-radius: 8px;
  background: rgba(143, 219, 173, 0.1);
  color: var(--green);
}

.analysis-dialog {
  width: min(920px, calc(100vw - 40px));
  max-height: min(820px, calc(100vh - 40px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #101611;
  color: var(--text);
  padding: 0;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}

.analysis-dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.dialog-close {
  position: sticky;
  top: 16px;
  float: right;
  margin: 16px 16px 0 0;
  width: 36px;
  min-height: 36px;
  padding: 0;
  z-index: 1;
}

.analysis-dialog-body {
  padding: 30px;
}

.analysis-dialog h2 {
  margin: 10px 0 12px;
}

.analysis-summary {
  color: var(--text);
  line-height: 1.7;
  border: 1px solid rgba(143, 219, 173, 0.2);
  border-radius: 8px;
  background: rgba(143, 219, 173, 0.07);
  padding: 14px;
}

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

.analysis-sections section {
  border: 1px solid rgba(42, 53, 47, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  padding: 14px;
}

.analysis-sections h3 {
  margin: 0 0 8px;
}

.analysis-sections p,
.analysis-sections li {
  color: var(--muted);
  line-height: 1.55;
}

.analysis-sections ul {
  margin: 0;
  padding-left: 20px;
}

.analysis-sections pre {
  overflow: auto;
  margin: 0;
  color: var(--muted);
  white-space: pre-wrap;
}

.analysis-sections .dialog-actions {
  grid-column: 1 / -1;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metric,
.briefing,
.panel,
.wide-panel,
.job-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent),
    var(--surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.wide-panel {
  margin-top: 28px;
  padding: 22px;
  min-height: 680px;
}

[data-view="game-mining"] .wide-panel {
  margin-top: 0;
}

.metric {
  min-height: 142px;
  padding: 22px;
}

.metric div,
.panel-head,
.opportunity-card div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.metric span,
.metric em {
  color: var(--muted);
  font-style: normal;
}

.metric strong {
  display: block;
  margin-top: 18px;
  font-size: 44px;
  line-height: 1;
}

.metric p {
  margin: 12px 0 0;
  color: var(--muted);
}

.metric.green {
  border-top-color: var(--green);
}

.metric.blue {
  border-top-color: var(--blue);
}

.metric.amber,
.opportunity-card span {
  border-top-color: var(--amber);
  color: var(--amber);
}

.metric.red {
  border-top-color: var(--red);
}

.briefing {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 106px;
  padding: 20px 22px;
  margin-bottom: 20px;
}

.briefing button {
  flex-shrink: 0;
}

.briefing h2,
.panel h2 {
  margin: 8px 0 0;
  font-size: 18px;
}

.briefing p {
  margin: 8px 0 0;
  max-width: 1100px;
  line-height: 1.7;
}

.grid {
  display: grid;
  grid-template-columns: 1.4fr 1.05fr 1fr;
  gap: 20px;
}

.opportunity-grid,
.job-grid,
.mining-layout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.job-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.task-console {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(0, 1.1fr);
  gap: 16px;
}

.task-card {
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  padding: 18px;
}

.task-card h3 {
  margin: 0;
}

.task-list {
  display: grid;
  gap: 10px;
}

.task-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101711;
  padding: 14px;
}

.task-row.running {
  border-color: rgba(143, 219, 173, 0.5);
  box-shadow: inset 3px 0 0 var(--green);
}

.task-row.failed {
  border-color: rgba(208, 106, 103, 0.55);
  box-shadow: inset 3px 0 0 var(--red);
}

.task-row.cancelled {
  border-color: rgba(216, 166, 79, 0.55);
  box-shadow: inset 3px 0 0 var(--amber);
}

.task-row h4 {
  margin: 0 0 6px;
}

.task-row p,
.task-row small {
  display: block;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.task-log {
  height: 500px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #070c09;
  padding: 14px;
  font-family: "SFMono-Regular", Consolas, monospace;
}

.task-log p {
  margin: 0 0 10px;
  color: #b8c2b8;
  line-height: 1.6;
  word-break: break-word;
}

.task-log span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.task-log .warn {
  color: var(--amber);
}

.task-log .error {
  color: var(--red);
}

.mining-layout {
  grid-template-columns: minmax(320px, 0.85fr) minmax(0, 1.4fr);
}

.mining-layout.mining-layout-full {
  grid-template-columns: minmax(0, 1fr);
}

.sync-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
  min-width: 280px;
}

.sync-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: right;
}

.sync-status.running {
  color: var(--green);
}

.sync-status.error {
  color: var(--red);
}

button.is-loading {
  position: relative;
  opacity: 0.82;
}

button.is-loading::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 8px;
  border: 2px solid rgba(9, 32, 19, 0.35);
  border-top-color: #092013;
  border-radius: 50%;
  vertical-align: -2px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.panel {
  min-height: 560px;
  padding: 22px;
}

.panel-head {
  align-items: center;
  margin-bottom: 18px;
}

.panel-head h2 {
  margin: 0;
}

.panel-head span {
  color: var(--muted);
}

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

.keyword-row {
  display: grid;
  grid-template-columns: 34px 1fr 48px;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid rgba(42, 53, 47, 0.7);
}

.keyword-row > b {
  display: grid;
  place-items: center;
  width: 28px;
  height: 26px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
}

.keyword-row h3,
.opportunity-card h3,
.source-row h3,
.signal-row h3,
.keyword-table-row h3,
.job-card h3 {
  margin: 0;
  font-size: 16px;
}

.keyword-row p {
  margin: 7px 0 4px;
  line-height: 1.45;
}

.keyword-row strong {
  color: var(--green);
  text-align: right;
  font-size: 18px;
}

.inline-actions,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.inline-actions button,
.row-actions button,
.icon-action {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

button.on,
.icon-action.on {
  border-color: var(--amber);
  color: var(--amber);
  background: rgba(216, 166, 79, 0.12);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.tags span {
  border: 1px solid #315f49;
  border-radius: 6px;
  background: rgba(143, 219, 173, 0.12);
  color: var(--green);
  padding: 4px 8px;
  font-size: 12px;
}

.opportunity-card {
  padding: 16px 0;
  border-bottom: 1px solid rgba(42, 53, 47, 0.7);
}

.opportunity-grid .opportunity-card {
  border: 1px solid rgba(42, 53, 47, 0.9);
  border-radius: 8px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.025);
}

.opportunity-card h3 {
  margin-top: 10px;
}

.opportunity-card p {
  margin: 8px 0;
  line-height: 1.55;
}

.opportunity-card time {
  color: var(--muted);
}

select,
.search {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d130f;
  color: var(--text);
  padding: 0 10px;
  font: inherit;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  padding: 12px;
  border: 1px solid rgba(42, 53, 47, 0.75);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.filter-bar label {
  display: grid;
  gap: 6px;
  min-width: 220px;
}

.filter-bar label span {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 2px;
}

.search {
  min-width: 320px;
}

.table-list {
  display: grid;
  gap: 10px;
}

.signal-row,
.keyword-table-row {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid rgba(42, 53, 47, 0.8);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.signal-row p,
.keyword-table-row p,
.job-card p {
  margin: 6px 0;
  color: var(--muted);
  line-height: 1.5;
}

.signal-row small,
.job-card small {
  color: var(--muted);
}

.ghost-link {
  color: var(--green);
  text-decoration: none;
  border: 1px solid rgba(143, 219, 173, 0.22);
  border-radius: 8px;
  padding: 8px 10px;
}

.keyword-table {
  display: grid;
  gap: 10px;
}

.table-head,
.keyword-table-row {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 80px 180px 280px;
  gap: 14px;
  align-items: center;
}

.table-head {
  color: var(--muted);
  padding: 0 14px;
  font-size: 13px;
  letter-spacing: 2px;
}

.job-card {
  padding: 18px;
}

.mining-card {
  border: 1px solid rgba(42, 53, 47, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  padding: 18px;
}

.mining-card h3 {
  margin: 10px 0 8px;
}

.mining-card p,
.empty-note {
  color: var(--muted);
  line-height: 1.6;
}

.source-stack {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.tool-list {
  margin-top: 18px;
}

.source-row.compact {
  grid-template-columns: 1fr auto;
  padding: 12px;
  border: 1px solid rgba(42, 53, 47, 0.75);
  border-radius: 8px;
}

.source-row.compact p {
  word-break: break-all;
}

.discovery-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, auto);
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(42, 53, 47, 0.8);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.discovery-actions {
  justify-content: flex-end;
  min-width: 360px;
  margin-top: 0;
}

.discovery-actions .ghost-link {
  min-height: 30px;
  padding: 6px 10px;
  font-size: 13px;
}

.discovery-row h3 {
  margin: 0;
}

.discovery-row p {
  margin: 6px 0;
  color: var(--muted);
  line-height: 1.5;
}

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

.discovery-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.discovery-meta span {
  border: 1px solid rgba(143, 219, 173, 0.18);
  border-radius: 6px;
  background: rgba(143, 219, 173, 0.08);
  color: #b8c2b8;
  padding: 4px 8px;
  font-size: 12px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 18px;
}

.pager a {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--green);
  padding: 8px 12px;
  text-decoration: none;
}

.pager a.disabled {
  color: var(--muted);
  pointer-events: none;
  opacity: 0.45;
}

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

.switch {
  display: inline-flex;
  align-items: center;
  margin: 12px 0;
}

.switch input {
  display: none;
}

.switch span {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: #26302a;
  border: 1px solid var(--line);
  position: relative;
  cursor: pointer;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.16s ease, background 0.16s ease;
}

.switch input:checked + span {
  background: #1c3428;
  border-color: #47745b;
}

.switch input:checked + span::after {
  transform: translateX(20px);
  background: var(--green);
}

.source-row {
  display: grid;
  grid-template-columns: 1fr 96px 36px;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid rgba(42, 53, 47, 0.7);
}

.source-row p {
  margin: 6px 0 0;
}

.source-row strong {
  color: var(--green);
  text-align: right;
}

meter {
  width: 96px;
  height: 8px;
}

@media (max-width: 1180px) {
  .shell {
    grid-template-columns: 1fr;
    width: calc(100vw - 24px);
    margin: 12px;
    border-radius: 22px;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    grid-template-columns: repeat(8, minmax(120px, 1fr));
    overflow-x: auto;
  }

  .topbar,
  .briefing {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar {
    flex-wrap: wrap;
  }
}

@media (max-width: 1300px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .opportunity-grid,
  .job-grid,
  .task-console,
  .mining-layout {
    grid-template-columns: 1fr 1fr;
  }

  .mining-layout.mining-layout-full {
    grid-template-columns: minmax(0, 1fr);
  }

  .table-head,
  .keyword-table-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .workspace,
  .sidebar {
    padding: 20px;
  }

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

  .metric strong {
    font-size: 36px;
  }

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

  .keyword-row {
    grid-template-columns: 28px 1fr;
  }

  .keyword-row strong {
    grid-column: 2;
    text-align: left;
  }

  .source-row {
    grid-template-columns: 1fr;
  }

  .opportunity-grid,
  .job-grid,
  .task-console,
  .mining-layout {
    grid-template-columns: 1fr;
  }

  .signal-row {
    grid-template-columns: 1fr;
  }

  .discovery-row {
    grid-template-columns: 1fr;
  }

  .discovery-actions {
    justify-content: flex-start;
    min-width: 0;
  }

  .search {
    min-width: 0;
    width: 100%;
  }

  .analysis-sections {
    grid-template-columns: 1fr;
  }
}
