:root {
  --bg: #fff1f6;
  --panel: #fff9fb;
  --ink: #33262c;
  --muted: #7d6872;
  --line: #efd3de;
  --gold: #e78caf;
  --gold-dark: #b9587c;
  --green: #2f7a5f;
  --red: #b95448;
  --blue: #3e6f8f;
  --shadow: 0 18px 45px rgba(162, 84, 116, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(231, 140, 175, 0.26), transparent 28rem),
    linear-gradient(135deg, #fff9fb 0%, var(--bg) 50%, #ffe5ef 100%);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 26px 18px;
  color: #fff7e8;
  background: linear-gradient(180deg, #5b2d42 0%, #8d4568 100%);
}

.brand,
.profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark,
.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  color: #6b2846;
  background: linear-gradient(135deg, #ffe0ec, #f3a2c2);
  font-weight: 800;
}

.brand strong,
.profile strong {
  display: block;
  font-size: 18px;
}

.brand span,
.profile span {
  display: block;
  margin-top: 3px;
  color: rgba(255, 247, 232, 0.68);
  font-size: 12px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: rgba(255, 247, 232, 0.78);
  background: transparent;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  color: #fff;
  border-color: rgba(244, 210, 140, 0.22);
  background: rgba(255, 255, 255, 0.08);
}

.icon {
  display: inline-grid;
  place-items: center;
  width: 24px;
}

.profile {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 247, 232, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.avatar {
  width: 38px;
  height: 38px;
  color: #fff;
  background: var(--green);
}

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

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold-dark);
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  margin-bottom: 0;
  font-size: 30px;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 18px;
}

.top-actions,
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(360px, 42vw);
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.8);
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.primary-btn,
.ghost-btn,
.icon-btn {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.primary-btn {
  padding: 0 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  box-shadow: 0 10px 20px rgba(117, 87, 46, 0.18);
}

.ghost-btn {
  padding: 0 14px;
  color: var(--gold-dark);
  border-color: var(--line);
  background: #fff9fb;
}

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

.view {
  display: none;
}

.view.active {
  display: block;
}

.home-banner {
  display: flex;
  align-items: center;
  min-height: 170px;
  margin-bottom: 16px;
  padding: 28px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, #f7a8c6 0%, #d66a99 55%, #b9587c 100%);
  box-shadow: var(--shadow);
}

.home-banner h2 {
  margin: 0;
  font-size: 34px;
}

.home-banner span {
  display: block;
  margin-top: 10px;
  color: rgba(255, 255, 255, 0.8);
}

.module-section {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 16px;
  margin-bottom: 16px;
}

.module-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

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

.module-item {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-height: 92px;
  padding: 10px 6px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
}

.module-item:hover {
  background: #fff1f6;
}

.module-item b {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  color: var(--gold-dark);
  background: #fde3ee;
  font-size: 22px;
}

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

.metric,
.panel,
.sales-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 249, 251, 0.94);
  box-shadow: var(--shadow);
}

.metric {
  min-height: 138px;
  padding: 18px;
}

.metric span,
.metric small,
.panel p,
.sales-card p,
.hint-line {
  color: var(--muted);
}

.metric strong {
  display: block;
  margin: 12px 0 8px;
  font-size: 36px;
}

.content-grid,
.allocation-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, 0.8fr);
  gap: 16px;
}

.panel {
  padding: 18px;
}

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

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 14px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.person {
  display: grid;
  gap: 4px;
}

.person strong {
  font-size: 15px;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--gold-dark);
  background: #fde3ee;
  font-size: 12px;
  font-weight: 700;
}

.badge.green {
  color: var(--green);
  background: #dcece5;
}

.badge.blue {
  color: var(--blue);
  background: #deebf2;
}

.badge.red {
  color: var(--red);
  background: #f4dfdc;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.text-btn {
  border: 0;
  color: var(--gold-dark);
  background: transparent;
  font-weight: 700;
}

.channel-list,
.lead-stack {
  display: grid;
  gap: 12px;
}

.channel-item {
  display: grid;
  gap: 7px;
}

.channel-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

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

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

.segmented {
  display: inline-flex;
  min-height: 40px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff9fb;
}

.segmented button {
  min-width: 76px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
}

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

.toolbar {
  justify-content: space-between;
  margin-bottom: 14px;
}

select,
textarea,
input {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffafd;
}

select {
  min-height: 40px;
  padding: 0 12px;
}

.lead-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffafd;
}

.lead-card.selected {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px var(--gold);
}

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

.assign-box {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

textarea,
input {
  width: 100%;
  padding: 10px 12px;
  color: var(--ink);
  outline: 0;
  resize: vertical;
}

.hint-line {
  margin-top: 14px;
  font-size: 13px;
}

.sales-card {
  padding: 18px;
}

.sales-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.sales-name {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sales-name .avatar {
  background: var(--blue);
}

.sales-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.sales-stats div {
  padding: 10px;
  border-radius: 8px;
  background: #fde3ee;
}

.sales-stats strong,
.sales-stats span {
  display: block;
}

.sales-stats span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

dialog {
  width: min(680px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.web-crm {
  display: grid;
  gap: 12px;
}

.crm-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 6px 2px;
}

.soft-btn,
.warning-btn,
.danger-btn,
.more-btn {
  min-width: 82px;
  min-height: 34px;
  padding: 0 16px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 700;
}

.soft-btn {
  color: #e45656;
  border: 1px solid #ffc5c5;
  background: #fff1f1;
}

.warning-btn {
  color: #ffffff;
  border: 1px solid #f3aa00;
  background: #f7ad00;
}

.danger-btn {
  color: #ffffff;
  border: 1px solid #ff4b42;
  background: #ff4b42;
}

.more-btn {
  color: #666666;
  border: 1px solid #dfe5ec;
  background: #ffffff;
}

.crm-filters {
  display: grid;
  grid-template-columns: 190px 190px 210px 230px 190px 190px 230px 190px 22px 190px 190px 22px 190px 230px 190px 190px 78px;
  align-items: end;
  gap: 12px 16px;
  padding: 8px 10px 12px;
  overflow-x: auto;
  border-bottom: 1px solid #edf1f5;
}

.crm-filters label {
  display: grid;
  grid-template-columns: auto minmax(110px, 1fr);
  align-items: center;
  gap: 8px;
  color: #666666;
  white-space: nowrap;
}

.crm-filters input,
.crm-filters select {
  min-height: 34px;
  border-radius: 2px;
  background: #ffffff;
}

.filter-to {
  align-self: center;
  color: #666666;
}

.search-btn {
  min-width: 66px;
}

.crm-main {
  display: grid;
  grid-template-columns: minmax(860px, 1fr) 380px;
  min-height: 560px;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #e7edf3;
}

.crm-table-wrap {
  overflow: auto;
}

.crm-table {
  min-width: 2480px;
  font-size: 14px;
}

.crm-table th,
.crm-table td {
  height: 40px;
  padding: 0 10px;
  border-right: 1px solid #e9eef4;
  border-bottom: 1px solid #e9eef4;
  color: #5f6f7e;
  white-space: nowrap;
}

.crm-table th {
  color: #607282;
  background: #f4f7fa;
  font-weight: 800;
  text-align: center;
}

.crm-table tbody tr {
  cursor: pointer;
}

.crm-table tbody tr:hover td {
  background: #fff7fa;
}

.crm-table tbody tr.selected-row td {
  background: #eeeeee;
}

.col-seq {
  width: 48px;
}

.col-check {
  width: 36px;
}

.col-name {
  width: 110px;
}

.col-phone {
  width: 140px;
}

.col-wechat {
  width: 120px;
}

.col-channel,
.col-owner,
.col-branch,
.col-assign,
.col-follow,
.col-transfer,
.col-share,
.col-visit {
  width: 92px;
}

.col-count {
  width: 90px;
}

.col-time,
.col-line,
.col-due {
  width: 125px;
}

.col-content {
  width: 190px;
}

.col-hospital {
  width: 150px;
}

.col-note {
  width: 120px;
}

.col-auto {
  width: 70px;
}

.col-converted,
.col-customer-phone,
.col-stage,
.col-area,
.col-package {
  width: 120px;
}

.link-btn {
  padding: 0;
  border: 0;
  color: #0000ee;
  background: transparent;
  text-decoration: underline;
  font: inherit;
}

.empty-table {
  height: 180px;
  color: #999999;
  text-align: center;
}

.tracking-side {
  overflow-y: auto;
  border-left: 1px solid #d8dee6;
  background: #ffffff;
}

.tracking-side h3,
.editor-tracking h3 {
  margin: 0;
  padding: 14px 18px;
  color: #4a3b42;
  font-size: 16px;
  text-align: center;
}

.track-card {
  position: relative;
  margin: 0;
  padding: 16px 84px 14px 18px;
  background: #f7f7f7;
  border-bottom: 10px solid #ffffff;
}

.track-card p {
  margin: 0 0 7px;
  color: #56606a;
  font-size: 13px;
  line-height: 1.45;
}

.track-tag {
  position: absolute;
  top: 18px;
  right: 18px;
  min-width: 64px;
  padding: 8px 10px;
  border-radius: 4px;
  color: #e87922;
  background: #fff0d9;
  font-size: 13px;
  text-align: center;
  font-weight: 800;
}

.track-tag.green {
  color: #2f7a5f;
  background: #dcece5;
}

.track-tag.blue {
  color: #3e6f8f;
  background: #deebf2;
}

.track-tag.red {
  color: #b95448;
  background: #f4dfdc;
}

.empty-track {
  padding: 90px 0;
  color: #999999;
  text-align: center;
}

.lead-editor-dialog {
  width: min(1900px, calc(100vw - 24px));
  max-width: none;
}

.editor-card {
  overflow: hidden;
  min-height: 560px;
  background: #ffffff;
}

.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 0 16px;
  color: #ffffff;
  background: #ff4738;
}

.editor-close {
  width: 34px;
  height: 34px;
  border: 0;
  color: #ffffff;
  background: transparent;
  font-size: 24px;
  line-height: 34px;
}

.editor-body {
  display: grid;
  grid-template-columns: minmax(900px, 1fr) 380px;
  min-height: 520px;
}

.editor-form {
  padding: 16px 28px 24px;
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(250px, 1fr));
  gap: 14px 80px;
  align-items: center;
}

.editor-grid label,
.full-field,
.upload-field {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  color: #5f5f5f;
  font-size: 14px;
  font-weight: 700;
}

.editor-grid input,
.editor-grid select,
.full-field textarea {
  min-height: 36px;
  border-radius: 2px;
  background: #ffffff;
}

.full-field {
  margin-top: 16px;
  grid-template-columns: 96px minmax(0, 1fr);
}

.full-field textarea {
  min-height: 66px;
}

.upload-field {
  align-items: start;
  margin-top: 14px;
}

.upload-box {
  display: grid;
  place-items: center;
  width: 96px;
  height: 86px;
  border: 1px solid #edf1f5;
  border-radius: 0;
  color: #d8d8d8;
  background: #ffffff;
}

.upload-box span {
  font-size: 34px;
  line-height: 1;
}

.upload-box b {
  margin-top: -18px;
  font-size: 32px;
  font-weight: 400;
}

.editor-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 22px;
}

.save-editor-btn {
  width: 180px;
  min-height: 36px;
  color: #666666;
  background: #eeeeee;
  border-color: #e0e0e0;
  box-shadow: none;
}

.editor-tracking {
  overflow-y: auto;
  border-left: 1px solid #e2e7ed;
  background: #ffffff;
}

dialog::backdrop {
  background: rgba(26, 18, 10, 0.46);
}

.dialog-card {
  display: grid;
  gap: 14px;
  padding: 20px;
  border-radius: 8px;
  background: #fff9fb;
  box-shadow: var(--shadow);
}

.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  transform: translateY(16px);
  padding: 12px 16px;
  border-radius: 8px;
  color: #fff;
  background: #2f7a5f;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
}

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

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

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

  .sidebar {
    align-items: center;
  }

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

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

  .content-grid,
  .allocation-layout {
    grid-template-columns: 1fr;
  }
}

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

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: row;
    justify-content: space-between;
    padding: 12px;
  }

  .nav {
    display: flex;
  }

  .profile {
    display: none;
  }

  .main {
    padding: 18px 12px;
  }

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

  .top-actions,
  .toolbar {
    align-items: stretch;
  }

  .search {
    width: 100%;
  }

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

  .segmented {
    width: 100%;
    overflow-x: auto;
  }

  .segmented button {
    min-width: 72px;
  }
}
