:root {
  color-scheme: light;
  --bg: #eef7f1;
  --surface: #fdfffc;
  --text: #172033;
  --muted: #647084;
  --line: #cfded3;
  --primary: #168062;
  --primary-dark: #0f5f49;
  --primary-soft: #e6f6ee;
  --warning: #b54708;
  --warning-bg: #fff4e5;
  --danger: #a33a31;
  --danger-bg: #fff1f0;
  --success: #087443;
  --success-bg: #ecfdf3;
  --shadow: 0 14px 36px rgba(24, 92, 68, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 0%, rgba(204, 238, 217, 0.7), transparent 30%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px clamp(10px, 2vw, 20px);
  background: rgba(253, 255, 252, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.nav,
.identity,
.actions,
.inline-form,
.mini-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav {
  flex: 1;
}

.nav a {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.nav a:hover,
.nav a.active {
  color: var(--primary);
}

.identity {
  color: var(--muted);
  font-size: 14px;
}

.page {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 4vw, 42px) clamp(16px, 4vw, 32px) 56px;
}

.admin-layout {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  margin: 0 auto;
  padding: 14px 10px 48px 6px;
}

.role-layout {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 14px 12px 48px;
}

.role-sidebar {
  position: sticky;
  top: 64px;
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: calc(100vh - 84px);
  border-right: 1px solid var(--line);
  padding-right: 8px;
}

.role-sidebar-stats {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
}

.role-sidebar-stats div {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  background: rgba(253, 255, 252, 0.86);
}

.role-sidebar-stats span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.role-sidebar-stats strong {
  display: block;
  margin-top: 2px;
  color: var(--primary-dark);
  font-size: 18px;
  line-height: 1.1;
}

.role-content {
  min-width: 0;
}

.admin-sidebar {
  position: sticky;
  top: 64px;
  display: grid;
  align-content: start;
  gap: 4px;
  min-height: calc(100vh - 84px);
  border-right: 1px solid var(--line);
  padding-right: 6px;
  transition: width 0.18s ease, opacity 0.18s ease, padding 0.18s ease;
}

.side-section-label {
  margin: 8px 4px 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
}

.side-section-label:first-child {
  margin-top: 0;
}

.form-note {
  align-self: end;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
}

.side-link {
  display: block;
  border-radius: 6px;
  padding: 9px 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.side-link:hover,
.side-link:focus {
  color: var(--primary);
  background: var(--primary-soft);
}

.side-link.active {
  color: var(--primary-dark);
  background: #d8f5e8;
  box-shadow: inset 3px 0 0 var(--primary);
}

.admin-content {
  min-width: 0;
}

.admin-content .form-panel,
.admin-content .list-panel {
  gap: 12px;
  padding: 14px;
}

.admin-content h1 {
  font-size: 24px;
}

.admin-content h2 {
  font-size: 18px;
}

.admin-content .eyebrow {
  margin-bottom: 4px;
}

.admin-content .stat-card {
  padding: 12px;
}

.admin-content .stat-card strong {
  margin-top: 4px;
  font-size: 24px;
}

.admin-layout.sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
  gap: 0;
  padding-left: 10px;
}

.admin-layout.sidebar-collapsed .admin-sidebar {
  width: 0;
  min-width: 0;
  overflow: hidden;
  opacity: 0;
  border-right: 0;
  padding-right: 0;
}

.sidebar-toggle {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.login-shell,
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(360px, 1.1fr);
  gap: 28px;
  align-items: start;
}

.workspace {
  grid-template-columns: minmax(320px, 0.88fr) minmax(0, 1.12fr);
}

.compact-workspace {
  grid-template-columns: minmax(300px, 0.7fr) minmax(0, 1.3fr);
  gap: 14px;
}

.intro {
  padding: 32px 0;
}

h1,
h2,
h3,
.intro h1 {
  margin: 0;
  line-height: 1.18;
}

.intro h1 {
  max-width: 520px;
  font-size: clamp(34px, 5vw, 56px);
}

.intro p:last-child {
  max-width: 460px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}

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

.form-panel,
.list-panel,
.recent-panel {
  display: grid;
  gap: 18px;
  padding: clamp(18px, 3vw, 28px);
}

.lead-form {
  position: sticky;
  top: 84px;
}

.compact-lead-form {
  gap: 12px;
  padding: 14px;
}

.operator-upload-card {
  align-self: start;
}

.operator-upload-card.is-dragging-file {
  outline: 2px solid #54b98d;
  outline-offset: 3px;
  background: #f4fbf7;
}

.operator-upload-summary {
  display: inline-grid;
  grid-template-columns: repeat(4, minmax(104px, max-content));
  gap: 8px;
  margin: 0 0 12px;
}

.summary-item {
  min-width: 104px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  background: #f8fcf9;
}

.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.summary-item strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 22px;
  line-height: 1.1;
}

.summary-item.urgent {
  border-color: #9bd6b7;
  background: #e6f6ee;
}

.summary-item.urgent strong {
  color: var(--primary-dark);
}

.ocr-dropzone {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 68px;
  border: 1px dashed #9bd6b7;
  border-radius: 8px;
  padding: 10px 12px;
  background: #f4fbf7;
}

.ocr-dropzone strong,
.ocr-dropzone span {
  display: block;
}

.ocr-dropzone strong {
  color: var(--primary-dark);
  font-size: 15px;
}

.ocr-dropzone span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.ocr-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.ocr-dropzone.is-dragging,
.ocr-dropzone.is-loading {
  border-color: var(--primary);
  background: #e6f6ee;
}

.ocr-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.ocr-result {
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
}

.ocr-result.info {
  color: var(--muted);
  background: #f4f8fb;
}

.ocr-result.success {
  color: var(--success);
  background: var(--success-bg);
}

.ocr-result.warn {
  color: var(--warning);
  background: var(--warning-bg);
}

.ocr-result.error {
  color: var(--danger);
  background: var(--danger-bg);
}

.source-detail {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  background: #fbfefc;
}

.source-detail summary {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.source-detail .grid-2 {
  margin-top: 10px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

label {
  display: grid;
  gap: 8px;
}

label span {
  color: #344054;
  font-size: 14px;
  font-weight: 700;
}

label small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cfd6e4;
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  background: #fff;
  font: inherit;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.14);
  outline: none;
}

.grid-2,
.config-grid,
.admin-grid {
  display: grid;
  gap: 14px;
}

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

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

.config-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 20px;
}

.admin-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 20px;
}

.stat-card {
  padding: 18px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
}

.role-dashboard {
  margin-bottom: 12px;
}

.role-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px;
}

.role-stat-card {
  min-height: 68px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 11px;
  background: #f8fcf9;
}

.role-stat-card span,
.role-stat-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.role-stat-card strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 24px;
  line-height: 1.1;
}

.role-stat-card.urgent {
  border-color: #9bd6b7;
  background: #e6f6ee;
}

.role-stat-card.urgent strong {
  color: var(--primary-dark);
  font-size: 32px;
}

.role-stat-card.warn {
  border-color: #fed7aa;
  background: #fff7ed;
}

.role-stat-card.warn strong {
  color: var(--warning);
}

.role-breakdown {
  margin-top: 10px;
}

.range-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.role-breakdown-table {
  min-width: 420px;
}

.team-dashboard-panel {
  margin-bottom: 10px;
}

.team-stat-grid {
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
}

.team-dashboard-grid {
  display: grid;
  grid-template-columns: minmax(560px, 1.25fr) minmax(420px, 0.75fr);
  gap: 10px;
  align-items: start;
}

.team-dashboard-grid .role-breakdown {
  min-width: 0;
}

.team-stat-table {
  min-width: 620px;
}

.compact-scroll {
  overflow-x: auto;
}

.operator-dashboard-filter {
  grid-template-columns: minmax(320px, auto) 130px 130px auto;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.primary-button,
.ghost-button,
.danger-button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

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

.primary-button:hover {
  background: var(--primary-dark);
}

.ghost-button {
  color: var(--primary);
  background: var(--primary-soft);
}

.danger-button {
  color: var(--danger);
  background: var(--danger-bg);
}

.small-button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 14px;
}

.alerts {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.alert,
.warning-banner,
.tag {
  border-radius: 6px;
  padding: 11px 13px;
  font-weight: 800;
}

.alert.error,
.tag.danger {
  color: var(--danger);
  background: var(--danger-bg);
}

.status-pill.danger {
  color: var(--danger);
  background: var(--danger-bg);
}

.tag.success {
  color: var(--success);
  background: var(--success-bg);
}

.tag.muted {
  color: var(--muted);
  background: #eef2f7;
}

.alert.success {
  color: var(--success);
  background: var(--success-bg);
}

.saved-row {
  animation: savedPulse 2.8s ease-out;
  background: var(--success-bg);
}

.inline-saved {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  color: var(--success);
  background: var(--success-bg);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

@keyframes savedPulse {
  0% {
    background: #c8f4d8;
  }
  100% {
    background: transparent;
  }
}

.warning-banner {
  margin-bottom: 12px;
  color: var(--warning);
  background: var(--warning-bg);
}

.section-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.compact-heading {
  align-items: center;
}

.workbench-panel {
  gap: 10px;
}

.admin-content .workbench-panel {
  padding: 10px 12px;
}

.workbench-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.workbench-panel input,
.workbench-panel select,
.workbench-panel textarea,
.workbench-panel .primary-button,
.workbench-panel .ghost-button,
.workbench-panel .danger-button,
.workbench-panel .ghost-link {
  min-height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

.workbench-panel input,
.workbench-panel select,
.workbench-panel textarea {
  padding-top: 4px;
  padding-bottom: 4px;
}

.workbench-panel label {
  gap: 4px;
}

.workbench-panel label span {
  font-size: 12px;
}

.count {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  padding: 0 12px;
  color: var(--primary);
  background: var(--primary-soft);
  font-weight: 800;
}

.lead-list,
.rule-list {
  display: grid;
  gap: 8px;
}

.lead-item,
.rule-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.warning-card {
  border-color: #f7b955;
  box-shadow: 0 0 0 3px rgba(247, 185, 85, 0.18);
}

.lead-main {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.lead-main span {
  color: var(--muted);
  font-size: 14px;
  text-align: right;
}

dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px 10px;
  margin: 0 0 10px;
}

dt {
  color: var(--muted);
  font-size: 12px;
}

dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 700;
}

.inline-form {
  margin-top: 12px;
  align-items: stretch;
}

.inline-form input {
  min-width: 0;
}

.muted-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.danger-text {
  color: var(--danger);
}

.nowrap {
  white-space: nowrap;
}

.clip-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.id-cell {
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.ok {
  color: var(--success);
  background: var(--success-bg);
}

.status-pill.warn {
  color: var(--warning);
  background: var(--warning-bg);
}

.status-pill.off {
  color: var(--muted);
  background: #eef1f6;
}

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

.sticky-table-wrap {
  position: relative;
}

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

.dense-table {
  table-layout: fixed;
  min-width: 760px;
  font-size: 13px;
  line-height: 1.25;
}

.lead-table {
  width: max-content;
  min-width: 100%;
}

.deal-table {
  min-width: 980px;
}

.system-table {
  min-width: 1080px;
}

.user-param-table {
  min-width: 1180px;
}

.flow-param-table {
  min-width: 1180px;
}

.flow-param-table th,
.flow-param-table td {
  width: 92px;
}

.flow-param-table th:nth-child(1),
.flow-param-table td:nth-child(1) {
  width: 130px;
}

.flow-param-table th:nth-child(2),
.flow-param-table td:nth-child(2) {
  width: 160px;
}

.flow-param-table th:nth-child(10),
.flow-param-table td:nth-child(10) {
  width: 110px;
}

.user-param-table th:nth-child(1),
.user-param-table td:nth-child(1) {
  width: 210px;
}

.user-param-table th:nth-child(2),
.user-param-table td:nth-child(2),
.user-param-table th:nth-child(3),
.user-param-table td:nth-child(3) {
  width: 170px;
}

.user-param-table th:nth-child(4),
.user-param-table td:nth-child(4) {
  width: 310px;
}

.user-param-table th:nth-child(5),
.user-param-table td:nth-child(5) {
  width: 170px;
}

.cell-input,
.cell-select {
  display: block;
  width: 100%;
  min-height: 26px;
  margin: 0 0 4px;
  padding: 3px 6px;
  font-size: 12px;
}

.number-cell {
  max-width: 74px;
}

.cell-input:last-child,
.cell-select:last-child {
  margin-bottom: 0;
}

.muted-input {
  color: var(--muted);
}

.cell-permission-grid {
  display: grid;
  grid-template-columns: 72px repeat(3, minmax(58px, auto));
  gap: 4px 8px;
  align-items: center;
}

.cell-permission-grid label {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cell-permission-grid label:first-child {
  display: grid;
  grid-template-columns: 28px 42px;
}

.cell-permission-grid input[type="number"] {
  min-height: 24px;
  padding: 2px 5px;
}

.cell-permission-grid .check-row input {
  width: 14px;
  min-height: 14px;
}

.cell-permission-grid span {
  font-size: 12px;
}

.dashboard-table {
  min-width: 980px;
}

.dashboard-business-table {
  min-width: 520px;
}

.dashboard-detail-table {
  min-width: 720px;
}

.dashboard-filter {
  display: grid;
  grid-template-columns: minmax(320px, auto) 130px 130px 150px auto;
  gap: 8px;
  align-items: center;
  justify-content: end;
}

.quick-range-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.quick-range-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 8px;
  color: var(--muted);
  background: #f8fcf9;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.quick-range-link:hover,
.quick-range-link.active {
  color: var(--primary);
  border-color: #a9d9bf;
  background: var(--primary-soft);
}

.dashboard-detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 10px;
}

.dashboard-detail-grid > .panel {
  align-self: start;
  width: fit-content;
  min-width: min(100%, 620px);
  max-width: 100%;
}

.source-tree {
  display: grid;
  gap: 4px;
}

.source-tree-head,
.source-group summary {
  display: grid;
  grid-template-columns: 22px minmax(120px, 1fr) 80px 80px 80px;
  align-items: center;
  gap: 8px;
}

.source-tree-head {
  padding: 0 8px 6px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.source-group {
  border-bottom: 1px solid var(--line);
}

.source-group summary {
  min-height: 34px;
  padding: 4px 8px;
  cursor: pointer;
  list-style: none;
}

.source-group summary::-webkit-details-marker {
  display: none;
}

.source-group summary:hover {
  background: #fbfcff;
}

.source-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 18px;
  transition: transform 0.15s ease;
}

.source-group[open] .source-arrow {
  transform: rotate(90deg);
}

.source-channel-table {
  min-width: 0;
  width: auto;
  min-width: min(100%, 520px);
  margin: 0 0 6px 30px;
  box-shadow: none;
}

.source-channel-table th,
.source-channel-table td {
  padding: 5px 8px;
  background: #fbfcff;
}

.dashboard-table th,
.dashboard-table td {
  width: 100px;
}

.dashboard-table th:first-child,
.dashboard-table td:first-child {
  width: 210px;
}

.system-table th:nth-child(1),
.system-table td:nth-child(1) {
  width: 72px;
}

.system-table th:nth-child(2),
.system-table td:nth-child(2) {
  width: 150px;
}

.system-table th:nth-child(3),
.system-table td:nth-child(3) {
  width: 220px;
}

.system-table th:nth-child(4),
.system-table td:nth-child(4) {
  width: 360px;
}

.system-table th:nth-child(5),
.system-table td:nth-child(5) {
  width: 180px;
}

.nested-table-wrap {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.nested-table {
  min-width: 720px;
  box-shadow: none;
}

.member-picker {
  display: grid;
  gap: 4px;
  min-width: 260px;
}

.member-picker > span {
  color: #344054;
  font-size: 12px;
  font-weight: 700;
}

.member-check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(110px, 1fr));
  gap: 2px 8px;
  max-height: 104px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px;
  background: #fff;
}

.member-check-grid .check-row {
  min-height: 22px;
  font-size: 12px;
}

.compact-table th,
.compact-table td {
  padding: 10px 10px;
}

.dense-table th,
.dense-table td {
  padding: 7px 8px;
  vertical-align: middle;
}

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

th {
  position: relative;
  color: var(--muted);
  background: #f4fbf6;
  font-size: 13px;
  white-space: nowrap;
}

td small {
  color: var(--muted);
}

.muted-inline {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.lead-table th:nth-child(1),
.lead-table td:nth-child(1) {
  width: 48px;
}

.lead-table th:nth-child(2),
.lead-table td:nth-child(2) {
  width: 102px;
}

.lead-table th:nth-child(3),
.lead-table td:nth-child(3) {
  width: 96px;
}

.lead-table th:nth-child(4),
.lead-table td:nth-child(4) {
  width: 122px;
}

.lead-table th:nth-child(5),
.lead-table td:nth-child(5) {
  width: 126px;
}

.lead-table th:nth-child(6),
.lead-table td:nth-child(6) {
  width: 110px;
}

.lead-table th:nth-child(7),
.lead-table td:nth-child(7),
.lead-table th:nth-child(8),
.lead-table td:nth-child(8) {
  width: 84px;
}

.lead-table th:nth-child(9),
.lead-table td:nth-child(9),
.lead-table th:nth-child(10),
.lead-table td:nth-child(10) {
  width: 72px;
}

.lead-table th:nth-child(11),
.lead-table td:nth-child(11),
.lead-table th:nth-child(12),
.lead-table td:nth-child(12) {
  width: 96px;
}

.lead-table th:nth-child(13),
.lead-table td:nth-child(13),
.lead-table th:nth-child(14),
.lead-table td:nth-child(14) {
  width: 54px;
}

.lead-table th:nth-child(15),
.lead-table td:nth-child(15) {
  width: 82px;
}

.lead-table th:nth-child(16),
.lead-table td:nth-child(16) {
  width: 236px;
}

.admin-leads-table th:nth-child(10),
.admin-leads-table td:nth-child(10) {
  width: 176px;
}

.admin-leads-table th:nth-child(13),
.admin-leads-table td:nth-child(13) {
  width: 236px;
}

.flow-history summary {
  cursor: pointer;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.flow-history ol {
  display: grid;
  gap: 4px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.flow-history li {
  display: grid;
  grid-template-columns: 64px 48px 58px auto;
  align-items: center;
  gap: 5px;
  min-width: 158px;
  color: #344054;
  font-size: 12px;
}

.flow-history-time {
  color: var(--muted);
}

.deal-table th:nth-child(1),
.deal-table td:nth-child(1) {
  width: 54px;
}

.deal-table th:nth-child(2),
.deal-table td:nth-child(2),
.deal-table th:nth-child(4),
.deal-table td:nth-child(4),
.deal-table th:nth-child(5),
.deal-table td:nth-child(5) {
  width: 92px;
}

.deal-table th:nth-child(3),
.deal-table td:nth-child(3) {
  width: 118px;
}

.deal-table th:nth-child(6),
.deal-table td:nth-child(6),
.deal-table th:nth-child(7),
.deal-table td:nth-child(7) {
  width: 70px;
}

.deal-table th:nth-child(8),
.deal-table td:nth-child(8),
.deal-table th:nth-child(9),
.deal-table td:nth-child(9),
.deal-table th:nth-child(10),
.deal-table td:nth-child(10) {
  width: 96px;
}

.deal-table th:nth-child(11),
.deal-table td:nth-child(11) {
  width: 98px;
}

.col-resizer {
  position: absolute;
  top: 0;
  right: -4px;
  z-index: 2;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
}

.col-resizer:hover {
  background: rgba(23, 107, 135, 0.14);
}

body.resizing-column {
  cursor: col-resize;
  user-select: none;
}

.dense-table .status-pill {
  min-height: 22px;
  padding: 0 8px;
  font-size: 12px;
}

.dense-table .mini-form {
  gap: 6px;
}

.dense-table .mini-form select,
.dense-table .mini-form button {
  min-height: 30px;
  font-size: 13px;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(150px, 1.1fr) repeat(6, minmax(104px, 0.8fr)) auto auto;
  gap: 8px;
  align-items: center;
}

.compact-search {
  display: flex;
  width: min(360px, 100%);
  gap: 6px;
}

.filter-bar input,
.filter-bar select {
  min-height: 34px;
  padding: 6px 9px;
  font-size: 13px;
}

.ghost-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 6px;
  padding: 0 10px;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.copy-cell-button {
  max-width: 100%;
  min-height: 26px;
  padding: 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
}

.sticky-action-cell,
.sticky-action {
  position: sticky;
  right: 0;
  z-index: 3;
  background: var(--surface);
  box-shadow: -8px 0 12px rgba(23, 32, 51, 0.06);
}

thead .sticky-action-cell,
thead .sticky-action {
  z-index: 4;
  background: var(--surface);
}

.mini-form select {
  min-width: 110px;
}

.assign-form {
  display: grid;
  grid-template-columns: 92px 48px 58px;
  gap: 6px;
  align-items: center;
  width: max-content;
  white-space: nowrap;
}

.assign-form select {
  width: 92px;
  min-width: 92px;
  min-height: 28px;
  padding: 3px 6px;
  font-size: 12px;
}

.assign-form .ghost-button {
  min-height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

.force-assign-action {
  color: var(--warning);
  font-size: 12px;
}

.mini-form input {
  min-width: 160px;
}

.stack-form {
  display: grid;
  gap: 8px;
  min-width: 160px;
}

.compact-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.edit-row {
  display: none;
}

.edit-row.open {
  display: table-row;
}

.edit-row td {
  background: #fbfcff;
  padding: 8px;
}

.inline-editor {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr)) auto auto;
  gap: 12px;
  align-items: end;
}

.tight-editor {
  grid-template-columns: repeat(auto-fit, minmax(108px, max-content));
  justify-content: start;
  gap: 6px 8px;
}

.tight-editor input,
.tight-editor select {
  max-width: 168px;
  min-height: 28px;
  padding: 4px 7px;
  font-size: 12px;
}

.tight-editor select[multiple] {
  max-width: 220px;
  min-height: 74px;
}

.compact-stats {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.compact-stats .stat-card {
  min-height: 68px;
  padding: 10px 12px;
}

.compact-stats .stat-card strong {
  font-size: 22px;
}

.compact-details {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.compact-details summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 800;
}

.mini-log {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.rule-inline-editor {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 180px)) auto;
  gap: 10px;
  align-items: end;
  justify-content: start;
}

.rule-inline-editor label span {
  font-size: 12px;
}

.rule-inline-editor input,
.rule-inline-editor select {
  min-height: 34px;
}

.rule-inline-editor .check-row {
  align-self: center;
}

.dictionary-editor {
  grid-template-columns: minmax(170px, 0.8fr) minmax(90px, 0.25fr) auto auto;
  justify-content: start;
}

.editor-check {
  align-self: center;
  padding-bottom: 2px;
}

.editor-actions {
  display: flex;
  align-items: end;
  height: 100%;
}

.permission-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.permission-box {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcff;
}

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

.check-row input {
  width: 18px;
  min-height: 18px;
}

.pool-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
}

.empty-state {
  display: grid;
  min-height: 150px;
  place-items: center;
  border: 1px dashed #cfd6e4;
  border-radius: 8px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.empty-state.compact {
  min-height: 36px;
  justify-content: center;
  padding: 8px 12px;
  border-style: solid;
  background: #fbfcff;
  font-size: 13px;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.stats-strip .stat-card {
  min-height: 64px;
  padding: 10px 12px;
  box-shadow: none;
}

.stats-strip .stat-card strong {
  margin-top: 4px;
  font-size: 22px;
}

.admin-data-table {
  min-width: 1040px;
}

.users-table {
  min-width: 1260px;
}

.dictionary-table,
.flow-rules-table {
  min-width: 980px;
}

.admin-data-table th,
.admin-data-table td {
  height: 42px;
  padding: 7px 9px;
  vertical-align: middle;
}

.admin-data-table .sticky-action {
  width: 160px;
}

.mini-tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 4px;
  padding: 0 7px;
  color: var(--muted);
  background: #eef1f6;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.mini-tag + .mini-tag {
  margin-left: 4px;
}

.mini-tag.ok {
  color: var(--success);
  background: var(--success-bg);
}

.mini-tag.warn {
  color: var(--warning);
  background: var(--warning-bg);
}

.mini-tag.danger {
  color: var(--danger);
  background: var(--danger-bg);
}

.mini-tag.off {
  color: var(--muted);
  background: #eef1f6;
}

.mini-tag.role {
  color: var(--primary);
  background: var(--primary-soft);
}

.attention-panel {
  border-color: #fed7aa;
  background: #fffaf2;
}

.attention-panel .eyebrow,
.attention-panel h2 {
  color: #c2410c;
}

.reason-cell {
  max-width: 520px;
  white-space: normal;
  line-height: 1.5;
}

.pending-admin-table {
  min-width: 1280px;
}

.role-tag.role-admin {
  color: #7c3aed;
  background: #f3ecff;
}

.role-tag.role-operator_leader {
  color: #0f766e;
  background: #dff7ef;
}

.role-tag.role-operator {
  color: #047857;
  background: #e4f8ed;
}

.role-tag.role-group_leader {
  color: #1d4ed8;
  background: #e8f0ff;
}

.role-tag.role-sales {
  color: #c2410c;
  background: #fff1e8;
}

.sort-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.sort-link.active {
  color: var(--primary);
}

.sort-mark {
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

.sort-link.active .sort-mark {
  color: var(--primary);
}

.action-links {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.action-links form {
  display: inline;
  margin: 0;
}

.text-action {
  min-height: 0;
  border: 0;
  padding: 0;
  color: #2384d8;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.text-action:hover,
.text-action:focus {
  text-decoration: underline;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.compact-button {
  min-height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.admin-ops-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.ops-summary-table td:first-child {
  width: 110px;
  color: var(--muted);
  font-weight: 800;
}

.mono-cell {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  white-space: nowrap;
}

.error-cell {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.highlight-row {
  background: #e8f8ef;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

body.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.48);
}

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

.modal-panel {
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.26);
}

.modal-panel.wide {
  width: min(860px, calc(100vw - 32px));
}

.modal-panel.config-modal {
  width: min(760px, calc(100vw - 32px));
}

.modal-panel.notice-modal {
  width: min(840px, calc(100vw - 32px));
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
}

.modal-header {
  border-bottom: 1px solid var(--line);
}

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

.modal-close {
  border: 0;
  padding: 0 4px;
  color: #98a2b3;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.modal-body {
  padding: 18px 20px;
}

.modal-footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  background: #fbfcff;
}

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

.modal-form-grid > label {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.modal-form-grid > label > span {
  color: #344054;
  text-align: right;
}

.modal-form-grid > label > input,
.modal-form-grid > label > select,
.modal-form-grid > label > textarea {
  min-height: 36px;
  padding: 6px 10px;
  font-size: 14px;
}

.modal-form-grid > label > small {
  grid-column: 2;
  margin-top: -6px;
}

.compact-modal-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}

.compact-modal-grid > label {
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 8px;
}

.compact-modal-grid > label > span {
  font-size: 13px;
}

.compact-modal-grid > label > input,
.compact-modal-grid > label > select,
.compact-modal-grid > label > textarea {
  min-height: 32px;
  padding: 4px 8px;
  font-size: 13px;
}

.numeric-config-grid > label > input[type="number"] {
  width: 110px;
  max-width: 100%;
}

.config-modal .modal-header,
.config-modal .modal-footer {
  padding: 12px 16px;
}

.config-modal .modal-body {
  padding: 14px 16px;
}

.config-modal .modal-header h2 {
  font-size: 17px;
}

.modal-full-row {
  display: grid;
  grid-column: 1 / -1;
  gap: 8px;
}

.form-group-title {
  margin: 0;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

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

.option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 7px 12px;
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfcff;
}

.option-grid.three-col {
  grid-template-columns: repeat(3, minmax(120px, 1fr));
}

.option-grid .check-row {
  min-height: 24px;
  font-size: 13px;
}

.member-select-grid {
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 6px 10px;
  max-height: 210px;
  padding: 8px;
}

.member-select-grid .check-row {
  min-width: 0;
  min-height: 26px;
  gap: 6px;
}

.member-select-grid .check-row input {
  flex: 0 0 auto;
  width: 16px;
  min-height: 16px;
}

.member-select-grid .check-row span {
  min-width: 0;
  overflow: hidden;
  color: #344054;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sales-work-table,
.operator-history-table {
  min-width: 1100px;
}

.customer-table {
  min-width: 1680px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 12px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcff;
  color: var(--muted);
  font-size: 13px;
}

.summary-grid strong {
  color: var(--text);
}

.modal-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.inline-footer {
  grid-column: 1 / -1;
  padding: 0;
  border-top: 0;
  background: transparent;
}

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

.two-col-form label {
  grid-template-columns: 82px minmax(0, 1fr);
}

@media (max-width: 980px) {
  .login-shell,
  .workspace,
  .config-grid,
  .dashboard-detail-grid,
  .team-dashboard-grid,
  .dashboard-filter,
  .admin-layout,
  .role-layout {
    grid-template-columns: 1fr;
  }

  .dashboard-filter {
    justify-content: stretch;
  }

  .admin-sidebar {
    position: static;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    min-height: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0 0 14px;
  }

  .role-sidebar {
    position: static;
    grid-template-columns: 1fr;
    min-height: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0 0 10px;
  }

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

  .admin-layout.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .admin-layout.sidebar-collapsed .admin-sidebar {
    display: none;
  }

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

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

  .inline-editor,
  .dictionary-editor,
  .rule-inline-editor,
  .filter-bar,
  .permission-editor,
    .operator-upload-summary,
    .stats-strip,
    .summary-grid,
    .two-col-form,
    .split-modal-body,
    .option-grid.three-col,
    .compact-modal-grid {
    grid-template-columns: 1fr 1fr;
  }

  .editor-actions {
    height: auto;
  }

  .lead-form {
    position: static;
  }
}

@media (max-width: 680px) {
  .topbar,
  .identity,
  .lead-main,
  .section-heading,
  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }

  .nav {
    flex-wrap: wrap;
  }

  .grid-2,
  .grid-4,
  .admin-grid,
  .operator-upload-summary,
  .stats-strip,
  .summary-grid,
  .two-col-form,
  .admin-sidebar,
  .inline-editor,
  .dictionary-editor,
  .rule-inline-editor,
  .filter-bar,
  .permission-editor,
  .split-modal-body,
  .option-grid,
  .option-grid.three-col,
  dl {
    grid-template-columns: 1fr;
  }

  .role-layout {
    padding: 10px 8px 40px;
  }

  .page {
    padding: 10px 8px 40px;
  }

  .compact-workspace {
    gap: 10px;
  }

  .operator-upload-card {
    order: -1;
    padding: 12px;
  }

  .operator-upload-card h1 {
    font-size: 28px;
  }

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

  .ocr-dropzone .ghost-button,
  .operator-upload-card .primary-button {
    width: 100%;
    min-height: 46px;
  }

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

  .role-sidebar {
    gap: 8px;
  }

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

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

  .role-sidebar-stats {
    grid-column: 1 / -1;
  }

  .sales-work-table {
    min-width: 0;
  }

  .sales-work-table thead {
    display: none;
  }

  .sales-work-table,
  .sales-work-table tbody,
  .sales-work-table tr,
  .sales-work-table td {
    display: block;
    width: 100%;
  }

  .sales-work-table tr {
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 8px 22px rgba(24, 92, 68, 0.06);
  }

  .sales-work-table td {
    border-bottom: 0;
    padding: 7px 10px;
  }

  .sales-work-table td:nth-child(1),
  .sales-work-table td:nth-child(2),
  .sales-work-table td:nth-child(3),
  .sales-work-table td:nth-child(4) {
    display: inline-flex;
    width: auto;
    align-items: center;
    gap: 6px;
  }

  .sales-work-table td:nth-child(5),
  .sales-work-table td:nth-child(6) {
    display: inline-flex;
    width: 49%;
  }

  .sales-work-table td:nth-child(7)::before {
    content: "业务：";
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }

  .sales-work-table td:nth-child(8)::before {
    content: "渠道：";
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }

  .sales-work-table td:nth-child(9)::before {
    content: "分配：";
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }

  .sales-work-table td:nth-child(10)::before {
    content: "流转：";
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }

  .sales-work-table .copy-cell-button {
    min-height: 44px;
    width: 100%;
    justify-content: center;
  }

  .sales-work-table .sticky-action {
    position: static;
    display: flex;
    gap: 12px;
    background: transparent;
  }

  .modal-backdrop {
    padding: 12px;
    align-items: flex-start;
  }

  .modal-panel,
  .modal-panel.wide,
  .modal-panel.config-modal,
  .modal-panel.notice-modal {
    width: 100%;
    max-height: calc(100vh - 24px);
  }

  .compact-modal-grid,
  .member-select-grid {
    grid-template-columns: 1fr;
  }

  .modal-form-grid > label,
  .compact-modal-grid > label {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .modal-form-grid > label > span,
  .compact-modal-grid > label > span {
    text-align: left;
  }

  .lead-main span {
    text-align: left;
  }

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

  .actions form,
  .actions button,
  .identity button,
  .compact-actions form,
  .compact-actions button {
    width: 100%;
  }

  .compact-actions {
    align-items: stretch;
    flex-direction: column;
    white-space: normal;
  }
}
