:root {
  --navy: #102a4c;
  --navy-2: #1b426d;
  --gold: #c79a3b;
  --green: #21865a;
  --red: #c54848;
  --amber: #a96c16;
  --ink: #17202b;
  --muted: #667085;
  --line: #e3e7ec;
  --canvas: #f4f6f8;
  --surface: #fff;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font: 14px/1.45 "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  letter-spacing: 0;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow: hidden;
  display: flex; flex-direction: column; color: #fff; background: var(--navy);
}
.brand { height: 70px; padding: 0 18px; display: flex; align-items: center; gap: 11px; border-bottom: 1px solid #ffffff1f; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border: 2px solid var(--gold); color: var(--gold); font-weight: 700; }
.brand strong { display: block; font-size: 18px; }
.brand small, .identity small { display: block; margin-top: 2px; color: #ffffff8c; font-size: 11px; }
nav { padding: 14px 10px; display: grid; gap: 5px; }
.nav-item {
  height: 44px; padding: 0 13px; border: 0; border-radius: 6px;
  display: flex; align-items: center; gap: 11px; text-align: left;
  color: #ffffffb8; background: transparent;
}
.nav-item:hover { color: #fff; background: #ffffff10; }
.nav-item.active { color: #fff; background: #c79a3b2d; box-shadow: inset 3px 0 var(--gold); }
.nav-icon { width: 20px; text-align: center; font-size: 18px; }
.identity { margin-top: auto; padding: 14px; border-top: 1px solid #ffffff1f; display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--gold); color: var(--navy); font-weight: 700; }
main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 10; height: 70px; padding: 0 26px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: #fff; border-bottom: 1px solid var(--line);
}
h1, h2, p { margin: 0; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
.topbar p, .panel-heading p { margin-top: 3px; color: var(--muted); font-size: 12px; }
.top-actions, .toolbar-actions, .filters, .kpi-head-row { display: flex; align-items: center; gap: 8px; }
.save-status { color: var(--green); font-size: 12px; }
.view { display: none; padding: 22px 26px 36px; }
.view.active { display: block; }
.button, .icon-button {
  min-height: 36px; border: 1px solid var(--line); border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink); background: #fff; font-weight: 600;
}
.button { padding: 0 13px; }
.button.primary { color: #fff; border-color: var(--navy); background: var(--navy); }
.button.danger { color: var(--red); border-color: #ecc1c1; }
.button.small { min-height: 30px; padding: 0 9px; font-size: 12px; }
.icon-button { width: 36px; padding: 0; font-size: 24px; }
.button:hover, .icon-button:hover { filter: brightness(.97); }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.metric {
  min-height: 105px; padding: 16px; border: 1px solid var(--line);
  border-radius: 6px; background: #fff; box-shadow: 0 1px 3px #102a4c0a;
}
.metric-label { color: var(--muted); }
.metric-value { margin-top: 10px; font-size: 27px; font-weight: 700; }
.metric-note { margin-top: 5px; color: var(--muted); font-size: 12px; }
.metric-note.good { color: var(--green); }
.metric-note.bad { color: var(--red); }
.dashboard-scope {
  margin-bottom: 14px; padding: 13px 16px; border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: #fff;
}
.dashboard-scope strong { font-size: 16px; }
.dashboard-scope p { margin-top: 3px; color: var(--muted); font-size: 12px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 14px; }
.attention-list, .dashboard-summary { display: grid; }
.attention-row, .summary-row {
  min-height: 62px; padding: 10px 16px; border-bottom: 1px solid #edf0f2;
  display: grid; align-items: center; gap: 10px;
}
.attention-row { grid-template-columns: 82px minmax(0, 1fr) auto; }
.attention-row:last-child, .summary-row:last-child { border-bottom: 0; }
.attention-main strong, .summary-row strong { display: block; }
.attention-main span, .summary-row span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.summary-row { grid-template-columns: minmax(0, 1fr) auto; }
.summary-value { color: var(--navy); font-size: 18px; font-weight: 700; text-align: right; }
.empty.compact { padding: 30px 16px; }
.toolbar { margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.filters { flex-wrap: wrap; }
.input, .select, textarea {
  height: 37px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px;
  color: var(--ink); background: #fff; outline: none;
}
.input:focus, .select:focus, textarea:focus { border-color: var(--navy-2); box-shadow: 0 0 0 3px #1b426d12; }
.search { width: 250px; }
.month-input { width: 150px; }
.check-filter { height: 37px; padding: 0 10px; display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.stage-strip { margin-bottom: 12px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.stage-card {
  padding: 11px 13px; border: 1px solid var(--line); border-radius: 6px;
  display: flex; justify-content: space-between; background: #fff;
}
.stage-card strong { font-size: 18px; }
.stage-card span { color: var(--muted); }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: 6px; background: #fff; box-shadow: 0 1px 3px #102a4c0a; }
.panel-heading { min-height: 58px; padding: 10px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-divider { height: 1px; margin: 18px 0; background: var(--line); }
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 920px; border-collapse: collapse; }
th { height: 42px; padding: 0 13px; color: var(--muted); background: #fafbfc; border-bottom: 1px solid var(--line); text-align: left; font-size: 12px; }
td { height: 58px; padding: 7px 13px; border-bottom: 1px solid #edf0f2; vertical-align: middle; }
tbody tr:hover { background: #fbfcfd; }
.cell-main { font-weight: 600; }
.cell-sub { margin-top: 2px; color: var(--muted); font-size: 12px; }
.amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.tag, .status-tag {
  display: inline-flex; align-items: center; height: 24px; padding: 0 8px;
  border-radius: 12px; color: var(--navy-2); background: #edf2f7; font-size: 12px; white-space: nowrap;
}
.tag.green, .status-tag.good { color: var(--green); background: #e8f5ee; }
.tag.red { color: var(--red); background: #faecec; }
.tag.amber, .status-tag.warning { color: var(--amber); background: #fff3dc; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.link-button { padding: 0; border: 0; color: var(--navy-2); background: transparent; font-weight: 600; }
.danger-text { color: var(--red); }
.priority { display: inline-flex; min-width: 30px; justify-content: center; color: var(--amber); font-weight: 700; }
.priority.high { color: var(--red); }
.priority.low { color: var(--green); }
.focus-mark { color: var(--gold); font-weight: 700; }
.task-result { max-width: 260px; color: var(--muted); white-space: normal; }
.visit-summary { display: grid; gap: 3px; }
.visit-summary strong { color: var(--ink); font-size: 12px; }
.visit-flags { display: flex; flex-wrap: wrap; gap: 4px; }
.visit-fields {
  grid-column: 1 / -1; padding: 14px; border: 1px solid var(--line);
  border-radius: 6px; display: grid; grid-template-columns: 1fr 1fr;
  gap: 13px; background: #fafbfc;
}
.visit-fields[hidden] { display: none; }
.visit-fields h3 { grid-column: 1 / -1; margin: 0; font-size: 14px; }
.visit-fields .full { grid-column: 1 / -1; }
.visit-completion-fields {
  grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 13px;
}
.visit-completion-fields[hidden] { display: none; }
.visit-completion-fields h3, .visit-completion-fields .full { grid-column: 1 / -1; }
.check-row {
  min-height: 37px; padding: 0 10px; border: 1px solid var(--line);
  border-radius: 6px; display: flex !important; align-items: center; gap: 7px;
  color: var(--ink) !important; background: #fff;
}
.empty { padding: 50px 20px; color: var(--muted); text-align: center; }
.kpi-head-row { margin-bottom: 14px; justify-content: space-between; flex-wrap: wrap; }
.segmented { padding: 3px; display: inline-flex; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.segmented button { height: 32px; padding: 0 14px; border: 0; border-radius: 4px; color: var(--muted); background: transparent; }
.segmented button.active { color: #fff; background: var(--navy); }
.kpi-panel input { width: 90px; }
.kpi-table th, .kpi-table td { text-align: center; }
.kpi-table th:first-child, .kpi-table td:first-child { text-align: left; }
.score { font-size: 16px; font-weight: 700; color: var(--navy); }
.score.high { color: var(--green); }
.score.low { color: var(--red); }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.settings-card { overflow: hidden; }
.staff-card { grid-column: 1 / -1; }
.staff-table { min-width: 760px; }
.staff-table input { width: 100%; min-width: 120px; }
.manager-report-table { min-width: 1080px; }
.manager-report-table td { height: 78px; vertical-align: top; }
.ai-comment { max-width: 310px; white-space: pre-line; color: var(--ink); line-height: 1.5; }
.form-stack { padding: 16px; display: grid; gap: 12px; }
.form-stack label, .form-grid label { display: grid; gap: 6px; color: #475467; font-size: 12px; font-weight: 600; }
.form-stack .input { width: 100%; }
.switch-row { min-height: 36px; display: flex !important; align-items: center; gap: 8px; }
.login-form { padding: 0; }
.login-form .notice { margin: 0; }
.notice { margin: 0 16px 16px; padding: 12px; color: #6d4c0c; background: #fff6e5; border-left: 3px solid var(--gold); font-size: 12px; }
.data-actions { padding: 16px; display: flex; gap: 8px; flex-wrap: wrap; }
.file-button input { display: none; }
.system-info { padding: 0 16px 16px; color: var(--muted); line-height: 1.8; }
.system-info code { padding: 2px 5px; border-radius: 4px; background: #eef2f6; color: var(--navy); font-size: 12px; word-break: break-all; }
.wecom-checklist { padding: 0 16px 12px; display: grid; gap: 8px; }
.wecom-checklist .rule-item { display: grid; grid-template-columns: 70px 1fr; gap: 10px; align-items: center; background: #fffaf0; border-color: #f0d7a5; }
.wecom-checklist .rule-item.ok { background: #f3fbf6; border-color: #cfe9db; }
.wecom-checklist .rule-item strong { color: var(--amber); font-size: 12px; }
.wecom-checklist .rule-item.ok strong { color: var(--green); }
.wecom-checklist .rule-item p { margin: 0; color: var(--ink); font-size: 12px; }
.audit-filters { padding: 12px 16px; display: flex; gap: 8px; border-bottom: 1px solid var(--line); }
.audit-filters .input { width: 220px; }
.audit-table { min-width: 900px; }
.audit-table td { height: 48px; font-size: 12px; }
.audit-detail { max-width: 260px; color: var(--muted); white-space: normal; }
.profit-grid { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.profit-insights { margin-bottom: 14px; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.insight-card { min-height: 92px; padding: 12px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.insight-card.green { border-color: #cfe9db; background: #f3fbf6; }
.insight-card.amber { border-color: #f1d9a6; background: #fff8e9; }
.insight-card.red { border-color: #f2c7c7; background: #fff3f3; }
.insight-title { color: var(--muted); font-size: 12px; }
.insight-value { margin-top: 6px; color: var(--navy); font-size: 20px; font-weight: 800; line-height: 1.1; }
.insight-note { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.profit-table { min-width: 1120px; }
.customer-table { min-width: 780px; }
.order-table { min-width: 880px; }
.profit-detail-table { min-width: 760px; }
.cost-center-table { min-width: 760px; }
.project-table { min-width: 1050px; }
.project-table td { height: 66px; }
.modal-layer { position: fixed; inset: 0; z-index: 40; padding: 20px; display: grid; place-items: center; background: #0c192a75; }
.modal-layer[hidden] { display: none; }
.modal { width: min(720px, 100%); max-height: calc(100vh - 40px); overflow: auto; border-radius: 7px; background: #fff; box-shadow: 0 24px 70px #0003; }
.modal-header, .modal-footer { min-height: 62px; padding: 11px 18px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal-header { border-bottom: 1px solid var(--line); }
.modal-header p { margin-top: 3px; color: var(--muted); font-size: 12px; }
.modal-footer { border-top: 1px solid var(--line); justify-content: flex-end; }
.modal-body { padding: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.form-grid > [hidden] { display: none !important; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .input, .form-grid .select, .form-grid textarea { width: 100%; }
.form-grid textarea { height: 75px; padding-top: 9px; resize: vertical; }
.history { margin-top: 18px; }
.history h3 { margin: 0 0 9px; font-size: 14px; }
.history-item { padding: 10px 12px; border-left: 3px solid var(--navy-2); background: #f7f9fb; margin-bottom: 8px; }
.history-item p { margin-top: 3px; color: var(--muted); font-size: 12px; }
.rule-list { display: grid; gap: 10px; }
.rule-item { padding: 11px; border: 1px solid var(--line); border-radius: 5px; }
.source-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.source-grid .rule-item { min-width: 0; }
.source-history { max-height: 210px; overflow: auto; }
.locked-input { color: var(--muted); background: #f4f5f6; cursor: not-allowed; }
.value-note { color: var(--muted); font-size: 12px; }
.value-progress-panel { margin-bottom: 14px; }
.value-progress-list { padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 7px; }
.value-progress-list .tag { height: 28px; }
.value-status-note { margin: 12px 0 0; padding: 10px 12px; border-left: 3px solid var(--amber); background: #fff8e9; }
.value-history { margin-top: 14px; }
.value-form { display: grid; gap: 16px; }
.score-section { padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: #fafbfc; }
.score-section-title { margin-bottom: 12px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.score-section-title span { color: var(--muted); font-size: 12px; }
.value-score-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.value-form label { display: grid; gap: 6px; color: #475467; font-size: 12px; font-weight: 600; }
.value-form textarea { width: 100%; height: 82px; margin-top: 12px; padding-top: 9px; resize: vertical; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 60; display: none; padding: 11px 14px; border-radius: 6px; color: #fff; background: var(--green); box-shadow: 0 12px 30px #0002; }
.toast.show { display: block; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 76px minmax(0, 1fr); }
  .brand { justify-content: center; padding: 0; }
  .brand > div:last-child, .nav-item span:last-child, .identity div { display: none; }
  .nav-item { justify-content: center; padding: 0; }
  .identity { justify-content: center; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .settings-grid { grid-template-columns: 1fr; }
  .profit-grid { grid-template-columns: 1fr; }
  .profit-insights { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .value-score-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; inset: auto 0 0; z-index: 30; width: auto; height: 64px; }
  .brand, .identity { display: none; }
  nav { height: 64px; padding: 5px; grid-template-columns: repeat(8, 1fr); }
  .nav-item { height: 52px; display: grid; place-items: center; gap: 0; }
  .nav-item span:last-child { display: block; font-size: 10px; }
  .nav-item.active { box-shadow: inset 0 -3px var(--gold); }
  .nav-icon { line-height: 18px; }
  .topbar { height: 66px; padding: 0 14px; }
  .topbar p, .save-status { display: none; }
  #account-action { min-width: 54px; padding: 0 9px; }
  .view { padding: 14px 12px 84px; }
  .metrics { grid-template-columns: 1fr 1fr; gap: 8px; }
  .profit-insights { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { min-height: 93px; padding: 12px; }
  .metric-value { font-size: 22px; }
  .stage-strip { grid-template-columns: 1fr 1fr; }
  .search { width: 100%; }
  .filters { width: 100%; }
  .filters .select { flex: 1; min-width: 120px; }
  .toolbar-actions { margin-left: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .visit-fields { grid-template-columns: 1fr; }
  .visit-fields h3, .visit-fields .full { grid-column: auto; }
  .visit-completion-fields { grid-column: auto; grid-template-columns: 1fr; }
  .visit-completion-fields h3, .visit-completion-fields .full { grid-column: auto; }
  .value-note { width: 100%; }
  .score-section-title { display: grid; }
  .value-score-grid { grid-template-columns: 1fr 1fr; }
  .audit-filters { flex-wrap: wrap; }
  .audit-filters .input, .audit-filters .select { width: 100%; }
  .source-grid { grid-template-columns: 1fr; }
  .dashboard-scope { align-items: flex-start; }
  .attention-row { grid-template-columns: 70px minmax(0, 1fr); }
  .attention-row .button { grid-column: 1 / -1; width: 100%; }
}
