:root {
  --primary: #2878e8;
  --primary-hover: #1768d6;
  --primary-soft: #eaf2ff;
  --bg: #f3f5f8;
  --workspace-bg: #f1f7fd;
  --card: #fff;
  --text: #273142;
  --muted: #7a8494;
  --border: #dfe4ec;
  --shadow: 0 1px 3px rgba(31, 50, 88, 0.07);
  --radius: 4px;
}

body {
  background: var(--workspace-bg);
  color: var(--text);
}

#appWrap.app {
  display: grid;
  grid-template-columns: 218px minmax(0, 1fr);
  grid-template-rows: 42px 36px minmax(0, 1fr);
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

#appWrap > .top {
  grid-column: 1 / -1;
  grid-row: 1;
  z-index: 45;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  margin: 0;
  padding: 0 16px 0 18px;
  background: #2878e8;
  border: 0;
  box-shadow: 0 1px 3px rgba(23, 75, 151, 0.22);
}

#appWrap > .top .global-page-title {
  display: none;
}

#appWrap > .top .global-brand {
  display: flex;
  align-items: center;
  min-width: 0;
  margin: 0;
  color: #fff;
}

#appWrap > .top .global-brand .logo,
#appWrap > .top .global-brand span {
  display: none;
}

#appWrap > .top .global-brand b {
  overflow: hidden;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#appWrap > .top .auth-bar {
  gap: 4px;
  color: rgba(255, 255, 255, 0.86);
}

#appWrap > .top .version-badge {
  margin-right: 3px;
  padding: 0 8px;
  color: rgba(255, 255, 255, 0.7);
  border: 0;
  font-weight: 400;
}

#appWrap > .top .bell-btn,
#appWrap > .top .workspace-help-btn,
#appWrap > .top .profile-trigger {
  min-height: 30px;
  color: rgba(255, 255, 255, 0.9);
  background: transparent;
  border: 0;
  box-shadow: none;
  font-weight: 400;
}

#appWrap > .top .bell-btn,
#appWrap > .top .workspace-help-btn {
  width: 34px;
  height: 30px;
  font-size: 16px;
}

#appWrap > .top .profile-trigger {
  gap: 7px;
  padding: 2px 7px;
}

#appWrap > .top .bell-btn:hover,
#appWrap > .top .workspace-help-btn:hover,
#appWrap > .top .profile-trigger:hover,
#appWrap > .top .bell-btn:focus-visible,
#appWrap > .top .workspace-help-btn:focus-visible,
#appWrap > .top .profile-trigger:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, 0.13);
}

#appWrap > .top .profile-avatar {
  width: 25px;
  height: 25px;
  color: #fff;
  background: rgba(255, 255, 255, 0.2);
  font-size: 12px;
  font-weight: 500;
}

#appWrap > .top .profile-menu {
  top: 36px;
  border-color: #e5e9f0;
  border-radius: 4px;
  box-shadow: 0 10px 28px rgba(31, 50, 88, 0.16);
}

#appWrap > .top .profile-menu button {
  color: #344054;
}

#appWrap > .top .profile-menu button:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

.workspace-tabs {
  grid-column: 1 / -1;
  grid-row: 2;
  z-index: 34;
  display: flex;
  align-items: stretch;
  height: 36px;
  min-width: 0;
  margin: 0;
  padding: 0 10px;
  overflow-x: auto;
  overflow-y: hidden;
  background: #f7f8fa;
  border-bottom: 1px solid #dce1e9;
  box-shadow: 0 1px 2px rgba(31, 50, 88, 0.04);
}

.workspace-menu-btn,
.workspace-home-btn {
  flex: 0 0 36px;
  width: 36px;
  height: 35px;
  min-height: 35px;
  padding: 0;
  color: #697386;
  background: transparent;
  border: 0;
  border-radius: 0;
  font-size: 17px;
  font-weight: 400;
}

.workspace-menu-btn {
  margin-right: 2px;
  border-right: 1px solid #e2e6ed;
}

.workspace-menu-btn:hover,
.workspace-home-btn:hover,
.workspace-home-btn.active {
  color: var(--primary);
  background: #edf3fd;
}

.workspace-tab {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 1 auto;
  min-width: 118px;
  max-width: 230px;
  height: 35px;
  padding: 0 5px 0 14px;
  color: #5f6978;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}

.workspace-tab::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  background: transparent;
  content: '';
}

.workspace-tab:hover {
  color: var(--primary);
  background: #f0f4fa;
}

.workspace-tab.active {
  color: var(--primary);
  background: #fff;
  font-weight: 500;
}

.workspace-tab.active::after {
  background: var(--primary);
}

.workspace-tab-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace-tab-close {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  min-height: 22px;
  margin-left: 3px;
  padding: 0;
  color: #a1a9b5;
  background: transparent;
  border: 0;
  border-radius: 2px;
  font-size: 17px;
  font-weight: 400;
  line-height: 22px;
}

.workspace-tab-close:hover {
  color: var(--primary);
  background: #e7eef9;
}

#appWrap > .side {
  grid-column: 1;
  grid-row: 3;
  position: relative;
  top: auto;
  width: 218px;
  height: auto;
  min-height: 0;
  padding: 10px 8px 16px;
  overflow: auto;
  color: #465266;
  background: #edf1f7;
  border-right: 1px solid #d9dfe9;
}

#appWrap > .side > .brand {
  display: none;
}

.side .navtitle {
  margin: 7px 10px 8px;
  color: #929baa;
  font-size: 12px;
  font-weight: 400;
}

.side .navgroup,
.side .navsubgroup,
.side .nav,
.side .navchild,
.side .navgrandchild {
  margin-bottom: 2px;
  border-radius: 3px;
  color: #1f2937;
  font-weight: 400;
}

.side .navgroup {
  min-height: 36px;
  padding: 8px 10px;
}

.side .navsubgroup {
  min-height: 32px;
  padding: 7px 10px 7px 22px;
  color: #344054;
}

.side .navchild {
  min-height: 32px;
  padding: 7px 10px 7px 30px;
}

.side .navgrandchild {
  min-height: 32px;
  padding: 7px 10px 7px 42px;
}

.side .navgroup:hover,
.side .navgroup.open,
.side .navsubgroup:hover,
.side .navsubgroup.open,
.side .nav:hover,
.side .navchild:hover,
.side .navgrandchild:hover {
  color: var(--primary);
  background: rgba(255, 255, 255, 0.58);
}

.side .nav.active,
.side .navchild.active,
.side .navgrandchild.active {
  position: relative;
  color: var(--primary);
  background: #fff;
  box-shadow: 0 1px 2px rgba(40, 76, 130, 0.06);
}

.side .nav.active::before,
.side .navchild.active::before,
.side .navgrandchild.active::before {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 0;
  width: 3px;
  background: var(--primary);
  content: '';
}

.side .caret {
  color: #929baa;
}

#appWrap > .main {
  grid-column: 2;
  grid-row: 3;
  min-width: 0;
  min-height: 0;
  padding: 12px 16px 14px;
  overflow: auto;
  background: var(--workspace-bg);
}

#appWrap.workspace-focus > .side,
#appWrap.workspace-nav-collapsed > .side {
  display: none;
}

#appWrap.workspace-focus > .main,
#appWrap.workspace-nav-collapsed > .main {
  grid-column: 1 / -1;
}

#appWrap.workspace-focus.workspace-nav-open > .side {
  display: block;
}

#appWrap.workspace-focus.workspace-nav-open > .main {
  grid-column: 2;
}

.section-title {
  min-height: 38px;
  margin: 0 0 10px;
}

.section-title h2 {
  color: #303a4b;
  font-size: 17px;
  font-weight: 600;
}

.card {
  border-color: var(--border);
  border-radius: 4px;
  box-shadow: var(--shadow);
}

button,
input,
select,
textarea {
  border-radius: 3px;
}

button {
  min-height: 32px;
  padding: 6px 12px;
  background: var(--primary);
  font-weight: 500;
}

button:hover,
button:focus-visible {
  background: var(--primary-hover);
}

.btn2 {
  color: var(--primary);
  background: #fff;
  border-color: #cbd6e7;
}

.btn2:hover,
.btn2:focus-visible,
.btn2:active {
  color: var(--primary-hover);
  background: var(--primary-soft);
  border-color: #8db4ec;
}

.btn3 {
  background: var(--primary);
}

input:focus,
select:focus,
textarea:focus {
  border-color: #70a5ef;
  box-shadow: 0 0 0 2px rgba(40, 120, 232, 0.1);
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  min-width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
  padding: 0;
  accent-color: var(--primary);
  box-shadow: none;
  vertical-align: middle;
}

.notice {
  color: #245ca8;
  background: #edf4ff;
  border-color: #bed4f3;
  border-radius: 3px;
}

table {
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  border-right: 1px solid #e3e7ed;
  border-bottom: 1px solid #e3e7ed;
}

th:first-child,
td:first-child {
  border-left: 1px solid #e3e7ed;
}

table thead th,
th.profit-group-head,
th.profit-category-head,
th.profit-metric-head {
  height: 36px;
  padding: 7px 9px;
  color: #172033 !important;
  background: #e6f1fc !important;
  border-color: #d4e1ef !important;
  font-weight: 600;
}

tbody tr:nth-child(even) td {
  background: #fafbfd;
}

tbody tr:hover td {
  background: #e8f1ff;
}

tbody tr:focus-within td {
  background: #dce9ff;
}

/* 财务利润分析使用三层复合表头：纵向冻结全部表头，横向只冻结前三列。 */
#profitDataTable {
  --profit-col-1-width: 56px;
  --profit-col-2-width: 96px;
  --profit-col-3-width: 180px;
}

#profitDataHead > tr:nth-child(1) > th {
  top: 0;
  z-index: 13;
}

#profitDataHead > tr:nth-child(2) > th {
  top: 36px;
  z-index: 12;
}

#profitDataHead > tr:nth-child(3) > th {
  top: 72px;
  z-index: 11;
}

#profitDataTable .profit-fixed-col {
  position: sticky;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#profitDataTable thead .profit-fixed-col {
  top: 0;
  z-index: 30;
  background: #e6f1fc !important;
}

#profitDataTable tbody .profit-fixed-col {
  z-index: 5;
  background: #fff;
}

#profitDataTable .profit-fixed-col-1 {
  left: 0;
  width: var(--profit-col-1-width);
  min-width: var(--profit-col-1-width);
  max-width: var(--profit-col-1-width);
}

#profitDataTable .profit-fixed-col-2 {
  left: var(--profit-col-1-width);
  width: var(--profit-col-2-width);
  min-width: var(--profit-col-2-width);
  max-width: var(--profit-col-2-width);
}

#profitDataTable .profit-fixed-col-3 {
  left: calc(var(--profit-col-1-width) + var(--profit-col-2-width));
  width: var(--profit-col-3-width);
  min-width: var(--profit-col-3-width);
  max-width: var(--profit-col-3-width);
  box-shadow: 2px 0 0 #bfd1e5;
}

#profitDataTable tbody tr:nth-child(even) .profit-fixed-col {
  background: #fafbfd;
}

#profitDataTable tbody tr:hover .profit-fixed-col {
  background: #e8f1ff;
}

#profitDataTable tbody tr:focus-within .profit-fixed-col {
  background: #dce9ff;
}

/* 财务利润核对使用两层复合表头，滚动区顶部不得保留会透出明细的卡片内边距。 */
#profit-analysis > .profit-matrix-wrap {
  position: relative;
  isolation: isolate;
  padding: 0 !important;
  background: #fff;
}

#profitMatrix {
  --profit-matrix-col-1-width: 140px;
  --profit-matrix-col-2-width: 150px;
  --profit-matrix-col-3-width: 190px;
}

#profitMatrixHead > tr:first-child > th {
  position: sticky;
  top: 0;
  z-index: 21;
  height: 36px;
  background: #e6f1fc !important;
}

#profitMatrixHead > tr:nth-child(2) > th {
  position: sticky;
  top: 36px;
  z-index: 20;
  height: 36px;
  background: #e6f1fc !important;
}

#profitMatrix .profit-matrix-fixed-col {
  position: sticky;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#profitMatrix thead .profit-matrix-fixed-col {
  top: 0;
  z-index: 30;
  background: #e6f1fc !important;
}

#profitMatrix tbody .profit-matrix-fixed-col {
  z-index: 5;
  background: #fff;
}

#profitMatrix .profit-matrix-fixed-col-1 {
  left: 0;
  width: var(--profit-matrix-col-1-width);
  min-width: var(--profit-matrix-col-1-width);
  max-width: var(--profit-matrix-col-1-width);
}

#profitMatrix .profit-matrix-fixed-col-2 {
  left: var(--profit-matrix-col-1-width);
  width: var(--profit-matrix-col-2-width);
  min-width: var(--profit-matrix-col-2-width);
  max-width: var(--profit-matrix-col-2-width);
}

#profitMatrix .profit-matrix-fixed-col-3 {
  left: calc(var(--profit-matrix-col-1-width) + var(--profit-matrix-col-2-width));
  width: var(--profit-matrix-col-3-width);
  min-width: var(--profit-matrix-col-3-width);
  max-width: var(--profit-matrix-col-3-width);
  box-shadow: 2px 0 0 #bfd1e5;
}

#profitMatrix tbody tr:nth-child(even) .profit-matrix-fixed-col {
  background: #fafbfd;
}

#profitMatrix tbody tr:hover .profit-matrix-fixed-col {
  background: #e8f1ff;
}

#profitMatrix tbody tr:focus-within .profit-matrix-fixed-col {
  background: #dce9ff;
}

.k3-data-page > .section-title {
  min-height: 38px;
  margin: 0 0 8px;
  padding: 3px 8px;
  background: transparent;
  border: 0;
  border-left: 3px solid var(--primary);
  box-shadow: none;
}

.k3-data-page > .section-title p {
  display: none;
}

.section-title p,
.workspace-help-source {
  display: none !important;
}

#shopify-payouts > .section-title > div:last-child,
#shopify-payouts > .section-title > .payout-actions {
  display: flex !important;
  align-items: center;
  justify-content: flex-end;
  flex: 1 1 auto;
  width: auto;
  margin-left: auto;
  gap: 8px !important;
  white-space: nowrap;
}

#shopify-payouts > .section-title > div:last-child #shopifyPayoutSyncStatus,
#shopify-payouts > .section-title > .payout-actions #shopifyPayoutSyncStatus {
  margin: 0 2px 0 auto;
}

.workspace-help-panel {
  color: #344054;
  font-size: 13px;
  line-height: 1.65;
}

.workspace-help-panel section {
  padding: 2px 0 14px;
  border-bottom: 1px solid #e7ebf1;
}

.workspace-help-panel section:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.workspace-help-panel h4 {
  margin: 10px 0 7px;
  color: #1f2937;
  font-size: 14px;
  font-weight: 600;
}

.workspace-help-panel p {
  margin: 0 0 6px;
  color: #596579;
}

.workspace-help-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.workspace-help-chip {
  display: inline-flex;
  max-width: 100%;
  padding: 3px 7px;
  overflow-wrap: anywhere;
  color: #245ca8;
  background: #edf4ff;
  border: 1px solid #d5e5fa;
  border-radius: 3px;
}

.workspace-help-empty {
  color: #8a94a3;
}

.log-error-reason {
  display: inline-block;
  max-width: 520px;
  margin-top: 4px;
  color: #b42318;
  white-space: normal;
}

.log-detail-modal {
  width: min(760px, calc(100vw - 32px));
}

.log-diagnosis {
  display: grid;
  gap: 10px;
  margin: 12px 0 14px;
  padding: 12px;
  color: #7a271a;
  background: #fff4ed;
  border: 1px solid #ffd6ae;
  border-radius: 4px;
}

.log-diagnosis label {
  color: #b42318;
}

.workbench-page > .card {
  padding: 10px 12px;
  border-radius: 4px;
  box-shadow: none;
}

/* 数据表滚动区必须与表头闭合，禁止明细从卡片顶部内边距透出。 */
.k3-data-page > .table-wrap {
  position: relative;
  isolation: isolate;
  padding: 0 !important;
  background: #fff;
}

.workbench-page > .card + .card {
  margin-top: 8px;
}

.workbench-page > .section-title + .card > .row5,
.workbench-page > .section-title + .card > .row6 {
  align-items: end;
  margin-bottom: 0;
  gap: 10px;
}

.workbench-page label {
  margin-bottom: 4px;
  color: #536075;
  font-size: 12px;
  font-weight: 500;
}

.workbench-page input,
.workbench-page select {
  height: 32px;
  padding: 5px 9px;
  font-size: 13px;
}

.workbench-page th,
.workbench-page td {
  height: 36px;
  padding: 7px 8px;
}

.workbench-page .empty {
  padding: 32px 20px;
  color: #8993a2;
  background: #fff;
  border: 0;
  border-radius: 0;
}

#appWrap.workspace-focus .k3-data-page.k3-has-pager.active {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 104px);
  min-height: 420px;
  overflow: hidden;
}

#appWrap.workspace-focus .k3-data-page.k3-has-pager > .table-wrap {
  flex: 1 1 auto;
  min-height: 150px;
  max-height: none;
  margin-bottom: 0;
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}

#appWrap.workspace-focus .k3-data-page.k3-has-pager > .k3-pager {
  position: sticky;
  bottom: 0;
  z-index: 20;
  flex: 0 0 auto;
  min-height: 44px;
  margin-top: 0;
  padding: 6px 10px;
  background: #fff;
  border-top: 1px solid #cfd6e1;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  box-shadow: 0 -2px 5px rgba(31, 50, 88, 0.05);
}

#fit-orders-multiplatform tbody td:nth-child(2),
#shopify-payouts tbody td:nth-child(3),
#shopify-payouts tbody td:nth-child(4) a {
  color: #155eef;
  font-weight: 600;
}

#shopify-payouts th:nth-child(13),
#shopify-payouts td.payout-message-cell,
#fit-order-import th:nth-child(10),
#fit-order-import td.fit-order-message-cell {
  width: 240px;
  min-width: 240px;
  max-width: 240px;
}

#shopify-payouts .payout-message-copy {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  color: #344054;
  background: transparent;
  border: 0;
  border-radius: 0;
  font: inherit;
  font-weight: 400;
  line-height: 20px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: copy;
}

#shopify-payouts .payout-message-copy:hover,
#shopify-payouts .payout-message-copy:focus-visible {
  color: #155eef;
  text-decoration: underline;
  outline: none;
}

#shopify-payouts .payout-message-empty {
  color: #98a2b3;
}

#fit-order-import .fit-order-message-copy {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  color: #344054;
  background: transparent;
  border: 0;
  border-radius: 0;
  font: inherit;
  font-weight: 400;
  line-height: 20px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: copy;
}

#fit-order-import .fit-order-message-copy:hover,
#fit-order-import .fit-order-message-copy:focus-visible {
  color: #155eef;
  text-decoration: underline;
  outline: none;
}

#fit-order-import .fit-order-message-empty {
  color: #98a2b3;
}

#shopify-payout-detail .payout-raw-type {
  min-width: 125px;
  color: #344054;
}

#shopify-payout-detail .payout-system-type {
  min-width: 180px;
  color: #172033;
  font-weight: 600;
}

#shopify-payout-mapping .spm-system-type {
  min-width: 220px;
  color: #344054;
  line-height: 1.5;
  white-space: normal;
}

.k3-status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  color: #475467;
  background: #eef1f5;
  border-radius: 2px;
}

.k3-status.success,
.k3-status.pushed {
  color: #087443;
  background: #e8f7ef;
}

.k3-status.warning,
.k3-status.pending {
  color: #925b00;
  background: #fff3d6;
}

.k3-status.failed,
.k3-status.error {
  color: #b42318;
  background: #fde8e7;
}

@media (max-width: 900px) {
  #appWrap.app {
    grid-template-columns: 196px minmax(0, 1fr);
  }

  #appWrap > .side {
    width: 196px;
  }

  .workbench-page > .section-title + .card > .row5,
  .workbench-page > .section-title + .card > .row6 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.settlement-code-link {
  display: inline;
  color: #1468d4;
  font: inherit;
  line-height: inherit;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}

.settlement-code-link:hover,
.settlement-code-link:focus-visible,
.settlement-code-link:active,
.settlement-code-link:visited {
  color: #0958d9;
  background: transparent;
}

.settlement-code-link:hover,
.settlement-code-link:focus-visible {
  text-decoration: underline;
}

.settlement-code-link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(20, 104, 212, 0.2);
}

@media (max-width: 600px) {
  #appWrap.app {
    grid-template-columns: 1fr;
  }

  #appWrap > .top {
    padding: 0 8px 0 12px;
  }

  #appWrap > .top .global-brand b {
    font-size: 14px;
  }

  #appWrap > .top .version-badge {
    display: none;
  }

  #appWrap > .side,
  #appWrap.workspace-focus > .side {
    display: none;
  }

  #appWrap.workspace-nav-open > .side,
  #appWrap.workspace-focus.workspace-nav-open > .side {
    position: absolute;
    top: 78px;
    bottom: 0;
    left: 0;
    z-index: 40;
    display: block;
    width: min(248px, 84vw);
    box-shadow: 8px 0 24px rgba(31, 50, 88, 0.15);
  }

  #appWrap > .main,
  #appWrap.workspace-focus.workspace-nav-open > .main {
    grid-column: 1;
    padding: 10px;
  }

  .workspace-tabs {
    padding: 0;
  }

  .workspace-tab {
    min-width: 112px;
  }

  .workbench-page > .section-title + .card > .row5,
  .workbench-page > .section-title + .card > .row6 {
    grid-template-columns: 1fr;
  }

  .workbench-page .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .workbench-page .section-title > div:last-child {
    width: 100%;
    margin-left: 0;
    justify-content: flex-end;
  }

  #appWrap.workspace-focus .k3-data-page.k3-has-pager.active {
    height: calc(100vh - 98px);
    min-height: 360px;
  }
}
