:root {
  --bg: #f3f6ef;
  --surface: #ffffff;
  --surface-2: #f8fbf5;
  --ink: #172018;
  --muted: #667064;
  --line: #dfe6da;
  --line-strong: #c5d0be;
  --green: #2e6b45;
  --green-dark: #172519;
  --gold: #d5a245;
  --blue: #356f91;
  --red: #b94d40;
  --orange: #b8792b;
  --shadow: 0 14px 34px rgba(38, 58, 35, 0.08);
  --radius: 8px;
  --sidebar: 238px;
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(46, 107, 69, 0.08), rgba(213, 162, 69, 0.08)),
    var(--bg);
}

.login-card {
  width: min(420px, 100%);
  padding: 28px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.login-card img {
  width: 160px;
  height: 50px;
  object-fit: contain;
}

.login-card h1 {
  margin: 22px 0 8px;
  font-size: 28px;
  letter-spacing: 0;
}

.login-card p,
.login-note {
  color: var(--muted);
  line-height: 1.65;
  font-size: 14px;
}

.login-card form {
  margin-top: 22px;
  display: grid;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: #3f4d3d;
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  min-height: 38px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  outline: none;
}

textarea {
  min-height: 86px;
  padding: 10px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(46, 107, 69, 0.12);
}

.login-card button,
.primary,
.ghost,
.danger,
.small-btn,
.icon-btn {
  min-height: 38px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.login-card button,
.primary {
  padding: 0 14px;
  background: var(--green);
  color: #fff;
  border-color: var(--green);
  font-weight: 800;
}

.ghost {
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.danger {
  padding: 0 12px;
  background: #fff2ef;
  color: var(--red);
  border-color: #efc1ba;
}

.small-btn {
  min-height: 30px;
  padding: 0 9px;
  background: #eef5e9;
  color: #244a31;
  border-color: #d5e2cf;
  font-size: 12px;
}

.icon-btn {
  width: 38px;
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

i {
  width: 17px;
  height: 17px;
  stroke-width: 2;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  background: var(--green-dark);
  color: #f5fbf0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand {
  padding: 0 8px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.13);
}

.brand img {
  width: 154px;
  height: 48px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 8px;
  padding: 6px 8px;
}

.brand span {
  display: block;
  margin-top: 9px;
  color: #b9c7b1;
  font-size: 12px;
}

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

.nav button {
  min-height: 42px;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #d8e5d2;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.nav button.active,
.nav button:hover {
  background: rgba(255, 255, 255, 0.11);
  color: #fff;
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
  line-height: 1.7;
}

.sidebar-foot span {
  display: block;
  color: #c2d0bb;
}

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

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

.crumb {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.topbar h1 {
  margin-bottom: 0;
  font-size: 26px;
  line-height: 1.25;
  letter-spacing: 0;
}

.toolbar,
.filters {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.filters input {
  width: min(310px, 100%);
}

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

.metric {
  min-height: 118px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 8px;
  font-size: 30px;
  font-weight: 900;
}

.metric-value small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.progress {
  height: 8px;
  margin-top: 13px;
  border-radius: 999px;
  overflow: hidden;
  background: #e9efe5;
}

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

.view {
  display: none;
}

.view.active {
  display: block;
}

.layout-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  gap: 14px;
  margin-bottom: 14px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  min-height: 60px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin-bottom: 4px;
  font-size: 16px;
  line-height: 1.25;
}

.panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.funnel,
.owner-grid,
.script-grid,
.profile-grid,
.ops-grid,
.import-guide,
.import-list,
.activity-grid,
.chart-list {
  display: grid;
  gap: 12px;
  padding: 14px;
}

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

.funnel-card,
.owner-card,
.script-card,
.profile-card,
.ops-card,
.guide-card,
.import-card,
.activity-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.funnel-card b {
  display: block;
  margin: 7px 0 5px;
  font-size: 25px;
}

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

.bar-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.bar-row span {
  color: #3c4939;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar {
  height: 12px;
  border-radius: 999px;
  background: #e8efe3;
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--gold));
}

.bar-row b {
  text-align: right;
}

.owner-card {
  background: #fff;
}

.owner-name {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-weight: 900;
}

.owner-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.timeline {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 14px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
}

.time {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.timeline-item strong {
  display: block;
  margin-bottom: 4px;
}

.timeline-item p {
  margin: 0;
  color: #394538;
  line-height: 1.55;
  font-size: 13px;
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(8, minmax(218px, 1fr));
  gap: 12px;
  padding: 14px;
  overflow-x: auto;
}

.kanban-column {
  min-height: 540px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.kanban-head {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 900;
}

.count {
  min-width: 24px;
  min-height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #e7efe2;
  color: #254b31;
  font-size: 12px;
}

.kanban-cards {
  display: grid;
  gap: 10px;
  padding: 10px;
}

.lead-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.lead-card:hover {
  border-color: var(--line-strong);
  box-shadow: 0 8px 18px rgba(31, 52, 29, 0.08);
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.lead-name {
  font-weight: 900;
}

.subtle {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.tag-row {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.tag {
  min-height: 22px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #edf4ea;
  color: #31583c;
  font-size: 11px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.tag.gold {
  background: #fff3d3;
  color: #735116;
}

.tag.blue {
  background: #e5f2f7;
  color: #26536b;
}

.tag.red {
  background: #fff0ed;
  color: #8e3a31;
}

.tag.gray {
  background: #f1f3ef;
  color: #626b61;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 2px;
}

.table-wrap {
  overflow: auto;
}

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

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

th {
  position: sticky;
  top: 0;
  background: #f7faf4;
  color: #42503f;
  z-index: 1;
  font-size: 12px;
}

tr:hover td {
  background: #fbfdf8;
}

.name-cell {
  font-weight: 900;
}

.due {
  color: var(--red);
  font-weight: 900;
}

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

.script-card,
.profile-card,
.ops-card {
  background: #fff;
  display: grid;
  gap: 10px;
}

.script-card p,
.profile-card p,
.ops-card p {
  margin: 0;
  color: #3d473a;
  line-height: 1.65;
  font-size: 13px;
}

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

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

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

.activity-card {
  background: #fff;
  display: grid;
  gap: 12px;
}

.activity-card.compact-activity {
  margin: 14px;
}

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

.activity-head h3 {
  margin: 8px 0 6px;
  font-size: 20px;
}

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

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

.activity-metrics div {
  min-height: 66px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.activity-metrics b {
  display: block;
  font-size: 20px;
  margin-bottom: 4px;
}

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

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

.activity-body section {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdf8;
}

.activity-body section:nth-child(3),
.activity-body section:nth-child(4),
.activity-body section:nth-child(5) {
  grid-column: 1 / -1;
}

.activity-body p,
.activity-body ul {
  margin: 8px 0 0;
  color: #394538;
  line-height: 1.6;
  font-size: 13px;
}

.activity-body ul {
  padding-left: 18px;
}

.activity-body li + li {
  margin-top: 7px;
}

.activity-body li span {
  display: block;
  color: var(--muted);
}

.integration-card {
  gap: 10px;
}

.import-guide {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.guide-card {
  background: #fff;
  display: grid;
  gap: 6px;
}

.guide-card span,
.import-help {
  color: var(--muted);
  line-height: 1.6;
  font-size: 13px;
}

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

.import-card {
  background: #fff;
  display: grid;
  gap: 12px;
}

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

.import-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.import-stat {
  min-height: 64px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.import-stat b {
  display: block;
  font-size: 19px;
  margin-bottom: 4px;
}

.review-box {
  padding: 10px;
  border-radius: 8px;
  background: #fff8f1;
  border: 1px solid #ecd6b7;
  color: #6c4b1f;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}

code {
  padding: 2px 5px;
  border-radius: 6px;
  background: #eef5e9;
  color: #234a30;
}

.danger-card {
  background: #fff8f6;
}

.empty {
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(14, 24, 16, 0.52);
  z-index: 40;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: min(900px, 100%);
  max-height: min(820px, calc(100vh - 40px));
  overflow: auto;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
}

.modal.compact {
  width: min(640px, 100%);
}

.modal-head {
  min-height: 60px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h2 {
  margin-bottom: 0;
  font-size: 18px;
}

.form-grid {
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.full {
  grid-column: 1 / -1;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  position: sticky;
  bottom: 0;
  background: var(--surface);
  padding-top: 4px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(70px);
  width: min(420px, calc(100% - 32px));
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(23, 32, 24, 0.94);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  text-align: center;
  font-size: 14px;
  z-index: 60;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

  .sidebar-foot {
    display: none;
  }

  .metric-grid,
  .owner-grid,
  .script-grid,
  .profile-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 760px) {
  .main {
    padding: 16px 12px 28px;
  }

  .topbar,
  .panel-head {
    display: grid;
  }

  .toolbar,
  .filters {
    justify-content: flex-start;
  }

  .nav,
  .metric-grid,
  .funnel,
  .owner-grid,
  .script-grid,
  .profile-grid,
  .ops-grid,
  .import-guide,
  .import-stats,
  .activity-metrics,
  .activity-body,
  .form-grid {
    grid-template-columns: 1fr;
  }

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