:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef2ed;
  --ink: #17201b;
  --muted: #68746d;
  --line: #dce2dc;
  --green: #1f7a4d;
  --green-2: #dff3e9;
  --blue: #245c91;
  --amber: #b46b20;
  --red: #a43e3e;
  --shadow: 0 18px 50px rgba(18, 32, 24, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 18px;
  color: #f6fff9;
  background: #18251f;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius);
  background: #2d8f5c;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.hero-copy h3,
.card h3,
.modal h3,
.debug-header h3 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
}

.brand p {
  margin-top: 3px;
  color: #b7c7be;
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius);
  color: #dce7e0;
  background: transparent;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 13px;
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

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

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar h2 {
  font-size: 26px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 310px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.primary-button,
.ghost-button {
  min-height: 38px;
  padding: 0 14px;
  border-radius: var(--radius);
  white-space: nowrap;
}

.primary-button {
  border: 1px solid #17623d;
  color: #ffffff;
  background: var(--green);
}

.primary-button:hover {
  background: #17623d;
}

.ghost-button {
  border: 1px solid var(--line);
  color: inherit;
  background: transparent;
}

.sidebar .ghost-button {
  border-color: rgba(255, 255, 255, 0.22);
  color: #f6fff9;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  margin-bottom: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, #ffffff 0%, #eaf4ee 100%);
}

.status-pill,
.tag,
.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
}

.status-pill {
  margin: 0 0 12px;
  padding: 6px 10px;
  color: #145738;
  background: var(--green-2);
  font-size: 13px;
  font-weight: 700;
}

.hero-copy h3 {
  max-width: 900px;
  font-size: 32px;
  line-height: 1.18;
}

.hero-copy p:last-child {
  max-width: 820px;
  color: var(--muted);
  line-height: 1.7;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  align-self: end;
}

.hero-metrics div {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
}

.hero-metrics strong {
  display: block;
  font-size: 28px;
}

.hero-metrics span {
  color: var(--muted);
  font-size: 13px;
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
}

.card {
  min-height: 120px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.card.span-3 {
  grid-column: span 3;
}

.card.span-4 {
  grid-column: span 4;
}

.card.span-5 {
  grid-column: span 5;
}

.card.span-6 {
  grid-column: span 6;
}

.card.span-7 {
  grid-column: span 7;
}

.card.span-8 {
  grid-column: span 8;
}

.card.span-12 {
  grid-column: span 12;
}

.card h3 {
  font-size: 18px;
}

.card p {
  color: var(--muted);
  line-height: 1.65;
}

.list {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.list li {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.list li span:last-child {
  color: var(--muted);
  text-align: right;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.tag {
  padding: 6px 9px;
  color: #244137;
  background: var(--surface-2);
  font-size: 13px;
}

.badge {
  padding: 5px 8px;
  color: #165238;
  background: var(--green-2);
  font-size: 12px;
  font-weight: 700;
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.pipeline-step {
  min-height: 112px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
}

.pipeline-step strong {
  display: block;
  margin-bottom: 8px;
}

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

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.table th,
.table td {
  padding: 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.table th {
  background: var(--surface-2);
  font-size: 13px;
}

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

.progress-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.progress-bar span {
  display: block;
  height: 100%;
  background: var(--green);
}

.debug-panel {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 20;
  display: none;
  width: min(380px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.debug-panel.open {
  display: block;
}

.debug-header,
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.debug-header button,
.modal-header button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.debug-section {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.debug-section label,
.lead-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.debug-section input,
.lead-form select {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: #fbfcfa;
}

pre {
  overflow: auto;
  margin: 0;
  padding: 12px;
  border-radius: var(--radius);
  background: #111a16;
  color: #dff3e9;
  font-size: 12px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(12, 18, 15, 0.42);
}

.modal {
  width: min(620px, 100%);
  padding: 22px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.lead-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.dify-test {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.dify-test label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.dify-test textarea {
  width: 100%;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: #fbfcfa;
  line-height: 1.6;
}

.diagnostic-result {
  margin-top: 16px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  line-height: 1.7;
}

.diagnostic-result:empty {
  display: none;
}

.tour-popover {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  align-items: end;
  justify-items: center;
  padding: 24px;
  background: rgba(12, 18, 15, 0.34);
}

.tour-card {
  width: min(520px, 100%);
  padding: 20px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tour-card > p {
  margin: 0 0 8px;
  color: var(--green);
  font-weight: 700;
}

.tour-card h3 {
  margin: 0;
}

.tour-card h3 + p {
  color: var(--muted);
  line-height: 1.7;
}

.tour-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.hidden {
  display: none;
}

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

  .brand div:not(.brand-mark),
  .nav-item span:last-child,
  .sidebar-footer {
    display: none;
  }

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

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

  .card.span-3,
  .card.span-4,
  .card.span-5,
  .card.span-6,
  .card.span-7,
  .card.span-8 {
    grid-column: span 6;
  }
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 10px;
  }

  .brand {
    flex: 0 0 auto;
  }

  .nav-list {
    display: flex;
    gap: 6px;
  }

  .nav-item {
    width: 42px;
    flex: 0 0 42px;
  }

  .main {
    padding: 16px;
  }

  .topbar,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .search-box {
    min-width: 0;
  }

  .hero-copy h3 {
    font-size: 24px;
  }

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

  .card,
  .card.span-3,
  .card.span-4,
  .card.span-5,
  .card.span-6,
  .card.span-7,
  .card.span-8,
  .card.span-12 {
    grid-column: span 12;
  }
}
