:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #657386;
  --line: #d8dee8;
  --accent: #246b55;
  --accent-strong: #164938;
  --blue: #315f9b;
  --warn: #9a5a19;
  --danger: #9b2f2f;
  --shadow: 0 10px 28px rgba(25, 38, 52, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #101820;
  color: #fff;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: #d9efe6;
  color: var(--accent-strong);
  font-weight: 700;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  max-width: 168px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand p,
.hint {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.sidebar .brand p,
.sidebar label {
  color: #b7c2cf;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-btn {
  width: 100%;
  height: 38px;
  text-align: left;
  padding: 0 12px;
  border-color: rgba(255, 255, 255, 0.14);
  background: transparent;
  color: #dce5ee;
}

.nav-btn.active,
.nav-btn:hover {
  background: #263543;
  color: #fff;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
  resize: vertical;
}


.main {
  padding: 22px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.topbar h2 {
  margin: 0;
  font-size: 24px;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.status-pill {
  padding: 7px 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}

.message {
  padding: 10px 12px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  background: #fff;
}

.message.ok {
  border-color: #8dc1a6;
  color: var(--accent-strong);
}

.message.error {
  border-color: #d99999;
  color: var(--danger);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(16, 24, 32, 0.48);
}

.modal-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(16, 24, 32, 0.2);
  padding: 18px;
}

.modal-panel h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.modal-panel p {
  margin: 0;
  color: var(--muted);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

.private-order-modal {
  width: min(1180px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
}

.private-order-dialog-head,
.private-order-items-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.private-order-section {
  margin: 16px 0 0;
  padding: 14px;
  border: 1px solid var(--line);
}

.private-order-section legend {
  padding: 0 6px;
  font-weight: 700;
}

.private-order-common-grid,
.private-order-item-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.private-order-common-grid label,
.private-order-item-grid label,
.private-order-total-receipt {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.private-order-common-grid .wide {
  grid-column: span 2;
}

.private-receipt-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.private-receipt-modes label {
  display: flex;
  align-items: center;
  gap: 7px;
}

.private-receipt-modes input {
  width: auto;
}

.private-order-total-receipt {
  max-width: 260px;
  margin-top: 12px;
}

.private-order-items {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.private-order-item {
  padding: 12px;
  border: 1px solid var(--line);
  background: #fbfcfd;
}

.private-order-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.private-order-item-head strong {
  color: var(--text);
}

.private-order-image-box {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto 72px minmax(150px, auto) auto;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.private-order-image-copy {
  display: grid;
  gap: 3px;
}

.private-order-image-copy strong {
  font-size: 13px;
}

.private-order-image-preview {
  width: 72px;
  height: 54px;
  border: 1px solid var(--line);
  background: #fff;
  object-fit: cover;
}

.private-order-image-preview.hidden {
  display: none;
}

.private-order-image-name {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.private-order-image-status {
  grid-column: 1 / -1;
  min-height: 16px;
  color: var(--muted);
  font-size: 12px;
}

.private-order-image-status[data-status="success"] {
  color: var(--accent-strong);
}

.private-order-image-status[data-status="error"] {
  color: var(--danger);
}

.private-order-item [aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(176, 63, 63, 0.12);
}

.private-order-error {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #d99999;
  color: var(--danger);
  background: #fff8f8;
}

.private-order-summary {
  margin-top: 12px;
  color: var(--muted);
  text-align: right;
}

.analysis-sections {
  display: grid;
  gap: 22px;
}

.analysis-channel-section {
  padding-top: 16px;
  border-top: 2px solid var(--line);
}

.analysis-channel-section:first-child {
  padding-top: 0;
  border-top: 0;
}

.analysis-channel-title {
  margin: 0 0 12px;
  font-size: 18px;
}

.supplier-binding-context {
  display: grid;
  gap: 0;
  margin-top: 14px;
  border: 1px solid var(--line);
}

.supplier-binding-context-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
}

.supplier-binding-context-row:last-child {
  border-bottom: 0;
}

.supplier-binding-context-row span {
  color: var(--muted);
}

.supplier-binding-context-row strong {
  min-width: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.image-action-panel {
  width: min(720px, 100%);
  border-radius: 6px;
}

.image-dialog-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  max-height: min(58vh, 520px);
  margin-top: 14px;
  padding: 10px;
  border: 1px solid var(--line);
  background: #f8fafb;
  overflow: hidden;
}

.image-dialog-preview img {
  display: block;
  max-width: 100%;
  max-height: min(54vh, 480px);
  object-fit: contain;
}

.hidden,
.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.analysis-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.metric {
  padding: 14px;
}

.metric .label {
  color: var(--muted);
  font-size: 13px;
}

.metric .value {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 700;
}

.metric .sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.grid {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
  padding: 14px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel h3 {
  margin: 0;
  font-size: 16px;
}

.report-block {
  border: 1px solid var(--line);
  background: #fbfcfd;
  padding: 12px;
}

.report-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.report-head h3 {
  margin: 0;
  font-size: 15px;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  min-height: 36px;
  padding: 0 13px;
}

.primary:hover {
  background: var(--accent-strong);
}

.secondary,
.ghost {
  min-height: 36px;
  padding: 0 12px;
}

.danger {
  min-height: 36px;
  padding: 0 13px;
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}

.danger:hover {
  background: #7f2525;
}

.ghost {
  background: #f9fbfc;
}

.small {
  min-height: 30px;
  font-size: 13px;
}

.tiny {
  min-height: 24px;
  padding: 0 7px;
  font-size: 12px;
  line-height: 1.2;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.company-create {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 130px;
  gap: 10px;
  margin-bottom: 14px;
}

.company-grid {
  display: grid;
  gap: 10px;
}

.company-card {
  border: 1px solid var(--line);
  background: #fbfcfd;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.company-card.active {
  border-color: #8dc1a6;
  background: #f2faf6;
}

.company-card strong,
.company-card span {
  display: block;
}

.company-card span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-actions {
  display: flex;
  gap: 8px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.settings-info {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.rollback-version-block {
  grid-column: 1 / -1;
}

.rollback-version-table-wrap {
  max-height: 520px;
}

.rollback-version-table-wrap td:nth-child(4) {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rollback-dialog {
  width: min(860px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.rollback-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.rollback-impact-warning {
  margin: 16px 0 12px;
  padding: 11px 12px;
  border: 1px solid #e4bd72;
  background: #fff8e8;
  color: #7a4b00;
  line-height: 1.55;
}

.rollback-impact-wrap {
  max-height: 340px;
}

.rollback-confirm-field {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.rollback-confirm-field strong {
  color: var(--danger);
}

.rollback-delta {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.rollback-delta.negative {
  color: var(--danger);
}

.rollback-delta.positive {
  color: var(--accent-strong);
}

.danger-zone {
  border-color: #d99999;
}

.payment-upload {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.payment-upload > button {
  align-self: end;
}

.supplier-toolbar {
  display: grid;
  gap: 8px;
  min-width: min(780px, 64%);
}

.supplier-query-tools,
.supplier-action-tools {
  min-width: 0;
  width: 100%;
}

.supplier-query-tools {
  grid-template-columns: minmax(100px, 0.65fr) minmax(120px, 0.85fr) minmax(120px, 0.85fr) minmax(220px, 1.4fr) auto;
}

.supplier-action-tools {
  justify-content: flex-end;
}

.supplier-split {
  align-items: start;
}

.supplier-side-panel {
  position: sticky;
  top: 12px;
}

.supplier-side-panel > button {
  width: 100%;
  margin-top: 12px;
}

.supplier-detail-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.supplier-detail-head.hidden,
.supplier-bottom-actions.hidden {
  display: none;
}

.supplier-bottom-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 10px;
}

.supplier-bottom-actions .hint {
  flex: 1;
}

.supplier-select-all {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.supplier-selection-column {
  width: 58px;
  min-width: 58px;
  text-align: center;
}

.supplier-batch-selected td {
  background: #e4f2f8;
}

.supplier-batch-selected:hover td {
  background: #d9ebf3;
}

.dialog-required-field {
  display: grid;
  gap: 6px;
  margin: 12px 0 8px;
}

.status-box {
  display: grid;
  gap: 4px;
  padding: 10px;
  margin-bottom: 12px;
  border: 1px solid #b7d8c8;
  background: #f2faf6;
  color: var(--accent-strong);
}

.supplier-rule-module {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid #cbdce8;
  background: #f3f8fb;
}

.supplier-rule-module h4 {
  margin: 0;
  font-size: 14px;
}

.supplier-rule-summary {
  display: grid;
  gap: 9px;
  min-width: 0;
}

.supplier-rule-note {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.supplier-rule-entry {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.supplier-rule-entry:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.supplier-rule-description {
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.supplier-rule-meta {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.supplier-rule-warning {
  padding: 8px 9px;
  border-left: 3px solid var(--warn);
  background: #fff8e8;
  color: #7a4b00;
  font-size: 12px;
  line-height: 1.45;
}

.supplier-profile-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}

.supplier-profile-module {
  display: grid;
  gap: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.supplier-profile-module h4 {
  margin: 0;
  font-size: 14px;
}

.supplier-profile-module textarea {
  min-height: 88px;
  line-height: 1.5;
}

.supplier-profile-view,
.supplier-profile-edit {
  display: grid;
  gap: 8px;
}

.supplier-profile-view.hidden,
.supplier-profile-edit.hidden {
  display: none;
}

.supplier-profile-text {
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  background: #f7f9fa;
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

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

.supplier-profile-view > button {
  justify-self: start;
}

.supplier-profile-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.attachment-list {
  display: grid;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.supplier-action-module {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #fbfcfd;
}

.supplier-action-module + .supplier-action-module {
  margin-top: 14px;
}

.supplier-action-module h4 {
  margin: 0;
  font-size: 14px;
}

.choice-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice-buttons button.active {
  background: var(--accent);
  color: #fff;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover td {
  background: #eef6f2;
}

.file-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 8px;
}

.backup-output-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px 96px;
  gap: 8px;
}

.backup-output-control input[readonly] {
  color: var(--text);
  background: #f7faf9;
}

@media (max-width: 760px) {
  .backup-output-control {
    grid-template-columns: 1fr 1fr;
  }

  .backup-output-control input {
    grid-column: 1 / -1;
  }
}

.file-input {
  display: none;
}

.file-button {
  width: 96px;
}

.file-name {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-box {
  display: grid;
  gap: 8px;
  margin: 10px 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #f7faf9;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.progress-head strong {
  color: var(--accent-strong);
}

.progress-track {
  height: 10px;
  background: #e1e8ed;
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.progress-bar.indeterminate {
  width: 35%;
  animation: progress-slide 1.1s ease-in-out infinite;
}

.progress-detail {
  color: var(--muted);
  font-size: 12px;
}

@keyframes progress-slide {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(300%);
  }
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.checks,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
}

.checks label {
  display: flex;
  align-items: center;
  gap: 7px;
}

.checks input {
  width: auto;
}

.run-log {
  margin: 14px 0 0;
  min-height: 90px;
  max-height: 260px;
  overflow: auto;
  background: #101820;
  color: #e6edf3;
  padding: 12px;
  white-space: pre-wrap;
}

.supplier-summary {
  border: 1px solid #b9d4c7;
  background: #f2faf6;
  padding: 10px;
  margin: 10px 0;
  display: grid;
  gap: 7px;
  font-size: 13px;
}

.supplier-summary strong {
  color: var(--accent-strong);
}

.image-upload-box {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.image-upload-box .file-name {
  white-space: normal;
}

.table-head {
  align-items: flex-end;
}

.table-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: min(420px, 52%);
}

.table-tools select {
  min-height: 36px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 0 10px;
}

.ledger-tools {
  display: grid;
  grid-template-columns: minmax(120px, 0.85fr) minmax(120px, 0.85fr) minmax(180px, 1.2fr) auto auto auto auto;
  min-width: min(980px, 74%);
  align-items: center;
}

.ledger-tools #ledgerDateFrom,
.ledger-tools #ledgerDateTo {
  width: 100%;
}

.ledger-tools #ledgerSearch {
  grid-column: 3;
}

.ledger-tools button {
  justify-self: start;
}

.ledger-tools [data-sheet-target] {
  grid-column: 4;
}

.ledger-tools #exportLedgerBtn {
  grid-column: 5;
}

.ledger-tools #addPrivateOrderBtn {
  grid-column: 6;
}

.ledger-tools #deletePrivateOrderBtn {
  grid-column: 7;
}

.ledger-head-actions {
  display: grid;
  justify-items: end;
  gap: 9px;
  min-width: min(980px, 74%);
}

.ledger-head-actions .ledger-tools {
  min-width: 0;
  width: 100%;
}

.douyin-import-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.douyin-import-tools.hidden {
  display: none;
}

.channel-badge {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid #b9d8cc;
  background: #eef8f4;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.douyin-import-panel {
  display: grid;
  gap: 8px;
  margin: -2px 0 12px;
  padding: 10px 12px;
  border: 1px solid #c8ddd5;
  background: #f6fbf9;
}

.douyin-import-panel.hidden,
.progress-box.hidden {
  display: none;
}

.douyin-import-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.douyin-import-panel .progress-box {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.douyin-import-panel .run-log {
  margin: 0;
  max-height: 120px;
}

.supplier-query-tools {
  grid-template-columns: minmax(100px, 0.65fr) minmax(120px, 0.85fr) minmax(120px, 0.85fr) minmax(180px, 1.2fr) auto;
  min-width: min(760px, 62%);
}

.supplier-query-tools #supplierSalesChannel {
  width: 100%;
  align-self: stretch;
}

.supplier-query-tools button {
  grid-column: 5;
}

.table-tools .inline-check {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  color: var(--text);
}

.table-tools .inline-check input,
td input[type="checkbox"] {
  width: auto;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
}

.ledger-table-area {
  min-width: 0;
  display: grid;
  gap: 8px;
  align-content: start;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  max-height: calc(100vh - 230px);
  background: #fff;
}

.table-wrap.full {
  max-height: calc(100vh - 190px);
}

.table-wrap.compact {
  max-height: 300px;
}

.bar-list {
  display: grid;
  gap: 9px;
}

.bar-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) 96px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.bar-track {
  height: 10px;
  background: #e8edf2;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--blue);
}

.bar-fill.negative {
  background: var(--warn);
}

.alert-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.alert-item {
  border: 1px solid var(--line);
  background: #fff;
  padding: 10px;
}

.alert-item strong {
  display: block;
  font-size: 20px;
  color: var(--danger);
}

.alert-item span {
  color: var(--muted);
  font-size: 13px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px 9px;
  text-align: left;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef3f7;
  color: #263543;
}

.column-menu-btn {
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-start;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.column-menu-btn b {
  color: var(--accent);
  min-width: 10px;
}

.column-menu-btn.active span {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.column-filter-menu {
  position: fixed;
  z-index: 30;
  width: 280px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.15);
  padding: 10px;
}

.column-filter-menu label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.column-filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 8px;
}

.column-value-tools {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin: 8px 0 6px;
}

.column-value-list {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  background: #fbfcfd;
}

.column-value-option {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  padding: 5px 7px;
  border-bottom: 1px solid #edf1f5;
  cursor: pointer;
  color: var(--text);
}

.column-value-option:last-child {
  border-bottom: 0;
}

.column-value-option input {
  width: auto;
}

.column-value-option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.column-value-option em {
  color: var(--muted);
  font-style: normal;
}

tr.selected {
  background: #e7f2ed;
}

tr:hover {
  background: #f5f8fa;
}

td.editable-cell {
  cursor: text;
  background: #fbfdfc;
}

td.editable-cell:hover {
  outline: 1px solid #8dc1a6;
  outline-offset: -1px;
}

td.editable-cell.editing {
  background: #fff;
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

td.editable-cell.saving {
  opacity: 0.65;
}

td.locked-cell {
  background: #f2f5f7;
  color: #53606b;
  cursor: not-allowed;
}

td.amount-cell {
  cursor: cell;
}

td.locked-cell.amount-cell {
  cursor: not-allowed;
}

td.amount-cell.amount-selected {
  background: #fff4c2;
  outline: 2px solid #d6a400;
  outline-offset: -2px;
}

td.pending-edit {
  background: #fff8db;
  box-shadow: inset 0 -2px 0 #d6a400;
}

td.recent-change {
  background: #dff7ea;
  box-shadow: inset 0 0 0 2px #2f9e63;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

td.needs-attention {
  background: #fff1f0;
  box-shadow: inset 0 0 0 2px #d92d20;
}

.ledger-totals,
.ledger-save-bar {
  border: 1px solid var(--line);
  background: #fbfcfd;
  padding: 8px 10px;
}

.ledger-total-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  min-height: 26px;
}

.ledger-total-line + .ledger-total-line {
  border-top: 1px solid var(--line);
  margin-top: 6px;
  padding-top: 6px;
}

.ledger-total-line span {
  display: inline-flex;
  gap: 5px;
  align-items: baseline;
}

.selected-total {
  color: var(--accent-strong);
}

.ledger-save-bar {
  position: sticky;
  bottom: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 -8px 18px rgba(15, 23, 42, 0.06);
}

.ledger-save-bar span {
  margin-right: auto;
  color: var(--text);
  font-weight: 600;
}

.table-thumb {
  display: block;
  width: 42px;
  height: 42px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #fff;
}

.attachment-file-thumb {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  background: #f4f7f8;
  color: var(--accent-strong);
  font-size: 11px;
  text-decoration: none;
}

.table-text-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent-strong);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.table-text-button:hover,
.table-text-button:focus-visible {
  color: var(--accent);
}

.supplier-check-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.image-empty {
  color: var(--muted);
  font-size: 12px;
}

.inline-editor {
  width: 100%;
  min-width: 120px;
  min-height: 30px;
  border: 1px solid var(--accent);
  background: #fff;
  color: var(--text);
  padding: 5px 7px;
  resize: vertical;
}

.inline-editor.floating-inline-editor {
  position: fixed;
  z-index: 1200;
  width: auto;
  max-width: min(360px, calc(100vw - 16px));
  min-width: 160px;
  box-shadow: 0 6px 18px rgb(20 32 42 / 18%);
}

.inline-edit-wrap {
  display: grid;
  gap: 4px;
  min-width: 150px;
}

.inline-edit-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  white-space: nowrap;
}

.editor {
  border: 1px solid var(--line);
  background: #fbfcfd;
  padding: 12px;
  min-width: 0;
}

.editor h3 {
  margin: 0 0 8px;
}

.edit-fields {
  display: grid;
  gap: 9px;
  margin: 10px 0 12px;
  max-height: calc(100vh - 310px);
  overflow: auto;
}

.edit-fields input,
.edit-fields textarea,
.edit-fields select {
  min-height: 34px;
}

.checkbox-group {
  display: grid;
  gap: 8px;
}

.checkbox-group.hidden {
  display: none;
}

.checkbox-group label {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  min-height: 34px;
  margin: 0;
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0;
}

.checkbox-group span {
  line-height: 1.4;
}

.funds-tools {
  min-width: min(1100px, 78%);
  align-items: center;
  justify-content: flex-end;
}

.funds-tools #fundsDateFrom,
.funds-tools #fundsDateTo {
  width: 132px;
  min-width: 118px;
  flex: 0 1 132px;
}

.funds-tools select {
  width: 108px;
  min-width: 96px;
  flex: 0 1 108px;
}

.funds-tools #fundsSearch {
  width: auto;
  min-width: 180px;
  flex: 1 1 220px;
}

.funds-tools button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.funds-account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.funds-account-card {
  padding: 16px;
  border: 1px solid #cddce8;
  background: #f2f7fb;
}

.funds-account-card > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.funds-account-card > div span,
.funds-account-card p {
  color: var(--muted);
}

.funds-account-card > b {
  display: block;
  margin: 8px 0;
  color: var(--accent);
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}

.funds-account-card p {
  margin: 0 0 12px;
}

.supplier-payment-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid #cddce8;
  background: #f2f7fb;
}

.supplier-payment-split.hidden {
  display: none;
}

.supplier-payment-split .hint {
  grid-column: 1 / -1;
}

.private-first-receipt-grid {
  margin-top: 12px;
}

.private-receipt-dialog,
.funds-dialog {
  width: min(980px, calc(100vw - 32px));
}

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

.funds-form label:last-child {
  grid-column: 1 / -1;
}

.funds-purchase-section {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  background: #f4f8fb;
}

.funds-purchase-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.funds-purchase-item {
  display: grid;
  grid-template-columns: 1.4fr 1fr .55fr .8fr 1fr auto;
  gap: 8px;
  align-items: end;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.funds-purchase-item label { min-width: 0; }
.funds-purchase-item input { width: 100%; }
.funds-purchase-item .purchase-note { grid-column: 1 / -2; }
.funds-purchase-total { margin-top: 10px; text-align: right; font-weight: 700; }

@media (max-width: 1100px) {
  .funds-purchase-item { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .funds-purchase-item .purchase-note { grid-column: 1 / -1; }
}

.cash-income {
  color: #18794e;
  font-weight: 700;
  white-space: nowrap;
}

.cash-expense {
  color: #b42318;
  font-weight: 700;
  white-space: nowrap;
}

.cash-row-reversed {
  color: var(--muted);
  text-decoration: line-through;
  opacity: 0.7;
}

.danger-text {
  color: var(--danger);
  font-weight: 700;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tab {
  min-height: 36px;
  padding: 0 12px;
  background: #fff;
}

.tab.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.mini-table {
  overflow: auto;
  max-height: 220px;
}

.mini-row,
.backup-row {
  display: grid;
  gap: 4px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.mini-row strong,
.backup-row strong {
  color: var(--text);
}

.mini-row span,
.backup-row span {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .metrics,
  .analysis-metrics,
  .grid.two,
  .form-grid,
  .company-create,
  .company-card,
  .settings-grid,
  .payment-upload,
  .split {
    grid-template-columns: 1fr;
  }

  .table-tools {
    min-width: 0;
    width: 100%;
  }

  #fundsView .table-head {
    flex-wrap: wrap;
  }

  .funds-tools {
    min-width: 0;
    width: 100%;
    justify-content: flex-start;
  }

  .ledger-head-actions {
    min-width: 0;
    width: 100%;
    justify-items: stretch;
  }

  .ledger-tools {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .douyin-import-tools {
    justify-content: flex-start;
  }

  .supplier-toolbar {
    min-width: 0;
    width: 100%;
  }

  .ledger-tools #ledgerSearch {
    grid-column: 1;
  }

  .ledger-tools button {
    grid-column: 2;
  }

  .ledger-tools #exportLedgerBtn {
    grid-column: 2;
  }

  .ledger-tools #addPrivateOrderBtn {
    grid-column: 1;
  }

  .ledger-tools #deletePrivateOrderBtn {
    grid-column: 2;
  }

  .private-order-common-grid,
  .private-order-item-grid,
  .funds-account-grid,
  .funds-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.table-pagination.hidden {
  display: none;
}

.table-pagination span {
  min-width: 170px;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.inventory-picker-dialog,
.inventory-history-dialog,
.inventory-disposal-dialog {
  width: min(1180px, calc(100vw - 40px));
  max-width: 1180px;
}

.inventory-picker-tools {
  margin: 10px 0;
  justify-content: flex-end;
}

.inventory-picker-tools input {
  min-width: min(480px, 70vw);
}

.inventory-quantity {
  width: 72px;
  min-width: 72px;
}

.sequence-column {
  width: 54px;
  min-width: 54px;
  max-width: 54px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.sequence-cell {
  color: var(--muted);
}

@media (max-width: 680px) {
  .private-order-common-grid,
  .private-order-item-grid,
  .funds-account-grid,
  .funds-form,
  .supplier-payment-split {
    grid-template-columns: 1fr;
  }

  .private-order-common-grid .wide {
    grid-column: auto;
  }

  .private-order-dialog-head,
  .private-order-items-head {
    align-items: stretch;
    flex-direction: column;
  }

  .private-order-image-box {
    grid-template-columns: 1fr auto;
  }

  .private-order-image-copy,
  .private-order-image-name,
  .private-order-image-status {
    grid-column: 1 / -1;
  }

  .douyin-import-panel-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
