:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #dce3ea;
  --text: #1f2937;
  --muted: #667085;
  --primary: #174a7c;
  --primary-soft: #e8f1fb;
  --success: #177245;
  --success-soft: #e7f6ee;
  --warning: #b76e00;
  --warning-soft: #fff3d7;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
  --sidebar-bg: #0f2438;
  --sidebar-surface: #152a40;
  --sidebar-text: #c5d3df;
  --sidebar-muted: #7a8fa3;
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-active-bg: rgba(23, 74, 124, 0.45);
  --sidebar-width: 248px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

button,
select,
input {
  font: inherit;
}

[hidden] {
  display: none !important;
}

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

.sidebar {
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand-mark,
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(145deg, #2a6cb0, #174a7c);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-brand-text strong,
.sidebar-brand-text span {
  display: block;
}

.sidebar-brand-text strong {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.sidebar-brand-text span {
  margin-top: 2px;
  font-size: 11px;
  color: var(--sidebar-muted);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
}

.nav-group {
  margin-bottom: 20px;
}

.nav-group:last-child {
  margin-bottom: 8px;
}

.nav-group-label {
  padding: 0 10px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--sidebar-muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  border-radius: 6px;
  padding: 0 10px;
  height: 40px;
  background: transparent;
  color: var(--sidebar-text);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  position: relative;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.75;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-item:hover svg {
  opacity: 1;
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: #fff;
  font-weight: 500;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: #5b9fd4;
}

.nav-item.active svg {
  opacity: 1;
  color: #93c5fd;
}

.nav-item:focus-visible,
.sidebar-footer .logout-btn:focus-visible {
  outline: 2px solid #5b9fd4;
  outline-offset: 1px;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px 10px 16px;
  margin-top: auto;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--sidebar-surface);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #2a5080;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  color: #b8d4f0;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-info strong {
  display: block;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info span {
  display: block;
  font-size: 11px;
  color: var(--sidebar-muted);
}

.sidebar-footer .logout-btn {
  border: 0;
  background: transparent;
  color: var(--sidebar-muted);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.sidebar-footer .logout-btn:hover {
  color: #fca5a5;
  background: rgba(255, 255, 255, 0.06);
}

.main {
  padding: 28px 32px 42px;
}

.topbar,
.toolbar,
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.panel-head--filters-end {
  justify-content: flex-end;
}

.panel-head--filters-center {
  justify-content: center;
}

.customer-table-head {
  justify-content: space-between;
  gap: 12px;
}

.customer-table-filters input[type="search"] {
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

.customer-table-filters input[type="search"]::placeholder {
  color: #98a2b3;
}

.customer-table-filters input[type="search"]:focus {
  outline: none;
  border-color: rgba(23, 74, 124, 0.42);
  box-shadow: 0 0 0 3px rgba(23, 74, 124, 0.12);
}

.customer-table-summary {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.exception-apply-bar {
  margin-bottom: 14px;
}

.exception-apply-hint {
  flex: 1;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.toolbar--end {
  justify-content: flex-end;
}

.topbar h1,
.toolbar h2,
.panel h2,
.page-intro h2 {
  margin: 0;
}

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

.topbar-actions,
.filters {
  display: flex;
  gap: 10px;
  align-items: center;
}

.report-month-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted, #5a6b7d);
}

.report-month-picker select {
  border: 1px solid rgba(13, 79, 140, 0.18);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: inherit;
  font: inherit;
}

.primary-btn,
.ghost-btn {
  border: 1px solid var(--primary);
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
}

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

.primary-btn.full {
  width: 100%;
}

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

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.kpi-card,
.panel,
.table-card,
.upload-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.kpi-card {
  padding: 20px;
  text-align: center;
}

.kpi-card span {
  display: block;
  color: var(--muted);
}

.kpi-card strong {
  display: block;
  margin: 10px 0 0;
  color: var(--primary);
  font-size: 34px;
}

.kpi-card.warning strong {
  color: var(--warning);
}

.kpi-card.danger strong {
  color: var(--danger);
}

.content-grid {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.two-col {
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
}

.panel {
  padding: 20px;
}

.status {
  display: inline-flex;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
}

.status.success {
  background: var(--success-soft);
  color: var(--success);
}

.status.warning {
  background: var(--warning-soft);
  color: var(--warning);
}

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

.score-bars {
  display: grid;
  gap: 16px;
}

.score-bars div {
  display: grid;
  grid-template-columns: 86px 1fr 40px;
  gap: 12px;
  align-items: center;
}

.score-bars i {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary) var(--v), #e5eaf0 var(--v));
}

.visit-plan-head {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.visit-plan-head-end {
  display: flex;
  align-items: center;
  gap: 12px;
}

.visit-plan-head-end #visitPlanExportHome {
  display: flex;
  gap: 10px;
  align-items: center;
}

.visit-view-tabs {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.visit-view-tabs .visit-category-tab {
  padding: 8px 12px;
  border-radius: 20px;
  font-size: 12px;
}

.visit-view-tabs .visit-tab-label,
.visit-view-tabs .visit-tab-count {
  display: inline;
}

.visit-category-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

.visit-cat-decline {
  background: var(--danger-soft);
  color: var(--danger);
}

.visit-cat-dormant {
  background: var(--warning-soft);
  color: var(--warning);
}

.visit-cat-upgrade {
  background: var(--success-soft);
  color: var(--success);
}

.visit-cat-other {
  background: var(--bg);
  color: var(--muted);
}

.visit-view-tabs .visit-result-tab {
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  border: 1px solid rgba(213, 222, 232, 0.9);
  background: #fff;
  color: #28435e;
  box-shadow: none;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.visit-view-tabs .visit-result-tab:hover {
  border-color: rgba(13, 79, 140, 0.35);
  background: rgba(13, 79, 140, 0.04);
}

.visit-view-tabs .visit-result-tab.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 16px rgba(23, 74, 124, 0.2);
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid rgba(213, 222, 232, 0.9);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.icon-btn:hover {
  color: var(--text);
  border-color: rgba(13, 79, 140, 0.35);
}

@media (max-width: 900px) {
  .visit-plan-head-end {
    flex-wrap: wrap;
    justify-content: center;
  }
}

.page-intro {
  margin-bottom: 18px;
}

.page-intro p,
.toolbar p {
  margin: 8px 0 0;
  color: var(--muted);
}

.upload-layout {
  display: grid;
  gap: 16px;
}

.upload-visit-priority-panel {
  margin-top: 0;
}

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

.upload-card {
  padding: 20px;
}

.upload-card h3 {
  margin: 0 0 10px;
}

.upload-card-title--sales,
.upload-card-title--visit {
  text-align: center;
}

.upload-card ul {
  margin: 16px 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.8;
}

.backend-upload-hint {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.5;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--muted);
}

.backend-upload-hint code {
  font-size: 11px;
  word-break: break-all;
}

.backend-upload-hint--muted {
  opacity: 0.95;
}

.backend-upload-hint--ok {
  border-color: #7bc96f;
  background: rgba(123, 201, 111, 0.12);
  color: var(--text, #1a1a1a);
}

.backend-upload-hint--ok .warn {
  color: #b45309;
  font-weight: 600;
}

.backend-upload-hint--error {
  border-color: #e07a7a;
  background: rgba(224, 122, 122, 0.12);
  color: #8b2c2c;
}

.backend-sheet-preview {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.35);
}

.backend-file-preview + .backend-file-preview {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.backend-file-head {
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text);
}

.backend-sheet-block + .backend-sheet-block {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.backend-sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 13px;
}

.backend-sheet-head span {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.backend-column-list {
  margin: 0;
  padding-left: 18px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted);
  max-height: 140px;
  overflow-y: auto;
}

.backend-column-more {
  list-style: none;
  margin-left: -18px;
  font-style: italic;
  color: var(--muted);
}

.backend-parse-meta {
  margin: 0 0 12px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.45;
  background: rgba(99, 153, 209, 0.12);
  border: 1px solid rgba(99, 153, 209, 0.35);
  color: var(--muted);
}

.backend-parse-meta code {
  font-size: 10px;
}

.backend-parse-meta--err {
  background: rgba(224, 122, 122, 0.12);
  border-color: rgba(224, 122, 122, 0.45);
  color: #8b2c2c;
}

.drop-zone {
  border: 1px dashed #9eb3c7;
  border-radius: 14px;
  padding: 18px;
  color: var(--primary);
  background: var(--primary-soft);
  text-align: center;
}

.drop-zone input {
  display: none;
}

.drop-zone label {
  display: block;
  cursor: pointer;
}

.file-name {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.cleaning-panel {
  margin-top: 0;
}

.cleaning-panel .panel-head {
  margin-bottom: 4px;
}

.cleaning-panel .panel-head .filters select {
  min-width: 168px;
  padding: 10px 14px;
  font-size: 14px;
}

.cleaning-panel .analysis-table-card.compact-table {
  max-height: calc(100vh - 220px);
  min-height: 520px;
}

.cleaning-panel .analysis-table-card.compact-table th,
.cleaning-panel .analysis-table-card.compact-table td {
  padding: 12px 14px;
  font-size: 14px;
}

.cleaning-panel .analysis-tabs {
  margin-top: 8px;
}

.compact-table {
  max-height: 420px;
}

.compact-table td,
.compact-table th {
  padding: 10px 12px;
  font-size: 13px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

/* 分析底表标签页样式 */
.analysis-tabs {
  display: flex;
  gap: 8px;
  margin: 16px 0 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.tab-btn {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.tab-btn:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.tab-content .table-card {
  max-height: 400px;
  overflow-y: auto;
}

.tab-content .compact-table th,
.tab-content .compact-table td {
  padding: 10px 12px;
  font-size: 13px;
}

.analysis-table-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.analysis-table-shell:has(#analysisDetailPanel:not([hidden])) {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
}

.analysis-table-hint {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.analysis-table-card {
  margin-top: 0;
}

.analysis-table {
  width: 100%;
  table-layout: auto;
}

.analysis-table th,
.analysis-table td {
  white-space: nowrap;
}

.analysis-table td:first-child,
.analysis-table th:first-child {
  max-width: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.analysis-table td:nth-child(2),
.analysis-table th:nth-child(2) {
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.analysis-row-selectable {
  cursor: pointer;
  transition: background 0.15s ease;
}

.analysis-row-selectable:hover,
.analysis-row-selectable.selected {
  background: #f0f6fc;
}

.analysis-row-action {
  color: var(--primary);
  font-weight: 600;
  font-size: 12px;
  text-align: center;
}

.analysis-detail-panel {
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 120px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.analysis-detail-panel[hidden] {
  display: none;
}

.analysis-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.analysis-detail-head h3 {
  margin: 4px 0 0;
  font-size: 18px;
  line-height: 1.35;
}

.analysis-detail-subtitle {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.analysis-detail-fields {
  display: grid;
  gap: 12px;
  margin: 0;
}

.analysis-detail-field {
  display: grid;
  gap: 4px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(220, 227, 234, 0.8);
}

.analysis-detail-field:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.analysis-detail-field dt {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.analysis-detail-field dd {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}

.analysis-detail-empty {
  color: var(--muted);
}

@media (max-width: 1100px) {
  .analysis-table-shell:has(#analysisDetailPanel:not([hidden])) {
    grid-template-columns: 1fr;
  }

  .analysis-detail-panel {
    position: static;
    max-height: none;
  }
}

/* 拜访计划行动面板 */
.visit-plan-action-panel {
  margin-top: 20px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  max-width: 520px;
}

.visit-plan-action-panel[hidden] {
  display: none;
}

.customer-ratio-visual,
.visit-plan-action {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.customer-ratio-visual h3,
.visit-plan-action h3 {
  margin: 0 0 16px 0;
  font-size: 16px;
  color: var(--text);
}

.ratio-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ratio-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ratio-label {
  width: 80px;
  font-size: 13px;
  color: var(--muted);
}

.ratio-bar-container {
  flex: 1;
  height: 24px;
  background: var(--surface-soft);
  border-radius: 12px;
  overflow: hidden;
}

.ratio-bar {
  height: 100%;
  border-radius: 12px;
  transition: width 0.3s ease;
}

.ratio-bar.has-sales {
  background: var(--success);
  width: var(--ratio, 37.5%);
}

.ratio-bar.no-sales {
  background: var(--warning);
  width: var(--ratio, 62.5%);
}

.ratio-value {
  width: 40px;
  text-align: right;
  font-weight: 600;
  font-size: 14px;
}

.ratio-note {
  margin: 12px 0 0 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.visit-plan-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.visit-plan-action p {
  margin: 0 0 16px 0;
  color: var(--muted);
  font-size: 14px;
}

.visit-plan-action .primary-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  font-size: 15px;
  position: relative;
  z-index: 2;
}

.btn-icon {
  font-size: 18px;
}

.action-hint {
  margin-top: 12px !important;
  font-size: 12px !important;
  color: var(--warning) !important;
}

.action-hint.ready {
  color: var(--success) !important;
}

@media (max-width: 768px) {
  .visit-plan-action-panel {
    grid-template-columns: 1fr;
  }
}

/* 业务员拜访计划：可视区约等于表头 + 10 行数据，其余纵向滚动（滚轮/触控板） */
#visits .visit-result-panel .table-card {
  max-height: calc(48px + 10 * 46px);
  overflow-y: auto;
  overflow-x: auto;
}

#visits .visit-result-panel .table-card thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: #f7f9fc;
  box-shadow: 0 1px 0 var(--line);
}

#visits .visit-result-panel .table-card thead th:nth-child(1),
#visits .visit-result-panel .table-card thead th:nth-child(2) {
  z-index: 9;
}

.table-card {
  margin-top: 16px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

/* 横向滚动时冻结前两列（客户主表 / 拜访计划为「客户ID」「客户名称」，异常表为前两列字段） */
:root {
  --table-freeze-col1-width: 7.5rem;
  --table-freeze-col2-width: 11rem;
}

table.table-freeze-2-cols th:nth-child(1),
table.table-freeze-2-cols td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 3;
  box-sizing: border-box;
  min-width: var(--table-freeze-col1-width);
  width: var(--table-freeze-col1-width);
  max-width: var(--table-freeze-col1-width);
  overflow: hidden;
  text-overflow: ellipsis;
  background: #fff;
  box-shadow: 1px 0 0 var(--line);
}

table.table-freeze-2-cols thead th:nth-child(1) {
  z-index: 5;
  background: #f7f9fc;
}

table.table-freeze-2-cols th:nth-child(2),
table.table-freeze-2-cols td:nth-child(2) {
  position: sticky;
  left: var(--table-freeze-col1-width);
  z-index: 3;
  box-sizing: border-box;
  min-width: var(--table-freeze-col2-width);
  width: var(--table-freeze-col2-width);
  max-width: var(--table-freeze-col2-width);
  overflow: hidden;
  text-overflow: ellipsis;
  background: #fff;
  box-shadow: 1px 0 0 var(--line);
}

table.table-freeze-2-cols thead th:nth-child(2) {
  z-index: 5;
  background: #f7f9fc;
}

table.table-freeze-2-cols tbody tr:hover td:nth-child(1),
table.table-freeze-2-cols tbody tr:hover td:nth-child(2) {
  background: #f8fbff;
}

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

th {
  background: #f7f9fc;
  color: #344054;
  font-size: 13px;
}

tbody tr {
  cursor: default;
}

tbody tr:hover {
  background: #f8fbff;
}

.tag {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}

.toolbar select,
.panel-head .filters select {
  min-width: 140px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  background: #fff;
}

.visit-plan-page .visit-result-tabs {
  margin-top: 0;
}

.visit-plan-main {
  margin-top: 8px;
}

.visit-plan-main .visit-result-panel {
  margin-top: 0;
}

.visit-plan-main .visit-result-panel .table-card {
  margin-top: 12px;
}

.visit-plan-page .visit-result-panel {
  margin-top: 16px;
}

.visit-table-section {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.visit-table-section .toolbar {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.visit-table-section .toolbar h2 {
  font-size: 16px;
  margin: 0 0 4px 0;
  color: var(--text);
}

.visit-table-section .toolbar p {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.count-badge {
  display: inline-block;
  background: var(--primary);
  color: white;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 8px;
}

.visit-result-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 12px;
  margin: 2px 0 18px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  width: fit-content;
  max-width: 100%;
}

.visit-result-tab {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 24px;
  background: var(--surface);
  color: #28435e;
  font-weight: 700;
  cursor: pointer;
}

.visit-result-tab.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 20px rgba(23, 74, 124, 0.18);
}

.visit-result-panel[data-visit-panel] {
  display: none;
}

.visit-result-panel[data-visit-panel].active {
  display: block;
}

.visit-result-panel h2 {
  margin: 0 0 4px;
}

.visit-panel-head-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.visit-panel-head-row h2 {
  margin: 0;
}

.visit-plan-export-slot .primary-btn {
  padding: 12px 20px;
}

.visit-table-hint {
  margin: 12px 0;
  color: var(--muted);
  font-size: 13px;
}

.visit-filter-line {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 12px 0 14px;
  align-items: center;
}

.visit-filter-line label {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.visit-filter-line select {
  min-width: 240px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  background: #fff;
  color: var(--text);
}

@media (max-width: 1100px) {
  .app-shell,
  .two-col,
  .upload-grid,
  .kpi-grid,
  .dashboard-chart-table-row {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }
}

/* 销售总览：大盘 / 多维对比图表（借鉴陪跑 demo） */
.sales-dashboard-panel {
  margin-bottom: 20px;
}

.sales-dashboard-panel + .sales-dashboard-panel {
  margin-top: 0;
}

.dashboard-kpi-bar {
  margin-bottom: 20px;
}

.sales-dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(260px, 0.95fr);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 18px;
}

.sales-hero-chart {
  margin: 0;
  min-height: 360px;
  padding: 16px;
  border: 1px solid rgba(13, 79, 140, 0.08);
  border-radius: 14px;
  background: #fff;
  overflow: visible;
}

.sales-hero-chart .chart-card-title {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.chart-canvas-host--hero {
  height: 300px;
  min-height: 300px;
  overflow: visible;
}

.sales-summary-panel {
  padding: 16px;
  border: 1px solid rgba(13, 79, 140, 0.08);
  border-radius: 14px;
  background: rgba(248, 251, 255, 0.92);
}

.sales-summary-title {
  margin: 0 0 12px;
  font-size: 15px;
}

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

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

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

.sales-summary-card strong {
  font-size: 18px;
  color: var(--primary);
  line-height: 1.25;
}

.sales-summary-card em {
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
}

.sales-summary-delta--up {
  color: var(--success);
}

.sales-summary-delta--down {
  color: var(--danger);
}

.sales-zone-summary {
  margin-bottom: 18px;
}

.sales-zone-summary-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.sales-zone-summary-head h3 {
  margin: 0;
  font-size: 15px;
}

.sales-zone-summary-note {
  color: var(--muted);
  font-size: 12px;
}

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

.sales-zone-card {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.sales-zone-card:hover {
  border-color: rgba(23, 74, 124, 0.35);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.sales-zone-card-rank {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.sales-zone-card strong {
  font-size: 15px;
  color: var(--text);
}

.sales-zone-card em {
  font-style: normal;
  color: var(--primary);
  font-weight: 700;
}

.sales-zone-card small {
  color: var(--muted);
  font-size: 12px;
}

.sales-dashboard-drill {
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid rgba(213, 222, 232, 0.85);
}

.sales-dashboard-drill[hidden] {
  display: none;
}

.sales-drill-tabs {
  margin-bottom: 12px;
}

.sales-drill-panels {
  padding-top: 0;
}

.dashboard-table-wrap--detail {
  max-height: 420px;
  overflow: auto;
}

@media (max-width: 1100px) {
  .sales-dashboard-hero,
  .sales-zone-summary-grid {
    grid-template-columns: 1fr;
  }

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

.dashboard-chart-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.sales-dashboard-panel .dashboard-tab-panels {
  padding-top: 20px;
}

.dashboard-tab-panel {
  display: none;
}

.dashboard-tab-panel.active {
  display: block;
}

.dashboard-tab-panel,
.dashboard-chart-table-row {
  min-width: 0;
}

.module-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(213, 222, 232, 0.85);
}

.module-title-row h2 {
  margin: 0;
  font-size: 22px;
}

.module-section {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(13, 79, 140, 0.08);
  border-radius: 14px;
  background: rgba(248, 251, 255, 0.72);
}

.module-section:first-of-type {
  margin-top: 0;
}

.module-section h3 {
  margin: 0;
  font-size: 17px;
}

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

.dashboard-zone-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.dashboard-zone-toolbar .dashboard-controls select {
  min-width: 160px;
}

.dashboard-chart-table-row {
  display: grid;
  grid-template-columns: minmax(0, 54%) minmax(0, 46%);
  gap: 12px;
  align-items: start;
  margin-top: 4px;
}

.sales-dashboard-panel .dashboard-tab-panel[data-dashboard-panel="multi"] > .chart-card {
  margin-top: 4px;
}

.dashboard-chart-table-row .chart-card {
  margin: 0;
  height: auto;
  min-height: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  overflow: visible;
  position: sticky;
  top: 12px;
  padding: 12px 14px 10px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.dashboard-chart-table-row .chart-card--static:not(:has(.chart-canvas-host--tall)):not(:has(.chart-canvas-host--compact)):not(:has(.chart-canvas-host--zone)) {
  height: auto;
}

.dashboard-chart-table-row .chart-canvas-host {
  flex: none;
  height: 320px;
  min-height: 320px;
  width: 100%;
  overflow: visible;
}

.dashboard-chart-table-row .chart-canvas-host--zone {
  height: 320px;
  min-height: 320px;
  overflow: visible;
}

.dashboard-table-row-link {
  cursor: pointer;
  transition: background 0.12s ease;
}

.dashboard-table-row-active {
  background: rgba(13, 79, 140, 0.1) !important;
}

.dashboard-table-row-active td:first-child {
  color: var(--primary);
  font-weight: 600;
}

.dashboard-row-incomplete {
  opacity: 0.62;
}

.dashboard-row-incomplete td:first-child {
  color: var(--muted);
}

.dashboard-row-note {
  margin-left: 6px;
  font-size: 10px;
  font-weight: 600;
  color: var(--warning);
  vertical-align: middle;
}

.dashboard-chart-table-row .chart-canvas-host canvas {
  display: block;
  max-width: 100%;
}

.dashboard-chart-table-row .dashboard-table-wrap {
  margin: 0;
  max-height: min(560px, calc(100vh - 280px));
  overflow: auto;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.dashboard-chart-table-row .dashboard-table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f4f8fc;
}

.dashboard-chart-table-row .dashboard-table-wrap table {
  width: 100%;
  table-layout: fixed;
  font-size: 12px;
}

.dashboard-chart-table-row .dashboard-table-wrap th,
.dashboard-chart-table-row .dashboard-table-wrap td {
  padding: 8px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard-chart-table-row .dashboard-table-wrap th:not(:first-child),
.dashboard-chart-table-row .dashboard-table-wrap td:not(:first-child) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.dashboard-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.sales-dashboard-drill .metric-pills {
  margin-top: 0;
  margin-bottom: 12px;
}

.dashboard-controls select {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
  max-width: 200px;
}

.toggle-pill,
.metric-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  background: #fff;
  color: #28435e;
  font-weight: 700;
  cursor: pointer;
}

.toggle-pill.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.metric-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.metric-pill.active {
  border-color: var(--metric-color, var(--primary));
  background: var(--metric-color, var(--primary));
  color: #fff;
}

.chart-card {
  margin: 14px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.dashboard-table-wrap {
  max-height: 320px;
  overflow: auto;
}

.dashboard-table-wrap--static {
  max-height: none;
  overflow: visible;
}

.chart-card--static {
  pointer-events: none;
  user-select: none;
  overflow: hidden;
  box-sizing: border-box;
}

.chart-card--static:not(:has(.chart-canvas-host--tall)):not(:has(.chart-canvas-host--compact)):not(:has(.chart-canvas-host--hero)):not(:has(.chart-canvas-host--zone)) {
  height: 252px;
}

.chart-card--static:has(.chart-canvas-host--hero),
.chart-card--static:has(.chart-canvas-host--zone) {
  height: auto;
  min-height: 0;
  overflow: visible;
}

.chart-card--static:has(.chart-canvas-host--tall) {
  height: 292px;
}

.chart-card--static:has(.chart-canvas-host--compact) {
  height: 232px;
}

.chart-canvas-host {
  height: 220px;
  overflow: visible;
  position: relative;
}

.chart-canvas-host--hero,
.chart-canvas-host--zone {
  overflow: visible;
}

.chart-canvas-host--tall {
  height: 260px;
}

.chart-canvas-host--compact {
  height: 200px;
}

.chart-card--static canvas {
  pointer-events: none;
  display: block;
}

.empty-row {
  text-align: center;
  color: var(--muted);
  white-space: normal;
  line-height: 1.6;
}

.module-section-title {
  margin: 0 0 12px;
  font-size: 17px;
}

.two-column-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
  margin-top: 18px;
}

.ranking-table-pair .module-section {
  display: flex;
  flex-direction: column;
  height: 100%;
  margin-top: 0;
}

.ranking-table-pair h2.module-section-title {
  min-height: 32px;
  line-height: 32px;
}

.ranking-table-pair .table-wrap {
  flex: 1;
}

.ranking-table {
  table-layout: fixed;
  width: 100%;
}

.ranking-table th:first-child,
.ranking-table td:first-child {
  width: 42%;
  text-align: left;
}

.ranking-table th:not(:first-child),
.ranking-table td:not(:first-child) {
  width: 19.33%;
  text-align: center;
}

/* 拜访诊断：频次/占比表 — 表头与数据统一居中 */
.visit-count-table {
  table-layout: fixed;
  width: 100%;
}

.visit-count-table th,
.visit-count-table td {
  text-align: center;
  vertical-align: middle;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.visit-count-table th:first-child,
.visit-count-table td:first-child {
  width: 50%;
}

.visit-count-table th:not(:first-child),
.visit-count-table td:not(:first-child) {
  width: 25%;
}

.visit-region-table th,
.visit-region-table td {
  width: auto;
}

.ranking-table tbody tr.ranking-placeholder td {
  color: transparent;
  user-select: none;
}

.dashboard-kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 8px;
}

.dashboard-kpi {
  min-width: 0;
  border: 1px solid rgba(13, 79, 140, 0.08);
  border-radius: 12px;
  padding: 13px 14px 14px;
  background: #f8fbff;
  text-align: left;
}

.dashboard-kpi span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.dashboard-kpi strong {
  display: block;
  margin-top: 5px;
  font-size: 20px;
  color: var(--text);
}

.visit-review-kpis {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.visit-review-loading {
  grid-column: 1 / -1;
  margin: 0;
  padding: 20px 16px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.visit-review-guidance {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid rgba(13, 79, 140, 0.12);
  border-radius: 12px;
  background: #f5f9ff;
  color: var(--text);
  font-size: 13px;
  line-height: 1.7;
}

.visit-review-guidance--muted {
  margin: 12px 0 0;
  color: var(--muted);
}

.visit-review-guidance:empty {
  display: none;
}

.visit-review-kpis .dashboard-kpi {
  min-height: 108px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  cursor: default;
}

.visit-review-kpis .dashboard-kpi span {
  font-size: 14px;
}

.visit-review-kpis .dashboard-kpi strong {
  margin-top: 8px;
  font-size: 34px;
  line-height: 1;
}

.dashboard-kpi.static {
  cursor: default;
}

.visit-funnel {
  display: flex;
  gap: 0;
  margin: 18px 0 8px;
  padding: 12px 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}

.funnel-step {
  flex: 1 1 0;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: stretch;
  min-width: 0;
}

.funnel-step:not(:last-child)::after {
  content: "";
  position: absolute;
  right: -4px;
  top: 50%;
  z-index: 2;
  width: 12px;
  height: 12px;
  border-top: 1.5px solid rgba(13, 79, 140, 0.25);
  border-right: 1.5px solid rgba(13, 79, 140, 0.25);
  transform: translateY(-50%) rotate(45deg);
}

.funnel-block {
  width: var(--step-width, 100%);
  min-width: 60px;
  padding: 12px 8px;
  border-radius: 10px;
  text-align: center;
  color: #fff;
  background: var(--primary);
  box-shadow: none;
  opacity: calc(1 - (var(--step-index) * 0.08));
}

.funnel-block span,
.funnel-block strong,
.funnel-block em {
  display: block;
}

.funnel-block span {
  font-size: 12px;
  font-weight: 700;
  opacity: 0.88;
}

.funnel-block strong {
  margin-top: 4px;
  font-size: 26px;
  line-height: 1.1;
}

.funnel-block em {
  margin-top: 4px;
  font-size: 12px;
  font-style: normal;
  opacity: 0.82;
}

.visit-review-detail-section {
  margin-top: 18px;
}

.visit-review-detail-section > .module-section-title {
  margin-bottom: 10px;
}

.visit-review-detail-tabs {
  margin-bottom: 14px;
}

.visit-review-detail-panels .two-column-sections {
  margin-top: 0;
}

.visit-review-detail-panels .module-section {
  margin-top: 0;
}

/* 产品竞品：堆叠布局（产品 4 列上，竞品 6 列下） */
.product-competitor-sections {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 1260px) {
  .product-competitor-sections {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
  }
}

/* 竞品表：六列宽度分配 */
.competitor-table {
  table-layout: fixed;
  width: 100%;
}

.competitor-table th:nth-child(1),
.competitor-table td:nth-child(1) {
  width: 11%;
  text-align: left;
}

.competitor-table th:nth-child(2),
.competitor-table td:nth-child(2),
.competitor-table th:nth-child(3),
.competitor-table td:nth-child(3),
.competitor-table th:nth-child(4),
.competitor-table td:nth-child(4) {
  width: 7%;
  text-align: center;
}

.competitor-table th:nth-child(5),
.competitor-table td:nth-child(5) {
  width: 12%;
  text-align: center;
}

.analysis-row-action .visit-competitor-view-btn {
  border: none;
  background: none;
  padding: 0;
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.analysis-row-action .visit-competitor-view-btn:hover {
  text-decoration: underline;
}

#visitCompetitorDetailModal:not([open]) {
  display: none;
}

.visit-competitor-detail-card {
  max-width: 520px;
}

.visit-competitor-detail-body {
  padding: 18px 20px 22px;
  max-height: min(70vh, 480px);
  overflow: auto;
}

.visit-competitor-detail-body dd {
  margin: 0;
  line-height: 1.6;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.visit-competitor-detail-body #visitCompetitorDetailStrategy {
  color: var(--primary);
}

.visit-detail-subtitle {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.visit-detail-single {
  margin-top: 0;
}

.visit-review-charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 8px;
  align-items: stretch;
  min-height: 220px;
}

.visit-review-charts .chart-card {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 16px;
  border: 1px solid rgba(13, 79, 140, 0.08);
  border-radius: 14px;
  background: #fff;
}

.visit-review-charts .chart-card-title {
  margin: 0 0 8px;
  min-height: 28px;
  font-size: 13px;
  line-height: 1.35;
  color: var(--muted);
  font-weight: 600;
}

.visit-review-charts .chart-canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
}

.visit-review-charts .chart-canvas-wrap canvas {
  display: block;
  max-width: 100%;
}

@media (max-width: 1100px) {
  .visit-review-charts {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    min-height: 0;
  }
}

.two-column-sections {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .visit-review-kpis,
  .visit-funnel {
    flex-direction: column;
  }

  .funnel-step:not(:last-child)::after {
    display: none;
  }
}

/* =====================================================
   Priority List (P4) — Card Grid
   ===================================================== */
.priority-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.priority-filter-segment {
  display: inline-flex;
  align-items: stretch;
  gap: 0;
  padding: 4px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

.priority-filter-segment .filter-btn {
  position: relative;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  padding: 8px 18px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background 0.18s ease,
    color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.12s ease;
}

.priority-filter-segment .filter-btn + .filter-btn::before {
  content: "";
  position: absolute;
  left: 0;
  top: 22%;
  bottom: 22%;
  width: 1px;
  background: rgba(220, 227, 234, 0.9);
  pointer-events: none;
}

.priority-filter-segment .filter-btn.active::before,
.priority-filter-segment .filter-btn.active + .filter-btn::before,
.priority-filter-segment .filter-btn:hover + .filter-btn::before,
.priority-filter-segment .filter-btn:focus-visible + .filter-btn::before {
  opacity: 0;
}

.priority-filter-segment .filter-btn:hover:not(.active) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
}

.priority-filter-segment .filter-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.priority-filter-segment .filter-btn[data-filter="churn"].active {
  color: var(--warning);
}

.priority-filter-segment .filter-btn[data-filter="new"].active {
  color: var(--success);
}

.priority-filter-segment .filter-btn:active:not(.active) {
  transform: scale(0.98);
}

.priority-filter-segment .filter-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px rgba(23, 74, 124, 0.28);
}

.priority-search-group input {
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  min-width: 240px;
  background: var(--surface);
  color: var(--text);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.priority-search-group input::placeholder {
  color: #98a2b3;
}

.priority-search-group input:focus {
  outline: none;
  border-color: rgba(23, 74, 124, 0.42);
  box-shadow: 0 0 0 3px rgba(23, 74, 124, 0.12);
}
.priority-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.priority-actions #priorityTotal {
  color: var(--muted);
  font-size: 0.9rem;
}
.priority-table-card {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.priority-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.priority-table th,
.priority-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
.priority-table thead th {
  background: var(--surface-soft);
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.priority-row:hover {
  background: var(--surface-soft);
}
.priority-row-selected {
  background: var(--primary-soft);
}
.priority-col-check {
  width: 44px;
}
.priority-row-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
}
.priority-col-name {
  min-width: 120px;
  font-weight: 600;
}
.priority-name-btn {
  font-weight: 600;
  text-align: left;
  padding: 0;
}
.priority-col-diagnosis {
  max-width: 280px;
  color: var(--muted);
  font-size: 12px;
}
.priority-loading {
  text-align: center;
  color: var(--muted);
  padding: 24px;
}
.card-tier {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 12px;
  display: inline-block;
}
.tier-p0 { background: var(--danger-soft); color: var(--danger); }
.tier-high { background: var(--warning-soft); color: var(--warning); }
.tier-mid { background: var(--primary-soft); color: var(--primary); }
.tier-low { background: var(--surface-soft); color: var(--muted); }
.card-segment {
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 10px;
}
.seg-purchased { background: var(--success-soft); color: var(--success); }
.seg-unpurchased { background: var(--warning-soft); color: var(--warning); }
.card-name {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--text);
}
.card-meta {
  display: flex;
  gap: 14px;
  font-size: 0.85rem;
  color: var(--muted);
}
.card-overdue {
  color: var(--danger);
  font-weight: 600;
}
.card-diagnosis {
  margin-top: 8px;
  font-size: 0.85rem;
  color: #555;
  line-height: 1.4;
}
.priority-loading,
.priority-error {
  text-align: center;
  padding: 48px;
  color: var(--muted);
}
.priority-error {
  color: var(--danger);
}

/* =====================================================
   Customer Detail Overlay (P5)
   ===================================================== */
.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.detail-overlay[hidden] { display: none; }
.detail-overlay-header {
  width: 100%;
  max-width: 720px;
  background: var(--primary);
  color: #fff;
  padding: 14px 20px;
  border-radius: 12px 12px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.detail-overlay-header h3 {
  margin: 0;
  font-size: 1.1rem;
}
.detail-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}
.detail-nav .ghost-btn {
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.15);
  border-color: transparent;
}
.detail-nav .ghost-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.detail-overlay-header .icon-btn {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.detail-overlay-header .icon-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}
.detail-overlay-body {
  width: 100%;
  max-width: 720px;
  background: var(--surface);
  border-radius: 0 0 12px 12px;
  padding: 20px;
  max-height: 70vh;
  overflow-y: auto;
}
.detail-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--line);
  margin-bottom: 16px;
}
.detail-tab {
  padding: 10px 24px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
}
.detail-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.detail-tab-content { display: none; }
.detail-tab-content.active { display: block; }
.detail-field-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 20px;
  padding: 0;
  margin: 0;
}
.detail-field {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--surface-soft);
}
.detail-field dt {
  font-size: 0.85rem;
  color: var(--muted);
  min-width: 100px;
}
.detail-field dd {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: right;
  word-break: break-all;
}
.detail-field--highlight {
  grid-column: 1 / -1;
  background: var(--primary-soft);
  border: 1px solid rgba(23, 74, 124, 0.15);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 4px 0;
}
.detail-field--highlight dt {
  color: var(--primary);
  font-weight: 600;
}
.detail-field--highlight dd {
  font-weight: 400;
  text-align: left;
  line-height: 1.6;
}
.detail-subheading {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 16px 0 8px;
  color: var(--text);
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}
.detail-empty {
  text-align: center;
  padding: 32px;
  color: var(--muted);
}
.detail-loading {
  text-align: center;
  padding: 48px;
  color: var(--muted);
}
.detail-error {
  text-align: center;
  padding: 48px;
  color: var(--danger);
}
.detail-top-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid var(--line);
}

/* 跟进时间轴（客户详情 Tab3） */
.followup-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.followup-timeline-item {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid #f0f2f5;
}
.followup-timeline-item:last-child {
  border-bottom: none;
}
.followup-timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
  margin-top: 5px;
}
.followup-timeline-body {
  flex: 1;
  font-size: 13px;
}
.followup-timeline-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.followup-timeline-date {
  font-weight: 600;
  color: var(--text);
}
.followup-timeline-result {
  font-size: 12px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
}
.followup-timeline-note {
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 2px;
}
.followup-timeline-sp {
  color: var(--muted);
  font-size: 12px;
}

/* 统一活动时间线来源徽章 */
.source-badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
  margin-right: 6px;
  font-weight: 500;
}
.source-badge--app { background: var(--primary-soft); color: var(--primary); }
.source-badge--advisor { background: var(--success-soft); color: var(--success); }
.source-badge--visit { background: var(--warning-soft); color: var(--warning); }

/* 过程评估洞察卡 */
.visit-review-insight {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 10px;
  font-size: 13px;
  line-height: 1.5;
}
.visit-review-insight--danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.visit-review-insight--warning {
  background: var(--warning-soft);
  color: var(--warning);
}
.visit-review-insight--success {
  background: var(--success-soft);
  color: var(--success);
}
.visit-review-insight-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 10px;
  background: currentColor;
  color: #fff;
  flex-shrink: 0;
}
.visit-review-insight-title {
  font-weight: 600;
  flex-shrink: 0;
}
.visit-review-insight-sub {
  opacity: 0.8;
}

/* 跟进弹窗 */
.followup-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.45);
  border: none;
}
.followup-modal-overlay[hidden] {
  display: none !important;
}
.followup-modal-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.22);
  overflow: hidden;
}
.followup-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--primary);
  color: #fff;
}
.followup-modal-head h3 {
  margin: 0;
  font-size: 16px;
}
.followup-modal-head .icon-btn {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.followup-modal-head .icon-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}
.followup-modal-form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.followup-modal-cust-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  padding: 8px 12px;
  background: var(--primary-soft);
  border-radius: 8px;
}
.followup-modal-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.followup-modal-row label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.followup-modal-row input,
.followup-modal-row select,
.followup-modal-row textarea {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  background: #fff;
  transition: border-color 0.15s;
}
.followup-modal-row input:focus,
.followup-modal-row select:focus,
.followup-modal-row textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(23, 74, 124, 0.1);
}
.followup-modal-row textarea {
  resize: vertical;
  min-height: 70px;
}
.followup-modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 8px;
}
.followup-modal-msg {
  font-size: 13px;
  margin-right: auto;
  min-height: 20px;
}
.followup-modal-msg--ok {
  color: var(--success);
}
.followup-modal-msg--error {
  color: var(--danger);
}
.detail-actions {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}

/* =====================================================
   Data Freshness Banner & Empty State
   ===================================================== */
.freshness-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: #92400e;
}
.freshness-banner .banner-icon {
  font-size: 1.2rem;
}
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.empty-state h3 {
  font-size: 1.2rem;
  margin: 0 0 8px;
  color: var(--text);
}
.empty-state p {
  margin: 0 0 16px;
}

.empty-state--dashboard {
  max-width: 520px;
  margin: 48px auto;
  padding: 40px 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

/* =====================================================
   Upload History & Template Links
   ===================================================== */
.upload-template-links {
  font-size: 0.85rem;
  color: var(--muted);
  margin-right: auto;
}
.upload-template-links .text-btn {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.85rem;
  text-decoration: underline;
  padding: 0 2px;
}
.upload-history-section {
  margin-top: 20px;
}
.upload-history-section h3 {
  font-size: 0.95rem;
  margin: 0 0 8px;
  color: var(--muted);
}
.upload-history-item {
  display: flex;
  gap: 16px;
  padding: 8px 12px;
  background: var(--surface-soft);
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 0.85rem;
}
.uh-type {
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  font-size: 0.75rem;
  min-width: 50px;
}
.uh-name {
  color: var(--text);
}
.uh-rows {
  color: var(--muted);
  margin-left: auto;
}

/* =====================================================
   Settings — 系统设置
   ===================================================== */

.settings-loading,
.settings-error,
.settings-no-access {
  text-align: center;
  padding: 40px 20px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.settings-loading {
  color: var(--muted);
}
.settings-error {
  color: var(--danger);
}
.settings-no-access h3 {
  margin: 0 0 8px;
  color: var(--text);
}
.settings-no-access p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.settings-section {
  margin-bottom: 20px;
}
.settings-section-title {
  margin: 0 0 16px;
  font-size: 18px;
  color: var(--text);
}
.settings-desc {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.settings-form--inline {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.settings-form-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.settings-label {
  width: 140px;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.settings-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.settings-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(23, 74, 124, 0.12);
}
.settings-input--short {
  flex: none;
  width: 180px;
}
.settings-form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding-top: 8px;
}
.settings-msg {
  font-size: 13px;
  min-height: 20px;
}
.settings-msg--ok {
  color: var(--success);
}
.settings-msg--error {
  color: var(--danger);
}

.settings-team-table {
  width: 100%;
  border-collapse: collapse;
}
.settings-team-table th,
.settings-team-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.settings-team-table th {
  background: var(--surface-soft);
  font-weight: 700;
  color: var(--muted);
  font-size: 13px;
}
.settings-team-table tbody tr:hover {
  background: #f8fafc;
}
.settings-empty-row {
  text-align: center;
  color: var(--muted);
  padding: 20px 14px !important;
}
.settings-delete-member {
  color: var(--danger);
  cursor: pointer;
  background: none;
  border: none;
  font-size: 13px;
  padding: 2px 0;
}
.settings-delete-member:hover {
  text-decoration: underline;
}
.settings-muted {
  color: var(--muted);
  font-size: 13px;
}

/* =====================================================
   Followup — 跟进记录（回执上传 / 在线标记 / 历史）
   ===================================================== */

.followup-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--line);
}
.followup-tabs .tab-btn {
  padding: 10px 20px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.followup-tabs .tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.followup-tab-panel {
  display: none;
}
.followup-tab-panel.active {
  display: block;
}

.followup-desc {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

.followup-empty,
.followup-error {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 14px;
}
.followup-error {
  color: var(--danger);
}

/* 回执上传 */
.followup-upload-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}
.followup-file-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  background: #fff;
}
.followup-status {
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--success);
}
.followup-status--error {
  color: var(--danger);
}

.followup-msg {
  font-size: 13px;
  min-height: 20px;
}
.followup-msg--ok {
  color: var(--success);
}
.followup-msg--error {
  color: var(--danger);
}

.followup-receipt-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  margin-bottom: 12px;
}

.followup-receipt-table,
.followup-records-table {
  width: 100%;
  border-collapse: collapse;
}
.followup-receipt-table th,
.followup-receipt-table td,
.followup-records-table th,
.followup-records-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.followup-receipt-table th,
.followup-records-table th {
  background: var(--surface-soft);
  font-weight: 700;
  color: var(--muted);
  font-size: 12px;
}
.followup-receipt-table tbody tr:hover,
.followup-records-table tbody tr:hover {
  background: #f8fafc;
}
.followup-receipt-unmatched td {
  color: var(--danger);
  background: #fff5f5;
}
.followup-receipt-table-card {
  max-height: 480px;
  overflow-y: auto;
}

/* 在线标记 */
.followup-inline-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}
.followup-inline-head h2 {
  margin: 0;
}
.followup-inline-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}
.followup-inline-table {
  width: 100%;
  border-collapse: collapse;
}
.followup-inline-table th,
.followup-inline-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  white-space: nowrap;
}
.followup-inline-table th {
  background: var(--surface-soft);
  font-weight: 700;
  color: var(--muted);
  font-size: 12px;
  position: sticky;
  top: 0;
  z-index: 1;
}
.followup-inline-table tbody tr:hover {
  background: #f8fafc;
}
.followup-inline-date,
.followup-inline-result,
.followup-inline-note {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}
.followup-inline-date {
  width: 130px;
}
.followup-inline-result {
  width: 120px;
}
.followup-inline-note {
  width: 180px;
}
.followup-inline-date:focus,
.followup-inline-result:focus,
.followup-inline-note:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(23, 74, 124, 0.1);
}
.followup-inline-table-card {
  max-height: 560px;
  overflow-y: auto;
}

.followup-record-count {
  font-size: 13px;
  color: var(--muted);
}

.badge--sm {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
}
.badge-tier {
  background: var(--primary-soft);
  color: var(--primary);
}

/* =====================================================
   Dashboard — Role Views (Boss / Manager)
   ===================================================== */

.kpi-card.success-card strong {
  color: var(--success);
}

/* Manager 待办看板 */
.manager-task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.manager-task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  transition: background 0.15s;
}
.manager-task-item:hover {
  background: #f0f4f8;
}
.task-priority {
  font-weight: 700;
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  white-space: nowrap;
}
.task-name {
  flex: 1;
  font-weight: 600;
  color: var(--text);
}
.task-segment {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.task-overdue {
  font-size: 12px;
  color: var(--danger);
  white-space: nowrap;
}

/* ── 目标管理模块 ── */

.goals-main-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.goals-main-panel[hidden] {
  display: none !important;
}
.goals-unsaved-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 12px;
  font-weight: 600;
  vertical-align: middle;
}
.goals-save-dirty {
  box-shadow: 0 0 0 2px var(--warning-soft);
}
.goals-loading {
  padding: 12px 16px;
  margin-bottom: 12px;
  background: var(--primary-soft);
  border-radius: 8px;
  color: var(--primary);
  font-size: 14px;
}
.goals-monitor-hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.goals-month-bar {
  margin-bottom: 16px;
}
.goals-month-bar input[type="month"] {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  margin-left: 8px;
}

.goals-workshop, .goals-monitor {
  background: var(--surface);
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.goals-section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--primary);
}

.goals-segment {
  margin-bottom: 20px;
  padding: 16px;
  background: var(--surface-soft);
  border-radius: 8px;
  border: 1px solid var(--line);
}
.goals-segment h4 {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--text);
}

.goals-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 10px;
}
.goals-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
  flex: 1;
  min-width: 140px;
}
.goals-label input, .goals-label select {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
}
.goals-label input:focus, .goals-label select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}
.goals-label--wide {
  flex: 2;
}
.goals-label--readonly {
  background: #f0f2f5;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
}
.goals-derived {
  color: var(--primary);
  font-size: 15px;
}

.goals-baseline-row {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
}
.goals-baseline-card {
  flex: 1;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
  font: inherit;
  color: inherit;
}
.goals-baseline-card--active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}
.goals-baseline-card--static {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
  cursor: default;
}
.goals-baseline-values {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.goals-kpi-mini {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.goals-kpi-mini span {
  font-size: 11px;
  color: var(--muted);
}
.goals-kpi-mini strong {
  font-size: 14px;
  color: var(--text);
}
.goals-growth-summary {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--text);
}
.goals-baseline-label {
  display: block;
  color: var(--muted);
  margin-bottom: 4px;
  font-size: 12px;
}

.goals-delta {
  font-size: 14px;
  font-weight: 700;
  padding: 8px 12px;
  background: var(--primary-soft);
  border-radius: 6px;
  color: var(--primary);
  margin-bottom: 6px;
}

.goals-growth-source {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.goals-growth-chip {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--line);
}
.goals-growth-chip.positive {
  border-color: var(--success);
  color: var(--success);
  background: var(--success-soft);
}
.goals-growth-chip.negative {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-soft);
}

.goals-reality-hint {
  margin-top: 10px;
  padding: 8px 12px;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 6px;
  font-size: 13px;
  color: #92400e;
}

.goals-matrix-table {
  margin-top: 10px;
  overflow-x: auto;
}
.goals-matrix-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.goals-matrix-table th {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
}
.goals-matrix-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
}
.goals-matrix-table td input {
  width: 100%;
  max-width: 120px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 13px;
  text-align: right;
}
.goals-matrix-table td input:focus {
  outline: none;
  border-color: var(--primary);
}
.goals-matrix-table td.goals-td-derived {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}
.goals-matrix-table tfoot td {
  font-weight: 700;
  background: var(--surface-soft);
  border-top: 2px solid var(--primary);
}
.goals-total-error {
  color: var(--danger);
  font-weight: 700;
}

.goals-monitor-controls {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}
.goals-health-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
}
.goals-health-lead { background: #22c55e; }
.goals-health-normal { background: #3b82f6; }
.goals-health-lag { background: #f97316; }
.goals-health-severe { background: #ef4444; }

.goals-distribute-hint {
  color: var(--success);
  font-size: 12px;
  font-weight: 600;
}
.goals-distribute-row {
  align-items: center;
}
.goals-toast {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
}
.goals-toast--info {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid #b8d4f0;
}
.goals-toast--warn {
  background: #fff3cd;
  color: #92400e;
  border: 1px solid #f59e0b;
}
.goals-toast--error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #f5b5b0;
}
#goalsAutoDistributeBtn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.goals-empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 20px !important;
}
.goals-kpi-pill {
  flex: 1;
  min-width: 180px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.goals-kpi-pill span {
  font-size: 12px;
  color: var(--muted);
}
.goals-kpi-pill strong {
  font-size: 20px;
  color: var(--text);
}
.goals-kpi-pill small {
  font-size: 11px;
  color: var(--muted);
}
.goals-kpi-pill--severe { border-color: #ef4444; background: #fef2f2; }
.goals-kpi-pill--lag { border-color: #f97316; background: #fff7ed; }
.goals-kpi-pill--normal { border-color: #3b82f6; background: #eff6ff; }
.goals-kpi-pill--lead { border-color: #22c55e; background: #f0fdf4; }
#goalsMetricPills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.goals-monitor-metric {
  display: grid;
  grid-template-columns: 1fr 1fr 0.8fr;
  gap: 6px;
  font-size: 12px;
}
.goals-monitor-target { color: var(--muted); }
.goals-monitor-mtd { font-weight: 600; }
.goals-monitor-rate { color: var(--primary); font-weight: 600; text-align: right; }
.goals-monitor-row--severe td { background: #fef2f2; }
.goals-monitor-row--lag td { background: #fff7ed; }
.goals-monitor-row--overall td { background: var(--surface-soft); font-weight: 600; }
.goals-monitor-row--unassigned td { color: var(--warning); font-style: italic; }

/* =====================================================
   Roadmap polish: focus, mobile nav, dialogs, a11y
   ===================================================== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

.primary-btn:focus-visible,
.ghost-btn:focus-visible,
.tab-btn:focus-visible,
.filter-btn:focus-visible,
.text-btn:focus-visible,
.toggle-pill:focus-visible,
.visit-result-tab:focus-visible {
  outline: 2px solid #5b9fd4;
  outline-offset: 2px;
}

.followup-modal-dialog {
  border: none;
  padding: 0;
  margin: auto;
  background: transparent;
  max-width: min(520px, calc(100vw - 32px));
  width: calc(100% - 32px);
}
.followup-modal-dialog[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}
.followup-modal-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.mobile-more-dialog {
  border: none;
  padding: 0;
  margin: auto 0 0;
  width: 100%;
  max-width: none;
  background: transparent;
}
.mobile-more-dialog::backdrop {
  background: rgba(15, 23, 42, 0.4);
}
.mobile-more-sheet {
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 16px 16px 24px;
  border-top: 1px solid var(--line);
}
.mobile-more-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.mobile-more-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 14px 12px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  min-height: 48px;
}
.mobile-more-item:hover {
  background: var(--surface-soft);
}
.mobile-more-close {
  width: 100%;
  margin-top: 8px;
}

#bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  z-index: 100;
  justify-content: space-around;
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  font-size: 12px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 4px;
  border-radius: 8px;
}
.bottom-nav-item.active {
  color: var(--primary);
  font-weight: 600;
  background: var(--primary-soft);
}
.bottom-nav-item:focus-visible {
  outline: 2px solid #5b9fd4;
  outline-offset: 1px;
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  #bottom-nav {
    display: flex;
  }
  .app-shell {
    grid-template-columns: 1fr;
  }
  .main {
    padding: 12px;
    padding-bottom: 72px;
  }
  .table-card,
  .priority-table-card {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .kpi-card strong {
    font-size: 24px;
  }
  .priority-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
