:root {
  --bg: #f5f7f6;
  --surface: #ffffff;
  --ink: #17211d;
  --muted: #64716b;
  --line: #dce4df;
  --accent: #16715f;
  --accent-dark: #0f5146;
  --red: #bd3b3b;
  --amber: #996316;
  --blue: #285f9f;
  --shadow: 0 16px 38px rgba(23, 33, 29, 0.07);
}

* { box-sizing: border-box; }

html,
body {
  height: 100%;
  overflow: hidden;
}

.hidden { display: none !important; }

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

button, input, select { font: inherit; }
button { cursor: pointer; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef4f1;
}

.login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 26px;
  display: grid;
  gap: 14px;
}

.login-card img {
  width: 82px;
  height: 82px;
  object-fit: contain;
  justify-self: center;
}

.login-card h1 {
  margin: 0;
  text-align: center;
  font-size: 24px;
}

.login-card label,
.user-form label {
  color: var(--muted);
  font-size: 13px;
  display: grid;
  gap: 6px;
}

.login-card input,
.user-form input {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
  color: var(--ink);
}

.app-shell {
  --theme-primary: #16715f;
  --theme-primary-dark: #0f5146;
  --theme-soft: #e3f2ed;
  --theme-sidebar: #f3faf7;
  --theme-sidebar-line: #cfe2da;
  --theme-nav-text: #2d463d;
  --theme-brand-surface: #dcefe8;
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-columns: 184px minmax(0, 1fr);
}

.app-shell.theme-youdaji {
  --accent: #cf6508;
  --accent-dark: #8d4000;
  --theme-primary: #cf6508;
  --theme-primary-dark: #8d4000;
  --theme-soft: #fff0dc;
  --theme-sidebar: #30363a;
  --theme-sidebar-line: #454c50;
  --theme-nav-text: #eef1ef;
  --theme-brand-surface: #454b4f;
}

.app-shell.theme-tianhuan {
  --accent: #2463a7;
  --accent-dark: #153f70;
  --theme-primary: #2463a7;
  --theme-primary-dark: #153f70;
  --theme-soft: #e4effa;
  --theme-sidebar: #edf4fb;
  --theme-sidebar-line: #c7d9eb;
  --theme-nav-text: #27445f;
  --theme-brand-surface: #d9e8f6;
}

.sidebar {
  background: var(--theme-sidebar);
  border-right: 1px solid var(--theme-sidebar-line);
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 8px 14px;
  margin-bottom: 10px;
  border-radius: 8px;
  background: var(--theme-brand-surface);
}

.brand img {
  width: 46px;
  height: 46px;
  object-fit: contain;
}

.brand strong { display: block; font-size: 17px; }
.brand span { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; font-weight: 700; }

.theme-youdaji .brand strong { color: #ffffff; }
.theme-youdaji .brand span { color: #ffd6a8; }

.nav { display: grid; gap: 6px; }

.nav-item {
  border: 0;
  background: transparent;
  color: var(--theme-nav-text);
  text-align: left;
  padding: 11px 10px 11px 14px;
  border-radius: 8px;
  position: relative;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.nav-item.active,
.nav-item:hover {
  background: var(--theme-soft);
  color: var(--theme-primary-dark);
  font-weight: 700;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--theme-primary);
}

.theme-youdaji .nav-item:not(.active):hover {
  background: #454c50;
  color: #ffffff;
}

.workspace {
  padding: 24px;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  background: #f5f8f6;
  transition: background-color 0.2s ease;
}

.workspace::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.theme-youdaji .workspace {
  background: #f7f5f2;
}

.theme-tianhuan .workspace {
  background: #f4f7fa;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 3px solid var(--theme-primary);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 28px; color: var(--theme-primary-dark); }
h2 { margin-bottom: 0; font-size: 17px; }

.page-title-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.module-help-button {
  display: inline-grid;
  place-items: center;
  width: 25px;
  height: 25px;
  padding: 0;
  border: 2px solid var(--theme-primary);
  border-radius: 50%;
  background: color-mix(in srgb, var(--theme-primary) 10%, #fff);
  color: var(--theme-primary-dark);
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.module-help-button:hover {
  background: var(--theme-primary);
  color: #fff;
}

.top-actions,
.filters,
.import-actions,
.settings-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.inventory-actions {
  flex-wrap: nowrap;
  justify-content: flex-start;
  margin-left: 0;
}

.inventory-panel-head {
  justify-content: flex-start;
  gap: 28px;
}

.inventory-actions .secondary-button,
.inventory-actions .file-button {
  min-height: 36px;
  padding: 0 12px;
  white-space: nowrap;
}

.inventory-actions .search-input {
  width: 210px;
  flex: 0 0 210px;
}

.finance-kpis .kpi strong {
  font-size: 22px;
}

.kpi-grid.finance-kpis {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.kpi-grid.finance-kpis.youdaji-finance-kpis {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px 10px;
  overflow: visible;
  padding-bottom: 0;
}

.finance-kpis .kpi {
  min-width: 0;
  padding: 9px 11px;
  min-height: 82px;
}

.finance-kpis .kpi strong {
  font-size: 21px;
  line-height: 1.15;
  margin-top: 5px;
  white-space: nowrap;
}

.finance-kpis .kpi small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.25;
}

#finance-table tr,
#finance-table td,
#finance-table input {
  font-weight: 700;
}

.danger-text {
  color: var(--red);
  font-weight: 800;
}

.user-chip {
  color: var(--muted);
  font-size: 13px;
  padding: 0 4px;
}

.platform-switcher {
  --platform-color: var(--accent);
  --platform-soft: #e3f2ed;
  color: var(--platform-color);
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 5px 8px 5px 6px;
  border: 2px solid color-mix(in srgb, var(--platform-color) 38%, #ffffff);
  border-radius: 8px;
  background: var(--platform-soft);
}

.platform-youdaji {
  --platform-color: #d96a00;
  --platform-soft: #fff1df;
}

.platform-tianhuan {
  --platform-color: #2463a7;
  --platform-soft: #e4effa;
}

.platform-badge {
  min-width: 56px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  background: var(--platform-color);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
}

.platform-switcher select {
  border: 0;
  border-radius: 7px;
  min-height: 36px;
  padding: 0 30px 0 11px;
  background: #fff;
  color: var(--platform-color);
  font-size: 17px;
  font-weight: 800;
  outline: none;
}

.primary-button,
.secondary-button,
.danger-button,
.file-button {
  border: 0;
  border-radius: 8px;
  min-height: 39px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

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

.secondary-button {
  background: #e8eeeb;
  color: #26332e;
}

.record-button {
  border: 1px solid transparent;
  transition: filter 0.15s ease, box-shadow 0.15s ease;
}

.record-button:hover {
  filter: brightness(0.96);
}

.record-button.expanded {
  filter: saturate(1.18) brightness(0.93);
  box-shadow: inset 0 0 0 2px currentColor;
}

.record-sales {
  background: #dbeafe;
  color: #1d4ed8;
}

.record-replenishment {
  background: #dcfce7;
  color: #15803d;
}

.record-orders {
  background: #ffedd5;
  color: #c2410c;
}

.record-app-stock {
  background: #fce7f3;
  color: #be185d;
}

.record-inventory {
  background: #ede9fe;
  color: #6d28d9;
}

.record-finance {
  background: #fef3c7;
  color: #a16207;
}

.record-pricing {
  background: #e0f2fe;
  color: #0369a1;
}

.record-archive {
  background: #ede9fe;
  color: #6d28d9;
}

.product-archive-import-button {
  background: #dcfce7;
  color: #15803d;
}

.product-archive-export-button {
  background: #dbeafe;
  color: #1d4ed8;
}

.pricing-sync-button {
  background: #dcfce7;
  color: #137a45;
  border-color: #86d8ad;
}

.pricing-parameter-button {
  background: #fff2c7;
  color: #8a5700;
  border-color: #e8c765;
}

.product-pricing-export-button {
  background: #dff4ff;
  color: #075f83;
  border-color: #8fcde6;
}

.pricing-parameter-dialog {
  width: min(620px, calc(100vw - 32px));
}

.pricing-parameter-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 22px;
}

.pricing-parameter-form label {
  display: grid;
  gap: 7px;
  color: #41534c;
  font-size: 14px;
  font-weight: 700;
}

.pricing-parameter-form input {
  width: 100%;
}

.pricing-parameter-actions {
  display: flex;
  grid-column: 1 / -1;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.record-export {
  background: #cffafe;
  color: #0e7490;
}

.embedded-record-panel {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
}

.embedded-record-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}

.embedded-record-head h2 {
  margin: 0;
}

a.secondary-button {
  text-decoration: none;
}

.danger-button {
  background: #f8e5e5;
  color: var(--red);
}

.table-action {
  min-height: 30px;
  padding: 0 11px;
}

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

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

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button-sales {
  background: #d9ecff;
  color: #165a96;
}

.file-button-replenishment {
  background: #ffe08a;
  color: #6f4a00;
}

.file-button-inventory {
  background: #e9ddff;
  color: #5b21b6;
}

.restore-button {
  background: #dcfce7;
  color: #166534;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.view { display: none; }
.view.active { display: block; }

#settings-view {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding-right: 8px;
}

#settings-view::-webkit-scrollbar {
  width: 18px;
}

#settings-view::-webkit-scrollbar-track {
  background: #e7eeeb;
}

#settings-view::-webkit-scrollbar-thumb {
  min-height: 90px;
  border: 2px solid #e7eeeb;
  border-radius: 10px;
  background: #6f7a74;
}

#settings-view::-webkit-scrollbar-thumb:hover {
  background: #4f5a54;
}

#finance-view.active {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

#finance-view > .finance-kpis {
  flex: 0 0 auto;
}

#finance-view > .panel {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  margin-bottom: 0;
}

.finance-main-panel {
  padding: 12px 14px 14px;
}

.finance-main-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.finance-main-head > div:first-child {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.finance-main-head > div:first-child h2 {
  flex: 0 0 auto;
  white-space: nowrap;
}

.finance-main-head #finance-hint {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finance-main-head .import-actions {
  flex-wrap: nowrap;
  gap: 8px;
}

.finance-main-head .secondary-button,
.finance-main-head .file-button {
  min-height: 38px;
  padding: 0 12px;
  white-space: nowrap;
}

.finance-main-head .month-picker {
  flex-wrap: nowrap;
  white-space: nowrap;
}

#finance-bill-result.muted {
  display: none;
}

.finance-daily-table-wrap {
  flex: 1 1 auto;
  min-height: 120px;
  max-height: none;
  overflow-x: auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.finance-daily-table-wrap::-webkit-scrollbar { width: 18px; height: 18px; }
.finance-daily-table-wrap::-webkit-scrollbar-track { background: #e7eeeb; }
.finance-daily-table-wrap::-webkit-scrollbar-thumb {
  min-width: 90px;
  min-height: 90px;
  border: 2px solid #e7eeeb;
  border-radius: 10px;
  background: #6f7a74;
}
.finance-daily-table-wrap::-webkit-scrollbar-thumb:hover { background: #4f5a54; }

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

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 17px;
  box-shadow: var(--shadow);
  min-width: 0;
  overflow: hidden;
}

.kpi span { color: var(--muted); font-size: 13px; }
.kpi strong {
  display: block;
  max-width: 100%;
  margin-top: 10px;
  overflow: hidden;
  color: #06110d;
  font-size: clamp(22px, 2.2vw, 31px);
  line-height: 1.16;
  letter-spacing: -0.05em;
  white-space: nowrap;
  text-overflow: clip;
}
.kpi small { color: var(--muted); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
  min-width: 0;
  margin-bottom: 14px;
}

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

.youdaji-stock-panel-head {
  flex-direction: row;
  align-items: center;
}

.youdaji-stock-description {
  min-width: 0;
  flex: 1 1 auto;
}

.youdaji-stock-description .hint {
  white-space: normal;
  overflow-wrap: anywhere;
}

.youdaji-stock-panel-head .import-actions {
  flex: 0 0 auto;
  flex-wrap: nowrap;
}

.youdaji-stock-panel-head .primary-button,
.youdaji-stock-panel-head .secondary-button {
  white-space: nowrap;
}

.month-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.month-picker input {
  min-height: 36px;
  width: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #f8faf9;
}

.order-date-picker {
  min-height: 39px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.order-date-picker input {
  width: 138px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  display: block;
  margin-top: 5px;
}

.import-result {
  border: 1px dashed #cbd6d1;
  background: #f8faf9;
  border-radius: 8px;
  padding: 12px;
}

.import-result.success {
  border-color: #b7ddcd;
  background: #edf8f3;
  color: #146246;
}

.import-result.error {
  border-color: #efbebe;
  background: #fff0f0;
  color: var(--red);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

/* Keep expanded import/collection records inside their own scroll area. */
.embedded-record-panel .table-wrap,
section[id$="-record-panel"] > .table-wrap {
  max-height: clamp(220px, 42vh, 420px);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

/* The combined inventory record list should leave more room for the ledger grid. */
#ledger-inventory-record-panel > .table-wrap {
  max-height: clamp(120px, 21vh, 210px);
}

.table-wrap.tall { max-height: calc(100vh - 320px); }

.pricing-table-wrap {
  height: calc(100vh - 218px);
  min-height: 220px;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  border: 0;
  border-radius: 0;
  scrollbar-gutter: stable;
}

.pricing-scroll-shell {
  display: grid;
  grid-template-rows: minmax(0, 1fr) 26px;
  border: 1px solid #cfd8d3;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.pricing-bottom-scroll {
  grid-row: 2;
  border-top: 1px solid #cfd8d3;
  border-bottom: 0;
}

.pricing-table {
  min-width: 1320px;
}

.product-archive-panel {
  min-height: 0;
}

.product-archive-panel > .panel-head {
  flex-wrap: nowrap;
}

.product-archive-panel > .panel-head > div:first-child {
  flex: 0 0 auto;
}

.product-archive-title {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

.product-archive-count {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: #e8f3ee;
  color: var(--theme-primary-dark);
  font-size: 15px;
  font-weight: 750;
}

.archive-unit-filters {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid #cbdad4;
  border-radius: 10px;
  background: #f1f5f3;
}

.archive-unit-filters button {
  min-width: 42px;
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #56665f;
  font-weight: 800;
}

.archive-unit-filters button:hover {
  background: #e0ebe6;
  color: var(--theme-primary-dark);
}

.archive-unit-filters button.active {
  background: var(--theme-primary);
  color: #fff;
  box-shadow: 0 2px 7px color-mix(in srgb, var(--theme-primary) 24%, transparent);
}

.product-archive-panel > .panel-head .import-actions {
  flex: 1 1 auto;
  flex-wrap: nowrap;
  justify-content: flex-end;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.product-archive-panel > .panel-head .import-actions > * {
  flex: 0 0 auto;
  white-space: nowrap;
}

.product-archive-panel > .panel-head .search-clear-wrap {
  flex-basis: 250px;
}

.product-archive-table-wrap {
  min-height: 220px;
  max-height: none;
  overflow: auto;
  scrollbar-gutter: stable;
}

.product-archive-table {
  min-width: 1460px;
  table-layout: fixed;
}

.product-archive-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
}

.product-archive-table th:nth-child(1) { width: 260px; }
.product-archive-table th:nth-child(2) { width: 180px; }
.product-archive-table th:nth-child(3),
.product-archive-table th:nth-child(4) { width: 130px; }
.product-archive-table th:nth-child(6),
.product-archive-table th:nth-child(7),
.product-archive-table th:nth-child(5),
.product-archive-table th:nth-child(8),
.product-archive-table th:nth-child(11) { width: 105px; }
.product-archive-table th:nth-child(9) { width: 76px; }
.product-archive-table th:nth-child(10) { width: 90px; }
.product-archive-table th:nth-child(12) { width: 82px; }

.master-data-readonly {
  display: inline-block;
  max-width: 100%;
  color: #263c34;
  font-weight: 650;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.master-data-readonly.number {
  white-space: nowrap;
}

.product-archive-table .archive-input {
  width: 100%;
  min-width: 0;
}

.product-archive-table .archive-input-wrap {
  position: relative;
  width: 100%;
}

.product-archive-table .archive-input-wrap .archive-input {
  padding-right: 25px;
}

.product-archive-table .archive-input-suffix {
  position: absolute;
  top: 50%;
  right: 8px;
  color: #52665e;
  font-weight: 650;
  pointer-events: none;
  transform: translateY(-50%);
}

.product-archive-table .archive-rate-input {
  appearance: textfield;
  -moz-appearance: textfield;
}

.product-archive-table .archive-rate-input::-webkit-inner-spin-button,
.product-archive-table .archive-rate-input::-webkit-outer-spin-button {
  appearance: none;
  margin: 0;
}

.product-archive-table .archive-name-input {
  font-weight: 650;
}

.product-archive-table .archive-profit {
  color: var(--theme-primary-dark);
  font-weight: 750;
  white-space: nowrap;
}

.product-archive-table .archive-box-row td {
  background: #f7fbf9;
}

.product-archive-table .archive-other-row td {
  background: #fff;
}

.product-archive-form {
  grid-template-columns: minmax(220px, 1.6fr) minmax(150px, 1fr) repeat(2, minmax(120px, .8fr)) repeat(3, 100px) 80px 80px 100px auto;
}

.product-archive-new-panel {
  background: #f8fbff;
}

.pricing-table th {
  white-space: nowrap;
}

.pricing-table th:nth-child(1),
.pricing-table td:nth-child(1) { min-width: 260px; width: 260px; }
.pricing-table th:nth-child(2),
.pricing-table td:nth-child(2) { min-width: 120px; width: 120px; }
.pricing-table th:nth-child(3),
.pricing-table td:nth-child(3) { min-width: 110px; width: 110px; }

.pricing-name {
  font-weight: 650;
  line-height: 1.35;
}

.pricing-sku {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pricing-profit {
  color: #087353;
  font-weight: 800;
  white-space: nowrap;
}

.pricing-profit.negative { color: #c62828; }

.pricing-price-result {
  color: var(--theme-primary-dark);
  font-weight: 800;
  white-space: nowrap;
}

.pricing-price-button {
  min-width: 96px;
  padding: 7px 10px;
  border: 1px solid color-mix(in srgb, var(--theme-primary) 40%, #ffffff);
  border-radius: 7px;
  background: var(--theme-soft);
  color: var(--theme-primary-dark);
  font-weight: 800;
  white-space: nowrap;
}

.pricing-price-button:hover {
  border-color: var(--theme-primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--theme-primary) 14%, transparent);
}

.search-clear-wrap {
  position: relative;
  display: inline-flex;
  min-width: 0;
}

.search-clear-wrap .search-input {
  width: 100%;
  padding-right: 34px;
}

.search-clear-button {
  position: absolute;
  right: 7px;
  top: 50%;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #e4ebe8;
  color: #46544e;
  font-size: 18px;
  line-height: 20px;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%);
}

.search-clear-button.has-value { background: #cfdad5; color: #17211d; }

.search-clear-button:hover { background: #cfdad5; color: #17211d; }

.pricing-simulator-dialog {
  --sim-primary: #16715f;
  --sim-primary-dark: #0f5146;
  --sim-soft: #e3f2ed;
  width: min(560px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(15, 30, 24, 0.28);
}

.pricing-simulator-dialog[data-platform="youdaji"] {
  --sim-primary: #cf6508;
  --sim-primary-dark: #8d4000;
  --sim-soft: #fff0dc;
}

.pricing-simulator-dialog::backdrop { background: rgba(18, 28, 24, 0.46); }

.module-help-dialog {
  --theme-primary: #16715f;
  --theme-primary-dark: #0f5146;
  width: min(780px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(15, 30, 24, 0.3);
}

.module-help-dialog[data-platform="youdaji"] {
  --theme-primary: #cf6508;
  --theme-primary-dark: #8d4000;
}

.module-help-dialog::backdrop { background: rgba(18, 28, 24, 0.5); }

.module-help-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 19px 22px 15px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--theme-primary) 7%, #fff);
}

.module-help-head h2 { margin-top: 4px; font-size: 23px; color: var(--theme-primary-dark); }

.module-help-platform {
  color: var(--theme-primary);
  font-size: 13px;
  font-weight: 800;
}

.module-help-body {
  max-height: calc(100vh - 210px);
  padding: 18px 22px 6px;
  overflow-y: auto;
}

.module-help-summary {
  margin: 0 0 15px;
  padding: 12px 14px;
  border-left: 4px solid var(--theme-primary);
  border-radius: 7px;
  background: color-mix(in srgb, var(--theme-primary) 6%, #fff);
  line-height: 1.6;
}

.module-help-section { margin-bottom: 18px; }
.module-help-section h3 { margin: 0 0 8px; font-size: 16px; color: var(--theme-primary-dark); }
.module-help-section ul { margin: 0; padding-left: 22px; }
.module-help-section li { margin: 5px 0; line-height: 1.55; }

.module-help-footer {
  padding: 11px 22px 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.pricing-simulator-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--line);
}

.pricing-simulator-head h2 { margin-bottom: 5px; font-size: 20px; }
.pricing-simulator-head span { color: var(--muted); font-size: 13px; }

.dialog-close-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #edf1ef;
  color: #53615b;
  font-size: 24px;
  line-height: 30px;
}

.pricing-simulator-price {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  font-weight: 700;
}

.pricing-simulator-price input {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid color-mix(in srgb, var(--sim-primary) 45%, #dce4df);
  border-radius: 8px;
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
}

.pricing-simulator-breakdown { padding: 0 22px 8px; }

.pricing-simulator-breakdown > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px dashed #dce4df;
}

.pricing-simulator-breakdown span { color: var(--muted); }

.pricing-simulator-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 10px 22px 0;
  padding: 15px 16px;
  border-radius: 9px;
  background: var(--sim-soft);
  font-weight: 800;
}

.pricing-simulator-result strong { color: var(--sim-primary-dark); font-size: 25px; }
.pricing-simulator-result strong.negative { color: #c62828; }
.pricing-simulator-note { margin: 0; padding: 12px 22px 20px; color: var(--muted); font-size: 12px; }

.pricing-import-button {
  background: #e8f4ff;
  color: #185b91;
  border: 1px solid #9bc8ee;
}

.pricing-panel > .panel-head {
  flex-flow: row nowrap;
  align-items: center;
  gap: 16px;
}

.product-pricing-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
  white-space: nowrap;
}

.product-pricing-title h2 {
  flex: 0 0 auto;
  margin: 0;
}

.product-pricing-count {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  min-height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  background: #e8f3ee;
  color: var(--theme-primary-dark);
  font-size: 15px;
  font-weight: 750;
}

.ledger-window-title,
.ledger-product-counts {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.daily-ledger-window-panel-head {
  align-items: center;
  flex-wrap: nowrap;
  gap: 12px;
}

.daily-ledger-window-panel-head > div:first-child {
  flex: 0 0 auto;
  min-width: 0;
}

.daily-ledger-window-panel-head > .import-actions {
  flex: 1 1 auto;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.daily-ledger-window-panel-head .search-clear-wrap {
  flex: 0 1 280px;
  min-width: 190px;
}

.daily-ledger-window-panel-head .month-picker {
  flex: 0 0 auto;
  white-space: nowrap;
}

.ledger-count {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e8f3ee;
  color: #285c49;
  font-size: 13px;
  font-weight: 800;
}

button.ledger-count {
  border: 0;
  cursor: pointer;
}

button.ledger-count:hover {
  box-shadow: inset 0 0 0 1px currentColor;
}

button.ledger-count.online.active {
  background: #18845d;
  color: #fff;
}

button.ledger-count.offline.active {
  background: #d83a45;
  color: #fff;
}

.ledger-count.online { background: #e2f5e9; color: #177044; }
.ledger-count.offline { background: #ffebee; color: #c62828; }

.daily-ledger-table .ledger-status-col {
  min-width: 105px;
  text-align: center;
}

.pricing-status-select {
  min-width: 78px;
  height: 34px;
  padding: 0 28px 0 10px;
  border: 1px solid #a9c9bc;
  border-radius: 9px;
  background: #edf8f3;
  color: #126747;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.pricing-status-select.is-offline {
  border-color: #ef8d8d;
  background: #ffebee;
  color: #c62828;
}

.product-pricing-title .hint {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pricing-panel > .panel-head .import-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  align-items: center;
  white-space: nowrap;
}

.pricing-panel > .panel-head .import-actions > * {
  flex: 0 0 auto;
}

.pricing-panel > .panel-head .search-clear-wrap {
  width: 230px;
}

.pricing-input-wrap {
  display: flex;
  align-items: center;
  min-width: 92px;
}

.pricing-input {
  width: 92px;
  min-width: 0;
}

.pricing-unit-input { width: 68px; }

.pricing-input-wrap .pricing-input { flex: 1; }

.pricing-input-suffix {
  margin-left: -22px;
  width: 18px;
  color: #6c7d76;
  pointer-events: none;
}
.sales-window-shell {
  border: 1px solid #cfd8d3;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  display: grid;
  grid-template-rows: 38px minmax(0, 1fr);
}

.sales-window-wrap {
  height: clamp(380px, calc(100vh - 340px), 620px);
  max-height: none;
  border: 0;
  border-radius: 0;
  background: #fff;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  overflow: auto;
  overflow-x: hidden;
}

.sales-window-wrap::-webkit-scrollbar,
.pricing-table-wrap::-webkit-scrollbar {
  width: 18px;
  height: 0;
}

.sales-window-top-scroll {
  height: 26px;
  overflow-x: scroll;
  overflow-y: hidden;
  border-bottom: 1px solid #cfd8d3;
  background: #f0f4f2;
}

.sales-window-top-scroll-inner {
  width: 3200px;
  height: 20px;
}

.sales-window-top-scroll::-webkit-scrollbar {
  height: 18px;
}

.sales-window-wrap::-webkit-scrollbar-track,
.pricing-table-wrap::-webkit-scrollbar-track,
.sales-window-top-scroll::-webkit-scrollbar-track {
  background: #e7eeeb;
}

.sales-window-wrap::-webkit-scrollbar-thumb,
.pricing-table-wrap::-webkit-scrollbar-thumb,
.sales-window-top-scroll::-webkit-scrollbar-thumb {
  background: #6f7a74;
  border: 2px solid #e7eeeb;
  border-radius: 10px;
  min-height: 90px;
  min-width: 90px;
}

.sales-window-wrap::-webkit-scrollbar-thumb:hover,
.pricing-table-wrap::-webkit-scrollbar-thumb:hover,
.sales-window-top-scroll::-webkit-scrollbar-thumb:hover {
  background: #4f5a54;
}

.sales-window-wrap::-webkit-scrollbar-corner,
.pricing-table-wrap::-webkit-scrollbar-corner,
.sales-window-top-scroll::-webkit-scrollbar-corner {
  background: #e7eeeb;
}

#daily-ledger-view .sales-window-shell {
  grid-template-rows: minmax(0, 1fr) 26px;
}

#daily-ledger-window-scroll {
  grid-row: 1;
}

#daily-ledger-window-top-scroll {
  grid-row: 2;
  border-top: 1px solid #cfd8d3;
  border-bottom: 0;
}

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

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

th {
  background: #f0f4f2;
  color: #3f5049;
  font-size: 13px;
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}

#inventory-table tr:nth-child(odd) td {
  background: #f7faf8;
}

#inventory-table tr td.stock-alert-low {
  background: #fff1b8;
  color: #7a5200;
  font-weight: 700;
}

#inventory-table tr td.stock-alert-zero {
  background: #f8caca;
  color: #a31515;
  font-weight: 700;
}

.app-stock-box {
  width: 70px;
  min-height: 36px;
  padding: 0 8px;
  border: 1px solid #cbd6d1;
  border-radius: 8px;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

#inventory-table tr .app-stock-box.app-stock-different {
  background: #ffd6e5;
  border-color: #efa7c2;
  color: #9a2452;
  font-weight: 800;
}

#youdaji-collector-result {
  white-space: pre-line;
}

.unmatched-product-list {
  color: var(--red);
  font-weight: 700;
}

td { font-size: 14px; }
.sales-window-table {
  width: max-content;
  min-width: 3200px;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
}
.sales-window-table th,
.sales-window-table td {
  border-right: 1px solid #d5ded9;
  border-bottom: 1px solid #d5ded9;
  color: #14211d;
  font-size: 14px;
  font-weight: 400;
  height: 36px;
  padding: 7px 10px;
  text-align: center;
  white-space: nowrap;
}
.sales-window-table th {
  background: #eef5f2;
  color: #263a33;
  font-weight: 700;
  box-shadow: inset 0 -1px 0 #b9c8c1;
}
.sales-window-table .name-col {
  min-width: 280px;
  width: 280px;
  left: 0;
}
.sales-window-table .sku-col {
  min-width: 126px;
  width: 126px;
  left: 280px;
}
#daily-replenishment-window-grid .replenishment-total-col {
  min-width: 96px;
  width: 96px;
  left: 406px;
}
.sales-window-table .week-sales-col {
  min-width: 86px;
  width: 86px;
  left: 406px;
}
.sales-window-table .month-sales-col {
  min-width: 86px;
  width: 86px;
  left: 492px;
}
.sales-window-table .date-col {
  min-width: 76px;
  text-align: center;
}
.sales-window-table .current-month-total-col {
  min-width: 92px;
}
.sales-window-table .sticky-col {
  position: sticky;
  background: #fff;
  z-index: 2;
  box-shadow: 1px 0 0 #c7d2cc;
}
.sales-window-table td.name-col {
  background: #fff;
  text-align: left;
}
.sales-window-table td.sku-col {
  background: #fff;
  font-variant-numeric: tabular-nums;
}
.sales-window-table td.week-sales-col,
.sales-window-table td.month-sales-col,
.sales-window-table td.replenishment-total-col {
  background: #fff;
  color: #14211d;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.sales-window-table td.name-col strong {
  font-weight: 600;
}
.sales-window-table th.sticky-col {
  background: #eef5f2;
  font-weight: 700;
  z-index: 3;
}
.sales-window-table tbody tr:nth-child(even) td {
  background: #fbfcfb;
}
.sales-window-table tbody tr:nth-child(even) td.sticky-col {
  background: #fbfcfb;
}
.sales-window-table tbody tr:hover td {
  background: #fff7d8;
}
.daily-ledger-table {
  min-width: 4380px;
  --ledger-monthly-left: 384px;
}
.daily-ledger-table.has-app-stock {
  --ledger-monthly-left: 476px;
}
.daily-ledger-table .name-col {
  min-width: 210px;
  width: 210px;
  max-width: 210px;
  left: 0;
}
.daily-ledger-table .sku-col {
  min-width: 96px;
  width: 96px;
  max-width: 96px;
  left: 210px;
}
.daily-ledger-table .stock-col {
  min-width: 78px;
  width: 78px;
  max-width: 78px;
  left: 306px;
}
.daily-ledger-table .week-sales-col {
  min-width: 86px;
  width: 86px;
}
.daily-ledger-table .month-sales-col {
  min-width: 98px;
  width: 98px;
}
.daily-ledger-table .current-month-sales-col {
  min-width: 78px;
  width: 78px;
  max-width: 78px;
  left: var(--ledger-monthly-left);
}
.daily-ledger-table .ledger-month-replenishment-col {
  min-width: 78px;
  width: 78px;
  max-width: 78px;
  left: calc(var(--ledger-monthly-left) + 78px);
}
.daily-ledger-table .app-stock-col {
  min-width: 92px;
  width: 92px;
  left: 384px;
}
.daily-ledger-table td.name-col strong {
  display: block;
  line-height: 1.35;
  overflow-wrap: anywhere;
  white-space: normal;
}
.daily-ledger-table td.sku-col {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.daily-ledger-table .date-group-col {
  min-width: 152px;
  background: #e8f4ee;
  color: #0f5c45;
}
.daily-ledger-table .ledger-sales-col {
  background: #f0f8ff;
  min-width: 74px;
}
.daily-ledger-table .ledger-replenishment-col {
  background: #fff7e8;
  min-width: 74px;
}
.daily-ledger-table tbody tr:nth-child(even) td.ledger-sales-col {
  background: #f7fbff;
}
.daily-ledger-table tbody tr:nth-child(even) td.ledger-replenishment-col {
  background: #fffbf2;
}
.daily-ledger-table td.stock-col,
.daily-ledger-table td.week-sales-col,
.daily-ledger-table td.month-sales-col,
.daily-ledger-table td.current-month-sales-col,
.daily-ledger-table td.ledger-month-replenishment-col,
.daily-ledger-table td.app-stock-col {
  background: #fff;
  color: #14211d;
  font-weight: 700;
}
.daily-ledger-table tbody tr:nth-child(even) td.stock-col,
.daily-ledger-table tbody tr:nth-child(even) td.week-sales-col,
.daily-ledger-table tbody tr:nth-child(even) td.month-sales-col,
.daily-ledger-table tbody tr:nth-child(even) td.current-month-sales-col,
.daily-ledger-table tbody tr:nth-child(even) td.ledger-month-replenishment-col,
.daily-ledger-table tbody tr:nth-child(even) td.app-stock-col {
  background: #fbfcfb;
}
.daily-ledger-table .tail-col {
  min-width: 88px;
}
.ledger-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: min(780px, 100%);
}
#daily-ledger-actions-panel .panel-head {
  display: grid;
  grid-template-columns: 142px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin-bottom: 0;
}
#daily-ledger-actions-panel .panel-head > div:first-child {
  min-width: 0;
}
#daily-ledger-actions-panel .panel-head h2 {
  margin: 0;
  white-space: nowrap;
}
#daily-ledger-actions-panel #ledger-actions-hint {
  display: none;
}
.ledger-action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-left-width: 5px;
  border-radius: 8px;
}
.ledger-action-row > :first-child {
  flex: 0 0 170px;
}
.ledger-action-row > :nth-child(2) {
  flex: 0 0 120px;
}
.ledger-action-sales {
  background: #eef6ff;
  border-color: #8fc2f3;
}
.ledger-action-orders {
  background: #fff2e5;
  border-color: #f2ad68;
}
.ledger-action-replenishment {
  background: #fff8dc;
  border-color: #e7bd3e;
}
.ledger-action-inventory {
  background: #f5efff;
  border-color: #b99aeb;
  grid-column: 1 / -1;
}
.ledger-actions.kuaailv-one-row {
  grid-template-columns: 210px 210px 250px;
  gap: 8px;
  width: auto;
  max-width: 100%;
  justify-content: end;
  margin-left: auto;
}
.ledger-actions.kuaailv-one-row .ledger-action-row {
  gap: 7px;
  min-height: 40px;
  padding: 4px 5px;
  min-width: 0;
  border-left-width: 4px;
  border-radius: 7px;
}
.ledger-actions.kuaailv-one-row .ledger-action-inventory {
  grid-column: auto;
}
.ledger-actions.kuaailv-one-row .ledger-action-row > :first-child {
  flex: 1 0 88px;
  min-width: 88px;
  padding-left: 8px;
  padding-right: 8px;
}
.ledger-actions.kuaailv-one-row .ledger-action-row > :nth-child(2) {
  flex: 0 0 88px;
  min-width: 88px;
}
.ledger-actions.kuaailv-one-row .ledger-action-inventory > :first-child {
  flex-basis: 112px;
  min-width: 112px;
  padding-left: 6px;
  padding-right: 6px;
}
.ledger-actions.kuaailv-one-row .ledger-action-inventory > :nth-child(2) {
  flex-basis: 104px;
  min-width: 104px;
}
.ledger-actions.kuaailv-one-row .file-button,
.ledger-actions.kuaailv-one-row .record-button {
  min-height: 32px;
  padding-left: 8px;
  padding-right: 8px;
  overflow: hidden;
  white-space: nowrap;
  border-radius: 7px;
  font-size: 14px;
}
.ledger-actions.youdaji-compact {
  grid-template-columns: minmax(220px, 0.62fr) minmax(0, 1.38fr);
  flex: 0 1 840px;
  width: min(840px, 100%);
  max-width: 840px;
  min-width: 0;
  margin-left: auto;
}
.ledger-actions.youdaji-compact .ledger-action-row {
  gap: 8px;
  min-height: 50px;
  padding: 6px 8px;
  flex-wrap: nowrap;
}
.ledger-actions.youdaji-compact .ledger-action-orders .order-date-picker {
  flex: 0 0 205px;
  min-width: 205px;
  padding-left: 8px;
  padding-right: 8px;
}
.ledger-actions.youdaji-compact .ledger-action-orders .order-date-picker input {
  width: 98px;
}
.ledger-actions.youdaji-compact #ledger-start-youdaji-orders {
  flex: 0 0 124px;
}
.ledger-actions.youdaji-compact #ledger-youdaji-orders-record-toggle {
  flex: 0 0 102px;
}
.ledger-actions.youdaji-compact .ledger-action-orders {
  grid-column: 1 / -1;
  width: 100%;
}
.ledger-actions.youdaji-compact .ledger-action-replenishment > :first-child {
  flex: 1 1 auto;
  min-width: 118px;
}
.ledger-actions.youdaji-compact .ledger-action-replenishment > :nth-child(2) {
  flex: 0 0 96px;
}
.ledger-actions.youdaji-compact .ledger-action-inventory {
  grid-column: auto;
}
.ledger-actions.youdaji-compact .ledger-action-inventory > :first-child {
  flex: 0 0 132px;
}
.ledger-actions.youdaji-compact .ledger-action-inventory > :nth-child(2) {
  flex: 0 0 88px;
}
.ledger-actions.youdaji-compact #ledger-start-youdaji-collector {
  flex: 0 0 110px;
}
.ledger-actions.youdaji-compact .ledger-action-orders > .order-date-picker,
.ledger-actions.youdaji-compact #ledger-start-youdaji-orders,
.ledger-actions.youdaji-compact #ledger-youdaji-orders-record-toggle {
  flex: 1 1 0;
  min-width: 0;
}
.ledger-actions.youdaji-compact .ledger-action-orders .order-date-picker input {
  flex: 1 1 auto;
  width: auto;
  min-width: 112px;
}
.ledger-actions.youdaji-compact .ledger-action-replenishment > :first-child,
.ledger-actions.youdaji-compact .ledger-action-replenishment > :nth-child(2) {
  flex: 1 1 0;
  min-width: 0;
}
.ledger-actions.youdaji-compact .ledger-action-inventory > :first-child,
.ledger-actions.youdaji-compact #ledger-start-youdaji-collector,
.ledger-actions.youdaji-compact #ledger-inventory-record-toggle {
  flex: 1 1 0;
  min-width: 0;
}
.ledger-actions.youdaji-compact .file-button,
.ledger-actions.youdaji-compact .secondary-button,
.ledger-actions.youdaji-compact .primary-button {
  min-height: 36px;
  padding-left: 8px;
  padding-right: 8px;
}
#ledger-new-product-toggle {
  background: #dbeafe;
  color: #1d4ed8;
  border: 1px solid #93c5fd;
}
#ledger-new-product-toggle.expanded {
  background: #bfdbfe;
  box-shadow: inset 0 0 0 1px #2563eb;
}
#ledger-export-inventory {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}
.ledger-actions .file-button,
.ledger-actions .secondary-button,
.ledger-actions .primary-button {
  min-height: 40px;
  white-space: nowrap;
}

@media (max-width: 1200px) {
  .ledger-actions { width: 100%; }
  .ledger-action-row { flex-wrap: wrap; }
  .ledger-actions.kuaailv-one-row .ledger-action-row { flex-wrap: nowrap; }
  .ledger-actions.youdaji-compact { grid-template-columns: 1fr; }
  .ledger-actions.youdaji-compact .ledger-action-row { flex-wrap: wrap; }
  .ledger-actions.youdaji-compact .ledger-action-inventory { grid-column: auto; }
}

@media (max-width: 720px) {
  .ledger-actions,
  .ledger-actions.kuaailv-one-row,
  .ledger-actions.youdaji-compact { grid-template-columns: 1fr; }
  .ledger-action-inventory { grid-column: auto; }
  .ledger-actions.youdaji-compact .ledger-action-row { flex-wrap: wrap; }
}
.number { font-variant-numeric: tabular-nums; font-weight: 700; }
.muted, .empty { color: var(--muted); }
.empty { text-align: center; padding: 28px; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 9px;
  border-radius: 999px;
  background: #edf1ef;
  color: #43514b;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.paid { background: #dcf4ea; color: #146246; }
.badge.pending { background: #fff1d6; color: var(--amber); }
.badge.danger { background: #f9dfdf; color: var(--red); }
.badge.info { background: #e3eefb; color: var(--blue); }

input, select {
  min-height: 38px;
  border: 1px solid #cfd8d3;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

.search-input { width: 250px; max-width: 100%; }
.qty-input { width: 92px; text-align: center; }
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.qty-input {
  appearance: textfield;
  -moz-appearance: textfield;
}
.mini-input { width: 70px; }
.text-mini { min-width: 62px; }
.name-input { width: 280px; }
.sku-input { width: 100px; }

.product-form {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) minmax(130px, 0.9fr) repeat(6, minmax(84px, 0.7fr)) auto;
  gap: 10px;
  align-items: end;
}

.tianhuan-manual-product-form {
  grid-template-columns: 130px minmax(340px, 2fr) minmax(180px, 1fr) 120px 120px auto;
}

.tianhuan-id-field {
  min-width: 0;
}

.tianhuan-name-field {
  min-width: 340px;
}

.tianhuan-manual-product-form .primary-button {
  min-width: 116px;
  padding: 0 20px;
  white-space: nowrap;
}

.theme-tianhuan #inventory-view table {
  table-layout: fixed;
}

.theme-tianhuan #inventory-table-head th:nth-child(1) { width: 9%; }
.theme-tianhuan #inventory-table-head th:nth-child(2) { width: 36%; }
.theme-tianhuan #inventory-table-head th:nth-child(3) { width: 20%; }
.theme-tianhuan #inventory-table-head th:nth-child(4) { width: 10%; }
.theme-tianhuan #inventory-table-head th:nth-child(5) { width: 9%; }
.theme-tianhuan #inventory-table-head th:nth-child(6) { width: 9%; }
.theme-tianhuan #inventory-table-head th:nth-child(7) { width: 7%; }

.theme-tianhuan #inventory-table td:nth-child(2) {
  overflow-wrap: anywhere;
}

.logic-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

.logic-form label {
  color: var(--muted);
  font-size: 13px;
  display: grid;
  gap: 6px;
}

.checkbox-field {
  min-height: 38px;
  grid-auto-flow: column;
  grid-template-columns: auto 1fr;
  align-items: center;
  justify-content: start;
}

.checkbox-field input {
  min-height: auto;
  width: 18px;
  height: 18px;
}

.wide-checkbox {
  grid-column: span 2;
}

.logic-preview {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #d7e2dd;
  background: #f8fbfa;
  border-radius: 8px;
  display: grid;
  gap: 7px;
}

.logic-preview strong {
  font-size: 14px;
}

.logic-preview span {
  color: #253a33;
}

.logic-preview code {
  color: #53645d;
  font-family: Consolas, "Microsoft YaHei", monospace;
  white-space: normal;
}

.user-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(120px, 0.7fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.product-form label {
  color: var(--muted);
  font-size: 13px;
  display: grid;
  gap: 6px;
}

.product-form input {
  width: 100%;
}

.settings-panel {
  width: 100%;
  max-width: none;
}

.settings-panel p {
  color: var(--muted);
  line-height: 1.8;
}

.auto-backup-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 14px 0 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
}

.auto-backup-setting .hint {
  margin-left: 26px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #17211d;
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .nav { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid.finance-kpis {
    grid-template-columns: repeat(6, minmax(145px, 1fr));
    overflow-x: auto;
  }
  .kpi-grid.finance-kpis.youdaji-finance-kpis {
    grid-template-columns: repeat(5, minmax(130px, 1fr));
    overflow-x: auto;
  }
  .topbar, .panel-head { align-items: stretch; flex-direction: column; }
  .product-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .user-form { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .workspace { padding: 16px; }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-grid.finance-kpis {
    grid-template-columns: repeat(6, minmax(145px, 1fr));
  }
  .kpi-grid.finance-kpis.youdaji-finance-kpis {
    grid-template-columns: repeat(5, minmax(130px, 1fr));
  }
  .search-input { width: 100%; }
  .product-form { grid-template-columns: 1fr; }
  .auto-backup-setting { align-items: stretch; flex-direction: column; }
}
