:root {
  --navy: #17365d;
  --navy-deep: #102945;
  --blue: #2f6fed;
  --blue-soft: #eaf2ff;
  --ink: #172033;
  --muted: #697386;
  --line: #e7ebf2;
  --canvas: #f4f6f9;
  --panel: #ffffff;
  --up: #d4380d;
  --down: #27864a;
  --warning: #d48806;
  --shadow: 0 9px 28px rgba(19, 45, 76, 0.08);
}

* { box-sizing: border-box; }

.report-version-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; padding: 10px 32px; background: var(--blue-soft); color: var(--navy); border-bottom: 1px solid var(--line); font-size: 14px; }
.version-summary { margin: 16px 0; }
.trace-number { appearance: none; border: 0; border-bottom: 1px dotted currentColor; padding: 0; background: transparent; color: inherit; font: inherit; text-align: inherit; cursor: pointer; max-width: 100%; }
.trace-number:hover { color: var(--blue); background: var(--blue-soft); }
.trace-number:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 2px; }
.trace-number .trend-badge { pointer-events: none; }
.quality-checks { margin: 18px 0; }
.quality-checks .ant-table { background: var(--panel); }
.trace-groups { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0; }
.trace-groups > div { display: flex; flex-direction: column; gap: 6px; flex: 1 1 220px; border: 1px solid var(--line); background: var(--canvas); border-radius: 8px; padding: 12px; font-size: 14px; }
.trace-groups strong { font-size: 20px; color: var(--navy); }
.trace-groups small { font-size: 14px; }
@media (max-width: 700px) { .report-version-bar { padding: 10px 14px; } .section-toolbar .ant-input-search { max-width: 100%; } }

html, body, #root { min-height: 100%; margin: 0; }

body {
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 14px;
}

.boot-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--navy);
}

.boot-screen strong, .boot-screen span { display: block; }
.boot-screen strong { font-size: 18px; }
.boot-screen span { color: var(--muted); margin-top: 3px; }

.boot-mark, .brand-mark {
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #2f6fed, #17365d);
  box-shadow: 0 7px 18px rgba(47, 111, 237, .28);
  font-weight: 800;
}

.boot-mark { width: 44px; height: 44px; border-radius: 13px; }

.app-shell { min-height: 100vh; }

.topbar {
  height: 68px;
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 28px;
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand { display: flex; align-items: center; min-width: 250px; gap: 12px; }
.brand-mark { width: 36px; height: 36px; border-radius: 11px; }
.brand strong { display: block; color: var(--navy-deep); font-size: 16px; line-height: 1.2; }
.brand small { display: block; color: #8a94a6; margin-top: 3px; font-size: 12px; }

.top-nav { display: flex; align-self: stretch; gap: 4px; }
.nav-button {
  position: relative;
  height: 100%;
  border: 0;
  padding: 0 17px;
  color: #586174;
  background: transparent;
  font-size: 14px;
  cursor: pointer;
}
.nav-button:hover { color: var(--blue); }
.nav-button:focus-visible,
.segment-tabs button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -3px;
}

.nav-button.active { color: var(--navy); font-weight: 600; }
.nav-button.active::after {
  content: "";
  position: absolute;
  left: 17px;
  right: 17px;
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--blue);
}

.top-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.db-indicator { color: #5e6b7c; font-size: 13px; white-space: nowrap; }
.db-indicator::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: #36a269;
  box-shadow: 0 0 0 3px rgba(54, 162, 105, .12);
}

.page { max-width: 1500px; margin: 0 auto; padding: 24px 28px 48px; }

.page-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.page-title h1 { margin: 0; color: var(--navy-deep); font-size: 25px; line-height: 1.25; letter-spacing: -.02em; }
.page-title p { margin: 7px 0 0; color: var(--muted); font-size: 14px; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  padding: 17px 18px;
  margin-bottom: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(20, 46, 80, .045);
}

.filter-item { min-width: 150px; }
.filter-item.wide { min-width: 190px; }
.filter-item label { display: block; margin-bottom: 7px; color: #737d8f; font-size: 12px; font-weight: 600; }
.filter-spacer { flex: 1; }
.filter-summary { align-self: center; color: #768196; font-size: 13px; white-space: nowrap; }

.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card {
  position: relative;
  overflow: hidden;
  min-height: 132px;
  padding: 19px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 4px 18px rgba(22, 49, 82, .045);
}
.metric-card.primary {
  color: #fff;
  background: linear-gradient(138deg, #17365d 0%, #245488 100%);
  border-color: transparent;
  box-shadow: 0 12px 28px rgba(23, 54, 93, .22);
}
.metric-card.primary::after {
  content: "";
  position: absolute;
  width: 150px;
  height: 150px;
  right: -62px;
  top: -78px;
  border-radius: 50%;
  border: 27px solid rgba(255, 255, 255, .07);
}
.metric-label { color: #7b8496; font-size: 13px; font-weight: 500; }
.primary .metric-label { color: rgba(255, 255, 255, .72); }
.metric-value { margin-top: 12px; font-size: 27px; line-height: 1.15; font-weight: 700; letter-spacing: -.02em; }
.metric-meta { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: #7b8496; font-size: 12px; }
.primary .metric-meta { color: rgba(255, 255, 255, .75); }
.metric-chip { padding: 2px 7px; border-radius: 99px; background: #f1f4f8; font-weight: 600; }
.primary .metric-chip { color: #fff; background: rgba(255, 255, 255, .13); }

.trend-up { color: var(--up) !important; }
.trend-down { color: var(--down) !important; }
.trend-flat { color: #7b8496 !important; }
.trend-badge { display: inline-flex; align-items: center; gap: 3px; font-weight: 650; white-space: nowrap; }
.trend-badge.small { font-size: 12px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, .72fr); gap: 18px; margin-bottom: 18px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 4px 18px rgba(22, 49, 82, .045);
}
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 19px 20px 13px; }
.panel-header h2 { margin: 0; color: var(--navy-deep); font-size: 16px; }
.panel-header p { margin: 5px 0 0; color: #8a94a6; font-size: 12px; }
.panel-body { padding: 4px 20px 20px; }

.bar-list { display: flex; flex-direction: column; gap: 15px; padding-top: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(80px, .8fr) minmax(150px, 2.3fr) 92px 76px; align-items: center; gap: 12px; }
.bar-label { display: flex; align-items: center; min-width: 0; font-weight: 600; }
.brand-dot { flex: none; width: 9px; height: 9px; margin-right: 8px; border-radius: 3px; }
.bar-label span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 12px; overflow: hidden; border-radius: 8px; background: #edf1f6; }
.bar-fill { height: 100%; min-width: 3px; border-radius: inherit; transition: width .35s ease; }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; }
.bar-share { text-align: right; color: #7b8496; font-variant-numeric: tabular-nums; }

.region-stack { display: flex; flex-direction: column; gap: 10px; padding-top: 5px; }
.region-row { padding: 11px 12px; border: 1px solid #edf0f4; border-radius: 10px; background: #fbfcfe; }
.region-top { display: flex; justify-content: space-between; gap: 12px; }
.region-name { color: #3f4857; font-weight: 600; }
.region-amount { font-weight: 650; font-variant-numeric: tabular-nums; }
.region-progress { display: flex; height: 6px; margin-top: 9px; overflow: hidden; border-radius: 8px; background: #eef1f5; }
.region-progress span { height: 100%; }
.region-meta { display: flex; justify-content: space-between; margin-top: 7px; color: #8a94a6; font-size: 12px; }

.table-panel { overflow: hidden; }
.table-toolbar { display: flex; gap: 8px; }
.table-panel .ant-table { border-top: 1px solid #f0f2f5; }
.table-panel .ant-table-thead > tr > th { background: #f8fafc; color: #5f6a7c; font-size: 12px; font-weight: 650; }
.table-panel .ant-table-tbody > tr > td { color: #374151; }
.rank-pill { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; color: #596477; background: #f0f3f7; font-size: 12px; font-weight: 700; }
.rank-pill.top { color: #fff; background: var(--navy); }
.sales-cell { font-weight: 650; font-variant-numeric: tabular-nums; }
.share-wrap { display: flex; align-items: center; gap: 9px; min-width: 130px; }
.share-line { flex: 1; height: 5px; border-radius: 9px; background: #edf1f5; overflow: hidden; }
.share-line > span { display: block; height: 100%; border-radius: inherit; background: #4f7edc; }
.share-wrap > b { width: 44px; text-align: right; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }

.content-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.section-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.section-toolbar h2 { margin: 0; color: var(--navy-deep); font-size: 17px; }
.section-toolbar p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.financial-subsection-toolbar { margin-top: 8px; border-top: 1px solid var(--line); background: #f8fbff; }
.financial-subsection-toolbar h3 { margin: 0; color: var(--navy-deep); font-size: 16px; }
.financial-quarter-details { margin-top: 8px; border-top: 1px solid var(--line); }
.financial-quarter-details > summary { padding: 16px 20px; color: var(--navy-deep); font-size: 16px; font-weight: 700; cursor: pointer; list-style-position: inside; background: #f8fbff; }
.financial-quarter-details[open] > summary { border-bottom: 1px solid var(--line); }
.financial-quarter-details .financial-subsection-toolbar { margin-top: 0; border-top: 0; }
.section-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.info-strip { display: flex; gap: 12px; align-items: flex-start; padding: 13px 15px; margin-bottom: 18px; border-radius: 10px; color: #234265; background: #eef5ff; border: 1px solid #dbeaff; }
.info-icon { flex: none; width: 23px; height: 23px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: #4b7ede; font-weight: 700; }
.info-strip strong { display: block; margin-bottom: 3px; }
.info-strip span { color: #60748e; font-size: 13px; }

.empty-pad { padding: 48px 20px; }
.history-total { color: var(--muted); font-size: 13px; }
.file-name { color: #26364b; font-weight: 600; }
.file-meta { display: block; color: #939cab; font-size: 12px; margin-top: 3px; }
.period-tag { color: #284e79; background: #edf4fc; border: 0; }

.product-name { font-weight: 600; color: #2f3948; }
.alias-text { display: block; max-width: 270px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #7c8798; }
.mapping-rate { color: #2c7650; font-weight: 650; }

.upload-shell { padding-top: 4px; }
.upload-drop {
  display: block;
  padding: 27px 20px;
  text-align: center;
  border: 1px dashed #aab9ce;
  border-radius: 12px;
  background: #f8fbff;
  cursor: pointer;
  transition: .2s ease;
}
.upload-drop:hover { border-color: var(--blue); background: #f2f7ff; }
.upload-symbol { display: grid; place-items: center; width: 44px; height: 44px; margin: 0 auto 11px; border-radius: 12px; color: var(--blue); background: #e7f0ff; font-size: 24px; font-weight: 400; }
.upload-drop strong { display: block; color: #2e3a4c; font-size: 15px; }
.upload-drop small { display: block; margin-top: 6px; color: #818b9b; }
.selected-file { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 13px; margin-top: 10px; border-radius: 10px; background: #f2f7ff; }
.selected-file b { color: #315a8c; }

.mapping-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; margin: 16px 0; }
.mapping-field label { display: block; margin-bottom: 6px; color: #6f798b; font-size: 12px; font-weight: 600; }
.step-note { padding: 11px 13px; margin: 14px 0; border-radius: 9px; color: #72520a; background: #fff9e8; border: 1px solid #f7e6ae; font-size: 13px; }
.step-good { color: #226542; background: #effaf4; border-color: #ccebd9; }
.preview-title { display: flex; align-items: center; justify-content: space-between; margin: 16px 0 8px; }
.preview-title strong { color: #344054; }
.preview-title span { color: #8993a4; font-size: 12px; }
.unmatched-list { max-height: 300px; overflow: auto; margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; }
.unmatched-row { display: grid; grid-template-columns: minmax(130px, 1fr) minmax(180px, 1.4fr); gap: 12px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.unmatched-row:last-child { border-bottom: 0; }
.raw-product b { display: block; color: #394456; }
.raw-product small { display: block; margin-top: 3px; color: #8a94a6; }

.import-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 16px 0; }
.summary-box { padding: 12px; border-radius: 10px; background: #f6f8fb; }
.summary-box span { display: block; color: #7b8597; font-size: 12px; }
.summary-box b { display: block; margin-top: 7px; color: #26364a; font-size: 17px; }
.trend-period-filter { min-width: 280px; flex: 2; }
.trend-table-card { overflow: hidden; }
.source-archive-card { margin-top: 24px; }
.financial-page .ant-alert { margin-bottom: 16px; }
.financial-card { margin-top: 18px; }
.financial-filter { margin-top: 18px; }
.financial-chart-wrap { padding: 12px 20px 20px; overflow-x: auto; }
.financial-chart { display: block; min-width: 760px; width: 100%; height: auto; color: #7b8496; font-size: 12px; }
.financial-chart text { fill: currentColor; font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif; }
.financial-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 20px; padding: 2px 10px 0; color: var(--muted); font-size: 12px; }
.financial-legend span { display: inline-flex; align-items: center; gap: 7px; }
.financial-legend i { display: inline-block; width: 18px; height: 3px; border-radius: 3px; }
.financial-trace-json { overflow: auto; max-height: 250px; padding: 14px; color: #26364b; background: #f6f8fb; border: 1px solid var(--line); border-radius: 9px; font-family: Consolas, monospace; font-size: 12px; }
.trend-unit { color: var(--muted); font-size: 12px; margin-left: 5px; }
.multi-year-table .ant-table-thead > tr > th { background: var(--navy); color: white; font-weight: 600; }
.multi-year-table .ant-table-tbody > tr.trend-group-start > td { border-top: 2px solid #c8d7e9; }
.multi-year-table .ant-table-tbody > tr.trend-share-row > td { background: #eef5ff; font-weight: 600; }
.multi-year-table .ant-table-cell { font-variant-numeric: tabular-nums; white-space: nowrap; }
.top-nav { flex-shrink: 0; }
@media (max-width: 1250px) { .topbar { gap: 12px; padding: 0 16px; } .brand { min-width: 200px; } .nav-button { padding: 0 10px; } .db-indicator { display: none; } }

.ant-btn-primary { background: var(--blue); border-color: var(--blue); }
.ant-btn-primary:hover, .ant-btn-primary:focus { background: #215fd8; border-color: #215fd8; }
.ant-modal-content { border-radius: 14px; overflow: hidden; }
.ant-modal-header { padding: 19px 24px; border-bottom-color: var(--line); }
.ant-modal-title { color: var(--navy-deep); font-weight: 700; }
.ant-steps { margin-bottom: 22px; }
.ant-select-selector, .ant-picker, .ant-input, .ant-input-number { border-radius: 7px !important; }
.ant-table-pagination.ant-pagination { margin-right: 16px; }

.privacy-note { display: flex; align-items: center; gap: 7px; color: #7b8595; font-size: 12px; }
.privacy-note::before { content: "✓"; display: grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; color: #2b8a56; background: #e9f6ef; font-size: 11px; font-weight: 700; }

.matrix-page { max-width: 1840px; }
.compact-title { margin-bottom: 14px; }
.segment-tabs {
  display: flex;
  gap: 3px;
  width: fit-content;
  padding: 4px;
  margin-bottom: 14px;
  border-radius: 9px;
  background: #e9edf3;
}
.segment-tabs button {
  min-width: 92px;
  padding: 8px 16px;
  border: 0;
  border-radius: 7px;
  color: #566174;
  background: transparent;
  font-weight: 650;
  cursor: pointer;
}
.segment-tabs button.active { color: #fff; background: #002060; box-shadow: 0 4px 10px rgba(0, 32, 96, .2); }
.matrix-filters { margin-bottom: 12px; padding: 13px 16px; border-radius: 10px; box-shadow: none; }

.matrix-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid #dce3ed;
  border-radius: 10px;
  background: #fff;
}
.matrix-summary > div { min-height: 82px; padding: 13px 17px; border-right: 1px solid #e3e8ef; }
.matrix-summary > div:last-child { border-right: 0; }
.matrix-summary span:first-child { display: block; color: #738096; font-size: 12px; }
.matrix-summary b { display: block; margin-top: 6px; color: #002060; font-size: 19px; line-height: 1.2; }
.matrix-summary b small { font-size: 11px; font-weight: 600; }
/* nav-icons/summary-align patch: keep number+trend bottom-aligned across tiles even when the label wraps to two lines */
.matrix-summary > div { display: flex; flex-direction: column; }
.matrix-summary span:first-child { line-height: 1.4; }
.matrix-summary b { margin-top: auto; }

.matrix-summary .trend-badge, .matrix-summary em { display: block; margin-top: 6px; font-size: 12px; font-style: normal; }
.matrix-summary em { color: #7d8798; }

.matrix-report {
  overflow: hidden;
  border: 1px solid #cfd7e3;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 6px 20px rgba(22, 45, 78, .06);
}
.matrix-report-title {
  padding: 14px 18px 7px;
  color: #173b72;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.02em;
}
.matrix-segment-band {
  min-height: 29px;
  margin: 0 18px;
  padding: 5px 12px;
  color: #fff;
  background: #002060;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  font-size: 15px;
}
.matrix-period-line { margin: 0 18px; padding: 5px 12px 7px; color: #263449; border-bottom: 1px solid #6e7b8e; font-size: 12px; font-weight: 650; }
.matrix-scroll { display: flex; gap: 16px; overflow-x: auto; padding: 18px; scrollbar-color: #aab5c5 #edf0f4; }
.matrix-region {
  flex: 0 0 286px;
  min-height: 432px;
  display: flex;
  flex-direction: column;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  font-size: 12px;
}
.matrix-region-title { display: flex; align-items: center; justify-content: space-between; min-height: 29px; padding: 5px 8px; color: #fff; background: #002060; }
.matrix-region-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matrix-region-title span { color: #dce9ff; }
.matrix-columns, .matrix-row {
  display: grid;
  grid-template-columns: 29px minmax(88px, 1fr) 58px 48px 62px;
  align-items: center;
  column-gap: 4px;
}
.matrix-columns { min-height: 28px; padding: 4px 5px; color: #263449; border-bottom: 1px solid #b7c0cd; font-weight: 650; }
.matrix-columns span:nth-child(n+3), .matrix-row > span:nth-child(n+3) { text-align: right; }
.matrix-row { min-height: 25px; padding: 3px 5px; color: #202733; border-bottom: 1px solid #e3e7ec; }
.matrix-row > span:nth-child(1) { color: #7a8495; text-align: center; }
.matrix-row > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matrix-row .trend-badge { justify-content: flex-end; font-size: 11px; }
.matrix-row.focus { background: #dcebf7; }
.matrix-row.focus > span:nth-child(2) { color: #0a4775; font-weight: 700; }
.matrix-spacer { flex: 1; min-height: 18px; border-bottom: 1px solid #d4dbe5; }
.matrix-others { margin-top: 5px; border-top: 1px solid #b7c0cd; }
.matrix-total { min-height: 29px; margin-top: 5px; border-top: 1px solid #6c7788; border-bottom: 0; font-weight: 750; }
.matrix-footnote { margin: 10px 3px 0; color: #747f91; font-size: 12px; }
.focus-swatch { display: inline-block; width: 20px; height: 10px; margin-right: 6px; border: 1px solid #c4dced; background: #dcebf7; vertical-align: -1px; }

@media (max-width: 1050px) {
  .topbar { gap: 14px; padding: 0 18px; }
  .brand { min-width: 210px; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .db-indicator { display: none; }
  .matrix-summary { grid-template-columns: repeat(2, 1fr); }
  .matrix-summary > div:nth-child(2) { border-right: 0; }
  .matrix-summary > div:nth-child(-n+2) { border-bottom: 1px solid #e3e8ef; }
}

@media (max-width: 760px) {
  .topbar { height: auto; min-height: 62px; flex-wrap: wrap; padding: 10px 14px 0; }
  .brand { min-width: 0; flex: 1; }
  .brand small { display: none; }
  .top-actions { order: 2; }
  .top-actions .ant-btn-default { display: none; }
  .top-nav { order: 3; width: 100%; height: 44px; overflow-x: auto; }
  .nav-button { flex: 1; min-width: 84px; padding: 0 10px; }
  .nav-button.active::after { left: 10px; right: 10px; }
  .page { padding: 18px 14px 36px; }
  .page-title-row { flex-direction: column; gap: 12px; }
  .filter-bar { align-items: stretch; }
  .filter-item, .filter-item.wide { flex: 1 1 44%; min-width: 135px; }
  .filter-spacer, .filter-summary { display: none; }
  .metrics-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 115px; }
  .bar-row { grid-template-columns: 92px minmax(100px, 1fr) 78px; }
  .bar-share { display: none; }
  .section-toolbar { align-items: flex-start; flex-direction: column; }
  .section-actions { justify-content: flex-start; }
  .mapping-grid { grid-template-columns: 1fr; }
  .import-summary { grid-template-columns: repeat(2, 1fr); }
  .unmatched-row { grid-template-columns: 1fr; }
  .segment-tabs { width: 100%; overflow-x: auto; }
  .segment-tabs button { min-width: 90px; }
  .matrix-summary { grid-template-columns: 1fr; }
  .matrix-summary > div { min-height: 72px; border-right: 0; border-bottom: 1px solid #e3e8ef; }
  .matrix-summary > div:last-child { border-bottom: 0; }
  .matrix-report-title { font-size: 18px; }
  .matrix-scroll { padding: 12px; }
  .matrix-region { flex-basis: 280px; }
}

@media print {
  .topbar, .filter-bar, .top-actions, .section-actions, .table-toolbar, .report-version-bar { display: none !important; }
  body { background: #fff; }
  .page { max-width: none; padding: 0; }
  .panel, .metric-card, .content-card { box-shadow: none; break-inside: avoid; }
  .matrix-report { box-shadow: none; }
  .matrix-scroll { overflow: visible; flex-wrap: wrap; }
  .matrix-region { flex-basis: calc(33.333% - 12px); min-width: 280px; }
}
/* Ant Design workspace shell */
.workspace-layout { min-height: 100vh; background: var(--canvas); }
.workspace-sider { position: sticky !important; top: 0; height: 100vh; overflow: hidden; border-right: 1px solid var(--line); }
.workspace-sider.ant-layout-sider-light { background: var(--panel); }
.workspace-sider .ant-layout-sider-children { height: 100%; }
.workspace-navigation { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; min-height: 76px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.sidebar-brand > div:last-child { min-width: 0; }
.sidebar-brand .ant-typography { display: block; margin: 0; }
.sidebar-brand .ant-typography-secondary { margin-top: 3px; font-size: 12px; }
.sidebar-menu { flex: 1; overflow-y: auto; padding: 12px 10px; border-right: 0 !important; }
.sidebar-menu .ant-menu-item-group-title { padding: 16px 14px 7px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; }
.sidebar-menu .ant-menu-item { width: 100%; height: 42px; margin: 2px 0 !important; border-radius: 8px; line-height: 42px; }
.sidebar-menu .ant-menu-item::after { display: none; }
.sidebar-menu .ant-menu-item-selected { color: var(--blue); background: var(--blue-soft) !important; font-weight: 650; }
.sidebar-menu .ant-menu-item a { color: inherit; }
.sidebar-account { display: flex; flex-direction: column; gap: 7px; padding: 16px 20px 20px; border-top: 1px solid var(--line); }
.sidebar-account > .ant-typography { display: block; margin: 0; }
.sidebar-section-title { font-size: 11px; font-weight: 700; letter-spacing: .08em; }
.theme-setting { justify-content: space-between; width: 100%; padding: 7px 0 5px; }
.workspace-main-layout { min-width: 0; background: var(--canvas); }
.workspace-header { position: sticky; top: 0; z-index: 18; display: flex; align-items: center; gap: 16px; height: 64px; padding: 0 28px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.workspace-page-label { min-width: 0; line-height: 1.25; }
.workspace-page-label .ant-typography { margin: 0 !important; }
.workspace-page-label > .ant-typography:first-child { font-size: 11px; }
.workspace-header .db-indicator { margin-left: auto; }
.workspace-header .db-indicator::before { display: none; }
.workspace-content { min-width: 0; background: var(--canvas); }
.mobile-nav-trigger { display: none; }
.workspace-drawer .ant-drawer-body { display: flex; min-height: 0; }
.workspace-drawer .workspace-navigation { width: 100%; }
.cloud-alert { position: fixed; top: 12px; right: 20px; z-index: 1100; width: min(520px, calc(100vw - 40px)); padding: 0; background: transparent; }

/* Dark mode: shared tokens plus Ant Design 4 component surfaces. */
html.theme-dark {
  color-scheme: dark;
  --navy: #9fc2ff;
  --navy-deep: #eef4ff;
  --blue: #6d9eff;
  --blue-soft: #172d4d;
  --ink: #e7edf5;
  --muted: #a8b4c4;
  --line: #334155;
  --canvas: #0f1720;
  --panel: #182330;
  --shadow: 0 9px 28px rgba(0,0,0,.22);
}
html.theme-dark body,
html.theme-dark .workspace-layout,
html.theme-dark .workspace-main-layout,
html.theme-dark .workspace-content { color: var(--ink); background: var(--canvas); }
html.theme-dark .workspace-header { background: rgba(24,35,48,.96); }
html.theme-dark .workspace-sider.ant-layout-sider-light,
html.theme-dark .ant-drawer-content,
html.theme-dark .ant-drawer-header,
html.theme-dark .ant-menu-light { color: var(--ink); background: var(--panel); }
html.theme-dark .ant-drawer-title,
html.theme-dark .ant-drawer-close,
html.theme-dark .ant-menu,
html.theme-dark .ant-menu-item a,
html.theme-dark .ant-typography,
html.theme-dark .ant-form-item-label > label,
html.theme-dark .ant-checkbox-wrapper,
html.theme-dark .ant-radio-wrapper { color: var(--ink); }
html.theme-dark .ant-typography-secondary,
html.theme-dark .ant-empty-description,
html.theme-dark .ant-badge-status-text { color: var(--muted); }
html.theme-dark .ant-card,
html.theme-dark .ant-modal-content,
html.theme-dark .ant-modal-header,
html.theme-dark .ant-table,
html.theme-dark .ant-table-container,
html.theme-dark .ant-table-thead > tr > th,
html.theme-dark .ant-table-tbody > tr > td,
html.theme-dark .ant-collapse,
html.theme-dark .ant-collapse-content,
html.theme-dark .filter-bar,
html.theme-dark .metric-card,
html.theme-dark .chart-card,
html.theme-dark .table-card,
html.theme-dark .summary-box,
html.theme-dark .source-card,
html.theme-dark .import-card,
html.theme-dark .mapping-card,
html.theme-dark .matrix-summary,
html.theme-dark .matrix-report { color: var(--ink); background: var(--panel); border-color: var(--line); }
html.theme-dark .ant-table-tbody > tr.ant-table-row:hover > td { background: #213044; }
html.theme-dark .ant-input,
html.theme-dark .ant-input-affix-wrapper,
html.theme-dark .ant-input-number,
html.theme-dark .ant-select:not(.ant-select-customize-input) .ant-select-selector,
html.theme-dark .ant-picker,
html.theme-dark .ant-dropdown-menu {
  color: var(--ink);
  background: #111c28;
  border-color: #415169;
}
html.theme-dark .ant-input::placeholder,
html.theme-dark .ant-select-selection-placeholder { color: #77869a; }
html.theme-dark .ant-select-arrow,
html.theme-dark .ant-picker-suffix,
html.theme-dark .ant-input-password-icon { color: var(--muted); }
html.theme-dark .ant-select-dropdown,
html.theme-dark .ant-dropdown-menu,
html.theme-dark .ant-popover-inner,
html.theme-dark .ant-tooltip-inner { color: var(--ink); background: #1b2938; }
html.theme-dark .ant-select-item,
html.theme-dark .ant-dropdown-menu-item { color: var(--ink); }
html.theme-dark .ant-select-item-option-active:not(.ant-select-item-option-disabled),
html.theme-dark .ant-dropdown-menu-item:hover { background: #26384c; }
html.theme-dark .ant-select-item-option-selected:not(.ant-select-item-option-disabled) { background: var(--blue-soft); }
html.theme-dark .ant-btn-default { color: var(--ink); background: #1b2938; border-color: #415169; }
html.theme-dark .ant-btn-default:hover,
html.theme-dark .ant-btn-default:focus { color: #8eb4ff; border-color: #6d9eff; }
html.theme-dark .ant-modal-close,
html.theme-dark .ant-modal-title { color: var(--ink); }
html.theme-dark .ant-modal-header,
html.theme-dark .ant-drawer-header { border-color: var(--line); }
html.theme-dark .cloud-login { background: linear-gradient(135deg,#0f1720,#142131); }
html.theme-dark .cloud-login-card { color: var(--ink); background: var(--panel); border-color: var(--line); box-shadow: 0 20px 70px rgba(0,0,0,.35); }
html.theme-dark .cloud-login h1 { color: var(--navy-deep); }
html.theme-dark .cloud-login p,
html.theme-dark .cloud-login-note { color: var(--muted); }

@media (max-width: 900px) {
  .workspace-sider { display: none; }
  .mobile-nav-trigger { display: inline-flex; }
  .workspace-header { height: 62px; padding: 0 14px; }
  .workspace-header .db-indicator { display: none; }
  .workspace-page-label { flex: 1; }
  .workspace-page-label .ant-typography { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
.auth-pending { min-height: 100vh; display: grid; place-items: center; background: var(--canvas); }
.workspace-header-actions { margin-left: auto; min-width: 0; }
.workspace-header-actions > .ant-btn { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html.theme-dark .auth-pending { background: var(--canvas); }
@media (max-width: 600px) {
  .workspace-header-actions { margin-left: 0; }
  .workspace-header-actions > .ant-btn { max-width: 132px; }
}
.brand-mark.ant-avatar { flex: 0 0 auto; color: #fff; background: #24527f; border-radius: 8px; box-shadow: none; font-size: 15px; }
.workspace-sider.ant-layout-sider-collapsed .sidebar-brand { justify-content: center; padding-inline: 12px; }
.workspace-sider .ant-layout-sider-trigger { color: var(--muted); background: var(--panel); border-top: 1px solid var(--line); }
.workspace-switcher { padding: 20px 32px 0; }
.workspace-switcher .ant-segmented { padding: 3px; background: #e9eef5; }
.workspace-switcher .ant-segmented-item { min-width: 112px; text-align: center; }
html.theme-dark .brand-mark.ant-avatar { background: #3f6f9e; }
html.theme-dark .workspace-sider .ant-layout-sider-trigger { color: var(--ink); background: var(--panel); }
html.theme-dark .workspace-switcher .ant-segmented { background: #243244; }
@media (max-width: 900px) {
  .workspace-switcher { padding: 14px 14px 0; overflow-x: auto; }
  .workspace-switcher .ant-segmented { min-width: max-content; }
}
/* brand-jitter patch: 侧边栏展开时 Sider 宽度是动画过渡的，品牌文字会先按窄宽度折行
   把品牌区顶高、菜单被推下去，动画结束再弹回 —— 表现为“向下抖一下”。
   钉死高度 + 禁止折行，展开过程中就不会有任何高度变化。 */
.sidebar-brand { height: 76px; min-height: 76px; overflow: hidden; flex: 0 0 76px; }
.sidebar-brand > div:last-child { min-width: 0; overflow: hidden; }
.sidebar-brand .ant-typography { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.workspace-navigation { overflow: hidden; }

/* table-overflow patch: .content-card 是 overflow:hidden，表格若没设 scroll 就会被直接裁掉，
   而不是变成可横向滚动；同时表格首尾列紧贴卡片边缘，文字看起来贴边。 */
.ant-table-wrapper { max-width: 100%; }
.ant-table-content, .ant-table-body { overflow-x: auto; }
.content-card .ant-table-cell:first-child { padding-left: 20px; }
.content-card .ant-table-cell:last-child { padding-right: 20px; }
.ant-table-cell { word-break: break-word; }
/* 宽内容块统一可滚动，避免撑破布局 */
.financial-trace-json, .matrix-scroll, .financial-chart-wrap { max-width: 100%; }

.app-loading { display: flex; align-items: center; justify-content: center; min-height: 55vh; }
