:root {
  --ink: #0d1715;
  --nav: #101a18;
  --nav-2: #16231f;
  --panel: #ffffff;
  --panel-2: #f5f8f7;
  --line: #dbe5e1;
  --muted: #65736f;
  --text: #182522;
  --accent: #0b7c61;
  --accent-2: #16a085;
  --cyan: #1aa6b7;
  --warn: #b96b10;
  --danger: #b42318;
  --ok: #13795b;
  --shadow: 0 18px 45px rgba(16, 35, 31, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background: #e9efed;
  letter-spacing: 0;
}

button,
select,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  color: #e9f3f0;
  background:
    linear-gradient(180deg, rgba(22, 160, 133, 0.08), transparent 38%),
    var(--nav);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 64px;
  margin-bottom: 24px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(93, 219, 191, 0.35);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
}

.brand-mark svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: #70e0c4;
  stroke-width: 2;
}

.brand strong {
  display: block;
  font-size: 17px;
  line-height: 1.2;
}

.brand span,
.side-status span {
  display: block;
  color: #9db3ad;
  font-size: 12px;
  margin-top: 4px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #c9d8d4;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  color: #fff;
  border-color: rgba(92, 222, 193, 0.22);
  background: rgba(255, 255, 255, 0.07);
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  flex: 0 0 auto;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.side-status {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 20px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.side-status strong {
  display: block;
  margin-top: 7px;
  font-size: 20px;
}

.status-meter {
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 14px;
}

.status-meter i {
  display: block;
  height: 100%;
  background: #67d9bd;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 20px;
}

.title-block p {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.title-block h1 {
  margin: 0;
  color: var(--ink);
  font-size: 28px;
  line-height: 1.25;
  font-weight: 800;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.toolbar label {
  height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
}

select,
input {
  border: none;
  background: transparent;
  color: var(--text);
  outline: none;
}

.search-box {
  height: 40px;
  min-width: 260px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
}

.search-box input {
  width: 100%;
}

.primary-action,
.ghost-button {
  height: 40px;
  border-radius: 8px;
  padding: 0 16px;
  border: 1px solid transparent;
  font-weight: 700;
}

.primary-action {
  color: #fff;
  background: var(--accent);
}

.primary-action:hover {
  background: #086c54;
}

.ghost-button {
  color: var(--accent);
  background: #fff;
  border-color: var(--line);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

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

.metric-card {
  padding: 16px;
  min-height: 142px;
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  min-height: 34px;
}

.metric-value {
  margin: 8px 0 6px;
  color: var(--ink);
  font-size: 25px;
  font-weight: 800;
  line-height: 1.1;
}

.metric-value small {
  font-size: 13px;
  color: var(--muted);
  margin-left: 4px;
}

.metric-meta {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.metric-source {
  margin-top: 8px;
  color: #7a8884;
  font-size: 11px;
  line-height: 1.35;
}

.overview-grid,
.analysis-grid,
.brand-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 14px;
}

.overview-grid {
  grid-template-columns: minmax(360px, 0.95fr) minmax(420px, 1.25fr) minmax(300px, 0.7fr);
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-head.compact {
  margin-bottom: 10px;
}

.panel h2 {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.25;
}

.panel p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.data-stamp {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border-radius: 7px;
  background: #edf8f5;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.segmented button {
  height: 30px;
  min-width: 58px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
}

.segmented button.active {
  color: #fff;
  background: var(--accent);
}

.china-map {
  position: relative;
  min-height: 360px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(11, 124, 97, 0.08), rgba(26, 166, 183, 0.08)),
    #f7fbfa;
  overflow: hidden;
  border: 1px solid #e1ebe8;
}

.map-outline {
  position: absolute;
  inset: 32px 24px;
  opacity: 0.36;
}

.map-node {
  position: absolute;
  transform: translate(-50%, -50%);
  border: none;
  background: transparent;
  color: var(--ink);
}

.map-node i {
  display: block;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: rgba(11, 124, 97, 0.18);
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 6px rgba(11, 124, 97, 0.08);
}

.map-node.active i {
  background: rgba(26, 166, 183, 0.28);
  border-color: var(--cyan);
}

.map-node span {
  position: absolute;
  left: 50%;
  top: calc(100% + 7px);
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}

.chart-canvas {
  min-height: 320px;
  position: relative;
}

.chart-canvas.tall {
  min-height: 380px;
}

.chart-canvas svg,
.knowledge-graph svg {
  width: 100%;
  height: 100%;
  min-height: inherit;
  display: block;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  padding: 7px 9px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  transform: translate(-50%, -125%);
  white-space: nowrap;
  z-index: 3;
}

.mini-list,
.insight-stack,
.brand-cards {
  display: grid;
  gap: 10px;
}

.mini-item,
.insight,
.brand-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.mini-item strong,
.insight strong,
.brand-card strong {
  display: block;
  color: var(--ink);
  margin-bottom: 5px;
}

.mini-item span,
.insight span,
.brand-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.level {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 24px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
}

.level.high {
  color: #fff;
  background: var(--danger);
}

.level.medium {
  color: #5b3306;
  background: #ffe2b8;
}

.level.low {
  color: #0f5f48;
  background: #d8f3eb;
}

.split-layout,
.trace-grid,
.report-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
}

.graph-stage {
  min-height: 640px;
}

.knowledge-graph {
  min-height: 540px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}

.graph-node {
  cursor: pointer;
}

.graph-node text {
  font-size: 13px;
  font-weight: 800;
  fill: var(--ink);
}

.graph-link {
  stroke: #aac4bd;
  stroke-width: 1.4;
}

.node-detail h3 {
  margin: 0 0 10px;
  font-size: 22px;
}

.node-detail p {
  margin-bottom: 16px;
}

.node-facts {
  display: grid;
  gap: 8px;
}

.node-facts div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border-radius: 8px;
  background: var(--panel-2);
  font-size: 13px;
}

.wide {
  grid-column: span 1;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  text-align: left;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  white-space: nowrap;
}

th {
  color: var(--muted);
  background: #f4f8f7;
  font-weight: 800;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f7fbfa;
}

.trace-search {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) 120px;
  gap: 10px;
  margin-bottom: 18px;
}

.trace-search select,
.trace-search input {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
}

.trace-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.trace-summary div {
  padding: 13px;
  border-radius: 8px;
  background: var(--panel-2);
}

.trace-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.timeline {
  display: grid;
  gap: 12px;
}

.timeline-step {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
}

.timeline-step i {
  width: 28px;
  height: 28px;
  margin-top: 2px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(11, 124, 97, 0.1);
}

.timeline-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.timeline-card strong {
  display: block;
}

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

.credential {
  display: grid;
  gap: 12px;
}

.credential-code {
  padding: 16px;
  border-radius: 8px;
  color: #d8fff5;
  background: var(--ink);
  font-family: "SFMono-Regular", Consolas, monospace;
  line-height: 1.8;
  word-break: break-all;
}

.empty-state {
  padding: 36px;
  border: 1px dashed #b7c9c3;
  border-radius: 8px;
  text-align: center;
  color: var(--muted);
  background: #f8fbfa;
}

.roadmap {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.roadmap-step {
  min-height: 180px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  position: relative;
}

.roadmap-step b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  color: #fff;
  background: var(--accent);
  margin-bottom: 16px;
}

.roadmap-step strong {
  display: block;
  margin-bottom: 9px;
}

.roadmap-step span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.report-control {
  align-self: start;
}

.wide-button {
  width: 100%;
  margin-top: 10px;
}

.report-status {
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel-2);
  font-size: 13px;
}

.report-paper {
  min-height: 620px;
  padding: 28px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.report-paper h2 {
  font-size: 26px;
}

.report-paper h3 {
  margin: 22px 0 8px;
}

.report-paper p,
.report-paper li {
  line-height: 1.75;
  color: #34413d;
}

.source-list {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(13, 23, 21, 0.48);
  z-index: 20;
  padding: 20px;
}

.modal.open {
  display: grid;
}

.modal-card {
  width: min(720px, 100%);
  max-height: 84vh;
  overflow: auto;
  position: relative;
  padding: 24px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.25);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 22px;
  line-height: 1;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  min-width: 260px;
  max-width: 360px;
  padding: 13px 15px;
  color: #fff;
  background: var(--ink);
  border-radius: 8px;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  z-index: 30;
}

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

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 86px minmax(0, 1fr);
  }

  .brand div:last-child,
  .nav-item {
    font-size: 0;
  }

  .nav-item {
    justify-content: center;
  }

  .side-status {
    display: none;
  }

  .metric-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .overview-grid,
  .split-layout,
  .trace-grid,
  .report-grid,
  .analysis-grid,
  .brand-grid {
    grid-template-columns: 1fr;
  }

  .roadmap {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 720px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 12px;
  }

  .brand {
    margin-bottom: 12px;
  }

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

  .nav-item {
    min-height: 40px;
    padding: 0;
  }

  .workspace {
    padding: 14px;
  }

  .topbar {
    display: block;
  }

  .toolbar {
    justify-content: stretch;
    margin-top: 14px;
  }

  .toolbar label,
  .search-box,
  .primary-action,
  .ghost-button {
    width: 100%;
  }

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

  .trace-search,
  .trace-summary,
  .roadmap {
    grid-template-columns: 1fr;
  }

  .title-block h1 {
    font-size: 22px;
  }

  .panel {
    padding: 14px;
  }

  .chart-canvas,
  .chart-canvas.tall,
  .china-map,
  .knowledge-graph {
    min-height: 300px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .sidebar,
  .topbar,
  .view:not(#report),
  .report-control,
  .modal,
  .toast {
    display: none !important;
  }

  .app-shell,
  .workspace,
  .report-grid {
    display: block;
    padding: 0;
  }

  .report-preview,
  .report-paper {
    border: none;
    box-shadow: none;
  }
}
